| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "base/test/scoped_feature_list.h" | 11 #include "base/test/scoped_feature_list.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 14 #import "chrome/browser/ui/cocoa/browser_window_touch_bar.h" | 14 #import "chrome/browser/ui/cocoa/browser_window_touch_bar.h" |
| 15 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 15 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
| 16 #include "chrome/common/chrome_features.h" | 16 #include "chrome/common/chrome_features.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #import "third_party/ocmock/OCMock/OCMock.h" | 20 #import "third_party/ocmock/OCMock/OCMock.h" |
| 21 #import "ui/base/cocoa/touch_bar_util.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // Touch bar identifiers. | 25 // Touch bar identifiers. |
| 25 NSString* const kBrowserWindowTouchBarId = @"browser-window"; | 26 NSString* const kBrowserWindowTouchBarId = @"browser-window"; |
| 26 NSString* const kTabFullscreenTouchBarId = @"tab-fullscreen"; | 27 NSString* const kTabFullscreenTouchBarId = @"tab-fullscreen"; |
| 27 | 28 |
| 28 // Touch bar items identifiers. | 29 // Touch bar items identifiers. |
| 29 NSString* const kBackForwardTouchId = @"BACK-FWD"; | 30 NSString* const kBackForwardTouchId = @"BACK-FWD"; |
| 30 NSString* const kReloadOrStopTouchId = @"RELOAD-STOP"; | 31 NSString* const kReloadOrStopTouchId = @"RELOAD-STOP"; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 51 isKindOfClass:[BrowserWindowController class]]; | 52 isKindOfClass:[BrowserWindowController class]]; |
| 52 [[bwc_ stub] invalidateTouchBar]; | 53 [[bwc_ stub] invalidateTouchBar]; |
| 53 | 54 |
| 54 touch_bar_.reset([[BrowserWindowTouchBar alloc] initWithBrowser:browser() | 55 touch_bar_.reset([[BrowserWindowTouchBar alloc] initWithBrowser:browser() |
| 55 browserWindowController:bwc_]); | 56 browserWindowController:bwc_]); |
| 56 } | 57 } |
| 57 | 58 |
| 58 id bwc() const { return bwc_; } | 59 id bwc() const { return bwc_; } |
| 59 | 60 |
| 60 NSString* GetFullscreenTouchBarItemId(NSString* id) { | 61 NSString* GetFullscreenTouchBarItemId(NSString* id) { |
| 61 return | 62 return ui::GetTouchBarItemId(kTabFullscreenTouchBarId, id); |
| 62 [BrowserWindowTouchBar identifierForTouchBarId:kTabFullscreenTouchBarId | |
| 63 itemId:id]; | |
| 64 } | 63 } |
| 65 | 64 |
| 66 NSString* GetBrowserTouchBarItemId(NSString* id) { | 65 NSString* GetBrowserTouchBarItemId(NSString* id) { |
| 67 return | 66 return ui::GetTouchBarItemId(kBrowserWindowTouchBarId, id); |
| 68 [BrowserWindowTouchBar identifierForTouchBarId:kBrowserWindowTouchBarId | |
| 69 itemId:id]; | |
| 70 } | 67 } |
| 71 | 68 |
| 72 void TearDown() override { CocoaProfileTest::TearDown(); } | 69 void TearDown() override { CocoaProfileTest::TearDown(); } |
| 73 | 70 |
| 74 // A mock BrowserWindowController object. | 71 // A mock BrowserWindowController object. |
| 75 id bwc_; | 72 id bwc_; |
| 76 | 73 |
| 77 // Used to enable the the browser window touch bar. | 74 // Used to enable the the browser window touch bar. |
| 78 base::test::ScopedFeatureList feature_list; | 75 base::test::ScopedFeatureList feature_list; |
| 79 | 76 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 NSTouchBarItem* item = | 147 NSTouchBarItem* item = |
| 151 [touch_bar_ touchBar:touch_bar | 148 [touch_bar_ touchBar:touch_bar |
| 152 makeItemForIdentifier:GetBrowserTouchBarItemId(kReloadOrStopTouchId)]; | 149 makeItemForIdentifier:GetBrowserTouchBarItemId(kReloadOrStopTouchId)]; |
| 153 EXPECT_EQ(IDC_RELOAD, [[item view] tag]); | 150 EXPECT_EQ(IDC_RELOAD, [[item view] tag]); |
| 154 | 151 |
| 155 [touch_bar_ setIsPageLoading:YES]; | 152 [touch_bar_ setIsPageLoading:YES]; |
| 156 item = [touch_bar_ touchBar:touch_bar | 153 item = [touch_bar_ touchBar:touch_bar |
| 157 makeItemForIdentifier:GetBrowserTouchBarItemId(kReloadOrStopTouchId)]; | 154 makeItemForIdentifier:GetBrowserTouchBarItemId(kReloadOrStopTouchId)]; |
| 158 EXPECT_EQ(IDC_STOP, [[item view] tag]); | 155 EXPECT_EQ(IDC_STOP, [[item view] tag]); |
| 159 } | 156 } |
| OLD | NEW |