| OLD | NEW |
| 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 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" | 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_nsautorelease_pool.h" | 11 #include "base/mac/scoped_nsautorelease_pool.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #include "base/test/scoped_feature_list.h" |
| 13 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 15 #include "chrome/browser/download/download_request_limiter.h" | 17 #include "chrome/browser/download/download_request_limiter.h" |
| 16 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 18 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 17 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 18 #import "chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_co
ntroller.h" | 20 #import "chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_co
ntroller.h" |
| 19 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" | 21 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" |
| 20 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 22 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 21 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 23 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 25 #include "chrome/common/chrome_features.h" |
| 23 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
| 24 #include "chrome/test/base/in_process_browser_test.h" | 27 #include "chrome/test/base/in_process_browser_test.h" |
| 25 #include "components/strings/grit/components_strings.h" | 28 #include "components/strings/grit/components_strings.h" |
| 26 #include "content/public/common/media_stream_request.h" | 29 #include "content/public/common/media_stream_request.h" |
| 27 #include "testing/gtest_mac.h" | 30 #include "testing/gtest_mac.h" |
| 31 #include "ui/base/cocoa/touch_bar_util.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 29 | 33 |
| 34 namespace { |
| 35 |
| 36 // Touch bar identifier. |
| 37 NSString* const kContentSettingsBubbleTouchBarId = @"content-settings-bubble"; |
| 38 |
| 39 // Touch bar item identifiers. |
| 40 NSString* const kManageTouchBarId = @"MANAGE"; |
| 41 NSString* const kDoneTouchBarId = @"DONE"; |
| 42 |
| 43 } // namespace |
| 44 |
| 30 class ContentSettingBubbleControllerTest : public InProcessBrowserTest { | 45 class ContentSettingBubbleControllerTest : public InProcessBrowserTest { |
| 31 protected: | 46 protected: |
| 32 ContentSettingBubbleControllerTest() {} | 47 ContentSettingBubbleControllerTest() {} |
| 33 | 48 |
| 34 content::WebContents* web_contents() { | 49 content::WebContents* web_contents() { |
| 35 return browser()->tab_strip_model()->GetActiveWebContents(); | 50 return browser()->tab_strip_model()->GetActiveWebContents(); |
| 36 } | 51 } |
| 37 | 52 |
| 38 Profile* profile() { | 53 Profile* profile() { |
| 39 return browser()->profile(); | 54 return browser()->profile(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 [manageCheckbox setState:NSOnState]; | 192 [manageCheckbox setState:NSOnState]; |
| 178 [filterController manageCheckboxChecked:manageCheckbox]; | 193 [filterController manageCheckboxChecked:manageCheckbox]; |
| 179 EXPECT_EQ([manageCheckbox state], NSOnState); | 194 EXPECT_EQ([manageCheckbox state], NSOnState); |
| 180 | 195 |
| 181 label = | 196 label = |
| 182 base::SysUTF16ToNSString(l10n_util::GetStringUTF16(IDS_APP_MENU_RELOAD)); | 197 base::SysUTF16ToNSString(l10n_util::GetStringUTF16(IDS_APP_MENU_RELOAD)); |
| 183 EXPECT_NSEQ([doneButton title], label); | 198 EXPECT_NSEQ([doneButton title], label); |
| 184 | 199 |
| 185 [parent_ close]; | 200 [parent_ close]; |
| 186 } | 201 } |
| 202 |
| 203 // Verifies the bubble's touch bar. |
| 204 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleControllerTest, TouchBar) { |
| 205 if (!base::mac::IsAtLeastOS10_12()) { |
| 206 [parent_ close]; |
| 207 return; |
| 208 } |
| 209 |
| 210 base::test::ScopedFeatureList feature_list; |
| 211 feature_list.InitAndEnableFeature(features::kBrowserTouchBar); |
| 212 |
| 213 TabSpecificContentSettings::FromWebContents(web_contents()) |
| 214 ->BlockAllContentForTesting(); |
| 215 ContentSettingBubbleController* controller = |
| 216 CreateBubbleController(new ContentSettingMediaStreamBubbleModel( |
| 217 nullptr, web_contents(), profile())); |
| 218 EXPECT_TRUE(controller); |
| 219 |
| 220 NSTouchBar* touch_bar = [controller makeTouchBar]; |
| 221 NSArray* touch_bar_items = [touch_bar itemIdentifiers]; |
| 222 EXPECT_TRUE([touch_bar_items |
| 223 containsObject:ui::GetTouchBarItemId(kContentSettingsBubbleTouchBarId, |
| 224 kDoneTouchBarId)]); |
| 225 EXPECT_TRUE([touch_bar_items |
| 226 containsObject:ui::GetTouchBarItemId(kContentSettingsBubbleTouchBarId, |
| 227 kManageTouchBarId)]); |
| 228 |
| 229 [parent_ close]; |
| 230 } |
| OLD | NEW |