| 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/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.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_window.h" |
| 16 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 17 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/test/base/testing_browser_process.h" | 20 #include "chrome/test/base/testing_browser_process.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "chrome/test/base/view_event_test_base.h" | 23 #include "chrome/test/base/view_event_test_base.h" |
| 23 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/page_navigator.h" | 25 #include "content/public/browser/page_navigator.h" |
| 25 #include "content/test/test_browser_thread.h" | 26 #include "content/test/test_browser_thread.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 profile_->CreateBookmarkModel(true); | 190 profile_->CreateBookmarkModel(true); |
| 190 profile_->BlockUntilBookmarkModelLoaded(); | 191 profile_->BlockUntilBookmarkModelLoaded(); |
| 191 profile_->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); | 192 profile_->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); |
| 192 | 193 |
| 193 browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); | 194 browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); |
| 194 | 195 |
| 195 model_ = profile_->GetBookmarkModel(); | 196 model_ = profile_->GetBookmarkModel(); |
| 196 model_->ClearStore(); | 197 model_->ClearStore(); |
| 197 | 198 |
| 198 bb_view_.reset(new BookmarkBarView(browser_.get())); | 199 bb_view_.reset(new BookmarkBarView(browser_.get())); |
| 200 bb_view_->set_parent_owned(false); |
| 199 bb_view_->SetPageNavigator(&navigator_); | 201 bb_view_->SetPageNavigator(&navigator_); |
| 200 | 202 |
| 201 AddTestData(CreateBigMenu()); | 203 AddTestData(CreateBigMenu()); |
| 202 | 204 |
| 203 // Calculate the preferred size so that one button doesn't fit, which | 205 // Calculate the preferred size so that one button doesn't fit, which |
| 204 // triggers the overflow button to appear. | 206 // triggers the overflow button to appear. |
| 205 // | 207 // |
| 206 // BookmarkBarView::Layout does nothing if the parent is NULL and | 208 // BookmarkBarView::Layout does nothing if the parent is NULL and |
| 207 // GetPreferredSize hard codes a width of 1. For that reason we add the | 209 // GetPreferredSize hard codes a width of 1. For that reason we add the |
| 208 // BookmarkBarView to a dumby view as the parent. | 210 // BookmarkBarView to a dumby view as the parent. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 228 ViewEventTestBase::SetUp(); | 230 ViewEventTestBase::SetUp(); |
| 229 } | 231 } |
| 230 | 232 |
| 231 virtual void TearDown() { | 233 virtual void TearDown() { |
| 232 // Destroy everything, then run the message loop to ensure we delete all | 234 // Destroy everything, then run the message loop to ensure we delete all |
| 233 // Tasks and fully shut down. | 235 // Tasks and fully shut down. |
| 234 browser_->CloseAllTabs(); | 236 browser_->CloseAllTabs(); |
| 235 bb_view_.reset(); | 237 bb_view_.reset(); |
| 236 browser_.reset(); | 238 browser_.reset(); |
| 237 profile_.reset(); | 239 profile_.reset(); |
| 240 |
| 241 // Run the message loop to ensure we delete allTasks and fully shut down. |
| 238 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 242 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 239 MessageLoop::current()->Run(); | 243 MessageLoop::current()->Run(); |
| 240 | 244 |
| 241 ViewEventTestBase::TearDown(); | 245 ViewEventTestBase::TearDown(); |
| 242 BookmarkBarView::testing_ = false; | 246 BookmarkBarView::testing_ = false; |
| 243 views::ViewsDelegate::views_delegate = NULL; | 247 views::ViewsDelegate::views_delegate = NULL; |
| 244 } | 248 } |
| 245 | 249 |
| 246 protected: | 250 protected: |
| 247 void InstallViewsDelegate() { | 251 void InstallViewsDelegate() { |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 ASSERT_TRUE(menu != NULL); | 1398 ASSERT_TRUE(menu != NULL); |
| 1395 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1399 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1396 | 1400 |
| 1397 // Button should be depressed. | 1401 // Button should be depressed. |
| 1398 views::TextButton* button = GetBookmarkButton(0); | 1402 views::TextButton* button = GetBookmarkButton(0); |
| 1399 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); | 1403 ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED); |
| 1400 | 1404 |
| 1401 // Close the window. | 1405 // Close the window. |
| 1402 window_->Close(); | 1406 window_->Close(); |
| 1403 window_ = NULL; | 1407 window_ = NULL; |
| 1408 |
| 1409 MessageLoop::current()->PostTask( |
| 1410 FROM_HERE, CreateEventTask(this, &BookmarkBarViewTest16::Done)); |
| 1404 } | 1411 } |
| 1405 }; | 1412 }; |
| 1406 | 1413 |
| 1407 // Disabled, http://crbug.com/64303. | 1414 VIEW_TEST(BookmarkBarViewTest16, DeleteMenu) |
| 1408 VIEW_TEST(BookmarkBarViewTest16, DISABLED_DeleteMenu) | |
| 1409 | 1415 |
| 1410 // Makes sure right clicking on an item while a context menu is already showing | 1416 // Makes sure right clicking on an item while a context menu is already showing |
| 1411 // doesn't crash and works. | 1417 // doesn't crash and works. |
| 1412 class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { | 1418 class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { |
| 1413 public: | 1419 public: |
| 1414 BookmarkBarViewTest17() | 1420 BookmarkBarViewTest17() |
| 1415 : ALLOW_THIS_IN_INITIALIZER_LIST( | 1421 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 1416 observer_(CreateEventTask(this, &BookmarkBarViewTest17::Step3))) { | 1422 observer_(CreateEventTask(this, &BookmarkBarViewTest17::Step3))) { |
| 1417 } | 1423 } |
| 1418 | 1424 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 ASSERT_TRUE(menu != NULL); | 1597 ASSERT_TRUE(menu != NULL); |
| 1592 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 1598 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 1593 | 1599 |
| 1594 menu->GetMenuController()->CancelAll(); | 1600 menu->GetMenuController()->CancelAll(); |
| 1595 | 1601 |
| 1596 Done(); | 1602 Done(); |
| 1597 } | 1603 } |
| 1598 }; | 1604 }; |
| 1599 | 1605 |
| 1600 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) | 1606 VIEW_TEST(BookmarkBarViewTest19, SiblingMenu) |
| OLD | NEW |