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

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: Fix nits 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
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/prefs/browser_prefs.h" 8 #include "chrome/browser/prefs/browser_prefs.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // the exact number. 125 // the exact number.
126 EXPECT_GT(itemCount, 10); 126 EXPECT_GT(itemCount, 10);
127 127
128 // Execute a couple of the items and make sure it gets back to our delegate. 128 // 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 129 // We can't use CountEnabledExecutable() here because the encoding menu's
130 // delegate is internal, it doesn't use the one we pass in. 130 // 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. 131 // Note: The new menu has a spacing separator at the first slot.
132 model.ActivatedAt(1); 132 model.ActivatedAt(1);
133 EXPECT_TRUE(model.IsEnabledAt(1)); 133 EXPECT_TRUE(model.IsEnabledAt(1));
134 // Make sure to use the index that is not separator in all configurations. 134 // Make sure to use the index that is not separator in all configurations.
135 model.ActivatedAt(2); 135 model.ActivatedAt(itemCount - 1);
136 EXPECT_TRUE(model.IsEnabledAt(2)); 136 EXPECT_TRUE(model.IsEnabledAt(itemCount - 1));
137
137 EXPECT_EQ(model.execute_count_, 2); 138 EXPECT_EQ(model.execute_count_, 2);
138 EXPECT_EQ(model.enable_count_, 2); 139 EXPECT_EQ(model.enable_count_, 2);
139 140
140 model.execute_count_ = 0; 141 model.execute_count_ = 0;
141 model.enable_count_ = 0; 142 model.enable_count_ = 0;
142 143
143 // Choose something from the bookmark submenu and make sure it makes it back 144 // Choose something from the bookmark submenu and make sure it makes it back
144 // to the delegate as well. 145 // to the delegate as well.
145 int bookmarksModelIndex = -1; 146 int bookmarksModelIndex = -1;
146 for (int i = 0; i < itemCount; ++i) { 147 for (int i = 0; i < itemCount; ++i) {
147 if (model.GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) { 148 if (model.GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) {
148 bookmarksModelIndex = i; 149 // Tabs is the first submenu item. Bookmarks submenu is under tabs.
150 bookmarksModelIndex = i + 1;
149 break; 151 break;
150 } 152 }
151 } 153 }
152 EXPECT_GT(bookmarksModelIndex, -1); 154 EXPECT_GT(bookmarksModelIndex, -1);
153 ui::MenuModel* bookmarksModel = model.GetSubmenuModelAt(bookmarksModelIndex); 155 ui::MenuModel* bookmarksModel = model.GetSubmenuModelAt(bookmarksModelIndex);
154 EXPECT_TRUE(bookmarksModel); 156 EXPECT_TRUE(bookmarksModel);
155 // The bookmarks model may be empty until we tell it we're going to show it. 157 // The bookmarks model may be empty until we tell it we're going to show it.
156 bookmarksModel->MenuWillShow(); 158 bookmarksModel->MenuWillShow();
157 EXPECT_GT(bookmarksModel->GetItemCount(), 1); 159 EXPECT_GT(bookmarksModel->GetItemCount(), 1);
158 bookmarksModel->ActivatedAt(1); 160
159 EXPECT_TRUE(bookmarksModel->IsEnabledAt(1)); 161 // Bookmark manager item.
162 bookmarksModel->ActivatedAt(4);
163 EXPECT_TRUE(bookmarksModel->IsEnabledAt(4));
160 EXPECT_EQ(model.execute_count_, 1); 164 EXPECT_EQ(model.execute_count_, 1);
161 EXPECT_EQ(model.enable_count_, 1); 165 EXPECT_EQ(model.enable_count_, 1);
162 } 166 }
163 167
164 // Tests global error menu items in the wrench menu. 168 // Tests global error menu items in the wrench menu.
165 TEST_F(WrenchMenuModelTest, GlobalError) { 169 TEST_F(WrenchMenuModelTest, GlobalError) {
166 // Make sure services required for tests are initialized. 170 // Make sure services required for tests are initialized.
167 GlobalErrorService* service = 171 GlobalErrorService* service =
168 GlobalErrorServiceFactory::GetForProfile(browser()->profile()); 172 GlobalErrorServiceFactory::GetForProfile(browser()->profile());
169 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()); 173 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile());
(...skipping 25 matching lines...) Expand all
195 199
196 class EncodingMenuModelTest : public BrowserWithTestWindowTest, 200 class EncodingMenuModelTest : public BrowserWithTestWindowTest,
197 public MenuModelTest { 201 public MenuModelTest {
198 }; 202 };
199 203
200 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) { 204 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) {
201 EncodingMenuModel model(browser()); 205 EncodingMenuModel model(browser());
202 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents()); 206 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents());
203 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252)); 207 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252));
204 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698