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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #import "chrome/browser/ui/browser_window.h" | 13 #import "chrome/browser/ui/browser_window.h" |
14 #import "chrome/browser/ui/cocoa/browser_test_helper.h" | 14 #import "chrome/browser/ui/cocoa/browser_test_helper.h" |
15 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 15 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
16 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h" | 16 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h" |
17 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | |
17 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
21 #include "third_party/ocmock/gtest_support.h" | |
22 #import "third_party/ocmock/OCMock/OCMock.h" | |
20 #include "webkit/glue/image_decoder.h" | 23 #include "webkit/glue/image_decoder.h" |
21 | 24 |
22 // ExtensionInstalledBubbleController with removePageActionPreview overridden | 25 // ExtensionInstalledBubbleController with removePageActionPreview overridden |
23 // to a no-op, because pageActions are not yet hooked up in the test browser. | 26 // to a no-op, because pageActions are not yet hooked up in the test browser. |
24 @interface ExtensionInstalledBubbleControllerForTest : | 27 @interface ExtensionInstalledBubbleControllerForTest : |
25 ExtensionInstalledBubbleController { | 28 ExtensionInstalledBubbleController { |
26 } | 29 } |
27 | 30 |
28 // Do nothing, because browser window is not set up with page actions | 31 // Do nothing, because browser window is not set up with page actions |
29 // for unit testing. | 32 // for unit testing. |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 extension_installed_bubble::kOuterVerticalMargin); | 196 extension_installed_bubble::kOuterVerticalMargin); |
194 NSRect msg1Frame = [controller getExtensionInstalledMsgFrame]; | 197 NSRect msg1Frame = [controller getExtensionInstalledMsgFrame]; |
195 // Top message should start kInnerVerticalMargin pixels above top of | 198 // Top message should start kInnerVerticalMargin pixels above top of |
196 // extensionInstalled message, because page action message is hidden. | 199 // extensionInstalled message, because page action message is hidden. |
197 EXPECT_EQ(msg1Frame.origin.y, | 200 EXPECT_EQ(msg1Frame.origin.y, |
198 msg3Frame.origin.y + msg3Frame.size.height + | 201 msg3Frame.origin.y + msg3Frame.size.height + |
199 extension_installed_bubble::kInnerVerticalMargin); | 202 extension_installed_bubble::kInnerVerticalMargin); |
200 | 203 |
201 [controller close]; | 204 [controller close]; |
202 } | 205 } |
206 | |
207 TEST_F(ExtensionInstalledBubbleControllerTest, ParentClose) { | |
208 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); | |
209 ExtensionInstalledBubbleControllerForTest* controller = | |
210 [[ExtensionInstalledBubbleControllerForTest alloc] | |
211 initWithParentWindow:window_ | |
212 extension:extension_.get() | |
213 browser:browser_ | |
214 icon:icon_]; | |
215 EXPECT_TRUE(controller); | |
216 | |
217 // Bring up the window and disable close animation. | |
218 [controller showWindow:nil]; | |
219 NSWindow* bubbleWindow = [controller window]; | |
220 ASSERT_TRUE([bubbleWindow isKindOfClass:[InfoBubbleWindow class]]); | |
221 [static_cast<InfoBubbleWindow*>(bubbleWindow) setDelayOnClose:NO]; | |
222 | |
223 // Observe whether the bubble window closes. | |
224 NSString* notification = NSWindowWillCloseNotification; | |
225 id observer = [OCMockObject observerMock]; | |
226 [[observer expect] notificationWithName:notification object:bubbleWindow]; | |
227 [[NSNotificationCenter defaultCenter] | |
228 addMockObserver:observer name:notification object:bubbleWindow]; | |
Scott Hess - ex-Googler
2011/09/03 14:07:21
I notice that the notifications need to be removed
| |
229 | |
230 // The bubble window goes from visible to not-visible. | |
231 EXPECT_TRUE([bubbleWindow isVisible]); | |
232 [window_ close]; | |
233 EXPECT_FALSE([bubbleWindow isVisible]); | |
234 | |
235 // And the appropriate notification was received. | |
236 EXPECT_OCMOCK_VERIFY(observer); | |
237 } | |
OLD | NEW |