| 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 #include "base/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_utils.h" | 8 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 9 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 9 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 bookmark_utils::ToggleWhenVisible(profile()); | 87 bookmark_utils::ToggleWhenVisible(profile()); |
| 88 EXPECT_EQ(before, bwc->IsBookmarkBarVisible()); | 88 EXPECT_EQ(before, bwc->IsBookmarkBarVisible()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 @interface FakeController : NSWindowController { | 91 @interface FakeController : NSWindowController { |
| 92 BOOL fullscreen_; | 92 BOOL fullscreen_; |
| 93 } | 93 } |
| 94 @end | 94 @end |
| 95 | 95 |
| 96 @implementation FakeController | 96 @implementation FakeController |
| 97 - (void)setFullscreen:(BOOL)fullscreen { | 97 - (void)setFullscreen:(BOOL)fullscreen |
| 98 url:(const GURL&)url |
| 99 askPermission:(BOOL)askPermission { |
| 98 fullscreen_ = fullscreen; | 100 fullscreen_ = fullscreen; |
| 99 } | 101 } |
| 100 - (BOOL)isFullscreen { | 102 - (BOOL)isFullscreen { |
| 101 return fullscreen_; | 103 return fullscreen_; |
| 102 } | 104 } |
| 103 @end | 105 @end |
| 104 | 106 |
| 105 TEST_F(BrowserWindowCocoaTest, TestFullscreen) { | 107 TEST_F(BrowserWindowCocoaTest, TestFullscreen) { |
| 106 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in | 108 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in |
| 107 // windowWillClose: because we never actually open a window in this test (so | 109 // windowWillClose: because we never actually open a window in this test (so |
| 108 // windowWillClose: never gets called). | 110 // windowWillClose: never gets called). |
| 109 scoped_nsobject<FakeController> fake_controller( | 111 scoped_nsobject<FakeController> fake_controller( |
| 110 [[FakeController alloc] init]); | 112 [[FakeController alloc] init]); |
| 111 BrowserWindowCocoaPong* bwc = new BrowserWindowCocoaPong( | 113 BrowserWindowCocoaPong* bwc = new BrowserWindowCocoaPong( |
| 112 browser(), | 114 browser(), |
| 113 (BrowserWindowController*)fake_controller.get()); | 115 (BrowserWindowController*)fake_controller.get()); |
| 114 scoped_ptr<BrowserWindowCocoaPong> scoped_bwc(bwc); | 116 scoped_ptr<BrowserWindowCocoaPong> scoped_bwc(bwc); |
| 115 | 117 |
| 116 EXPECT_FALSE(bwc->IsFullscreen()); | 118 EXPECT_FALSE(bwc->IsFullscreen()); |
| 117 bwc->SetFullscreen(true); | 119 bwc->EnterFullscreen(GURL(), false); |
| 118 EXPECT_TRUE(bwc->IsFullscreen()); | 120 EXPECT_TRUE(bwc->IsFullscreen()); |
| 119 bwc->SetFullscreen(false); | 121 bwc->ExitFullscreen(); |
| 120 EXPECT_FALSE(bwc->IsFullscreen()); | 122 EXPECT_FALSE(bwc->IsFullscreen()); |
| 121 [fake_controller close]; | 123 [fake_controller close]; |
| 122 } | 124 } |
| 123 | 125 |
| 124 // TODO(???): test other methods of BrowserWindowCocoa | 126 // TODO(???): test other methods of BrowserWindowCocoa |
| OLD | NEW |