1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/strings/string_number_conversions.h"
6 #include "chrome/test/remoting/remote_desktop_browsertest.h"
10 class It2MeBrowserTest
: public RemoteDesktopBrowserTest
{
12 std::string
GetAccessCode(content::WebContents
* contents
);
14 // Launches a Chromoting app instance for the helper.
15 content::WebContents
* SetUpHelperInstance();
18 std::string
It2MeBrowserTest::GetAccessCode(content::WebContents
* contents
) {
19 RunJavaScriptTest(contents
, "GetAccessCode", "{}");
20 std::string access_code
= RemoteTestHelper::ExecuteScriptAndExtractString(
21 contents
, "document.getElementById('access-code-display').innerText");
25 content::WebContents
* It2MeBrowserTest::SetUpHelperInstance() {
26 content::WebContents
* helper_content
=
27 LaunchChromotingApp(false, NEW_FOREGROUND_TAB
);
28 LoadBrowserTestJavaScript(helper_content
);
29 LoadScript(helper_content
, FILE_PATH_LITERAL("it2me_browser_test.js"));
30 return helper_content
;
33 IN_PROC_BROWSER_TEST_F(It2MeBrowserTest
, MANUAL_Connect
) {
34 content::WebContents
* helpee_content
= SetUpTest();
35 LoadScript(helpee_content
, FILE_PATH_LITERAL("it2me_browser_test.js"));
37 content::WebContents
* helper_content
= SetUpHelperInstance();
38 RunJavaScriptTest(helper_content
, "ConnectIt2Me", "{"
39 "accessCode: '" + GetAccessCode(helpee_content
) + "'"
45 IN_PROC_BROWSER_TEST_F(It2MeBrowserTest
, MANUAL_InvalidAccessCode
) {
46 content::WebContents
* helpee_content
= SetUpTest();
47 LoadScript(helpee_content
, FILE_PATH_LITERAL("it2me_browser_test.js"));
49 // Generate an invalid access code by generating a valid access code and
50 // changing its PIN portion.
51 std::string access_code
= GetAccessCode(helpee_content
);
53 uint64 invalid_access_code
= 0;
54 ASSERT_TRUE(base::StringToUint64(access_code
, &invalid_access_code
));
55 std::ostringstream invalid_access_code_string
;
57 invalid_access_code_string
<< ++invalid_access_code
;
59 content::WebContents
* helper_content
= SetUpHelperInstance();
60 RunJavaScriptTest(helper_content
, "InvalidAccessCode", "{"
61 "accessCode: '" + invalid_access_code_string
.str() + "'"
67 } // namespace remoting