OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" |
9 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
14 #include "net/test/test_server.h" | 15 #include "net/test/test_server.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 struct IsSearchProviderTestData { | 19 struct IsSearchProviderTestData { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 Browser* browser, | 53 Browser* browser, |
53 const char* host, | 54 const char* host, |
54 const char* expected_result) { | 55 const char* expected_result) { |
55 GURL test_url(std::string("http://") + host + | 56 GURL test_url(std::string("http://") + host + |
56 search_provider_test_url_.path() + "#" + expected_result); | 57 search_provider_test_url_.path() + "#" + expected_result); |
57 ui_test_utils::NavigateToURLWithDisposition( | 58 ui_test_utils::NavigateToURLWithDisposition( |
58 browser, test_url, NEW_FOREGROUND_TAB, | 59 browser, test_url, NEW_FOREGROUND_TAB, |
59 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 60 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
60 | 61 |
61 // Bundle up information needed to verify the result. | 62 // Bundle up information needed to verify the result. |
62 content::WebContents* tab = browser->GetActiveWebContents(); | 63 content::WebContents* tab = chrome::GetActiveWebContents(browser); |
63 return IsSearchProviderTestData(tab, host, test_url); | 64 return IsSearchProviderTestData(tab, host, test_url); |
64 } | 65 } |
65 | 66 |
66 void FinishIsSearchProviderInstalledTest( | 67 void FinishIsSearchProviderInstalledTest( |
67 const IsSearchProviderTestData& data) { | 68 const IsSearchProviderTestData& data) { |
68 string16 title = data.tab->GetTitle(); | 69 string16 title = data.tab->GetTitle(); |
69 if (title.empty()) { | 70 if (title.empty()) { |
70 ui_test_utils::TitleWatcher title_watcher(data.tab, ASCIIToUTF16("OK")); | 71 ui_test_utils::TitleWatcher title_watcher(data.tab, ASCIIToUTF16("OK")); |
71 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 72 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
72 title = title_watcher.WaitAndGetTitle(); | 73 title = title_watcher.WaitAndGetTitle(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 IN_PROC_BROWSER_TEST_F(SearchProviderTest, | 128 IN_PROC_BROWSER_TEST_F(SearchProviderTest, |
128 TestIsSearchProviderInstalledWithException) { | 129 TestIsSearchProviderInstalledWithException) { |
129 // Change the url for the test page to one that throws an exception when | 130 // Change the url for the test page to one that throws an exception when |
130 // toString is called on the argument given to isSearchProviderInstalled. | 131 // toString is called on the argument given to isSearchProviderInstalled. |
131 search_provider_test_url_ = test_server()->GetURL( | 132 search_provider_test_url_ = test_server()->GetURL( |
132 "files/is_search_provider_installed_with_exception.html"); | 133 "files/is_search_provider_installed_with_exception.html"); |
133 | 134 |
134 FinishIsSearchProviderInstalledTest(StartIsSearchProviderInstalledTest( | 135 FinishIsSearchProviderInstalledTest(StartIsSearchProviderInstalledTest( |
135 browser(), "www.google.com", "")); | 136 browser(), "www.google.com", "")); |
136 } | 137 } |
OLD | NEW |