summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 19:14:20 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 19:14:20 +0000
commit3f36ad405b50affcad06ac039b5546524176f585 (patch)
tree97d9bf7db741eb5ac9caa35286c043ce707f6e4d
parent71e46cdd37f11fe5a334831a87d7db7d59478b46 (diff)
downloadchromium_src-3f36ad405b50affcad06ac039b5546524176f585.zip
chromium_src-3f36ad405b50affcad06ac039b5546524176f585.tar.gz
chromium_src-3f36ad405b50affcad06ac039b5546524176f585.tar.bz2
Convert chrome_switches ui_test to a browser_test.
BUG=121574 Review URL: https://chromiumcodereview.appspot.com/10071017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132029 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_switches_browsertest.cc49
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/common/chrome_switches_uitest.cc64
3 files changed, 50 insertions, 65 deletions
diff --git a/chrome/browser/chrome_switches_browsertest.cc b/chrome/browser/chrome_switches_browsertest.cc
new file mode 100644
index 0000000..9e2ff0a
--- /dev/null
+++ b/chrome/browser/chrome_switches_browsertest.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 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/command_line.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/web_contents.h"
+#include "net/test/test_server.h"
+
+class HostRulesTest : public InProcessBrowserTest {
+ protected:
+ HostRulesTest() {
+ EnableDOMAutomation();
+ }
+
+ virtual void SetUpCommandLine(CommandLine* command_line) {
+ ASSERT_TRUE(test_server()->Start());
+
+ // Map all hosts to our local server.
+ std::string host_rule(
+ "MAP * " + test_server()->host_port_pair().ToString());
+ command_line->AppendSwitchASCII(switches::kHostRules, host_rule);
+ // Use no proxy or otherwise this test will fail on a machine that has a
+ // proxy configured.
+ command_line->AppendSwitch(switches::kNoProxyServer);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(HostRulesTest);
+};
+
+IN_PROC_BROWSER_TEST_F(HostRulesTest, TestMap) {
+ // Go to the empty page using www.google.com as the host.
+ GURL local_url = test_server()->GetURL("files/empty.html");
+ GURL test_url(std::string("http://www.google.com") + local_url.path());
+ ui_test_utils::NavigateToURL(browser(), test_url);
+
+ std::string html;
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
+ browser()->GetSelectedWebContents()->GetRenderViewHost(),
+ L"",
+ L"window.domAutomationController.send(document.body.outerHTML);",
+ &html));
+
+ EXPECT_STREQ("<body></body>", html.c_str());
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 3e3a31b..e4182f7 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -775,7 +775,6 @@
'browser/ui/webui/options2/options_ui2_uitest.cc',
'browser/ui/webui/options2/options_ui2_uitest.h',
'browser/ui/webui/print_preview/print_preview_ui_uitest.cc',
- 'common/chrome_switches_uitest.cc',
'common/logging_chrome_uitest.cc',
'renderer/external_extension_uitest.cc',
'renderer/loadtimes_extension_bindings_uitest.cc',
@@ -2693,6 +2692,7 @@
'browser/browsing_data_indexed_db_helper_browsertest.cc',
'browser/browsing_data_local_storage_helper_browsertest.cc',
'browser/chrome_main_browsertest.cc',
+ 'browser/chrome_switches_browsertest.cc',
'browser/chromeos/cros/cros_in_process_browser_test.cc',
'browser/chromeos/cros/cros_in_process_browser_test.h',
'browser/chromeos/cros/cros_mock.cc',
diff --git a/chrome/common/chrome_switches_uitest.cc b/chrome/common/chrome_switches_uitest.cc
deleted file mode 100644
index f1d5634..0000000
--- a/chrome/common/chrome_switches_uitest.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2012 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 "chrome/common/chrome_switches.h"
-#include "chrome/test/automation/automation_proxy.h"
-#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/automation/tab_proxy.h"
-#include "chrome/test/ui/ui_test.h"
-#include "net/test/test_server.h"
-
-class HostRulesTest : public UITest {
- protected:
- HostRulesTest();
-
- net::TestServer test_server_;
- bool test_server_started_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HostRulesTest);
-};
-
-HostRulesTest::HostRulesTest()
- : test_server_(net::TestServer::TYPE_HTTP,
- net::TestServer::kLocalhost,
- FilePath(FILE_PATH_LITERAL("chrome/test/data"))),
- test_server_started_(false) {
- dom_automation_enabled_ = true;
-
- // The test_server is started in the constructor (rather than the test body)
- // so the mapping rules below can include the ephemeral port number.
- // TODO(phajdan.jr): Change this code when we can ask the test server whether
- // it started.
- test_server_started_ = test_server_.Start();
- if (!test_server_started_)
- return;
-
- // Map all hosts to our local server.
- std::string host_rule("MAP * " + test_server_.host_port_pair().ToString());
- launch_arguments_.AppendSwitchASCII(switches::kHostRules, host_rule);
-}
-
-TEST_F(HostRulesTest, TestMap) {
- ASSERT_TRUE(test_server_started_);
-
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- scoped_refptr<TabProxy> tab(browser->GetActiveTab());
- ASSERT_TRUE(tab.get());
-
- // Go to the empty page using www.google.com as the host.
- GURL local_url = test_server_.GetURL("files/empty.html");
- GURL test_url(std::string("http://www.google.com") + local_url.path());
- EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url));
-
- std::wstring html;
- EXPECT_TRUE(tab->ExecuteAndExtractString(
- L"",
- L"window.domAutomationController.send(document.body.outerHTML);",
- &html));
-
- EXPECT_STREQ(L"<body></body>", html.c_str());
-}