OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacementIsLoaded, Test) { | 121 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacementIsLoaded, Test) { |
122 #if defined(OS_WIN) && defined(USE_ASH) | 122 #if defined(OS_WIN) && defined(USE_ASH) |
123 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 123 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
124 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 124 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
125 return; | 125 return; |
126 #endif | 126 #endif |
127 | 127 |
128 // The window should open with the new reference profile, with window | 128 // The window should open with the new reference profile, with window |
129 // placement values stored in the user data directory. | 129 // placement values stored in the user data directory. |
130 JSONFileValueSerializer deserializer(tmp_pref_file_); | 130 JSONFileValueSerializer deserializer(tmp_pref_file_); |
131 scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL)); | 131 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); |
132 | 132 |
133 ASSERT_TRUE(root.get()); | 133 ASSERT_TRUE(root.get()); |
134 ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); | 134 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); |
135 | 135 |
136 DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); | 136 base::DictionaryValue* root_dict = |
| 137 static_cast<base::DictionaryValue*>(root.get()); |
137 | 138 |
138 // Retrieve the screen rect for the launched window | 139 // Retrieve the screen rect for the launched window |
139 gfx::Rect bounds = browser()->window()->GetRestoredBounds(); | 140 gfx::Rect bounds = browser()->window()->GetRestoredBounds(); |
140 | 141 |
141 // Retrieve the expected rect values from "Preferences" | 142 // Retrieve the expected rect values from "Preferences" |
142 int bottom = 0; | 143 int bottom = 0; |
143 std::string kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); | 144 std::string kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); |
144 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".bottom", | 145 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".bottom", |
145 &bottom)); | 146 &bottom)); |
146 EXPECT_EQ(bottom, bounds.y() + bounds.height()); | 147 EXPECT_EQ(bottom, bounds.y() + bounds.height()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 #if defined(OS_WIN) && defined(USE_ASH) | 182 #if defined(OS_WIN) && defined(USE_ASH) |
182 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 183 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
183 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 184 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
184 return; | 185 return; |
185 #endif | 186 #endif |
186 | 187 |
187 // The window should open with the old reference profile, with window | 188 // The window should open with the old reference profile, with window |
188 // placement values stored in Local State. | 189 // placement values stored in Local State. |
189 | 190 |
190 JSONFileValueSerializer deserializer(tmp_pref_file_); | 191 JSONFileValueSerializer deserializer(tmp_pref_file_); |
191 scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL)); | 192 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); |
192 | 193 |
193 ASSERT_TRUE(root.get()); | 194 ASSERT_TRUE(root.get()); |
194 ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); | 195 ASSERT_TRUE(root->IsType(base::Value::TYPE_DICTIONARY)); |
195 | 196 |
196 // Retrieve the screen rect for the launched window | 197 // Retrieve the screen rect for the launched window |
197 gfx::Rect bounds = browser()->window()->GetRestoredBounds(); | 198 gfx::Rect bounds = browser()->window()->GetRestoredBounds(); |
198 | 199 |
199 // Values from old reference profile in Local State should have been | 200 // Values from old reference profile in Local State should have been |
200 // correctly migrated to the user's Preferences -- if so, the window | 201 // correctly migrated to the user's Preferences -- if so, the window |
201 // should be set to values taken from the user's Local State. | 202 // should be set to values taken from the user's Local State. |
202 DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); | 203 base::DictionaryValue* root_dict = |
| 204 static_cast<base::DictionaryValue*>(root.get()); |
203 | 205 |
204 // Retrieve the expected rect values from User Preferences, where they | 206 // Retrieve the expected rect values from User Preferences, where they |
205 // should have been migrated from Local State. | 207 // should have been migrated from Local State. |
206 int bottom = 0; | 208 int bottom = 0; |
207 std::string kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); | 209 std::string kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); |
208 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".bottom", | 210 EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".bottom", |
209 &bottom)); | 211 &bottom)); |
210 EXPECT_EQ(bottom, bounds.y() + bounds.height()); | 212 EXPECT_EQ(bottom, bounds.y() + bounds.height()); |
211 | 213 |
212 int top = 0; | 214 int top = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
225 EXPECT_EQ(right, bounds.x() + bounds.width()); | 227 EXPECT_EQ(right, bounds.x() + bounds.width()); |
226 | 228 |
227 // Find if launched window is maximized. | 229 // Find if launched window is maximized. |
228 bool is_window_maximized = browser()->window()->IsMaximized(); | 230 bool is_window_maximized = browser()->window()->IsMaximized(); |
229 bool is_maximized = false; | 231 bool is_maximized = false; |
230 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", | 232 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", |
231 &is_maximized)); | 233 &is_maximized)); |
232 EXPECT_EQ(is_maximized, is_window_maximized); | 234 EXPECT_EQ(is_maximized, is_window_maximized); |
233 } | 235 } |
234 #endif | 236 #endif |
OLD | NEW |