| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/history/history.h" | 11 #include "chrome/browser/history/history.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/test/browser_test_utils.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread.h" |
| 24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 25 | 26 |
| 26 using content::BrowserThread; | 27 using content::BrowserThread; |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Note: WaitableEvent is not used for synchronization between the main thread | 31 // Note: WaitableEvent is not used for synchronization between the main thread |
| 31 // and history backend thread because the history subsystem posts tasks back | 32 // and history backend thread because the history subsystem posts tasks back |
| 32 // to the main thread. Had we tried to Signal an event in such a task | 33 // to the main thread. Had we tried to Signal an event in such a task |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ui_test_utils::RunMessageLoop(); | 132 ui_test_utils::RunMessageLoop(); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void ExpectEmptyHistory() { | 135 void ExpectEmptyHistory() { |
| 135 std::vector<GURL> urls(GetHistoryContents()); | 136 std::vector<GURL> urls(GetHistoryContents()); |
| 136 EXPECT_EQ(0U, urls.size()); | 137 EXPECT_EQ(0U, urls.size()); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void LoadAndWaitForURL(const GURL& url) { | 140 void LoadAndWaitForURL(const GURL& url) { |
| 140 string16 expected_title(ASCIIToUTF16("OK")); | 141 string16 expected_title(ASCIIToUTF16("OK")); |
| 141 ui_test_utils::TitleWatcher title_watcher( | 142 content::TitleWatcher title_watcher( |
| 142 chrome::GetActiveWebContents(browser()), expected_title); | 143 chrome::GetActiveWebContents(browser()), expected_title); |
| 143 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 144 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
| 144 ui_test_utils::NavigateToURL(browser(), url); | 145 ui_test_utils::NavigateToURL(browser(), url); |
| 145 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 146 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void LoadAndWaitForFile(const char* filename) { | 149 void LoadAndWaitForFile(const char* filename) { |
| 149 GURL url = ui_test_utils::GetTestUrl( | 150 GURL url = ui_test_utils::GetTestUrl( |
| 150 FilePath().AppendASCII("History"), | 151 FilePath().AppendASCII("History"), |
| 151 FilePath().AppendASCII(filename)); | 152 FilePath().AppendASCII(filename)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // Mainly, this is to ensure we send a synchronous message to the renderer | 303 // Mainly, this is to ensure we send a synchronous message to the renderer |
| 303 // so that we're not susceptible (less susceptible?) to a race condition. | 304 // so that we're not susceptible (less susceptible?) to a race condition. |
| 304 // Should a race condition ever trigger, it won't result in flakiness. | 305 // Should a race condition ever trigger, it won't result in flakiness. |
| 305 int num = ui_test_utils::FindInPage( | 306 int num = ui_test_utils::FindInPage( |
| 306 chrome::GetActiveTabContents(browser()), ASCIIToUTF16("<img"), true, | 307 chrome::GetActiveTabContents(browser()), ASCIIToUTF16("<img"), true, |
| 307 true, NULL); | 308 true, NULL); |
| 308 EXPECT_GT(num, 0); | 309 EXPECT_GT(num, 0); |
| 309 EXPECT_EQ(ASCIIToUTF16("History"), | 310 EXPECT_EQ(ASCIIToUTF16("History"), |
| 310 chrome::GetActiveWebContents(browser())->GetTitle()); | 311 chrome::GetActiveWebContents(browser())->GetTitle()); |
| 311 } | 312 } |
| OLD | NEW |