| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/cocoa/content_blocked_bubble_controller.h" | 5 #import "chrome/browser/cocoa/content_blocked_bubble_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/scoped_nsobject.h" | 9 #include "base/scoped_nsobject.h" |
| 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 set_radio_group(radio_group); | 24 set_radio_group(radio_group); |
| 25 } | 25 } |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class ContentBlockedBubbleControllerTest : public CocoaTest { | 28 class ContentBlockedBubbleControllerTest : public CocoaTest { |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // Check that the bubble doesn't crash or leak for any settings type | 31 // Check that the bubble doesn't crash or leak for any settings type |
| 32 TEST_F(ContentBlockedBubbleControllerTest, Init) { | 32 TEST_F(ContentBlockedBubbleControllerTest, Init) { |
| 33 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 33 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 34 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) |
| 35 continue; // Notifications have no bubble. |
| 36 |
| 34 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i); | 37 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i); |
| 35 | 38 |
| 36 scoped_nsobject<NSWindow> parent([[NSWindow alloc] | 39 scoped_nsobject<NSWindow> parent([[NSWindow alloc] |
| 37 initWithContentRect:NSMakeRect(0, 0, 800, 600) | 40 initWithContentRect:NSMakeRect(0, 0, 800, 600) |
| 38 styleMask:NSBorderlessWindowMask | 41 styleMask:NSBorderlessWindowMask |
| 39 backing:NSBackingStoreBuffered | 42 backing:NSBackingStoreBuffered |
| 40 defer:NO]); | 43 defer:NO]); |
| 41 [parent setReleasedWhenClosed:NO]; | 44 [parent setReleasedWhenClosed:NO]; |
| 42 if (DebugUtil::BeingDebugged()) | 45 if (DebugUtil::BeingDebugged()) |
| 43 [parent.get() orderFront:nil]; | 46 [parent.get() orderFront:nil]; |
| 44 else | 47 else |
| 45 [parent.get() orderBack:nil]; | 48 [parent.get() orderBack:nil]; |
| 46 | 49 |
| 47 ContentBlockedBubbleController* controller = [ContentBlockedBubbleController | 50 ContentBlockedBubbleController* controller = [ContentBlockedBubbleController |
| 48 showForModel:new DummyContentSettingBubbleModel(settingsType) | 51 showForModel:new DummyContentSettingBubbleModel(settingsType) |
| 49 parentWindow:parent | 52 parentWindow:parent |
| 50 anchoredAt:NSMakePoint(50, 20)]; | 53 anchoredAt:NSMakePoint(50, 20)]; |
| 51 EXPECT_TRUE(controller != nil); | 54 EXPECT_TRUE(controller != nil); |
| 52 EXPECT_TRUE([[controller window] isVisible]); | 55 EXPECT_TRUE([[controller window] isVisible]); |
| 53 [parent.get() close]; | 56 [parent.get() close]; |
| 54 } | 57 } |
| 55 } | 58 } |
| 56 | 59 |
| 57 } // namespace | 60 } // namespace |
| 58 | 61 |
| 59 | 62 |
| OLD | NEW |