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