Chromium Code Reviews| 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/scoped_nsautorelease_pool.h" | 9 #include "base/mac/scoped_nsautorelease_pool.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/strings/sys_string_conversions.h" | |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 13 #include "chrome/browser/download/download_request_limiter.h" | 14 #include "chrome/browser/download/download_request_limiter.h" |
| 14 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 15 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #import "chrome/browser/ui/cocoa/subresource_filter/subresource_filter_bubble_co ntroller.h" | |
| 16 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" | 18 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" |
| 17 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 19 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 18 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 20 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 24 #include "components/strings/grit/components_strings.h" | |
| 22 #include "content/public/common/media_stream_request.h" | 25 #include "content/public/common/media_stream_request.h" |
| 23 #include "testing/gtest_mac.h" | 26 #include "testing/gtest_mac.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 25 | 28 |
| 26 class ContentSettingBubbleControllerTest : public InProcessBrowserTest { | 29 class ContentSettingBubbleControllerTest : public InProcessBrowserTest { |
| 27 protected: | 30 protected: |
| 28 ContentSettingBubbleControllerTest() {} | 31 ContentSettingBubbleControllerTest() {} |
| 29 | 32 |
| 30 content::WebContents* web_contents() { | 33 content::WebContents* web_contents() { |
| 31 return browser()->tab_strip_model()->GetActiveWebContents(); | 34 return browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 mediaMenus->begin(); i != mediaMenus->end(); ++i) { | 113 mediaMenus->begin(); i != mediaMenus->end(); ++i) { |
| 111 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || | 114 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || |
| 112 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); | 115 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); |
| 113 EXPECT_EQ(0, [i->first numberOfItems]); | 116 EXPECT_EQ(0, [i->first numberOfItems]); |
| 114 EXPECT_NSEQ(title, [i->first title]); | 117 EXPECT_NSEQ(title, [i->first title]); |
| 115 EXPECT_FALSE([i->first isEnabled]); | 118 EXPECT_FALSE([i->first isEnabled]); |
| 116 } | 119 } |
| 117 | 120 |
| 118 [parent_ close]; | 121 [parent_ close]; |
| 119 } | 122 } |
| 123 | |
| 124 // Subresource Filter bubble. | |
| 125 | |
| 126 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleControllerTest, | |
| 127 InitSubresourceFilter) { | |
| 128 ContentSettingBubbleController* controller = | |
| 129 CreateBubbleController(new ContentSettingSubresourceFilterBubbleModel( | |
| 130 nullptr, web_contents(), profile())); | |
| 131 EXPECT_TRUE(controller); | |
| 132 | |
| 133 SubresourceFilterBubbleController* filterController = | |
| 134 (SubresourceFilterBubbleController*)controller; | |
|
Robert Sesek
2017/05/05 16:53:34
C-style casts are banned in Chromium, but base::ma
shivanisha
2017/05/05 17:33:21
done
| |
| 135 | |
| 136 EXPECT_TRUE([filterController titleLabel]); | |
| 137 NSString* label = base::SysUTF16ToNSString( | |
| 138 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE)); | |
| 139 EXPECT_TRUE( | |
|
Robert Sesek
2017/05/05 16:53:34
Use EXPECT_NSEQ to get a better failure message if
shivanisha
2017/05/05 17:33:21
done
| |
| 140 [[[filterController titleLabel] stringValue] isEqualToString:label]); | |
| 141 | |
| 142 EXPECT_TRUE([filterController messageLabel]); | |
| 143 label = base::SysUTF16ToNSString(l10n_util::GetStringUTF16( | |
| 144 IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_EXPLANATION)); | |
| 145 EXPECT_TRUE( | |
| 146 [[[filterController messageLabel] stringValue] isEqualToString:label]); | |
| 147 | |
| 148 EXPECT_TRUE([filterController manageCheckbox]); | |
| 149 label = base::SysUTF16ToNSString( | |
| 150 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD)); | |
| 151 EXPECT_TRUE( | |
| 152 [[[filterController manageCheckbox] title] isEqualToString:label]); | |
| 153 | |
| 154 EXPECT_TRUE([filterController doneButton]); | |
| 155 label = base::SysUTF16ToNSString(l10n_util::GetStringUTF16(IDS_OK)); | |
| 156 EXPECT_TRUE([[[filterController doneButton] title] isEqualToString:label]); | |
| 157 | |
| 158 [parent_ close]; | |
| 159 } | |
| 160 | |
| 161 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleControllerTest, | |
|
Robert Sesek
2017/05/05 16:53:34
Same comments above as in this test.
shivanisha
2017/05/05 17:33:21
done
| |
| 162 ManageCheckboxSubresourceFilter) { | |
| 163 ContentSettingSubresourceFilterBubbleModel* model = | |
| 164 new ContentSettingSubresourceFilterBubbleModel(nullptr, web_contents(), | |
| 165 profile()); | |
| 166 ContentSettingBubbleController* controller = CreateBubbleController(model); | |
| 167 EXPECT_TRUE(controller); | |
| 168 | |
| 169 SubresourceFilterBubbleController* filterController = | |
| 170 (SubresourceFilterBubbleController*)controller; | |
| 171 NSButton* manageCheckbox = [filterController manageCheckbox]; | |
| 172 NSButton* doneButton = [filterController doneButton]; | |
| 173 | |
| 174 EXPECT_EQ([manageCheckbox state], NSOffState); | |
| 175 | |
| 176 NSString* label = base::SysUTF16ToNSString(l10n_util::GetStringUTF16(IDS_OK)); | |
| 177 EXPECT_TRUE([[doneButton title] isEqualToString:label]); | |
| 178 | |
| 179 [manageCheckbox setState:NSOnState]; | |
| 180 [filterController manageCheckboxChecked:manageCheckbox]; | |
| 181 EXPECT_EQ([manageCheckbox state], NSOnState); | |
| 182 | |
| 183 label = | |
| 184 base::SysUTF16ToNSString(l10n_util::GetStringUTF16(IDS_APP_MENU_RELOAD)); | |
| 185 EXPECT_TRUE([[doneButton title] isEqualToString:label]); | |
| 186 | |
| 187 [parent_ close]; | |
| 188 } | |
| OLD | NEW |