Chromium Code Reviews| Index: chrome/browser/ui/cocoa/browser_window_touch_bar_unittest.mm |
| diff --git a/chrome/browser/ui/cocoa/browser_window_touch_bar_unittest.mm b/chrome/browser/ui/cocoa/browser_window_touch_bar_unittest.mm |
| index 94b131aca749137e2aa705031cef26543f85549a..0f8d1cbad6df6d682b9b74c5125771b21d052355 100644 |
| --- a/chrome/browser/ui/cocoa/browser_window_touch_bar_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/browser_window_touch_bar_unittest.mm |
| @@ -39,6 +39,16 @@ class BrowserWindowTouchBarUnitTest : public CocoaProfileTest { |
| id bwc() const { return bwc_; } |
| + NSString* GetFullscreenTouchBarItemId(NSString* id) { |
| + return [BrowserWindowTouchBar identifierForTouchBarId:@"tab-fullscreen" |
| + itemId:id]; |
| + } |
| + |
| + NSString* GetBrowserTouchBarItemId(NSString* id) { |
| + return [BrowserWindowTouchBar identifierForTouchBarId:@"browser-window" |
|
Avi (use Gerrit)
2017/05/05 19:09:34
:( Can't we reuse the constants that you declared?
spqchan
2017/05/05 22:38:09
Done.
|
| + itemId:id]; |
| + } |
| + |
| void TearDown() override { CocoaProfileTest::TearDown(); } |
| // A mock BrowserWindowController object. |
| @@ -68,44 +78,40 @@ TEST_F(BrowserWindowTouchBarUnitTest, TouchBarItems) { |
| NSTouchBar* touch_bar = [touch_bar_ makeTouchBar]; |
| NSArray* touch_bar_items = [touch_bar itemIdentifiers]; |
| EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar |
| - touchBarIdForItemId:@"FULLSCREEN-ORIGIN-LABEL"]]); |
| + containsObject:GetFullscreenTouchBarItemId(@"FULLSCREEN-ORIGIN-LABEL")]); |
| EXPECT_TRUE([[touch_bar escapeKeyReplacementItemIdentifier] |
| - isEqualToString:[BrowserWindowTouchBar |
| - touchBarIdForItemId:@"EXIT-FULLSCREEN"]]); |
| + isEqualToString:GetFullscreenTouchBarItemId(@"EXIT-FULLSCREEN")]); |
| BOOL no = NO; |
| [[[bwc() stub] andReturnValue:OCMOCK_VALUE(no)] |
| isFullscreenForTabContentOrExtension]; |
| touch_bar_items = [[touch_bar_ makeTouchBar] itemIdentifiers]; |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"BACK-FWD"]]); |
| EXPECT_TRUE( |
| - [touch_bar_items containsObject:[BrowserWindowTouchBar |
| - touchBarIdForItemId:@"RELOAD-STOP"]]); |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"BACK-FWD")]); |
| EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"HOME"]]); |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"SEARCH"]]); |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"BOOKMARK"]]); |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"NEW-TAB"]]); |
| + containsObject:GetBrowserTouchBarItemId(@"RELOAD-STOP")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"HOME")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"SEARCH")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"BOOKMARK")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"NEW-TAB")]); |
| prefs->SetBoolean(prefs::kShowHomeButton, false); |
| touch_bar_items = [[touch_bar_ makeTouchBar] itemIdentifiers]; |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"BACK-FWD"]]); |
| EXPECT_TRUE( |
| - [touch_bar_items containsObject:[BrowserWindowTouchBar |
| - touchBarIdForItemId:@"RELOAD-STOP"]]); |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"SEARCH"]]); |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"BACK-FWD")]); |
| EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"BOOKMARK"]]); |
| - EXPECT_TRUE([touch_bar_items |
| - containsObject:[BrowserWindowTouchBar touchBarIdForItemId:@"NEW-TAB"]]); |
| + containsObject:GetBrowserTouchBarItemId(@"RELOAD-STOP")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"SEARCH")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"BOOKMARK")]); |
| + EXPECT_TRUE( |
| + [touch_bar_items containsObject:GetBrowserTouchBarItemId(@"NEW-TAB")]); |
| } |
| // Tests the reload or stop touch bar item. |
| @@ -122,13 +128,11 @@ TEST_F(BrowserWindowTouchBarUnitTest, ReloadOrStopTouchBarItem) { |
| NSTouchBarItem* item = |
| [touch_bar_ touchBar:touch_bar |
| - makeItemForIdentifier:[BrowserWindowTouchBar |
| - touchBarIdForItemId:@"RELOAD-STOP"]]; |
| + makeItemForIdentifier:GetBrowserTouchBarItemId(@"RELOAD-STOP")]; |
| EXPECT_EQ(IDC_RELOAD, [[item view] tag]); |
| [touch_bar_ setIsPageLoading:YES]; |
| item = [touch_bar_ touchBar:touch_bar |
| - makeItemForIdentifier:[BrowserWindowTouchBar |
| - touchBarIdForItemId:@"RELOAD-STOP"]]; |
| + makeItemForIdentifier:GetBrowserTouchBarItemId(@"RELOAD-STOP")]; |
| EXPECT_EQ(IDC_STOP, [[item view] tag]); |
| } |