| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_stats.h" | 9 #include "chrome/browser/bookmarks/bookmark_stats.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/test/base/browser_with_test_window_test.h" | 11 #include "chrome/test/base/browser_with_test_window_test.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "components/bookmarks/browser/bookmark_model.h" | 13 #include "components/bookmarks/browser/bookmark_model.h" |
| 14 #include "components/bookmarks/test/bookmark_test_helpers.h" | 14 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 15 #include "ui/views/controls/menu/menu_item_view.h" | 15 #include "ui/views/controls/menu/menu_item_view.h" |
| 16 #include "ui/views/controls/menu/menu_runner.h" | 16 #include "ui/views/controls/menu/menu_runner.h" |
| 17 #include "ui/views/controls/menu/submenu_view.h" | 17 #include "ui/views/controls/menu/submenu_view.h" |
| 18 | 18 |
| 19 using base::ASCIIToUTF16; | 19 using base::ASCIIToUTF16; |
| 20 | 20 |
| 21 class BookmarkMenuDelegateTest : public BrowserWithTestWindowTest { | 21 class BookmarkMenuDelegateTest : public BrowserWithTestWindowTest { |
| 22 public: | 22 public: |
| 23 BookmarkMenuDelegateTest() : model_(NULL) {} | 23 BookmarkMenuDelegateTest() : model_(NULL) {} |
| 24 | 24 |
| 25 virtual void SetUp() override { | 25 void SetUp() override { |
| 26 BrowserWithTestWindowTest::SetUp(); | 26 BrowserWithTestWindowTest::SetUp(); |
| 27 | 27 |
| 28 profile()->CreateBookmarkModel(true); | 28 profile()->CreateBookmarkModel(true); |
| 29 | 29 |
| 30 model_ = BookmarkModelFactory::GetForProfile(profile()); | 30 model_ = BookmarkModelFactory::GetForProfile(profile()); |
| 31 bookmarks::test::WaitForBookmarkModelToLoad(model_); | 31 bookmarks::test::WaitForBookmarkModelToLoad(model_); |
| 32 | 32 |
| 33 AddTestData(); | 33 AddTestData(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual void TearDown() override { | 36 void TearDown() override { |
| 37 if (bookmark_menu_delegate_.get()) { | 37 if (bookmark_menu_delegate_.get()) { |
| 38 // Since we never show the menu we need to pass the MenuItemView to | 38 // Since we never show the menu we need to pass the MenuItemView to |
| 39 // MenuRunner so that the MenuItemView is destroyed. | 39 // MenuRunner so that the MenuItemView is destroyed. |
| 40 views::MenuRunner menu_runner(bookmark_menu_delegate_->menu(), 0); | 40 views::MenuRunner menu_runner(bookmark_menu_delegate_->menu(), 0); |
| 41 bookmark_menu_delegate_.reset(); | 41 bookmark_menu_delegate_.reset(); |
| 42 } | 42 } |
| 43 BrowserWithTestWindowTest::TearDown(); | 43 BrowserWithTestWindowTest::TearDown(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 protected: | 46 protected: |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 EXPECT_EQ(1, root_item->GetSubmenu()->GetMenuItemCount()); | 219 EXPECT_EQ(1, root_item->GetSubmenu()->GetMenuItemCount()); |
| 220 EXPECT_EQ(1, root_item->GetSubmenu()->child_count()); // No separator. | 220 EXPECT_EQ(1, root_item->GetSubmenu()->child_count()); // No separator. |
| 221 | 221 |
| 222 // Verify correct handling of integer overflow with range, set kint32max as | 222 // Verify correct handling of integer overflow with range, set kint32max as |
| 223 // maximum and 1 less as minimum. Only "a" item should be created. | 223 // maximum and 1 less as minimum. Only "a" item should be created. |
| 224 NewAndInitDelegateForPermanent(kint32max - 1, kint32max); | 224 NewAndInitDelegateForPermanent(kint32max - 1, kint32max); |
| 225 root_item = bookmark_menu_delegate_->menu(); | 225 root_item = bookmark_menu_delegate_->menu(); |
| 226 EXPECT_EQ(1, root_item->GetSubmenu()->GetMenuItemCount()); | 226 EXPECT_EQ(1, root_item->GetSubmenu()->GetMenuItemCount()); |
| 227 EXPECT_EQ(1, root_item->GetSubmenu()->child_count()); // No separator. | 227 EXPECT_EQ(1, root_item->GetSubmenu()->child_count()); // No separator. |
| 228 } | 228 } |
| OLD | NEW |