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

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: Corrected bookmark 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 #include <stdio.h>
Peter Kasting 2015/03/30 19:37:02 Why add this?
edwardjung 2015/03/31 11:44:06 Removed, debug.
4 5
5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 6 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
6 7
7 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/prefs/browser_prefs.h" 9 #include "chrome/browser/prefs/browser_prefs.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/global_error/global_error.h" 12 #include "chrome/browser/ui/global_error/global_error.h"
12 #include "chrome/browser/ui/global_error/global_error_service.h" 13 #include "chrome/browser/ui/global_error/global_error_service.h"
13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 14 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Verify it has items. The number varies by platform, so we don't check 125 // Verify it has items. The number varies by platform, so we don't check
125 // the exact number. 126 // the exact number.
126 EXPECT_GT(itemCount, 10); 127 EXPECT_GT(itemCount, 10);
127 128
128 // Execute a couple of the items and make sure it gets back to our delegate. 129 // 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 130 // We can't use CountEnabledExecutable() here because the encoding menu's
130 // delegate is internal, it doesn't use the one we pass in. 131 // 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. 132 // Note: The new menu has a spacing separator at the first slot.
132 model.ActivatedAt(1); 133 model.ActivatedAt(1);
133 EXPECT_TRUE(model.IsEnabledAt(1)); 134 EXPECT_TRUE(model.IsEnabledAt(1));
134 // Make sure to use the index that is not separator in all configurations. 135 // Make sure to use the index that is not separator in all configurations.
Peter Kasting 2015/03/30 19:37:02 Is there an index that is a non-separator in all p
edwardjung 2015/03/31 11:44:05 Let me find something that works for all. i tried
136 #if defined(OS_MACOSX) or defined(CHROMEOS)
Peter Kasting 2015/03/30 19:37:02 "or" needs to be ||, this won't work as you have i
edwardjung 2015/03/31 11:44:05 Done.
135 model.ActivatedAt(2); 137 model.ActivatedAt(2);
136 EXPECT_TRUE(model.IsEnabledAt(2)); 138 EXPECT_TRUE(model.IsEnabledAt(2));
139 #else
140 model.ActivatedAt(3);
141 EXPECT_TRUE(model.IsEnabledAt(3));
142 #endif
137 EXPECT_EQ(model.execute_count_, 2); 143 EXPECT_EQ(model.execute_count_, 2);
138 EXPECT_EQ(model.enable_count_, 2); 144 EXPECT_EQ(model.enable_count_, 2);
139 145
140 model.execute_count_ = 0; 146 model.execute_count_ = 0;
141 model.enable_count_ = 0; 147 model.enable_count_ = 0;
142 148
143 // Choose something from the bookmark submenu and make sure it makes it back 149 // Choose something from the bookmark submenu and make sure it makes it back
144 // to the delegate as well. 150 // to the delegate as well.
145 int bookmarksModelIndex = -1; 151 int bookmarksModelIndex = -1;
146 for (int i = 0; i < itemCount; ++i) { 152 for (int i = 0; i < itemCount; ++i) {
147 if (model.GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) { 153 if (model.GetTypeAt(i) == ui::MenuModel::TYPE_SUBMENU) {
148 bookmarksModelIndex = i; 154 // Bookmarks is now under the tabs submenu item.
Peter Kasting 2015/03/30 19:37:02 What does "now" mean? This seems to be implicitly
edwardjung 2015/03/31 11:44:05 Done.
155 bookmarksModelIndex = i + 1;
149 break; 156 break;
150 } 157 }
151 } 158 }
152 EXPECT_GT(bookmarksModelIndex, -1); 159 EXPECT_GT(bookmarksModelIndex, -1);
153 ui::MenuModel* bookmarksModel = model.GetSubmenuModelAt(bookmarksModelIndex); 160 ui::MenuModel* bookmarksModel = model.GetSubmenuModelAt(bookmarksModelIndex);
154 EXPECT_TRUE(bookmarksModel); 161 EXPECT_TRUE(bookmarksModel);
155 // The bookmarks model may be empty until we tell it we're going to show it. 162 // The bookmarks model may be empty until we tell it we're going to show it.
156 bookmarksModel->MenuWillShow(); 163 bookmarksModel->MenuWillShow();
157 EXPECT_GT(bookmarksModel->GetItemCount(), 1); 164 EXPECT_GT(bookmarksModel->GetItemCount(), 1);
158 bookmarksModel->ActivatedAt(1); 165
159 EXPECT_TRUE(bookmarksModel->IsEnabledAt(1)); 166 // Bookmark manager item.
167 bookmarksModel->ActivatedAt(4);
168 EXPECT_TRUE(bookmarksModel->IsEnabledAt(4));
160 EXPECT_EQ(model.execute_count_, 1); 169 EXPECT_EQ(model.execute_count_, 1);
161 EXPECT_EQ(model.enable_count_, 1); 170 EXPECT_EQ(model.enable_count_, 1);
162 } 171 }
163 172
164 // Tests global error menu items in the wrench menu. 173 // Tests global error menu items in the wrench menu.
165 TEST_F(WrenchMenuModelTest, GlobalError) { 174 TEST_F(WrenchMenuModelTest, GlobalError) {
166 // Make sure services required for tests are initialized. 175 // Make sure services required for tests are initialized.
167 GlobalErrorService* service = 176 GlobalErrorService* service =
168 GlobalErrorServiceFactory::GetForProfile(browser()->profile()); 177 GlobalErrorServiceFactory::GetForProfile(browser()->profile());
169 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()); 178 ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile());
(...skipping 25 matching lines...) Expand all
195 204
196 class EncodingMenuModelTest : public BrowserWithTestWindowTest, 205 class EncodingMenuModelTest : public BrowserWithTestWindowTest,
197 public MenuModelTest { 206 public MenuModelTest {
198 }; 207 };
199 208
200 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) { 209 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) {
201 EncodingMenuModel model(browser()); 210 EncodingMenuModel model(browser());
202 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents()); 211 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents());
203 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252)); 212 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252));
204 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698