| 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/mac/mac_util.h" | 5 #include "base/mac/mac_util.h" |
| 6 #include "base/memory/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/ui/bookmarks/bookmark_utils.h" | 9 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 10 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #import "third_party/ocmock/OCMock/OCMock.h" |
| 17 #import "third_party/ocmock/gtest_support.h" | 18 #import "third_party/ocmock/gtest_support.h" |
| 18 #import "third_party/ocmock/OCMock/OCMock.h" | |
| 19 | 19 |
| 20 // Main test class. | 20 // Main test class. |
| 21 class BrowserWindowCocoaTest : public CocoaProfileTest { | 21 class BrowserWindowCocoaTest : public CocoaProfileTest { |
| 22 virtual void SetUp() { | 22 virtual void SetUp() { |
| 23 CocoaProfileTest::SetUp(); | 23 CocoaProfileTest::SetUp(); |
| 24 ASSERT_TRUE(browser()); | 24 ASSERT_TRUE(browser()); |
| 25 | 25 |
| 26 controller_ = [[BrowserWindowController alloc] initWithBrowser:browser() | 26 controller_ = [[BrowserWindowController alloc] initWithBrowser:browser() |
| 27 takeOwnership:NO]; | 27 takeOwnership:NO]; |
| 28 } | 28 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 - (BOOL)inPresentationMode { | 73 - (BOOL)inPresentationMode { |
| 74 return windowState_ == kPresentation; | 74 return windowState_ == kPresentation; |
| 75 } | 75 } |
| 76 @end | 76 @end |
| 77 | 77 |
| 78 TEST_F(BrowserWindowCocoaTest, TestFullscreen) { | 78 TEST_F(BrowserWindowCocoaTest, TestFullscreen) { |
| 79 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in | 79 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in |
| 80 // windowWillClose: because we never actually open a window in this test (so | 80 // windowWillClose: because we never actually open a window in this test (so |
| 81 // windowWillClose: never gets called). | 81 // windowWillClose: never gets called). |
| 82 scoped_nsobject<FakeController> fake_controller( | 82 base::scoped_nsobject<FakeController> fake_controller( |
| 83 [[FakeController alloc] init]); | 83 [[FakeController alloc] init]); |
| 84 scoped_ptr<BrowserWindowCocoa> bwc(new BrowserWindowCocoa( | 84 scoped_ptr<BrowserWindowCocoa> bwc(new BrowserWindowCocoa( |
| 85 browser(), static_cast<BrowserWindowController*>(fake_controller.get()))); | 85 browser(), static_cast<BrowserWindowController*>(fake_controller.get()))); |
| 86 | 86 |
| 87 EXPECT_FALSE(bwc->IsFullscreen()); | 87 EXPECT_FALSE(bwc->IsFullscreen()); |
| 88 bwc->EnterFullscreen(GURL(), FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); | 88 bwc->EnterFullscreen(GURL(), FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); |
| 89 EXPECT_FALSE(bwc->IsFullscreenWithChrome()); | 89 EXPECT_FALSE(bwc->IsFullscreenWithChrome()); |
| 90 EXPECT_TRUE(bwc->IsFullscreenWithoutChrome()); | 90 EXPECT_TRUE(bwc->IsFullscreenWithoutChrome()); |
| 91 bwc->ExitFullscreen(); | 91 bwc->ExitFullscreen(); |
| 92 EXPECT_FALSE(bwc->IsFullscreen()); | 92 EXPECT_FALSE(bwc->IsFullscreen()); |
| 93 [fake_controller close]; | 93 [fake_controller close]; |
| 94 } | 94 } |
| 95 | 95 |
| 96 TEST_F(BrowserWindowCocoaTest, TestFullscreenWithChrome) { | 96 TEST_F(BrowserWindowCocoaTest, TestFullscreenWithChrome) { |
| 97 if (!base::mac::IsOSLionOrLater()) | 97 if (!base::mac::IsOSLionOrLater()) |
| 98 return; | 98 return; |
| 99 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in | 99 // Wrap the FakeController in a scoped_nsobject instead of autoreleasing in |
| 100 // windowWillClose: because we never actually open a window in this test (so | 100 // windowWillClose: because we never actually open a window in this test (so |
| 101 // windowWillClose: never gets called). | 101 // windowWillClose: never gets called). |
| 102 scoped_nsobject<FakeController> fake_controller( | 102 base::scoped_nsobject<FakeController> fake_controller( |
| 103 [[FakeController alloc] init]); | 103 [[FakeController alloc] init]); |
| 104 scoped_ptr<BrowserWindowCocoa> bwc(new BrowserWindowCocoa( | 104 scoped_ptr<BrowserWindowCocoa> bwc(new BrowserWindowCocoa( |
| 105 browser(), static_cast<BrowserWindowController*>(fake_controller.get()))); | 105 browser(), static_cast<BrowserWindowController*>(fake_controller.get()))); |
| 106 | 106 |
| 107 EXPECT_FALSE(bwc->IsFullscreen()); | 107 EXPECT_FALSE(bwc->IsFullscreen()); |
| 108 bwc->EnterFullscreenWithChrome(); | 108 bwc->EnterFullscreenWithChrome(); |
| 109 EXPECT_TRUE(bwc->IsFullscreenWithChrome()); | 109 EXPECT_TRUE(bwc->IsFullscreenWithChrome()); |
| 110 EXPECT_FALSE(bwc->IsFullscreenWithoutChrome()); | 110 EXPECT_FALSE(bwc->IsFullscreenWithoutChrome()); |
| 111 bwc->ExitFullscreen(); | 111 bwc->ExitFullscreen(); |
| 112 EXPECT_FALSE(bwc->IsFullscreen()); | 112 EXPECT_FALSE(bwc->IsFullscreen()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 [[[window_ stub] andReturn:nil] delegate]; | 227 [[[window_ stub] andReturn:nil] delegate]; |
| 228 [[[controller_ stub] andReturn:window_] window]; | 228 [[[controller_ stub] andReturn:window_] window]; |
| 229 [[window_ expect] orderOut:nil]; | 229 [[window_ expect] orderOut:nil]; |
| 230 [[window_ expect] close]; | 230 [[window_ expect] close]; |
| 231 CreateAndCloseBrowserWindow(); | 231 CreateAndCloseBrowserWindow(); |
| 232 EXPECT_OCMOCK_VERIFY(controller_); | 232 EXPECT_OCMOCK_VERIFY(controller_); |
| 233 EXPECT_OCMOCK_VERIFY(window_); | 233 EXPECT_OCMOCK_VERIFY(window_); |
| 234 } | 234 } |
| 235 | 235 |
| 236 // TODO(???): test other methods of BrowserWindowCocoa | 236 // TODO(???): test other methods of BrowserWindowCocoa |
| OLD | NEW |