| OLD | NEW |
| 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/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| 11 #include "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
| 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 13 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 13 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| 14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
| 15 #include "chrome/common/content_settings_types.h" | 15 #include "chrome/common/content_settings_types.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using content::BrowserThread; | 20 using content::BrowserThread; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 class DummyContentSettingBubbleModel : public ContentSettingBubbleModel { | 24 class DummyContentSettingBubbleModel : public ContentSettingBubbleModel { |
| 25 public: | 25 public: |
| 26 DummyContentSettingBubbleModel(TabContentsWrapper* tab_contents, | 26 DummyContentSettingBubbleModel(TabContentsWrapper* tab_contents, |
| 27 Profile* profile, | 27 Profile* profile, |
| 28 ContentSettingsType content_type) | 28 ContentSettingsType content_type) |
| 29 : ContentSettingBubbleModel(tab_contents, profile, content_type) { | 29 : ContentSettingBubbleModel(tab_contents, profile, content_type) { |
| 30 RadioGroup radio_group; | 30 RadioGroup radio_group; |
| 31 radio_group.default_item = 0; | 31 radio_group.default_item = 0; |
| 32 radio_group.radio_items.resize(2); | 32 radio_group.radio_items.resize(2); |
| 33 set_radio_group(radio_group); | 33 set_radio_group(radio_group); |
| 34 } | 34 } |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class ContentSettingBubbleControllerTest | 37 class ContentSettingBubbleControllerTest |
| 38 : public TabContentsWrapperTestHarness { | 38 : public TabContentsTestHarness { |
| 39 public: | 39 public: |
| 40 ContentSettingBubbleControllerTest(); | 40 ContentSettingBubbleControllerTest(); |
| 41 virtual ~ContentSettingBubbleControllerTest(); | 41 virtual ~ContentSettingBubbleControllerTest(); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 content::TestBrowserThread browser_thread_; | 44 content::TestBrowserThread browser_thread_; |
| 45 | 45 |
| 46 base::mac::ScopedNSAutoreleasePool pool_; | 46 base::mac::ScopedNSAutoreleasePool pool_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 ContentSettingBubbleControllerTest::ContentSettingBubbleControllerTest() | 49 ContentSettingBubbleControllerTest::ContentSettingBubbleControllerTest() |
| 50 : TabContentsWrapperTestHarness(), | 50 : TabContentsTestHarness(), |
| 51 browser_thread_(BrowserThread::UI, &message_loop_) { | 51 browser_thread_(BrowserThread::UI, &message_loop_) { |
| 52 } | 52 } |
| 53 | 53 |
| 54 ContentSettingBubbleControllerTest::~ContentSettingBubbleControllerTest() { | 54 ContentSettingBubbleControllerTest::~ContentSettingBubbleControllerTest() { |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Check that the bubble doesn't crash or leak for any settings type | 57 // Check that the bubble doesn't crash or leak for any settings type |
| 58 TEST_F(ContentSettingBubbleControllerTest, Init) { | 58 TEST_F(ContentSettingBubbleControllerTest, Init) { |
| 59 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 59 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 60 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || | 60 if (i == CONTENT_SETTINGS_TYPE_NOTIFICATIONS || |
| (...skipping 12 matching lines...) Expand all Loading... |
| 73 styleMask:NSBorderlessWindowMask | 73 styleMask:NSBorderlessWindowMask |
| 74 backing:NSBackingStoreBuffered | 74 backing:NSBackingStoreBuffered |
| 75 defer:NO]); | 75 defer:NO]); |
| 76 [parent setReleasedWhenClosed:NO]; | 76 [parent setReleasedWhenClosed:NO]; |
| 77 if (base::debug::BeingDebugged()) | 77 if (base::debug::BeingDebugged()) |
| 78 [parent.get() orderFront:nil]; | 78 [parent.get() orderFront:nil]; |
| 79 else | 79 else |
| 80 [parent.get() orderBack:nil]; | 80 [parent.get() orderBack:nil]; |
| 81 | 81 |
| 82 ContentSettingBubbleController* controller = [ContentSettingBubbleController | 82 ContentSettingBubbleController* controller = [ContentSettingBubbleController |
| 83 showForModel:new DummyContentSettingBubbleModel(contents_wrapper(), | 83 showForModel:new DummyContentSettingBubbleModel(tab_contents(), |
| 84 profile(), | 84 profile(), |
| 85 settingsType) | 85 settingsType) |
| 86 parentWindow:parent | 86 parentWindow:parent |
| 87 anchoredAt:NSMakePoint(50, 20)]; | 87 anchoredAt:NSMakePoint(50, 20)]; |
| 88 EXPECT_TRUE(controller != nil); | 88 EXPECT_TRUE(controller != nil); |
| 89 EXPECT_TRUE([[controller window] isVisible]); | 89 EXPECT_TRUE([[controller window] isVisible]); |
| 90 [parent.get() close]; | 90 [parent.get() close]; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace | 94 } // namespace |
| OLD | NEW |