Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc

Issue 1007993004: Restructure the wrench menu into an action based order (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update unit test. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
Peter Kasting 2015/04/01 21:06:29 Nit: Don't remove this blank line
edwardjung 2015/04/02 13:13:28 Done.
5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 4 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
6 5
7 #include "chrome/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/prefs/browser_prefs.h" 7 #include "chrome/browser/prefs/browser_prefs.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/global_error/global_error.h" 10 #include "chrome/browser/ui/global_error/global_error.h"
12 #include "chrome/browser/ui/global_error/global_error_service.h" 11 #include "chrome/browser/ui/global_error/global_error_service.h"
13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 12 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // the exact number. 124 // the exact number.
126 EXPECT_GT(itemCount, 10); 125 EXPECT_GT(itemCount, 10);
127 126
128 // Execute a couple of the items and make sure it gets back to our delegate. 127 // Execute a couple of the items and make sure it gets back to our delegate.
129 // We can't use CountEnabledExecutable() here because the encoding menu's 128 // We can't use CountEnabledExecutable() here because the encoding menu's
130 // delegate is internal, it doesn't use the one we pass in. 129 // delegate is internal, it doesn't use the one we pass in.
131 // Note: The new menu has a spacing separator at the first slot. 130 // Note: The new menu has a spacing separator at the first slot.
132 model.ActivatedAt(1); 131 model.ActivatedAt(1);
133 EXPECT_TRUE(model.IsEnabledAt(1)); 132 EXPECT_TRUE(model.IsEnabledAt(1));
134 // Make sure to use the index that is not separator in all configurations. 133 // Make sure to use the index that is not separator in all configurations.
135 model.ActivatedAt(2); 134 model.ActivatedAt(itemCount - 1);
136 EXPECT_TRUE(model.IsEnabledAt(2)); 135 EXPECT_TRUE(model.IsEnabledAt(itemCount - 1));
136
137 EXPECT_EQ(model.execute_count_, 2); 137 EXPECT_EQ(model.execute_count_, 2);
138 EXPECT_EQ(model.enable_count_, 2); 138 EXPECT_EQ(model.enable_count_, 2);
139 139
140 model.execute_count_ = 0; 140 model.execute_count_ = 0;
141 model.enable_count_ = 0; 141 model.enable_count_ = 0;
142 142
143 // Choose something from the bookmark submenu and make sure it makes it back 143 // Choose something from the bookmark submenu and make sure it makes it back
144 // to the delegate as well. 144 // to the delegate as well.
145 int bookmarksModelIndex = -1; 145 int bookmarksModelIndex = -1;
146 for (int i = 0; i < itemCount; ++i) { 146 for (int i = 0; i < itemCount; ++i) {
147 if (model.GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) { 147 if (model.GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) {
148 bookmarksModelIndex = i; 148 // Tabs is the first submenu item. Bookmarks submenu is under tabs.
149 bookmarksModelIndex = i + 1;
149 break; 150 break;
150 } 151 }
151 } 152 }
152 EXPECT_GT(bookmarksModelIndex, -1); 153 EXPECT_GT(bookmarksModelIndex, -1);
153 ui::MenuModel* bookmarksModel = model.GetSubmenuModelAt(bookmarksModelIndex); 154 ui::MenuModel* bookmarksModel = model.GetSubmenuModelAt(bookmarksModelIndex);
154 EXPECT_TRUE(bookmarksModel); 155 EXPECT_TRUE(bookmarksModel);
155 // The bookmarks model may be empty until we tell it we're going to show it. 156 // The bookmarks model may be empty until we tell it we're going to show it.
156 bookmarksModel->MenuWillShow(); 157 bookmarksModel->MenuWillShow();
157 EXPECT_GT(bookmarksModel->GetItemCount(), 1); 158 EXPECT_GT(bookmarksModel->GetItemCount(), 1);
158 bookmarksModel->ActivatedAt(1); 159
159 EXPECT_TRUE(bookmarksModel->IsEnabledAt(1)); 160 // Bookmark manager item.
161 bookmarksModel->ActivatedAt(4);
162 EXPECT_TRUE(bookmarksModel->IsEnabledAt(4));
160 EXPECT_EQ(model.execute_count_, 1); 163 EXPECT_EQ(model.execute_count_, 1);
161 EXPECT_EQ(model.enable_count_, 1); 164 EXPECT_EQ(model.enable_count_, 1);
162 } 165 }
163 166
164 // Tests global error menu items in the wrench menu. 167 // Tests global error menu items in the wrench menu.
165 TEST_F(WrenchMenuModelTest, GlobalError) { 168 TEST_F(WrenchMenuModelTest, GlobalError) {
166 // Make sure services required for tests are initialized. 169 // Make sure services required for tests are initialized.
167 GlobalErrorService* service = 170 GlobalErrorService* service =
168 GlobalErrorServiceFactory::GetForProfile(browser()->profile()); 171 GlobalErrorServiceFactory::GetForProfile(browser()->profile());
169 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()); 172 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile());
(...skipping 25 matching lines...) Expand all
195 198
196 class EncodingMenuModelTest : public BrowserWithTestWindowTest, 199 class EncodingMenuModelTest : public BrowserWithTestWindowTest,
197 public MenuModelTest { 200 public MenuModelTest {
198 }; 201 };
199 202
200 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) { 203 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) {
201 EncodingMenuModel model(browser()); 204 EncodingMenuModel model(browser());
202 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents()); 205 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents());
203 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252)); 206 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252));
204 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698