Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm

Issue 8399017: Fix a crash in FullscreenExitBubbleController when the user clicks the "Exit full screen" button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
index 6a293e2c1e079501adf1324fdda53486f9784512..65e3e93048ec4f38dc2fd18c0e0d688aec391bfb 100644
--- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm
@@ -4,7 +4,14 @@
#import "chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.h"
-#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/cocoa/browser_window_controller.h"
+#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
+#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/browser/site_instance.h"
#include "testing/gtest_mac.h"
#include "ui/base/models/accelerator_cocoa.h"
@@ -29,14 +36,16 @@
}
@end
-class FullscreenExitBubbleControllerTest : public CocoaTest {
+class FullscreenExitBubbleControllerTest : public CocoaProfileTest {
public:
virtual void SetUp() {
- CocoaTest::SetUp();
+ CocoaProfileTest::SetUp();
+ ASSERT_TRUE(profile());
+ site_instance_ = SiteInstance::CreateSiteInstance(profile());
controller_.reset(
[[FullscreenExitBubbleController alloc] initWithOwner:nil
- browser:nil
+ browser:browser()
url:GURL()
bubbleType:FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION]);
EXPECT_TRUE([controller_ window]);
@@ -45,12 +54,52 @@ class FullscreenExitBubbleControllerTest : public CocoaTest {
virtual void TearDown() {
[controller_ close];
controller_.reset();
- CocoaTest::TearDown();
+ CocoaProfileTest::TearDown();
}
+ void AppendTabToStrip() {
+ TabContentsWrapper* tab_contents = Browser::TabContentsFactory(
+ profile(), site_instance_, MSG_ROUTING_NONE,
+ NULL, NULL);
+ browser()->tabstrip_model()->AppendTabContents(
+ tab_contents, /*foreground=*/true);
+ }
+
+ scoped_refptr<SiteInstance> site_instance_;
scoped_nsobject<FullscreenExitBubbleController> controller_;
};
+TEST_F(FullscreenExitBubbleControllerTest, DenyExitsFullscreen) {
+ CreateBrowserWindow();
+ AppendTabToStrip();
+ TabContents* fullscreen_tab = browser()->GetSelectedTabContents();
+ {
+ base::mac::ScopedNSAutoreleasePool pool;
+ ui_test_utils::WindowedNotificationObserver fullscreen_observer(
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ content::NotificationService::AllSources());
+ browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
+ fullscreen_observer.Wait();
+ ASSERT_TRUE(browser()->window()->IsFullscreen());
+ }
+
+ NSWindow* window = browser()->window()->GetNativeHandle();
+ BrowserWindowController* bwc = [BrowserWindowController
+ browserWindowControllerForWindow:window];
+ FullscreenExitBubbleController* bubble = [bwc fullscreenExitBubbleController];
+ ASSERT_TRUE(bubble);
+ {
+ ui_test_utils::WindowedNotificationObserver fullscreen_observer(
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ content::NotificationService::AllSources());
+ [bubble deny:nil];
+ fullscreen_observer.Wait();
+ }
+ EXPECT_FALSE([bwc fullscreenExitBubbleController]);
+ EXPECT_FALSE(browser()->window()->IsFullscreen());
+ CloseBrowserWindow();
+}
+
TEST_F(FullscreenExitBubbleControllerTest, LabelWasReplaced) {
EXPECT_FALSE([controller_ exitLabelPlaceholder]);
EXPECT_TRUE([controller_ exitLabel]);
« no previous file with comments | « chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698