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..697ef5d9ea42578220f7d9a5899680321905e879 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,37 @@ 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]; |
+ |
+ // The bubble window goes from visible to not-visible. |
+ EXPECT_TRUE([bubbleWindow isVisible]); |
+ [window_ close]; |
+ EXPECT_FALSE([bubbleWindow isVisible]); |
+ |
+ [[NSNotificationCenter defaultCenter] removeObserver:observer]; |
+ |
+ // Check that the appropriate notification was received. |
+ EXPECT_OCMOCK_VERIFY(observer); |
+} |