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 = RemoteTestHelper::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 = |
| 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; |
| 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) { |
| 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 |