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

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

Issue 1061663003: Fixed logic for display of upgrade menu item. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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/defaults.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"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/browser/upgrade_detector.h"
15 #include "chrome/test/base/browser_with_test_window_test.h" 17 #include "chrome/test/base/browser_with_test_window_test.h"
16 #include "chrome/test/base/menu_model_test.h" 18 #include "chrome/test/base/menu_model_test.h"
17 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
18 #include "chrome/test/base/testing_io_thread_state.h" 20 #include "chrome/test/base/testing_io_thread_state.h"
19 #include "chrome/test/base/testing_pref_service_syncable.h" 21 #include "chrome/test/base/testing_pref_service_syncable.h"
20 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
21 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
22 24
23 namespace { 25 namespace {
24 26
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 }; 120 };
119 121
120 TEST_F(WrenchMenuModelTest, Basics) { 122 TEST_F(WrenchMenuModelTest, Basics) {
121 TestWrenchMenuModel model(this, browser()); 123 TestWrenchMenuModel model(this, browser());
122 int itemCount = model.GetItemCount(); 124 int itemCount = model.GetItemCount();
123 125
124 // Verify it has items. The number varies by platform, so we don't check 126 // Verify it has items. The number varies by platform, so we don't check
125 // the exact number. 127 // the exact number.
126 EXPECT_GT(itemCount, 10); 128 EXPECT_GT(itemCount, 10);
127 129
130 UpgradeDetector* detector = UpgradeDetector::GetInstance();
131 detector->NotifyUpgradeRecommended();
132 EXPECT_TRUE(detector->notify_upgrade());
133 if (browser_defaults::kShowUpgradeMenuItem)
msw 2015/04/23 22:06:41 nit: EXPECT_EQ(browser_defaults::kShowUpgradeMenuI
Lei Zhang 2015/04/23 22:07:45 Maybe reduce the if/else to: EXPECT_EQ(browser_de
Albert Bodenhamer 2015/04/23 22:26:48 Done.
Albert Bodenhamer 2015/04/23 22:26:48 Done.
134 EXPECT_TRUE(model.IsCommandIdVisible(IDC_UPGRADE_DIALOG));
135 else
136 EXPECT_FALSE(model.IsCommandIdVisible(IDC_UPGRADE_DIALOG));
137
128 // Execute a couple of the items and make sure it gets back to our delegate. 138 // 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 139 // We can't use CountEnabledExecutable() here because the encoding menu's
130 // delegate is internal, it doesn't use the one we pass in. 140 // 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. 141 // Note: The new menu has a spacing separator at the first slot.
132 model.ActivatedAt(1); 142 model.ActivatedAt(1);
133 EXPECT_TRUE(model.IsEnabledAt(1)); 143 EXPECT_TRUE(model.IsEnabledAt(1));
134 // Make sure to use the index that is not separator in all configurations. 144 // Make sure to use the index that is not separator in all configurations.
135 model.ActivatedAt(itemCount - 1); 145 model.ActivatedAt(itemCount - 1);
136 EXPECT_TRUE(model.IsEnabledAt(itemCount - 1)); 146 EXPECT_TRUE(model.IsEnabledAt(itemCount - 1));
137 147
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 209
200 class EncodingMenuModelTest : public BrowserWithTestWindowTest, 210 class EncodingMenuModelTest : public BrowserWithTestWindowTest,
201 public MenuModelTest { 211 public MenuModelTest {
202 }; 212 };
203 213
204 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) { 214 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) {
205 EncodingMenuModel model(browser()); 215 EncodingMenuModel model(browser());
206 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents()); 216 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents());
207 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252)); 217 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252));
208 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698