Chromium Code Reviews| Index: chrome/test/remoting/it2me_browsertest.cc |
| diff --git a/chrome/test/remoting/it2me_browsertest.cc b/chrome/test/remoting/it2me_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..42f892057294f4480575f154ae70629cacbdd618 |
| --- /dev/null |
| +++ b/chrome/test/remoting/it2me_browsertest.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/strings/string_number_conversions.h" |
| +#include "chrome/test/remoting/remote_desktop_browsertest.h" |
| + |
| +namespace remoting { |
| + |
| +class It2MeBrowserTest : public RemoteDesktopBrowserTest { |
| + protected: |
| + std::string GetAccessCode(content::WebContents* contents); |
| + |
| + // Launches a Chromoting app instance for the helper. |
| + content::WebContents* SetUpHelperInstance(); |
| +}; |
| + |
| +std::string It2MeBrowserTest::GetAccessCode(content::WebContents* contents) { |
| + RunJavaScriptTest(contents, "GetAccessCode", "{}"); |
| + std::string access_code = ExecuteScriptAndExtractString( |
| + contents, "document.getElementById('access-code-display').innerText"); |
| + return access_code; |
| +} |
| + |
| +content::WebContents* It2MeBrowserTest::SetUpHelperInstance() { |
| + content::WebContents* helper_content = nullptr; |
| + LaunchChromotingApp(false, NEW_FOREGROUND_TAB, &helper_content); |
| + 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.
|
| + LoadScript(helper_content, FILE_PATH_LITERAL("it2me_browser_test.js")); |
| + return helper_content; |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(It2MeBrowserTest, MANUAL_Connect) { |
| + content::WebContents* helpee_content = SetUpTest(); |
| + LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js")); |
| + |
| + content::WebContents* helper_content = SetUpHelperInstance(); |
| + RunJavaScriptTest(helper_content, "ConnectIt2Me", "{" |
| + "accessCode: '" + GetAccessCode(helpee_content) + "'" |
| + "}"); |
| + |
| + Cleanup(); |
| +} |
| + |
| +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.
|
| + content::WebContents* helpee_content = SetUpTest(); |
| + LoadScript(helpee_content, FILE_PATH_LITERAL("it2me_browser_test.js")); |
| + |
| + // Generate an invalid access code by generating a valid access code and |
| + // changing its PIN portion. |
| + std::string access_code = GetAccessCode(helpee_content); |
| + |
| + uint64 invalid_access_code = 0; |
| + ASSERT_TRUE(base::StringToUint64(access_code, &invalid_access_code)); |
| + std::ostringstream invalid_access_code_string; |
| + |
| + invalid_access_code_string << ++invalid_access_code; |
| + |
| + content::WebContents* helper_content = SetUpHelperInstance(); |
| + RunJavaScriptTest(helper_content, "InvalidAccessCode", "{" |
| + "accessCode: '" + invalid_access_code_string.str() + "'" |
| + "}"); |
| + |
| + Cleanup(); |
| +} |
| + |
| +} // namespace remoting |