| 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/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" | 14 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
| 15 #include "chrome/browser/chrome_content_browser_client.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 18 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" | 20 #include "chrome/browser/ui/browser_tabstrip.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 23 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 24 #include "chrome/common/chrome_content_client.h" |
| 23 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/test/base/chrome_unit_test_suite.h" |
| 24 #include "chrome/test/base/interactive_test_utils.h" | 27 #include "chrome/test/base/interactive_test_utils.h" |
| 25 #include "chrome/test/base/scoped_testing_local_state.h" | 28 #include "chrome/test/base/scoped_testing_local_state.h" |
| 26 #include "chrome/test/base/test_browser_window.h" | 29 #include "chrome/test/base/test_browser_window.h" |
| 27 #include "chrome/test/base/testing_browser_process.h" | 30 #include "chrome/test/base/testing_browser_process.h" |
| 28 #include "chrome/test/base/testing_profile.h" | 31 #include "chrome/test/base/testing_profile.h" |
| 29 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
| 30 #include "chrome/test/base/view_event_test_base.h" | 33 #include "chrome/test/base/view_event_test_base.h" |
| 31 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/page_navigator.h" | 35 #include "content/public/browser/page_navigator.h" |
| 33 #include "content/public/test/test_browser_thread.h" | 36 #include "content/public/test/test_browser_thread.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // | 114 // |
| 112 // Subclasses should be sure and invoke super's implementation of SetUp and | 115 // Subclasses should be sure and invoke super's implementation of SetUp and |
| 113 // TearDown. | 116 // TearDown. |
| 114 class BookmarkBarViewEventTestBase : public ViewEventTestBase { | 117 class BookmarkBarViewEventTestBase : public ViewEventTestBase { |
| 115 public: | 118 public: |
| 116 BookmarkBarViewEventTestBase() | 119 BookmarkBarViewEventTestBase() |
| 117 : ViewEventTestBase(), | 120 : ViewEventTestBase(), |
| 118 model_(NULL) {} | 121 model_(NULL) {} |
| 119 | 122 |
| 120 virtual void SetUp() OVERRIDE { | 123 virtual void SetUp() OVERRIDE { |
| 124 ChromeUnitTestSuite::InitializeProviders(); |
| 125 ChromeUnitTestSuite::InitializeResourceBundle(); |
| 126 content_client_.reset(new ChromeContentClient); |
| 127 content::SetContentClient(content_client_.get()); |
| 128 browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); |
| 129 content::SetBrowserClientForTesting(browser_content_client_.get()); |
| 130 |
| 121 views::MenuController::TurnOffMenuSelectionHoldForTest(); | 131 views::MenuController::TurnOffMenuSelectionHoldForTest(); |
| 122 BookmarkBarView::DisableAnimationsForTesting(true); | 132 BookmarkBarView::DisableAnimationsForTesting(true); |
| 123 | 133 |
| 124 profile_.reset(new TestingProfile()); | 134 profile_.reset(new TestingProfile()); |
| 125 profile_->CreateBookmarkModel(true); | 135 profile_->CreateBookmarkModel(true); |
| 126 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); | 136 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); |
| 127 test::WaitForBookmarkModelToLoad(model_); | 137 test::WaitForBookmarkModelToLoad(model_); |
| 128 profile_->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); | 138 profile_->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); |
| 129 | 139 |
| 130 Browser::CreateParams native_params(profile_.get(), | 140 Browser::CreateParams native_params(profile_.get(), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 browser_.reset(); | 188 browser_.reset(); |
| 179 profile_.reset(); | 189 profile_.reset(); |
| 180 | 190 |
| 181 // Run the message loop to ensure we delete allTasks and fully shut down. | 191 // Run the message loop to ensure we delete allTasks and fully shut down. |
| 182 base::MessageLoop::current()->PostTask(FROM_HERE, | 192 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 183 base::MessageLoop::QuitClosure()); | 193 base::MessageLoop::QuitClosure()); |
| 184 base::MessageLoop::current()->Run(); | 194 base::MessageLoop::current()->Run(); |
| 185 | 195 |
| 186 ViewEventTestBase::TearDown(); | 196 ViewEventTestBase::TearDown(); |
| 187 BookmarkBarView::DisableAnimationsForTesting(false); | 197 BookmarkBarView::DisableAnimationsForTesting(false); |
| 198 |
| 199 browser_content_client_.reset(); |
| 200 content_client_.reset(); |
| 201 content::SetContentClient(NULL); |
| 188 } | 202 } |
| 189 | 203 |
| 190 protected: | 204 protected: |
| 191 virtual views::View* CreateContentsView() OVERRIDE { | 205 virtual views::View* CreateContentsView() OVERRIDE { |
| 192 return bb_view_.get(); | 206 return bb_view_.get(); |
| 193 } | 207 } |
| 194 | 208 |
| 195 virtual gfx::Size GetPreferredSize() OVERRIDE { return bb_view_pref_; } | 209 virtual gfx::Size GetPreferredSize() OVERRIDE { return bb_view_pref_; } |
| 196 | 210 |
| 197 views::TextButton* GetBookmarkButton(int view_index) { | 211 views::TextButton* GetBookmarkButton(int view_index) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ASCIIToUTF16("OF")); | 246 ASCIIToUTF16("OF")); |
| 233 model_->AddURL(of, 0, ASCIIToUTF16("ofa"), GURL(test_base + "ofa")); | 247 model_->AddURL(of, 0, ASCIIToUTF16("ofa"), GURL(test_base + "ofa")); |
| 234 model_->AddURL(of, 1, ASCIIToUTF16("ofb"), GURL(test_base + "ofb")); | 248 model_->AddURL(of, 1, ASCIIToUTF16("ofb"), GURL(test_base + "ofb")); |
| 235 const BookmarkNode* of2 = model_->AddFolder(model_->other_node(), 2, | 249 const BookmarkNode* of2 = model_->AddFolder(model_->other_node(), 2, |
| 236 ASCIIToUTF16("OF2")); | 250 ASCIIToUTF16("OF2")); |
| 237 model_->AddURL(of2, 0, ASCIIToUTF16("of2a"), GURL(test_base + "of2a")); | 251 model_->AddURL(of2, 0, ASCIIToUTF16("of2a"), GURL(test_base + "of2a")); |
| 238 model_->AddURL(of2, 1, ASCIIToUTF16("of2b"), GURL(test_base + "of2b")); | 252 model_->AddURL(of2, 1, ASCIIToUTF16("of2b"), GURL(test_base + "of2b")); |
| 239 } | 253 } |
| 240 | 254 |
| 241 gfx::Size bb_view_pref_; | 255 gfx::Size bb_view_pref_; |
| 256 scoped_ptr<ChromeContentClient> content_client_; |
| 257 scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; |
| 242 scoped_ptr<TestingProfile> profile_; | 258 scoped_ptr<TestingProfile> profile_; |
| 243 scoped_ptr<Browser> browser_; | 259 scoped_ptr<Browser> browser_; |
| 244 scoped_ptr<ScopedTestingLocalState> local_state_; | 260 scoped_ptr<ScopedTestingLocalState> local_state_; |
| 245 }; | 261 }; |
| 246 | 262 |
| 247 // Clicks on first menu, makes sure button is depressed. Moves mouse to first | 263 // Clicks on first menu, makes sure button is depressed. Moves mouse to first |
| 248 // child, clicks it and makes sure a navigation occurs. | 264 // child, clicks it and makes sure a navigation occurs. |
| 249 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { | 265 class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { |
| 250 protected: | 266 protected: |
| 251 virtual void DoTestOnMessageLoop() OVERRIDE { | 267 virtual void DoTestOnMessageLoop() OVERRIDE { |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 EXPECT_TRUE(bb_view_->GetContextMenu() == NULL); | 1836 EXPECT_TRUE(bb_view_->GetContextMenu() == NULL); |
| 1821 EXPECT_TRUE(bb_view_->GetMenu() == NULL); | 1837 EXPECT_TRUE(bb_view_->GetMenu() == NULL); |
| 1822 | 1838 |
| 1823 Done(); | 1839 Done(); |
| 1824 } | 1840 } |
| 1825 | 1841 |
| 1826 BookmarkContextMenuNotificationObserver observer_; | 1842 BookmarkContextMenuNotificationObserver observer_; |
| 1827 }; | 1843 }; |
| 1828 | 1844 |
| 1829 VIEW_TEST(BookmarkBarViewTest21, ContextMenusForEmptyFolder) | 1845 VIEW_TEST(BookmarkBarViewTest21, ContextMenusForEmptyFolder) |
| OLD | NEW |