Chromium Code Reviews| 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..bff3a19e30aa2554aa6448bd64a6a3c4cb9ad7e0 |
| --- /dev/null |
| +++ b/chrome/common/chrome_switches_uitest.cc |
| @@ -0,0 +1,61 @@ |
| +// 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. |
| + test_server_started_ = test_server_.Start(); |
|
Paweł Hajdan Jr.
2011/06/08 09:05:55
nit: Please add a TODO(phajdan.jr) to change this
|
| + 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()) << "GetBrowserWindow failed."; |
|
Paweł Hajdan Jr.
2011/06/08 09:05:55
nit: Generally there is no need for those "GetBrow
|
| + |
| + scoped_refptr<TabProxy> tab(browser->GetActiveTab()); |
| + ASSERT_TRUE(tab.get()) << "BrowserProxy::GetActiveTab failed."; |
| + |
| + // 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()); |
| +} |