Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4033)

Unified Diff: chrome/common/chrome_switches_uitest.cc

Issue 7024017: Fix --host-rules command switch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/create/Create/ Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/chrome_switches_uitest.cc
diff --git a/chrome/common/chrome_switches_uitest.cc b/chrome/common/chrome_switches_uitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..feb8d9dffffb13848b23da783c167898165d2647
--- /dev/null
+++ b/chrome/common/chrome_switches_uitest.cc
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 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,
+ 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());
+}
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698