summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/page_info_window_controller_unittest.mm
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 14:19:09 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-21 14:19:09 +0000
commit61e76d9bf46423e8dcb6f77e8e91262af55b7a03 (patch)
treea02f4e6e9812331d7026705f4f08ba740607fa90 /chrome/browser/cocoa/page_info_window_controller_unittest.mm
parent1c9b152007f05e1767b05986e5cb69fbb2629e43 (diff)
downloadchromium_src-61e76d9bf46423e8dcb6f77e8e91262af55b7a03.zip
chromium_src-61e76d9bf46423e8dcb6f77e8e91262af55b7a03.tar.gz
chromium_src-61e76d9bf46423e8dcb6f77e8e91262af55b7a03.tar.bz2
Make the page info window remember its placement origin on the Mac
* Store x/y origin in the local state PrefService * Offset new windows when creating them so they don't overlap * Add a unit test for remembering window placement * Refactor PageInfoWindowControllerTest to make use of SetUp() Patch from Robert Sesek (rsesek@chromium.org) BUG=none TEST=Open a page info window and move it. Open another and it should open in the new location. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/page_info_window_controller_unittest.mm')
-rw-r--r--chrome/browser/cocoa/page_info_window_controller_unittest.mm52
1 files changed, 34 insertions, 18 deletions
diff --git a/chrome/browser/cocoa/page_info_window_controller_unittest.mm b/chrome/browser/cocoa/page_info_window_controller_unittest.mm
index ef73e6b..66018a2 100644
--- a/chrome/browser/cocoa/page_info_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/page_info_window_controller_unittest.mm
@@ -8,46 +8,62 @@
#import "chrome/browser/cocoa/page_info_window_controller.h"
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "chrome/common/pref_names.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
class PageInfoWindowControllerTest : public PlatformTest {
+ virtual void SetUp() {
+ controller_.reset([[PageInfoWindowController alloc] init]);
+ }
+
public:
CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
BrowserTestHelper helper_;
+ scoped_nsobject<PageInfoWindowController> controller_;
};
TEST_F(PageInfoWindowControllerTest, TestImages) {
- scoped_nsobject<PageInfoWindowController>
- controller([[PageInfoWindowController alloc] init]);
- [controller window]; // Force nib load.
- EXPECT_TRUE([controller goodImg]);
- EXPECT_TRUE([controller badImg]);
+ [controller_ window]; // Force nib load.
+ EXPECT_TRUE([controller_ goodImg]);
+ EXPECT_TRUE([controller_ badImg]);
}
TEST_F(PageInfoWindowControllerTest, TestGrow) {
- scoped_nsobject<PageInfoWindowController>
- controller([[PageInfoWindowController alloc] init]);
- [controller window]; // Force nib load.
- NSRect frame = [[controller window] frame];
- [controller setShowHistoryBox:YES];
- NSRect newFrame = [[controller window] frame];
+ [controller_ window]; // Force nib load.
+ NSRect frame = [[controller_ window] frame];
+ [controller_ setShowHistoryBox:YES];
+ NSRect newFrame = [[controller_ window] frame];
EXPECT_GE(newFrame.size.height, frame.size.height);
EXPECT_LE(newFrame.origin.y, frame.origin.y);
}
TEST_F(PageInfoWindowControllerTest, TestShrink) {
- scoped_nsobject<PageInfoWindowController>
- controller([[PageInfoWindowController alloc] init]);
- [controller window]; // Force nib to load.
- [controller setShowHistoryBox:YES];
- NSRect frame = [[controller window] frame];
- [controller setShowHistoryBox:NO];
- NSRect newFrame = [[controller window] frame];
+ [controller_ window]; // Force nib to load.
+ [controller_ setShowHistoryBox:YES];
+ NSRect frame = [[controller_ window] frame];
+ [controller_ setShowHistoryBox:NO];
+ NSRect newFrame = [[controller_ window] frame];
EXPECT_LE(newFrame.size.height, frame.size.height);
EXPECT_GE(newFrame.origin.y, frame.origin.y);
}
+
+TEST_F(PageInfoWindowControllerTest, TestSaveWindowPlacement) {
+ PrefService* prefs = helper_.profile()->GetPrefs();
+ ASSERT_TRUE(prefs != NULL);
+
+ // Check to make sure there is no existing pref for window placement.
+ ASSERT_TRUE(prefs->GetDictionary(prefs::kPageInfoWindowPlacement) == 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::kPageInfoWindowPlacement) != NULL);
+}
+