| 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 ContentSettingBubbleController* controller = CreateBubbleController(type); |
| 108 i == CONTENT_SETTINGS_TYPE_FULLSCREEN || | |
| 109 i == CONTENT_SETTINGS_TYPE_MOUSELOCK || | |
| 110 i == CONTENT_SETTINGS_TYPE_MEDIASTREAM || | |
| 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; | |
| 122 } | |
| 123 | |
| 124 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i); | |
| 125 | |
| 126 ContentSettingBubbleController* controller = | |
| 127 CreateBubbleController(settingsType); | |
| 128 EXPECT_EQ(0u, [controller mediaMenus]->size()); | 108 EXPECT_EQ(0u, [controller mediaMenus]->size()); |
| 129 [parent_ close]; | 109 [parent_ close]; |
| 130 } | 110 } |
| 131 } | 111 } |
| 132 | 112 |
| 133 // Check that the bubble works for CONTENT_SETTINGS_TYPE_MEDIASTREAM. | 113 // Check that the bubble works for CONTENT_SETTINGS_TYPE_MEDIASTREAM. |
| 134 TEST_F(ContentSettingBubbleControllerTest, MediaStreamBubble) { | 114 TEST_F(ContentSettingBubbleControllerTest, MediaStreamBubble) { |
| 135 MediaCaptureDevicesDispatcher::GetInstance()-> | 115 MediaCaptureDevicesDispatcher::GetInstance()-> |
| 136 DisableDeviceEnumerationForTesting(); | 116 DisableDeviceEnumerationForTesting(); |
| 137 ContentSettingBubbleController* controller = | 117 ContentSettingBubbleController* controller = |
| 138 CreateBubbleController(CONTENT_SETTINGS_TYPE_MEDIASTREAM); | 118 CreateBubbleController(CONTENT_SETTINGS_TYPE_MEDIASTREAM); |
| 139 content_setting_bubble::MediaMenuPartsMap* mediaMenus = | 119 content_setting_bubble::MediaMenuPartsMap* mediaMenus = |
| 140 [controller mediaMenus]; | 120 [controller mediaMenus]; |
| 141 EXPECT_EQ(2u, mediaMenus->size()); | 121 EXPECT_EQ(2u, mediaMenus->size()); |
| 142 NSString* title = l10n_util::GetNSString(IDS_MEDIA_MENU_NO_DEVICE_TITLE); | 122 NSString* title = l10n_util::GetNSString(IDS_MEDIA_MENU_NO_DEVICE_TITLE); |
| 143 for (content_setting_bubble::MediaMenuPartsMap::const_iterator i = | 123 for (content_setting_bubble::MediaMenuPartsMap::const_iterator i = |
| 144 mediaMenus->begin(); i != mediaMenus->end(); ++i) { | 124 mediaMenus->begin(); i != mediaMenus->end(); ++i) { |
| 145 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || | 125 EXPECT_TRUE((content::MEDIA_DEVICE_AUDIO_CAPTURE == i->second->type) || |
| 146 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); | 126 (content::MEDIA_DEVICE_VIDEO_CAPTURE == i->second->type)); |
| 147 EXPECT_EQ(0, [i->first numberOfItems]); | 127 EXPECT_EQ(0, [i->first numberOfItems]); |
| 148 EXPECT_NSEQ(title, [i->first title]); | 128 EXPECT_NSEQ(title, [i->first title]); |
| 149 EXPECT_FALSE([i->first isEnabled]); | 129 EXPECT_FALSE([i->first isEnabled]); |
| 150 } | 130 } |
| 151 | 131 |
| 152 [parent_ close]; | 132 [parent_ close]; |
| 153 } | 133 } |
| 154 | 134 |
| 155 } // namespace | 135 } // namespace |
| OLD | NEW |