Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: chrome/browser/ui/cocoa/window_size_autosaver_unittest.mm

Issue 5915004: Introduce incognito preference settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed whitespaces in mac files Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/window_size_autosaver.h" 7 #import "chrome/browser/ui/cocoa/window_size_autosaver.h"
8 8
9 #include "base/scoped_nsobject.h" 9 #include "base/scoped_nsobject.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/ui/cocoa/browser_test_helper.h" 11 #include "chrome/browser/ui/cocoa/browser_test_helper.h"
(...skipping 25 matching lines...) Expand all
37 BrowserTestHelper browser_helper_; 37 BrowserTestHelper browser_helper_;
38 NSWindow* window_; 38 NSWindow* window_;
39 const char* path_; 39 const char* path_;
40 }; 40 };
41 41
42 TEST_F(WindowSizeAutosaverTest, RestoresAndSavesPos) { 42 TEST_F(WindowSizeAutosaverTest, RestoresAndSavesPos) {
43 PrefService* pref = browser_helper_.profile()->GetPrefs(); 43 PrefService* pref = browser_helper_.profile()->GetPrefs();
44 ASSERT_TRUE(pref != NULL); 44 ASSERT_TRUE(pref != NULL);
45 45
46 // Check to make sure there is no existing pref for window placement. 46 // Check to make sure there is no existing pref for window placement.
47 ASSERT_TRUE(pref->GetDictionary(path_) == NULL); 47 const DictionaryValue* placement = pref->GetDictionary(path_);
48 ASSERT_TRUE(placement);
49 EXPECT_TRUE(placement->empty());
48 50
49 // Replace the window with one that doesn't have resize controls. 51 // Replace the window with one that doesn't have resize controls.
50 [window_ close]; 52 [window_ close];
51 window_ = 53 window_ =
52 [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 101, 150, 151) 54 [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 101, 150, 151)
53 styleMask:NSTitledWindowMask 55 styleMask:NSTitledWindowMask
54 backing:NSBackingStoreBuffered 56 backing:NSBackingStoreBuffered
55 defer:NO]; 57 defer:NO];
56 58
57 // Ask the window to save its position, then check that a preference 59 // Ask the window to save its position, then check that a preference
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ASSERT_TRUE(windowPref->GetInteger("y", &y)); 104 ASSERT_TRUE(windowPref->GetInteger("y", &y));
103 EXPECT_EQ(300, x); 105 EXPECT_EQ(300, x);
104 EXPECT_EQ(310, y); 106 EXPECT_EQ(310, y);
105 } 107 }
106 108
107 TEST_F(WindowSizeAutosaverTest, RestoresAndSavesRect) { 109 TEST_F(WindowSizeAutosaverTest, RestoresAndSavesRect) {
108 PrefService* pref = browser_helper_.profile()->GetPrefs(); 110 PrefService* pref = browser_helper_.profile()->GetPrefs();
109 ASSERT_TRUE(pref != NULL); 111 ASSERT_TRUE(pref != NULL);
110 112
111 // Check to make sure there is no existing pref for window placement. 113 // Check to make sure there is no existing pref for window placement.
112 ASSERT_TRUE(pref->GetDictionary(path_) == NULL); 114 const DictionaryValue* placement = pref->GetDictionary(path_);
115 ASSERT_TRUE(placement);
116 EXPECT_TRUE(placement->empty());
113 117
114 // Ask the window to save its position, then check that a preference 118 // Ask the window to save its position, then check that a preference
115 // exists. We're technically passing in a pointer to the user prefs 119 // exists. We're technically passing in a pointer to the user prefs
116 // and not the local state prefs, but a PrefService* is a 120 // and not the local state prefs, but a PrefService* is a
117 // PrefService*, and this is a unittest. 121 // PrefService*, and this is a unittest.
118 122
119 { 123 {
120 NSRect frame = [window_ frame]; 124 NSRect frame = [window_ frame];
121 // Empty state, shouldn't restore: 125 // Empty state, shouldn't restore:
122 scoped_nsobject<WindowSizeAutosaver> sizeSaver([[WindowSizeAutosaver alloc] 126 scoped_nsobject<WindowSizeAutosaver> sizeSaver([[WindowSizeAutosaver alloc]
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 int x1, y1, x2, y2; 196 int x1, y1, x2, y2;
193 EXPECT_FALSE(windowPref->GetInteger("x", &x1)); 197 EXPECT_FALSE(windowPref->GetInteger("x", &x1));
194 EXPECT_FALSE(windowPref->GetInteger("y", &x1)); 198 EXPECT_FALSE(windowPref->GetInteger("y", &x1));
195 ASSERT_FALSE(windowPref->GetInteger("left", &x1)); 199 ASSERT_FALSE(windowPref->GetInteger("left", &x1));
196 ASSERT_FALSE(windowPref->GetInteger("right", &x2)); 200 ASSERT_FALSE(windowPref->GetInteger("right", &x2));
197 ASSERT_FALSE(windowPref->GetInteger("top", &y1)); 201 ASSERT_FALSE(windowPref->GetInteger("top", &y1));
198 ASSERT_FALSE(windowPref->GetInteger("bottom", &y2)); 202 ASSERT_FALSE(windowPref->GetInteger("bottom", &y2));
199 } 203 }
200 204
201 } // namespace 205 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698