Chromium Code Reviews| 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/history/history_db_task.h" | 13 #include "chrome/browser/history/history_db_task.h" |
| 14 #include "chrome/browser/history/history_service.h" | 14 #include "chrome/browser/history/history_service.h" |
| 15 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/browser_commands.h" | 18 #include "chrome/browser/ui/browser_commands.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "content/public/browser/notification_service.h" | |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
| 27 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 29 | 30 |
| 30 using content::BrowserThread; | 31 using content::BrowserThread; |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 // Note: WaitableEvent is not used for synchronization between the main thread | 35 // Note: WaitableEvent is not used for synchronization between the main thread |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 55 private: | 56 private: |
| 56 virtual ~WaitForHistoryTask() {} | 57 virtual ~WaitForHistoryTask() {} |
| 57 | 58 |
| 58 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); | 59 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 } // namespace | 62 } // namespace |
| 62 | 63 |
| 63 class HistoryBrowserTest : public InProcessBrowserTest { | 64 class HistoryBrowserTest : public InProcessBrowserTest { |
| 64 protected: | 65 protected: |
| 66 virtual void SetUpOnMainThread() OVERRIDE { | |
| 67 InProcessBrowserTest::SetUpOnMainThread(); | |
| 68 // Wait for the InstantNTP prerendered contents to load. | |
| 69 content::WindowedNotificationObserver observer( | |
|
sky
2013/10/07 20:30:59
Why do some tests need to do this?
samarth
2013/10/11 22:26:04
It's because the prerendering of the Instant NTP c
| |
| 70 content::NOTIFICATION_LOAD_STOP, | |
| 71 content::NotificationService::AllSources()); | |
| 72 observer.Wait(); | |
| 73 } | |
| 74 | |
| 65 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 75 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 66 command_line->AppendSwitch(switches::kEnableFileCookies); | 76 command_line->AppendSwitch(switches::kEnableFileCookies); |
| 67 } | 77 } |
| 68 | 78 |
| 69 PrefService* GetPrefs() { | 79 PrefService* GetPrefs() { |
| 70 return GetProfile()->GetPrefs(); | 80 return GetProfile()->GetPrefs(); |
| 71 } | 81 } |
| 72 | 82 |
| 73 Profile* GetProfile() { | 83 Profile* GetProfile() { |
| 74 return browser()->profile(); | 84 return browser()->profile(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, InvalidURLNoHistory) { | 314 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, InvalidURLNoHistory) { |
| 305 GURL non_existant = ui_test_utils::GetTestUrl( | 315 GURL non_existant = ui_test_utils::GetTestUrl( |
| 306 base::FilePath().AppendASCII("History"), | 316 base::FilePath().AppendASCII("History"), |
| 307 base::FilePath().AppendASCII("non_existant_file.html")); | 317 base::FilePath().AppendASCII("non_existant_file.html")); |
| 308 ui_test_utils::NavigateToURL(browser(), non_existant); | 318 ui_test_utils::NavigateToURL(browser(), non_existant); |
| 309 ExpectEmptyHistory(); | 319 ExpectEmptyHistory(); |
| 310 } | 320 } |
| 311 | 321 |
| 312 // New tab page should not show up in history. | 322 // New tab page should not show up in history. |
| 313 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, NewTabNoHistory) { | 323 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, NewTabNoHistory) { |
| 314 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 324 ui_test_utils::NavigateToURLWithDisposition( |
| 325 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, | |
| 326 ui_test_utils::BROWSER_TEST_NONE); | |
| 315 ExpectEmptyHistory(); | 327 ExpectEmptyHistory(); |
| 316 } | 328 } |
| 317 | 329 |
| 318 // Incognito browsing should not show up in history. | 330 // Incognito browsing should not show up in history. |
| 319 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, IncognitoNoHistory) { | 331 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, IncognitoNoHistory) { |
| 320 ui_test_utils::NavigateToURL(CreateIncognitoBrowser(), GetTestUrl()); | 332 ui_test_utils::NavigateToURL(CreateIncognitoBrowser(), GetTestUrl()); |
| 321 ExpectEmptyHistory(); | 333 ExpectEmptyHistory(); |
| 322 } | 334 } |
| 323 | 335 |
| 324 // Multiple navigations to the same url should have a single history. | 336 // Multiple navigations to the same url should have a single history. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 | 512 |
| 501 content::WebContents* active_web_contents = | 513 content::WebContents* active_web_contents = |
| 502 browser()->tab_strip_model()->GetActiveWebContents(); | 514 browser()->tab_strip_model()->GetActiveWebContents(); |
| 503 ASSERT_EQ(web_contents, active_web_contents); | 515 ASSERT_EQ(web_contents, active_web_contents); |
| 504 ASSERT_EQ(history_url, active_web_contents->GetURL()); | 516 ASSERT_EQ(history_url, active_web_contents->GetURL()); |
| 505 | 517 |
| 506 content::WebContents* second_tab = | 518 content::WebContents* second_tab = |
| 507 browser()->tab_strip_model()->GetWebContentsAt(1); | 519 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 508 ASSERT_NE(history_url, second_tab->GetURL()); | 520 ASSERT_NE(history_url, second_tab->GetURL()); |
| 509 } | 521 } |
| OLD | NEW |