Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm

Issue 6854035: Move blocked content from TabContents to TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "base/memory/scoped_nsobject.h" 10 #include "base/memory/scoped_nsobject.h"
11 #include "chrome/browser/content_setting_bubble_model.h"
12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
12 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
13 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
13 #include "chrome/common/content_settings_types.h" 14 #include "chrome/common/content_settings_types.h"
15 #include "chrome/test/testing_profile.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 namespace { 18 namespace {
17 19
18 class DummyContentSettingBubbleModel : public ContentSettingBubbleModel { 20 class DummyContentSettingBubbleModel : public ContentSettingBubbleModel {
19 public: 21 public:
20 DummyContentSettingBubbleModel(ContentSettingsType content_type) 22 DummyContentSettingBubbleModel(TabContentsWrapper* tab_contents,
stevenjb 2011/04/21 19:03:00 nit: tab_contents_wrapper
21 : ContentSettingBubbleModel(NULL, NULL, content_type) { 23 Profile* profile,
24 ContentSettingsType content_type)
25 : ContentSettingBubbleModel(tab_contents, profile, content_type) {
22 RadioGroup radio_group; 26 RadioGroup radio_group;
23 radio_group.default_item = 0; 27 radio_group.default_item = 0;
24 radio_group.radio_items.resize(2); 28 radio_group.radio_items.resize(2);
25 set_radio_group(radio_group); 29 set_radio_group(radio_group);
26 } 30 }
27 }; 31 };
28 32
29 class ContentSettingBubbleControllerTest : public CocoaTest { 33 class ContentSettingBubbleControllerTest
34 : public TabContentsWrapperTestHarness {
35 public:
36 ContentSettingBubbleControllerTest();
37 virtual ~ContentSettingBubbleControllerTest();
38
39 private:
40 NSAutoreleasePool* pool_;
30 }; 41 };
31 42
43 ContentSettingBubbleControllerTest::ContentSettingBubbleControllerTest()
44 : pool_([[NSAutoreleasePool alloc] init]) {
45 }
46
47 ContentSettingBubbleControllerTest::~ContentSettingBubbleControllerTest() {
48 [pool_ drain];
49 }
50
32 // Check that the bubble doesn't crash or leak for any settings type 51 // Check that the bubble doesn't crash or leak for any settings type
33 TEST_F(ContentSettingBubbleControllerTest, Init) { 52 TEST_F(ContentSettingBubbleControllerTest, Init) {
34 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 53 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
35 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) 54 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
36 continue; // Notifications have no bubble. 55 continue; // Notifications have no bubble.
37 if (i == CONTENT_SETTINGS_TYPE_PRERENDER) 56 if (i == CONTENT_SETTINGS_TYPE_PRERENDER)
38 continue; // Prerender has no bubble. 57 continue; // Prerender has no bubble.
39 58
40 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i); 59 ContentSettingsType settingsType = static_cast<ContentSettingsType>(i);
41 60
42 scoped_nsobject<NSWindow> parent([[NSWindow alloc] 61 scoped_nsobject<NSWindow> parent([[NSWindow alloc]
43 initWithContentRect:NSMakeRect(0, 0, 800, 600) 62 initWithContentRect:NSMakeRect(0, 0, 800, 600)
44 styleMask:NSBorderlessWindowMask 63 styleMask:NSBorderlessWindowMask
45 backing:NSBackingStoreBuffered 64 backing:NSBackingStoreBuffered
46 defer:NO]); 65 defer:NO]);
47 [parent setReleasedWhenClosed:NO]; 66 [parent setReleasedWhenClosed:NO];
48 if (base::debug::BeingDebugged()) 67 if (base::debug::BeingDebugged())
49 [parent.get() orderFront:nil]; 68 [parent.get() orderFront:nil];
50 else 69 else
51 [parent.get() orderBack:nil]; 70 [parent.get() orderBack:nil];
52 71
53 ContentSettingBubbleController* controller = [ContentSettingBubbleController 72 ContentSettingBubbleController* controller = [ContentSettingBubbleController
54 showForModel:new DummyContentSettingBubbleModel(settingsType) 73 showForModel:new DummyContentSettingBubbleModel(contents_wrapper(),
74 profile(),
75 settingsType)
55 parentWindow:parent 76 parentWindow:parent
56 anchoredAt:NSMakePoint(50, 20)]; 77 anchoredAt:NSMakePoint(50, 20)];
57 EXPECT_TRUE(controller != nil); 78 EXPECT_TRUE(controller != nil);
58 EXPECT_TRUE([[controller window] isVisible]); 79 EXPECT_TRUE([[controller window] isVisible]);
59 [parent.get() close]; 80 [parent.get() close];
60 } 81 }
61 } 82 }
62 83
63 } // namespace 84 } // namespace
64 85
65 86
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698