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_CancelShare
) {
46 content::WebContents
* helpee_content
= SetUpTest();
47 LoadScript(helpee_content
, FILE_PATH_LITERAL("it2me_browser_test.js"));
48 std::string access_code
= GetAccessCode(helpee_content
);
49 RunJavaScriptTest(helpee_content
, "CancelShare", "{}");
51 content::WebContents
* helper_content
= SetUpHelperInstance();
52 RunJavaScriptTest(helper_content
, "InvalidAccessCode", "{"
53 "accessCode: '" + access_code
+ "'"
58 IN_PROC_BROWSER_TEST_F(It2MeBrowserTest
, MANUAL_VerifyAccessCodeNonReusable
) {
59 content::WebContents
* helpee_content
= SetUpTest();
60 LoadScript(helpee_content
, FILE_PATH_LITERAL("it2me_browser_test.js"));
61 std::string access_code
= GetAccessCode(helpee_content
);
63 content::WebContents
* helper_content
= SetUpHelperInstance();
64 RunJavaScriptTest(helper_content
, "ConnectIt2Me", "{"
65 "accessCode: '" + access_code
+ "'"
68 RunJavaScriptTest(helper_content
, "InvalidAccessCode", "{"
69 "accessCode: '" + access_code
+ "'"
74 IN_PROC_BROWSER_TEST_F(It2MeBrowserTest
, MANUAL_InvalidAccessCode
) {
75 content::WebContents
* helpee_content
= SetUpTest();
76 LoadScript(helpee_content
, FILE_PATH_LITERAL("it2me_browser_test.js"));
78 // Generate an invalid access code by generating a valid access code and
79 // changing its PIN portion.
80 std::string access_code
= GetAccessCode(helpee_content
);
82 uint64 invalid_access_code
= 0;
83 ASSERT_TRUE(base::StringToUint64(access_code
, &invalid_access_code
));
84 std::ostringstream invalid_access_code_string
;
86 invalid_access_code_string
<< ++invalid_access_code
;
88 content::WebContents
* helper_content
= SetUpHelperInstance();
89 RunJavaScriptTest(helper_content
, "InvalidAccessCode", "{"
90 "accessCode: '" + invalid_access_code_string
.str() + "'"
96 } // namespace remoting