| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 SkBitmap icon_; | 111 SkBitmap icon_; |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 // Confirm that window sizes are set correctly for a page action extension. | 114 // Confirm that window sizes are set correctly for a page action extension. |
| 115 TEST_F(ExtensionInstalledBubbleControllerTest, PageActionTest) { | 115 TEST_F(ExtensionInstalledBubbleControllerTest, PageActionTest) { |
| 116 extension_ = CreateExtension(extension_installed_bubble::kPageAction); | 116 extension_ = CreateExtension(extension_installed_bubble::kPageAction); |
| 117 ExtensionInstalledBubbleControllerForTest* controller = | 117 ExtensionInstalledBubbleControllerForTest* controller = |
| 118 [[ExtensionInstalledBubbleControllerForTest alloc] | 118 [[ExtensionInstalledBubbleControllerForTest alloc] |
| 119 initWithParentWindow:window_ | 119 initWithParentWindow:window_ |
| 120 extension:extension_.get() | 120 extension:extension_.get() |
| 121 bundle:NULL |
| 121 browser:browser() | 122 browser:browser() |
| 122 icon:icon_]; | 123 icon:icon_]; |
| 123 EXPECT_TRUE(controller); | 124 EXPECT_TRUE(controller); |
| 124 | 125 |
| 125 // Initialize window without having to calculate tabstrip locations. | 126 // Initialize window without having to calculate tabstrip locations. |
| 126 [controller initializeWindow]; | 127 [controller initializeWindow]; |
| 127 EXPECT_TRUE([controller window]); | 128 EXPECT_TRUE([controller window]); |
| 128 | 129 |
| 129 int height = [controller calculateWindowHeight]; | 130 int height = [controller calculateWindowHeight]; |
| 130 // Height should equal the vertical padding + height of all messages. | 131 // Height should equal the vertical padding + height of all messages. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 154 [controller setPageActionRemoved:YES]; | 155 [controller setPageActionRemoved:YES]; |
| 155 [controller close]; | 156 [controller close]; |
| 156 } | 157 } |
| 157 | 158 |
| 158 TEST_F(ExtensionInstalledBubbleControllerTest, BrowserActionTest) { | 159 TEST_F(ExtensionInstalledBubbleControllerTest, BrowserActionTest) { |
| 159 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); | 160 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); |
| 160 ExtensionInstalledBubbleControllerForTest* controller = | 161 ExtensionInstalledBubbleControllerForTest* controller = |
| 161 [[ExtensionInstalledBubbleControllerForTest alloc] | 162 [[ExtensionInstalledBubbleControllerForTest alloc] |
| 162 initWithParentWindow:window_ | 163 initWithParentWindow:window_ |
| 163 extension:extension_.get() | 164 extension:extension_.get() |
| 165 bundle:NULL |
| 164 browser:browser() | 166 browser:browser() |
| 165 icon:icon_]; | 167 icon:icon_]; |
| 166 EXPECT_TRUE(controller); | 168 EXPECT_TRUE(controller); |
| 167 | 169 |
| 168 // Initialize window without having to calculate tabstrip locations. | 170 // Initialize window without having to calculate tabstrip locations. |
| 169 [controller initializeWindow]; | 171 [controller initializeWindow]; |
| 170 EXPECT_TRUE([controller window]); | 172 EXPECT_TRUE([controller window]); |
| 171 | 173 |
| 172 int height = [controller calculateWindowHeight]; | 174 int height = [controller calculateWindowHeight]; |
| 173 // Height should equal the vertical padding + height of all messages. | 175 // Height should equal the vertical padding + height of all messages. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 191 | 193 |
| 192 [controller close]; | 194 [controller close]; |
| 193 } | 195 } |
| 194 | 196 |
| 195 TEST_F(ExtensionInstalledBubbleControllerTest, ParentClose) { | 197 TEST_F(ExtensionInstalledBubbleControllerTest, ParentClose) { |
| 196 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); | 198 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); |
| 197 ExtensionInstalledBubbleControllerForTest* controller = | 199 ExtensionInstalledBubbleControllerForTest* controller = |
| 198 [[ExtensionInstalledBubbleControllerForTest alloc] | 200 [[ExtensionInstalledBubbleControllerForTest alloc] |
| 199 initWithParentWindow:window_ | 201 initWithParentWindow:window_ |
| 200 extension:extension_.get() | 202 extension:extension_.get() |
| 203 bundle:NULL |
| 201 browser:browser() | 204 browser:browser() |
| 202 icon:icon_]; | 205 icon:icon_]; |
| 203 EXPECT_TRUE(controller); | 206 EXPECT_TRUE(controller); |
| 204 | 207 |
| 205 // Bring up the window and disable close animation. | 208 // Bring up the window and disable close animation. |
| 206 [controller showWindow:nil]; | 209 [controller showWindow:nil]; |
| 207 NSWindow* bubbleWindow = [controller window]; | 210 NSWindow* bubbleWindow = [controller window]; |
| 208 ASSERT_TRUE([bubbleWindow isKindOfClass:[InfoBubbleWindow class]]); | 211 ASSERT_TRUE([bubbleWindow isKindOfClass:[InfoBubbleWindow class]]); |
| 209 [static_cast<InfoBubbleWindow*>(bubbleWindow) setDelayOnClose:NO]; | 212 [static_cast<InfoBubbleWindow*>(bubbleWindow) setDelayOnClose:NO]; |
| 210 | 213 |
| 211 // Observe whether the bubble window closes. | 214 // Observe whether the bubble window closes. |
| 212 NSString* notification = NSWindowWillCloseNotification; | 215 NSString* notification = NSWindowWillCloseNotification; |
| 213 id observer = [OCMockObject observerMock]; | 216 id observer = [OCMockObject observerMock]; |
| 214 [[observer expect] notificationWithName:notification object:bubbleWindow]; | 217 [[observer expect] notificationWithName:notification object:bubbleWindow]; |
| 215 [[NSNotificationCenter defaultCenter] | 218 [[NSNotificationCenter defaultCenter] |
| 216 addMockObserver:observer name:notification object:bubbleWindow]; | 219 addMockObserver:observer name:notification object:bubbleWindow]; |
| 217 | 220 |
| 218 // The bubble window goes from visible to not-visible. | 221 // The bubble window goes from visible to not-visible. |
| 219 EXPECT_TRUE([bubbleWindow isVisible]); | 222 EXPECT_TRUE([bubbleWindow isVisible]); |
| 220 [window_ close]; | 223 [window_ close]; |
| 221 EXPECT_FALSE([bubbleWindow isVisible]); | 224 EXPECT_FALSE([bubbleWindow isVisible]); |
| 222 | 225 |
| 223 [[NSNotificationCenter defaultCenter] removeObserver:observer]; | 226 [[NSNotificationCenter defaultCenter] removeObserver:observer]; |
| 224 | 227 |
| 225 // Check that the appropriate notification was received. | 228 // Check that the appropriate notification was received. |
| 226 EXPECT_OCMOCK_VERIFY(observer); | 229 EXPECT_OCMOCK_VERIFY(observer); |
| 227 } | 230 } |
| OLD | NEW |