OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "base/strings/string_number_conversions.h" | |
6 #include "chrome/test/remoting/remote_desktop_browsertest.h" | |
7 | |
8 namespace remoting { | |
9 | |
10 class It2MeBrowserTest : public RemoteDesktopBrowserTest { | |
11 protected: | |
12 std::string GetAccessCode(content::WebContents* contents); | |
13 | |
14 // Launches a Chromoting app instance for the helper. | |
15 content::WebContents* SetUpHelperInstance(); | |
16 }; | |
17 | |
18 std::string It2MeBrowserTest::GetAccessCode(content::WebContents* contents) { | |
19 RunJavaScriptTest(contents, "GetAccessCode", "{}"); | |
20 std::string access_code = ExecuteScriptAndExtractString( | |
21 contents, "document.getElementById('access-code-display').innerText"); | |
22 return access_code; | |
23 } | |
24 | |
25 content::WebContents* It2MeBrowserTest::SetUpHelperInstance() { | |
26 content::WebContents* helper_content = nullptr; | |
27 LaunchChromotingApp(false, NEW_FOREGROUND_TAB, &helper_content); | |
28 LoadScript(helper_content, FILE_PATH_LITERAL("browser_test.js")); | |
Jamie
2015/01/10 00:14:24
Since my CL adding LoadBrowserTestJavaScript is al
kelvinp
2015/01/12 21:15:24
Acknowledged.
| |
29 LoadScript(helper_content, FILE_PATH_LITERAL("it2me_browser_test.js")); | |
30 return helper_content; | |
31 } | |
32 | |
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")); | |
36 | |
37 content::WebContents* helper_content = SetUpHelperInstance(); | |
38 RunJavaScriptTest(helper_content, "ConnectIt2Me", "{" | |
39 "accessCode: '" + GetAccessCode(helpee_content) + "'" | |
40 "}"); | |
41 | |
42 Cleanup(); | |
43 } | |
44 | |
45 IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_InvalidAccessCode) { | |
Jamie
2015/01/10 00:14:23
We should have two tests here: one to check that a
kelvinp
2015/01/12 21:15:24
Acknowledged.
| |
46 content::WebContents* helpee_content = SetUpTest(); | |
47 LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js")); | |
48 | |
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); | |
52 | |
53 uint64 invalid_access_code = 0; | |
54 ASSERT_TRUE(base::StringToUint64(access_code, &invalid_access_code)); | |
55 std::ostringstream invalid_access_code_string; | |
56 | |
57 invalid_access_code_string << ++invalid_access_code; | |
58 | |
59 content::WebContents* helper_content = SetUpHelperInstance(); | |
60 RunJavaScriptTest(helper_content, "InvalidAccessCode", "{" | |
61 "accessCode: '" + invalid_access_code_string.str() + "'" | |
62 "}"); | |
63 | |
64 Cleanup(); | |
65 } | |
66 | |
67 } // namespace remoting | |
OLD | NEW |