| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/content_setting_bubble_cocoa.h" | |
| 6 | |
| 7 #import <Cocoa/Cocoa.h> | |
| 8 | |
| 9 #include "base/debug/debugger.h" | |
| 10 #include "base/scoped_nsobject.h" | |
| 11 #include "chrome/browser/content_setting_bubble_model.h" | |
| 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | |
| 13 #include "chrome/common/content_settings_types.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 class DummyContentSettingBubbleModel : public ContentSettingBubbleModel { | |
| 19 public: | |
| 20 DummyContentSettingBubbleModel(ContentSettingsType content_type) | |
| 21 : ContentSettingBubbleModel(NULL, NULL, content_type) { | |
| 22 RadioGroup radio_group; | |
| 23 radio_group.default_item = 0; | |
| 24 radio_group.radio_items.resize(2); | |
| 25 set_radio_group(radio_group); | |
| 26 } | |
| 27 }; | |
| 28 | |
| 29 class ContentSettingBubbleControllerTest : public CocoaTest { | |
| 30 }; | |
| 31 | |
| 32 // Check that the bubble doesn't crash or leak for any settings type | |
| 33 TEST_F(ContentSettingBubbleControllerTest, Init) { | |
| 34 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | |
| 35 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | |
| 36 continue; // Notifications have no bubble. | |
| 37 | |
| 38 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i); | |
| 39 | |
| 40 scoped_nsobject<NSWindow> parent([[NSWindow alloc] | |
| 41 initWithContentRect:NSMakeRect(0, 0, 800, 600) | |
| 42 styleMask:NSBorderlessWindowMask | |
| 43 backing:NSBackingStoreBuffered | |
| 44 defer:NO]); | |
| 45 [parent setReleasedWhenClosed:NO]; | |
| 46 if (base::debug::BeingDebugged()) | |
| 47 [parent.get() orderFront:nil]; | |
| 48 else | |
| 49 [parent.get() orderBack:nil]; | |
| 50 | |
| 51 ContentSettingBubbleController* controller = [ContentSettingBubbleController | |
| 52 showForModel:new DummyContentSettingBubbleModel(settingsType) | |
| 53 parentWindow:parent | |
| 54 anchoredAt:NSMakePoint(50, 20)]; | |
| 55 EXPECT_TRUE(controller != nil); | |
| 56 EXPECT_TRUE([[controller window] isVisible]); | |
| 57 [parent.get() close]; | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 } // namespace | |
| 62 | |
| 63 | |
| OLD | NEW |