| 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 "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" | 
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" | 
| 9 #include "chrome/browser/sync/sync_ui_util.h" | 9 #include "chrome/browser/sync/sync_ui_util.h" | 
|  | 10 #include "chrome/browser/ui/browser_list.h" | 
| 10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" | 
| 11 #include "chrome/browser/ui/cocoa/browser_test_helper.h" | 12 #include "chrome/browser/ui/cocoa/browser_test_helper.h" | 
| 12 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 
| 13 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 14 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 
| 14 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 15 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" | 
| 16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" | 
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" | 
| 18 #include "ui/base/l10n/l10n_util_mac.h" | 19 #include "ui/base/l10n/l10n_util_mac.h" | 
| 19 | 20 | 
| 20 @interface BrowserWindowController (JustForTesting) | 21 @interface BrowserWindowController (JustForTesting) | 
| 21 // Already defined in BWC. | 22 // Already defined in BWC. | 
| 22 - (void)saveWindowPositionToPrefs:(PrefService*)prefs; | 23 - (void)saveWindowPositionIfNeeded; | 
| 23 - (void)layoutSubviews; | 24 - (void)layoutSubviews; | 
| 24 @end | 25 @end | 
| 25 | 26 | 
| 26 @interface BrowserWindowController (ExposedForTesting) | 27 @interface BrowserWindowController (ExposedForTesting) | 
| 27 // Implementations are below. | 28 // Implementations are below. | 
| 28 - (NSView*)infoBarContainerView; | 29 - (NSView*)infoBarContainerView; | 
| 29 - (NSView*)toolbarView; | 30 - (NSView*)toolbarView; | 
| 30 - (NSView*)bookmarkView; | 31 - (NSView*)bookmarkView; | 
| 31 - (BOOL)bookmarkBarVisible; | 32 - (BOOL)bookmarkBarVisible; | 
| 32 @end | 33 @end | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 85   ASSERT_TRUE(prefs != NULL); | 86   ASSERT_TRUE(prefs != NULL); | 
| 86 | 87 | 
| 87   // Check to make sure there is no existing pref for window placement. | 88   // Check to make sure there is no existing pref for window placement. | 
| 88   const DictionaryValue* browser_window_placement = | 89   const DictionaryValue* browser_window_placement = | 
| 89       prefs->GetDictionary(prefs::kBrowserWindowPlacement); | 90       prefs->GetDictionary(prefs::kBrowserWindowPlacement); | 
| 90   ASSERT_TRUE(browser_window_placement); | 91   ASSERT_TRUE(browser_window_placement); | 
| 91   EXPECT_TRUE(browser_window_placement->empty()); | 92   EXPECT_TRUE(browser_window_placement->empty()); | 
| 92 | 93 | 
| 93   // Ask the window to save its position, then check that a preference | 94   // Ask the window to save its position, then check that a preference | 
| 94   // exists. | 95   // exists. | 
| 95   [controller_ saveWindowPositionToPrefs:prefs]; | 96   BrowserList::SetLastActive(browser_helper_.browser()); | 
|  | 97   [controller_ saveWindowPositionIfNeeded]; | 
| 96   browser_window_placement = | 98   browser_window_placement = | 
| 97       prefs->GetDictionary(prefs::kBrowserWindowPlacement); | 99       prefs->GetDictionary(prefs::kBrowserWindowPlacement); | 
| 98   ASSERT_TRUE(browser_window_placement); | 100   ASSERT_TRUE(browser_window_placement); | 
| 99   EXPECT_FALSE(browser_window_placement->empty()); | 101   EXPECT_FALSE(browser_window_placement->empty()); | 
| 100 } | 102 } | 
| 101 | 103 | 
| 102 TEST_F(BrowserWindowControllerTest, TestFullScreenWindow) { | 104 TEST_F(BrowserWindowControllerTest, TestFullScreenWindow) { | 
| 103   // Confirm that |-createFullscreenWindow| doesn't return nil. | 105   // Confirm that |-createFullscreenWindow| doesn't return nil. | 
| 104   // See BrowserWindowFullScreenControllerTest for more fullscreen tests. | 106   // See BrowserWindowFullScreenControllerTest for more fullscreen tests. | 
| 105   EXPECT_TRUE([controller_ createFullscreenWindow]); | 107   EXPECT_TRUE([controller_ createFullscreenWindow]); | 
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 719   testFullscreenWindow_.reset( | 721   testFullscreenWindow_.reset( | 
| 720       [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 722       [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400) | 
| 721                                   styleMask:NSBorderlessWindowMask | 723                                   styleMask:NSBorderlessWindowMask | 
| 722                                     backing:NSBackingStoreBuffered | 724                                     backing:NSBackingStoreBuffered | 
| 723                                       defer:NO]); | 725                                       defer:NO]); | 
| 724   return testFullscreenWindow_.get(); | 726   return testFullscreenWindow_.get(); | 
| 725 } | 727 } | 
| 726 @end | 728 @end | 
| 727 | 729 | 
| 728 /* TODO(???): test other methods of BrowserWindowController */ | 730 /* TODO(???): test other methods of BrowserWindowController */ | 
| OLD | NEW | 
|---|