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

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: Fix nit. 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') | chrome/browser/upgrade_detector.h » ('j') | 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/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 EXPECT_EQ(browser_defaults::kShowUpgradeMenuItem,
134 model.IsCommandIdVisible(IDC_UPGRADE_DIALOG));
135
128 // Execute a couple of the items and make sure it gets back to our delegate. 136 // 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 137 // We can't use CountEnabledExecutable() here because the encoding menu's
130 // delegate is internal, it doesn't use the one we pass in. 138 // 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. 139 // Note: The new menu has a spacing separator at the first slot.
132 model.ActivatedAt(1); 140 model.ActivatedAt(1);
133 EXPECT_TRUE(model.IsEnabledAt(1)); 141 EXPECT_TRUE(model.IsEnabledAt(1));
134 // Make sure to use the index that is not separator in all configurations. 142 // Make sure to use the index that is not separator in all configurations.
135 model.ActivatedAt(itemCount - 1); 143 model.ActivatedAt(itemCount - 1);
136 EXPECT_TRUE(model.IsEnabledAt(itemCount - 1)); 144 EXPECT_TRUE(model.IsEnabledAt(itemCount - 1));
137 145
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 207
200 class EncodingMenuModelTest : public BrowserWithTestWindowTest, 208 class EncodingMenuModelTest : public BrowserWithTestWindowTest,
201 public MenuModelTest { 209 public MenuModelTest {
202 }; 210 };
203 211
204 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) { 212 TEST_F(EncodingMenuModelTest, IsCommandIdCheckedWithNoTabs) {
205 EncodingMenuModel model(browser()); 213 EncodingMenuModel model(browser());
206 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents()); 214 ASSERT_EQ(NULL, browser()->tab_strip_model()->GetActiveWebContents());
207 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252)); 215 EXPECT_FALSE(model.IsCommandIdChecked(IDC_ENCODING_WINDOWS1252));
208 } 216 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/wrench_menu_model.cc ('k') | chrome/browser/upgrade_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698