Index: chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm |
diff --git a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm |
index a6ccdcb69a02566ac51aa192dd65bf9413adb288..30f927763dcd6c1c60df9e93f399cf3eeb6b841f 100644 |
--- a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm |
+++ b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm |
@@ -14,9 +14,12 @@ |
#import "chrome/browser/ui/cocoa/browser_test_helper.h" |
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
#import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.h" |
+#import "chrome/browser/ui/cocoa/info_bubble_window.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/extension_constants.h" |
+#include "third_party/ocmock/gtest_support.h" |
+#import "third_party/ocmock/OCMock/OCMock.h" |
#include "webkit/glue/image_decoder.h" |
// ExtensionInstalledBubbleController with removePageActionPreview overridden |
@@ -200,3 +203,35 @@ TEST_F(ExtensionInstalledBubbleControllerTest, BrowserActionTest) { |
[controller close]; |
} |
+ |
+TEST_F(ExtensionInstalledBubbleControllerTest, ParentClose) { |
+ extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); |
+ ExtensionInstalledBubbleControllerForTest* controller = |
+ [[ExtensionInstalledBubbleControllerForTest alloc] |
+ initWithParentWindow:window_ |
+ extension:extension_.get() |
+ browser:browser_ |
+ icon:icon_]; |
+ EXPECT_TRUE(controller); |
+ |
+ // Bring up the window and disable close animation. |
+ [controller showWindow:nil]; |
+ NSWindow* bubbleWindow = [controller window]; |
+ ASSERT_TRUE([bubbleWindow isKindOfClass:[InfoBubbleWindow class]]); |
+ [static_cast<InfoBubbleWindow*>(bubbleWindow) setDelayOnClose:NO]; |
+ |
+ // Observe whether the bubble window closes. |
+ NSString* notification = NSWindowWillCloseNotification; |
+ id observer = [OCMockObject observerMock]; |
+ [[observer expect] notificationWithName:notification object:bubbleWindow]; |
+ [[NSNotificationCenter defaultCenter] |
+ 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
|
+ |
+ // The bubble window goes from visible to not-visible. |
+ EXPECT_TRUE([bubbleWindow isVisible]); |
+ [window_ close]; |
+ EXPECT_FALSE([bubbleWindow isVisible]); |
+ |
+ // And the appropriate notification was received. |
+ EXPECT_OCMOCK_VERIFY(observer); |
+} |