Index: remoting/test/remote_desktop_browsertest.cc |
diff --git a/remoting/test/remote_desktop_browsertest.cc b/remoting/test/remote_desktop_browsertest.cc |
index c8d8bf7158bcd1648bb51895c79c4a584365ce14..8d91a06fb11245d32e10b4193d2547de4812fd25 100644 |
--- a/remoting/test/remote_desktop_browsertest.cc |
+++ b/remoting/test/remote_desktop_browsertest.cc |
@@ -36,59 +36,6 @@ void RemoteDesktopBrowserTest::TearDownInProcessBrowserTestFixture() { |
DisableDNSLookupForThisTest(); |
} |
-void RemoteDesktopBrowserTest::ParseCommandLine() { |
- CommandLine* command_line = CommandLine::ForCurrentProcess(); |
- |
- // The test framework overrides any command line user-data-dir |
- // argument with a /tmp/.org.chromium.Chromium.XXXXXX directory. |
- // That happens in the ChromeTestLauncherDelegate, and affects |
- // all unit tests (no opt out available). It intentionally erases |
- // any --user-data-dir switch if present and appends a new one. |
- // Re-override the default data dir if override-user-data-dir |
- // is specified. |
- if (command_line->HasSwitch(kOverrideUserDataDir)) { |
- const base::FilePath& override_user_data_dir = |
- command_line->GetSwitchValuePath(kOverrideUserDataDir); |
- |
- ASSERT_FALSE(override_user_data_dir.empty()); |
- |
- command_line->AppendSwitchPath(switches::kUserDataDir, |
- override_user_data_dir); |
- } |
- |
- username_ = command_line->GetSwitchValueASCII(kUsername); |
- password_ = command_line->GetSwitchValueASCII(kkPassword); |
- |
- no_cleanup_ = command_line->HasSwitch(kNoCleanup); |
- no_install_ = command_line->HasSwitch(kNoInstall); |
- |
- if (!no_install_) { |
- webapp_crx_ = command_line->GetSwitchValuePath(kWebAppCrx); |
- ASSERT_FALSE(webapp_crx_.empty()); |
- } |
-} |
- |
-void RemoteDesktopBrowserTest::EnableDNSLookupForThisTest( |
- net::RuleBasedHostResolverProc* host_resolver) { |
- // mock_host_resolver_override_ takes ownership of the resolver. |
- scoped_refptr<net::RuleBasedHostResolverProc> resolver = |
- new net::RuleBasedHostResolverProc(host_resolver); |
- resolver->AllowDirectLookup("*.google.com"); |
- // On Linux, we use Chromium's NSS implementation which uses the following |
- // hosts for certificate verification. Without these overrides, running the |
- // integration tests on Linux causes errors as we make external DNS lookups. |
- resolver->AllowDirectLookup("*.thawte.com"); |
- resolver->AllowDirectLookup("*.geotrust.com"); |
- resolver->AllowDirectLookup("*.gstatic.com"); |
- resolver->AllowDirectLookup("*.googleapis.com"); |
- mock_host_resolver_override_.reset( |
- new net::ScopedDefaultHostResolverProc(resolver.get())); |
-} |
- |
-void RemoteDesktopBrowserTest::DisableDNSLookupForThisTest() { |
- mock_host_resolver_override_.reset(); |
-} |
- |
void RemoteDesktopBrowserTest::VerifyInternetAccess() { |
GURL google_url("http://www.google.com"); |
NavigateToURLAndWait(google_url); |
@@ -109,15 +56,6 @@ void RemoteDesktopBrowserTest::UninstallChromotingApp() { |
chromoting_id_.clear(); |
} |
-void RemoteDesktopBrowserTest::LaunchChromotingApp() { |
- ASSERT_FALSE(ChromotingID().empty()); |
- |
- const GURL chromoting_main = Chromoting_Main_URL(); |
- NavigateToURLAndWait(chromoting_main); |
- |
- EXPECT_EQ(GetCurrentURL(), chromoting_main); |
-} |
- |
void RemoteDesktopBrowserTest::VerifyChromotingLoaded(bool expected) { |
const ExtensionSet* extensions = extension_service()->extensions(); |
scoped_refptr<const extensions::Extension> extension; |
@@ -147,6 +85,15 @@ void RemoteDesktopBrowserTest::VerifyChromotingLoaded(bool expected) { |
EXPECT_EQ(installed, expected); |
} |
+void RemoteDesktopBrowserTest::LaunchChromotingApp() { |
+ ASSERT_FALSE(ChromotingID().empty()); |
+ |
+ const GURL chromoting_main = Chromoting_Main_URL(); |
+ NavigateToURLAndWait(chromoting_main); |
+ |
+ EXPECT_EQ(GetCurrentURL(), chromoting_main); |
+} |
+ |
void RemoteDesktopBrowserTest::Authorize() { |
// The chromoting extension should be installed. |
ASSERT_FALSE(ChromotingID().empty()); |
@@ -210,4 +157,151 @@ void RemoteDesktopBrowserTest::Approve() { |
"remoting.OAuth2.prototype.isAuthenticated()")); |
} |
+void RemoteDesktopBrowserTest::Install() { |
+ // TODO: add support for installing unpacked extension (the v2 app needs it). |
+ if (!NoInstall()) { |
+ VerifyChromotingLoaded(false); |
+ InstallChromotingApp(); |
+ } |
+ |
+ VerifyChromotingLoaded(true); |
+} |
+ |
+void RemoteDesktopBrowserTest::Cleanup() { |
+ // TODO: Remove this hack by blocking on the appropriate notification. |
+ // The browser may still be loading images embedded in the webapp. If we |
+ // uinstall it now those load will fail. Navigating away to avoid the load |
+ // failures. |
+ ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
+ |
+ if (!NoCleanup()) { |
+ UninstallChromotingApp(); |
+ VerifyChromotingLoaded(false); |
+ } |
+} |
+ |
+void RemoteDesktopBrowserTest::Auth() { |
+ Authorize(); |
+ Authenticate(); |
+ Approve(); |
+} |
+ |
+void RemoteDesktopBrowserTest::EnableDNSLookupForThisTest( |
+ net::RuleBasedHostResolverProc* host_resolver) { |
+ // mock_host_resolver_override_ takes ownership of the resolver. |
+ scoped_refptr<net::RuleBasedHostResolverProc> resolver = |
+ new net::RuleBasedHostResolverProc(host_resolver); |
+ resolver->AllowDirectLookup("*.google.com"); |
+ // On Linux, we use Chromium's NSS implementation which uses the following |
+ // hosts for certificate verification. Without these overrides, running the |
+ // integration tests on Linux causes errors as we make external DNS lookups. |
+ resolver->AllowDirectLookup("*.thawte.com"); |
+ resolver->AllowDirectLookup("*.geotrust.com"); |
+ resolver->AllowDirectLookup("*.gstatic.com"); |
+ resolver->AllowDirectLookup("*.googleapis.com"); |
+ mock_host_resolver_override_.reset( |
+ new net::ScopedDefaultHostResolverProc(resolver.get())); |
+} |
+ |
+void RemoteDesktopBrowserTest::DisableDNSLookupForThisTest() { |
+ mock_host_resolver_override_.reset(); |
+} |
+ |
+void RemoteDesktopBrowserTest::ParseCommandLine() { |
+ CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ |
+ // The test framework overrides any command line user-data-dir |
+ // argument with a /tmp/.org.chromium.Chromium.XXXXXX directory. |
+ // That happens in the ChromeTestLauncherDelegate, and affects |
+ // all unit tests (no opt out available). It intentionally erases |
+ // any --user-data-dir switch if present and appends a new one. |
+ // Re-override the default data dir if override-user-data-dir |
+ // is specified. |
+ if (command_line->HasSwitch(kOverrideUserDataDir)) { |
+ const base::FilePath& override_user_data_dir = |
+ command_line->GetSwitchValuePath(kOverrideUserDataDir); |
+ |
+ ASSERT_FALSE(override_user_data_dir.empty()); |
+ |
+ command_line->AppendSwitchPath(switches::kUserDataDir, |
+ override_user_data_dir); |
+ } |
+ |
+ username_ = command_line->GetSwitchValueASCII(kUsername); |
+ password_ = command_line->GetSwitchValueASCII(kkPassword); |
+ |
+ no_cleanup_ = command_line->HasSwitch(kNoCleanup); |
+ no_install_ = command_line->HasSwitch(kNoInstall); |
+ |
+ if (!no_install_) { |
+ webapp_crx_ = command_line->GetSwitchValuePath(kWebAppCrx); |
+ ASSERT_FALSE(webapp_crx_.empty()); |
+ } |
+} |
+ |
+void RemoteDesktopBrowserTest::ExecuteScript(const std::string& script) { |
+ ASSERT_TRUE(content::ExecuteScript( |
+ browser()->tab_strip_model()->GetActiveWebContents(), script)); |
+} |
+ |
+void RemoteDesktopBrowserTest::ExecuteScriptAndWait(const std::string& script) { |
+ content::WindowedNotificationObserver observer( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<content::NavigationController>( |
+ &browser()->tab_strip_model()->GetActiveWebContents()-> |
+ GetController())); |
+ |
+ ExecuteScript(script); |
+ |
+ observer.Wait(); |
+} |
+ |
+void RemoteDesktopBrowserTest::ExecuteScriptAndWaitUntil( |
+ const std::string& script, |
+ const GURL& target) { |
+ content::WindowedNotificationObserver observer( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<content::NavigationController>( |
+ &browser()->tab_strip_model()->GetActiveWebContents()-> |
+ GetController())); |
+ |
+ ExecuteScript(script); |
+ |
+ observer.Wait(); |
+ |
+ // TODO: is there a better way to wait for all the redirections to complete? |
+ while (GetCurrentURL() != target) { |
+ content::WindowedNotificationObserver( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<content::NavigationController>( |
+ &browser()->tab_strip_model()->GetActiveWebContents()-> |
+ GetController())).Wait(); |
+ } |
+} |
+ |
+bool RemoteDesktopBrowserTest::ExecuteScriptAndExtractBool( |
+ const std::string& script) { |
+ bool result; |
+ // Using a private assert function because ASSERT_TRUE can only be used in |
+ // void returning functions. |
+ _ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
+ browser()->tab_strip_model()->GetActiveWebContents(), |
+ "window.domAutomationController.send(" + script + ");", |
+ &result)); |
+ |
+ return result; |
+} |
+ |
+// Helper to navigate to a given url. |
+void RemoteDesktopBrowserTest::NavigateToURLAndWait(const GURL& url) { |
+ content::WindowedNotificationObserver observer( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<content::NavigationController>( |
+ &browser()->tab_strip_model()->GetActiveWebContents()-> |
+ GetController())); |
+ |
+ ui_test_utils::NavigateToURL(browser(), url); |
+ observer.Wait(); |
+} |
+ |
} // namespace remoting |