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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm

Issue 493143004: mac: Major fullscreen refactor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2 minor bugs, remove 2 unit tests that no longer test anything. Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "base/mac/mac_util.h" 5 #include "base/mac/mac_util.h"
6 #include "base/mac/scoped_nsobject.h" 6 #include "base/mac/scoped_nsobject.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/fullscreen.h" 10 #include "chrome/browser/fullscreen.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 new BrowserWindowCocoa(browser(), controller_)); 43 new BrowserWindowCocoa(browser(), controller_));
44 44
45 bool before = bwc->IsBookmarkBarVisible(); 45 bool before = bwc->IsBookmarkBarVisible();
46 chrome::ToggleBookmarkBarWhenVisible(profile()); 46 chrome::ToggleBookmarkBarWhenVisible(profile());
47 EXPECT_NE(before, bwc->IsBookmarkBarVisible()); 47 EXPECT_NE(before, bwc->IsBookmarkBarVisible());
48 48
49 chrome::ToggleBookmarkBarWhenVisible(profile()); 49 chrome::ToggleBookmarkBarWhenVisible(profile());
50 EXPECT_EQ(before, bwc->IsBookmarkBarVisible()); 50 EXPECT_EQ(before, bwc->IsBookmarkBarVisible());
51 } 51 }
52 52
53 @interface FakeController : NSWindowController {
54 enum { kNormal, kFullscreen, kPresentation } windowState_;
55 }
56 @end
57
58 @implementation FakeController
59 - (void)enterFullscreen {
60 windowState_ = kFullscreen;
61 }
62 - (void)exitFullscreen {
63 windowState_ = kNormal;
64 }
65 - (BOOL)isFullscreen {
66 return windowState_ != kNormal;
67 }
68 - (void)enterPresentationModeForURL:(const GURL&)url
69 bubbleType:(FullscreenExitBubbleType)bubbleType {
70 windowState_ = kPresentation;
71 }
72 - (void)exitPresentationMode {
73 windowState_ = kNormal;
74 }
75 - (BOOL)inPresentationMode {
76 return windowState_ == kPresentation;
77 }
78 @end
79
80 TEST_F(BrowserWindowCocoaTest, TestFullscreen) {
81 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in
82 // windowWillClose: because we never actually open a window in this test (so
83 // windowWillClose: never gets called).
84 base::scoped_nsobject<FakeController> fake_controller(
85 [[FakeController alloc] init]);
86 scoped_ptr<BrowserWindowCocoa> bwc(new BrowserWindowCocoa(
87 browser(), static_cast<BrowserWindowController*>(fake_controller.get())));
88
89 EXPECT_FALSE(bwc->IsFullscreen());
90 bwc->EnterFullscreen(GURL(), FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
91 EXPECT_FALSE(bwc->IsFullscreenWithChrome());
92 EXPECT_TRUE(bwc->IsFullscreenWithoutChrome());
93 bwc->ExitFullscreen();
94 EXPECT_FALSE(bwc->IsFullscreen());
95 [fake_controller close];
96 }
97
98 TEST_F(BrowserWindowCocoaTest, TestFullscreenWithChrome) {
99 if (!chrome::mac::SupportsSystemFullscreen())
100 return;
101 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in
102 // windowWillClose: because we never actually open a window in this test (so
103 // windowWillClose: never gets called).
104 base::scoped_nsobject<FakeController> fake_controller(
105 [[FakeController alloc] init]);
106 scoped_ptr<BrowserWindowCocoa> bwc(new BrowserWindowCocoa(
107 browser(), static_cast<BrowserWindowController*>(fake_controller.get())));
108
109 EXPECT_FALSE(bwc->IsFullscreen());
110 bwc->EnterFullscreenWithChrome();
111 EXPECT_TRUE(bwc->IsFullscreenWithChrome());
112 EXPECT_FALSE(bwc->IsFullscreenWithoutChrome());
113 bwc->ExitFullscreen();
114 EXPECT_FALSE(bwc->IsFullscreen());
115 [fake_controller close];
116 }
117
118 // Tests that BrowserWindowCocoa::Close mimics the behavior of 53 // Tests that BrowserWindowCocoa::Close mimics the behavior of
119 // -[NSWindow performClose:]. 54 // -[NSWindow performClose:].
120 class BrowserWindowCocoaCloseTest : public CocoaProfileTest { 55 class BrowserWindowCocoaCloseTest : public CocoaProfileTest {
121 public: 56 public:
122 BrowserWindowCocoaCloseTest() 57 BrowserWindowCocoaCloseTest()
123 : controller_( 58 : controller_(
124 [OCMockObject mockForClass:[BrowserWindowController class]]), 59 [OCMockObject mockForClass:[BrowserWindowController class]]),
125 window_([OCMockObject mockForClass:[NSWindow class]]) { 60 window_([OCMockObject mockForClass:[NSWindow class]]) {
126 [[[controller_ stub] andReturn:nil] overlayWindow]; 61 [[[controller_ stub] andReturn:nil] overlayWindow];
127 } 62 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 [[[window_ stub] andReturn:nil] delegate]; 164 [[[window_ stub] andReturn:nil] delegate];
230 [[[controller_ stub] andReturn:window_] window]; 165 [[[controller_ stub] andReturn:window_] window];
231 [[window_ expect] orderOut:nil]; 166 [[window_ expect] orderOut:nil];
232 [[window_ expect] close]; 167 [[window_ expect] close];
233 CreateAndCloseBrowserWindow(); 168 CreateAndCloseBrowserWindow();
234 EXPECT_OCMOCK_VERIFY(controller_); 169 EXPECT_OCMOCK_VERIFY(controller_);
235 EXPECT_OCMOCK_VERIFY(window_); 170 EXPECT_OCMOCK_VERIFY(window_);
236 } 171 }
237 172
238 // TODO(???): test other methods of BrowserWindowCocoa 173 // TODO(???): test other methods of BrowserWindowCocoa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698