| 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/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/test/browser_test_utils.h" |
| 15 #include "net/test/test_server.h" | 16 #include "net/test/test_server.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 struct IsSearchProviderTestData { | 20 struct IsSearchProviderTestData { |
| 20 IsSearchProviderTestData() : tab(NULL) {} | 21 IsSearchProviderTestData() : tab(NULL) {} |
| 21 IsSearchProviderTestData(content::WebContents* t, std::string h, GURL url) | 22 IsSearchProviderTestData(content::WebContents* t, std::string h, GURL url) |
| 22 : tab(t), host(h), test_url(url) { | 23 : tab(t), host(h), test_url(url) { |
| 23 } | 24 } |
| 24 | 25 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 62 |
| 62 // Bundle up information needed to verify the result. | 63 // Bundle up information needed to verify the result. |
| 63 content::WebContents* tab = chrome::GetActiveWebContents(browser); | 64 content::WebContents* tab = chrome::GetActiveWebContents(browser); |
| 64 return IsSearchProviderTestData(tab, host, test_url); | 65 return IsSearchProviderTestData(tab, host, test_url); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void FinishIsSearchProviderInstalledTest( | 68 void FinishIsSearchProviderInstalledTest( |
| 68 const IsSearchProviderTestData& data) { | 69 const IsSearchProviderTestData& data) { |
| 69 string16 title = data.tab->GetTitle(); | 70 string16 title = data.tab->GetTitle(); |
| 70 if (title.empty()) { | 71 if (title.empty()) { |
| 71 ui_test_utils::TitleWatcher title_watcher(data.tab, ASCIIToUTF16("OK")); | 72 content::TitleWatcher title_watcher(data.tab, ASCIIToUTF16("OK")); |
| 72 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 73 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
| 73 title = title_watcher.WaitAndGetTitle(); | 74 title = title_watcher.WaitAndGetTitle(); |
| 74 } | 75 } |
| 75 EXPECT_EQ(ASCIIToUTF16("OK"), title); | 76 EXPECT_EQ(ASCIIToUTF16("OK"), title); |
| 76 } | 77 } |
| 77 | 78 |
| 78 GURL search_provider_test_url_; | 79 GURL search_provider_test_url_; |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); | 82 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 IN_PROC_BROWSER_TEST_F(SearchProviderTest, | 129 IN_PROC_BROWSER_TEST_F(SearchProviderTest, |
| 129 TestIsSearchProviderInstalledWithException) { | 130 TestIsSearchProviderInstalledWithException) { |
| 130 // Change the url for the test page to one that throws an exception when | 131 // Change the url for the test page to one that throws an exception when |
| 131 // toString is called on the argument given to isSearchProviderInstalled. | 132 // toString is called on the argument given to isSearchProviderInstalled. |
| 132 search_provider_test_url_ = test_server()->GetURL( | 133 search_provider_test_url_ = test_server()->GetURL( |
| 133 "files/is_search_provider_installed_with_exception.html"); | 134 "files/is_search_provider_installed_with_exception.html"); |
| 134 | 135 |
| 135 FinishIsSearchProviderInstalledTest(StartIsSearchProviderInstalledTest( | 136 FinishIsSearchProviderInstalledTest(StartIsSearchProviderInstalledTest( |
| 136 browser(), "www.google.com", "")); | 137 browser(), "www.google.com", "")); |
| 137 } | 138 } |
| OLD | NEW |