diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 15:24:31 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-14 15:24:31 +0000 |
commit | 96649a0f3cafe764eb191532f635d99c234ea005 (patch) | |
tree | 4450b4a03d498df44850ef549814a458cbc77be9 /chrome/browser/cocoa/browser_window_controller_unittest.mm | |
parent | 3313359d46d2a4f0e0dc8c4dc476462dec8c988a (diff) | |
download | chromium_src-96649a0f3cafe764eb191532f635d99c234ea005.zip chromium_src-96649a0f3cafe764eb191532f635d99c234ea005.tar.gz chromium_src-96649a0f3cafe764eb191532f635d99c234ea005.tar.bz2 |
Enable basic saving/restoring window placements on Mac.
Refactors the existing WindowSizer code to move platform-specific code
into separate files. Future CLs will add Mac support for muliple
monitors.
TEST=Browser windows should remember their position on Mac. The
corresponding behavior on Windows should not have changed.
Review URL: http://codereview.chromium.org/113286
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/browser_window_controller_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller_unittest.mm | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm new file mode 100644 index 0000000..0dff06d --- /dev/null +++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm @@ -0,0 +1,53 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/scoped_nsobject.h" +#include "base/scoped_nsautorelease_pool.h" +#include "base/scoped_ptr.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/cocoa/browser_test_helper.h" +#include "chrome/browser/cocoa/browser_window_controller.h" +#include "chrome/browser/cocoa/cocoa_test_helper.h" +#include "chrome/common/pref_names.h" +#include "chrome/common/pref_service.h" +#include "chrome/test/testing_browser_process.h" +#include "testing/gtest/include/gtest/gtest.h" + +@interface BrowserWindowController (ExposedForTesting) +- (void)saveWindowPositionToPrefs:(PrefService*)prefs; +@end + +class BrowserWindowControllerTest : public testing::Test { + virtual void SetUp() { + controller_.reset([[BrowserWindowController alloc] + initWithBrowser:browser_helper_.browser() + takeOwnership:NO]); + } + + public: + // Order is very important here. We want the controller deleted + // before the pool, and want the pool deleted before + // BrowserTestHelper. + CocoaTestHelper cocoa_helper_; + BrowserTestHelper browser_helper_; + base::ScopedNSAutoreleasePool pool_; + scoped_nsobject<BrowserWindowController> controller_; +}; + +TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) { + PrefService* prefs = browser_helper_.profile()->GetPrefs(); + ASSERT_TRUE(prefs != NULL); + + // Check to make sure there is no existing pref for window placement. + ASSERT_TRUE(prefs->GetDictionary(prefs::kBrowserWindowPlacement) == NULL); + + // Ask the window to save its position, then check that a preference + // exists. We're technically passing in a pointer to the user prefs + // and not the local state prefs, but a PrefService* is a + // PrefService*, and this is a unittest. + [controller_ saveWindowPositionToPrefs:prefs]; + EXPECT_TRUE(prefs->GetDictionary(prefs::kBrowserWindowPlacement) != NULL); +} + +/* TODO(???): test other methods of BrowserWindowController */ |