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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/timer.h" | 6 #include "base/timer.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_utils.h" | 11 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
| 19 #include "chrome/browser/ui/search/search.h" | |
| 19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/url_constants.h" | |
| 20 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 const char kPersistBookmarkURL[] = "http://www.cnn.com/"; | 28 const char kPersistBookmarkURL[] = "http://www.cnn.com/"; |
| 27 const char kPersistBookmarkTitle[] = "CNN"; | 29 const char kPersistBookmarkTitle[] = "CNN"; |
| 28 } | 30 } |
| 29 | 31 |
| 30 class BookmarkBrowsertest : public InProcessBrowserTest { | 32 class BookmarkBrowsertest : public InProcessBrowserTest { |
| 31 public: | 33 public: |
| 32 BookmarkBrowsertest() {} | |
| 33 | |
| 34 bool IsVisible() { | 34 bool IsVisible() { |
| 35 return browser()->bookmark_bar_state() == BookmarkBar::SHOW; | 35 return browser()->bookmark_bar_state() == BookmarkBar::SHOW; |
| 36 } | 36 } |
| 37 | 37 |
| 38 static void CheckAnimation(Browser* browser, const base::Closure& quit_task) { | 38 static void CheckAnimation(Browser* browser, const base::Closure& quit_task) { |
| 39 if (!browser->window()->IsBookmarkBarAnimating()) | 39 if (!browser->window()->IsBookmarkBarAnimating()) |
| 40 quit_task.Run(); | 40 quit_task.Run(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 base::TimeDelta WaitForBookmarkBarAnimationToFinish() { | 43 base::TimeDelta WaitForBookmarkBarAnimationToFinish() { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 55 } | 55 } |
| 56 | 56 |
| 57 BookmarkModel* WaitForBookmarkModel(Profile* profile) { | 57 BookmarkModel* WaitForBookmarkModel(Profile* profile) { |
| 58 BookmarkModel* bookmark_model = | 58 BookmarkModel* bookmark_model = |
| 59 BookmarkModelFactory::GetForProfile(profile); | 59 BookmarkModelFactory::GetForProfile(profile); |
| 60 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model); | 60 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model); |
| 61 return bookmark_model; | 61 return bookmark_model; |
| 62 } | 62 } |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 class BookmarkInstantExtendedBrowsertest : public InProcessBrowserTest { | |
| 66 public: | |
| 67 BookmarkInstantExtendedBrowsertest() { | |
| 68 chrome::search::EnableInstantExtendedAPIForTesting(); | |
| 69 } | |
| 70 }; | |
|
sky
2013/02/12 03:27:49
private:DISALLOW... and move this above tests that
sail
2013/02/12 03:34:04
Done.
One advantage of making this a browser test
| |
| 71 | |
| 65 // Test of bookmark bar toggling, visibility, and animation. | 72 // Test of bookmark bar toggling, visibility, and animation. |
| 66 IN_PROC_BROWSER_TEST_F(BookmarkBrowsertest, BookmarkBarVisibleWait) { | 73 IN_PROC_BROWSER_TEST_F(BookmarkBrowsertest, BookmarkBarVisibleWait) { |
| 67 ASSERT_FALSE(IsVisible()); | 74 ASSERT_FALSE(IsVisible()); |
| 68 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); | 75 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); |
| 69 base::TimeDelta delay = WaitForBookmarkBarAnimationToFinish(); | 76 base::TimeDelta delay = WaitForBookmarkBarAnimationToFinish(); |
| 70 LOG(INFO) << "Took " << delay.InMilliseconds() << " ms to show bookmark bar"; | 77 LOG(INFO) << "Took " << delay.InMilliseconds() << " ms to show bookmark bar"; |
| 71 ASSERT_TRUE(IsVisible()); | 78 ASSERT_TRUE(IsVisible()); |
| 72 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); | 79 chrome::ExecuteCommand(browser(), IDC_SHOW_BOOKMARK_BAR); |
| 73 delay = WaitForBookmarkBarAnimationToFinish(); | 80 delay = WaitForBookmarkBarAnimationToFinish(); |
| 74 LOG(INFO) << "Took " << delay.InMilliseconds() << " ms to hide bookmark bar"; | 81 LOG(INFO) << "Took " << delay.InMilliseconds() << " ms to hide bookmark bar"; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 bookmark_model1, GURL(kPersistBookmarkURL), | 123 bookmark_model1, GURL(kPersistBookmarkURL), |
| 117 ASCIIToUTF16(kPersistBookmarkTitle)); | 124 ASCIIToUTF16(kPersistBookmarkTitle)); |
| 118 std::vector<BookmarkService::URLAndTitle> urls1, urls2; | 125 std::vector<BookmarkService::URLAndTitle> urls1, urls2; |
| 119 bookmark_model1->GetBookmarks(&urls1); | 126 bookmark_model1->GetBookmarks(&urls1); |
| 120 bookmark_model2->GetBookmarks(&urls2); | 127 bookmark_model2->GetBookmarks(&urls2); |
| 121 ASSERT_EQ(1u, urls1.size()); | 128 ASSERT_EQ(1u, urls1.size()); |
| 122 ASSERT_TRUE(urls2.empty()); | 129 ASSERT_TRUE(urls2.empty()); |
| 123 } | 130 } |
| 124 | 131 |
| 125 #endif | 132 #endif |
| 133 | |
| 134 // Verify that the detached bookmark bar is visible on the new tab page. | |
| 135 IN_PROC_BROWSER_TEST_F(BookmarkBrowsertest, DetachedBookmarkBar) { | |
| 136 AddTabAtIndex(1, | |
| 137 GURL(chrome::kChromeUINewTabURL), | |
| 138 content::PAGE_TRANSITION_LINK); | |
| 139 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | |
| 140 } | |
| 141 | |
| 142 // Verify that in instant extended mode the detached bookmark bar is visible on | |
| 143 // the new tab page. | |
| 144 IN_PROC_BROWSER_TEST_F(BookmarkInstantExtendedBrowsertest, | |
| 145 DetachedBookmarkBar) { | |
| 146 chrome::search::EnableInstantExtendedAPIForTesting(); | |
| 147 AddTabAtIndex(1, | |
| 148 GURL(chrome::kChromeUINewTabURL), | |
| 149 content::PAGE_TRANSITION_LINK); | |
| 150 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | |
| 151 } | |
| OLD | NEW |