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

Side by Side Diff: chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm

Issue 1182493009: Wrench menu reorg phase 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge error Created 5 years, 6 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/mac/scoped_nsobject.h" 6 #include "base/mac/scoped_nsobject.h"
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/sync/profile_sync_service_factory.h" 10 #include "chrome/browser/sync/profile_sync_service_factory.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 [controller() setModel:fake_model_.get()]; 192 [controller() setModel:fake_model_.get()];
193 NSMenu* menu = [controller() menu]; 193 NSMenu* menu = [controller() menu];
194 [controller() updateRecentTabsSubmenu]; 194 [controller() updateRecentTabsSubmenu];
195 195
196 NSString* title = l10n_util::GetNSStringWithFixup(IDS_RECENT_TABS_MENU); 196 NSString* title = l10n_util::GetNSStringWithFixup(IDS_RECENT_TABS_MENU);
197 NSMenu* recent_tabs_menu = [[menu itemWithTitle:title] submenu]; 197 NSMenu* recent_tabs_menu = [[menu itemWithTitle:title] submenu];
198 EXPECT_TRUE(recent_tabs_menu); 198 EXPECT_TRUE(recent_tabs_menu);
199 EXPECT_EQ(7, [recent_tabs_menu numberOfItems]); 199 EXPECT_EQ(7, [recent_tabs_menu numberOfItems]);
200 200
201 // Index 0: restore tabs menu item.
202 NSString* restore_tab_label = l10n_util::FixUpWindowsStyleLabel(
203 recent_tabs_sub_menu_model.GetLabelAt(0));
204 EXPECT_NSEQ(restore_tab_label, [[recent_tabs_menu itemAtIndex:0] title]);
205
206 // Item 1: separator. 201 // Item 1: separator.
207 EXPECT_TRUE([[recent_tabs_menu itemAtIndex:1] isSeparatorItem]); 202 EXPECT_TRUE([[recent_tabs_menu itemAtIndex:1] isSeparatorItem]);
208 203
209 // Item 2: window title. 204 // Index 2: restore tabs menu item.
205 NSString* restore_tab_label = l10n_util::FixUpWindowsStyleLabel(
206 recent_tabs_sub_menu_model.GetLabelAt(2));
207 EXPECT_NSEQ(restore_tab_label, [[recent_tabs_menu itemAtIndex:2] title]);
208
209 // Item 3: separator.
210 EXPECT_TRUE([[recent_tabs_menu itemAtIndex:3] isSeparatorItem]);
211
212 // Item 4: window title.
210 EXPECT_NSEQ( 213 EXPECT_NSEQ(
211 base::SysUTF16ToNSString(recent_tabs_sub_menu_model.GetLabelAt(2)), 214 base::SysUTF16ToNSString(recent_tabs_sub_menu_model.GetLabelAt(4)),
212 [[recent_tabs_menu itemAtIndex:2] title]); 215 [[recent_tabs_menu itemAtIndex:4] title]);
213 216
214 // Item 3: short tab title. 217 // Item 5: short tab title.
215 EXPECT_NSEQ(base::SysUTF16ToNSString(tab1_short_title), 218 EXPECT_NSEQ(base::SysUTF16ToNSString(tab1_short_title),
216 [[recent_tabs_menu itemAtIndex:3] title]); 219 [[recent_tabs_menu itemAtIndex:5] title]);
217 220
218 // Item 4: long tab title. 221 // Item 6: long tab title.
219 NSString* tab2_actual_title = [[recent_tabs_menu itemAtIndex:4] title]; 222 NSString* tab2_actual_title = [[recent_tabs_menu itemAtIndex:6] title];
220 NSUInteger title_length = [tab2_actual_title length]; 223 NSUInteger title_length = [tab2_actual_title length];
221 EXPECT_GT(tab2_long_title.size(), title_length); 224 EXPECT_GT(tab2_long_title.size(), title_length);
222 NSString* actual_substring = 225 NSString* actual_substring =
223 [tab2_actual_title substringToIndex:title_length - 1]; 226 [tab2_actual_title substringToIndex:title_length - 1];
224 NSString* expected_substring = [base::SysUTF16ToNSString(tab2_long_title) 227 NSString* expected_substring = [base::SysUTF16ToNSString(tab2_long_title)
225 substringToIndex:title_length - 1]; 228 substringToIndex:title_length - 1];
226 EXPECT_NSEQ(expected_substring, actual_substring); 229 EXPECT_NSEQ(expected_substring, actual_substring);
227 230
228 controller_.reset(); 231 controller_.reset();
229 fake_model_.reset(); 232 fake_model_.reset();
230 } 233 }
231 234
232 // Verify that |RecentTabsMenuModelDelegate| is deleted before the model 235 // Verify that |RecentTabsMenuModelDelegate| is deleted before the model
233 // it's observing. 236 // it's observing.
234 TEST_F(WrenchMenuControllerTest, RecentTabDeleteOrder) { 237 TEST_F(WrenchMenuControllerTest, RecentTabDeleteOrder) {
235 [controller_ menuNeedsUpdate:[controller_ menu]]; 238 [controller_ menuNeedsUpdate:[controller_ menu]];
236 // If the delete order is wrong then the test will crash on exit. 239 // If the delete order is wrong then the test will crash on exit.
237 } 240 }
238 241
239 } // namespace 242 } // namespace
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698