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" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 anchoredAt:NSMakePoint(50, 20)]; | 95 anchoredAt:NSMakePoint(50, 20)]; |
| 96 | 96 |
| 97 EXPECT_TRUE(controller); | 97 EXPECT_TRUE(controller); |
| 98 EXPECT_TRUE([[controller window] isVisible]); | 98 EXPECT_TRUE([[controller window] isVisible]); |
| 99 | 99 |
| 100 return controller; | 100 return controller; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Check that the bubble doesn't crash or leak for any settings type | 103 // Check that the bubble doesn't crash or leak for any settings type |
| 104 TEST_F(ContentSettingBubbleControllerTest, Init) { | 104 TEST_F(ContentSettingBubbleControllerTest, Init) { |
| 105 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 105 for (ContentSettingsType type : |
| 106 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || | 106 ContentSettingBubbleModel::GetSupportedBubbleTypes()) { |
| 107 i == CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE || | 107 // Media stream is tested in the MediaStreamBubble test below. |
| 108 i == CONTENT_SETTINGS_TYPE_FULLSCREEN || | 108 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM || |
| 109 i == CONTENT_SETTINGS_TYPE_MOUSELOCK || | 109 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
| 110 i == CONTENT_SETTINGS_TYPE_MEDIASTREAM || | 110 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
| 111 i == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | |
| 112 i == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || | |
| 113 i == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || | |
| 114 i == CONTENT_SETTINGS_TYPE_MIDI_SYSEX || | |
| 115 i == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING || | |
| 116 i == CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS || | |
| 117 i == CONTENT_SETTINGS_TYPE_APP_BANNER || | |
| 118 i == CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT || | |
| 119 i == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) { | |
| 120 // These types have no bubble. | |
| 121 continue; | 111 continue; |
| 122 } | 112 } |
| 123 | 113 ContentSettingBubbleController* controller = CreateBubbleController(type); |
| 124 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i); | |
| 125 | |
| 126 ContentSettingBubbleController* controller = | |
| 127 CreateBubbleController(settingsType); | |
| 128 EXPECT_EQ(0u, [controller mediaMenus]->size()); | 114 EXPECT_EQ(0u, [controller mediaMenus]->size()); |
| 129 [parent_ close]; | 115 [parent_ close]; |
| 130 } | 116 } |
| 131 } | 117 } |
| 132 | 118 |
| 133 // Check that the bubble works for CONTENT_SETTINGS_TYPE_MEDIASTREAM. | 119 // Check that the bubble works for CONTENT_SETTINGS_TYPE_MEDIASTREAM. |
| 134 TEST_F(ContentSettingBubbleControllerTest, MediaStreamBubble) { | 120 TEST_F(ContentSettingBubbleControllerTest, MediaStreamBubble) { |
| 135 MediaCaptureDevicesDispatcher::GetInstance()-> | 121 MediaCaptureDevicesDispatcher::GetInstance()-> |
| 136 DisableDeviceEnumerationForTesting(); | 122 DisableDeviceEnumerationForTesting(); |
| 137 ContentSettingBubbleController* controller = | 123 ContentSettingBubbleController* controller = |
| 138 CreateBubbleController(CONTENT_SETTINGS_TYPE_MEDIASTREAM); | 124 CreateBubbleController(CONTENT_SETTINGS_TYPE_MEDIASTREAM); |
|
tapted
2015/09/07 05:39:21
Should this iterate over _MIC and _CAMERA as well
| |
| 139 content_setting_bubble::MediaMenuPartsMap* mediaMenus = | 125 content_setting_bubble::MediaMenuPartsMap* mediaMenus = |
| 140 [controller mediaMenus]; | 126 [controller mediaMenus]; |
| 141 EXPECT_EQ(2u, mediaMenus->size()); | 127 EXPECT_EQ(2u, mediaMenus->size()); |
| 142 NSString* title = l10n_util::GetNSString(IDS_MEDIA_MENU_NO_DEVICE_TITLE); | 128 NSString* title = l10n_util::GetNSString(IDS_MEDIA_MENU_NO_DEVICE_TITLE); |
| 143 for (content_setting_bubble::MediaMenuPartsMap::const_iterator i = | 129 for (content_setting_bubble::MediaMenuPartsMap::const_iterator i = |
| 144 mediaMenus->begin(); i != mediaMenus->end(); ++i) { | 130 mediaMenus->begin(); i != mediaMenus->end(); ++i) { |
| 145 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || | 131 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || |
| 146 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); | 132 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); |
| 147 EXPECT_EQ(0, [i->first numberOfItems]); | 133 EXPECT_EQ(0, [i->first numberOfItems]); |
| 148 EXPECT_NSEQ(title, [i->first title]); | 134 EXPECT_NSEQ(title, [i->first title]); |
| 149 EXPECT_FALSE([i->first isEnabled]); | 135 EXPECT_FALSE([i->first isEnabled]); |
| 150 } | 136 } |
| 151 | 137 |
| 152 [parent_ close]; | 138 [parent_ close]; |
| 153 } | 139 } |
| 154 | 140 |
| 155 } // namespace | 141 } // namespace |
| OLD | NEW |