OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/chrome_constants.h" | 10 #include "chrome/common/chrome_constants.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 std::wstring tmp_profile_; | 75 std::wstring tmp_profile_; |
76 }; | 76 }; |
77 | 77 |
78 TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { | 78 TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { |
79 // The window should open with the reference profile | 79 // The window should open with the reference profile |
80 ASSERT_TRUE(LaunchAppWithProfile()); | 80 ASSERT_TRUE(LaunchAppWithProfile()); |
81 | 81 |
82 ASSERT_TRUE(file_util::PathExists(tmp_pref_file_)); | 82 ASSERT_TRUE(file_util::PathExists(tmp_pref_file_)); |
83 | 83 |
84 JSONFileValueSerializer deserializer(tmp_pref_file_); | 84 JSONFileValueSerializer deserializer(tmp_pref_file_); |
85 Value* root = NULL; | 85 scoped_ptr<Value> root(deserializer.Deserialize(NULL)); |
86 ASSERT_TRUE(deserializer.Deserialize(&root, NULL)); | |
87 | 86 |
88 ASSERT_TRUE(root); | 87 ASSERT_TRUE(root.get()); |
89 ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); | 88 ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY)); |
90 | 89 |
91 DictionaryValue* root_dict = static_cast<DictionaryValue*>(root); | 90 DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); |
92 | 91 |
93 // Retrieve the screen rect for the launched window | 92 // Retrieve the screen rect for the launched window |
94 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 93 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
95 ASSERT_TRUE(browser.get()); | 94 ASSERT_TRUE(browser.get()); |
96 scoped_ptr<WindowProxy> window( | 95 scoped_ptr<WindowProxy> window( |
97 automation()->GetWindowForBrowser(browser.get())); | 96 automation()->GetWindowForBrowser(browser.get())); |
98 HWND hWnd; | 97 HWND hWnd; |
99 ASSERT_TRUE(window->GetHWND(&hWnd)); | 98 ASSERT_TRUE(window->GetHWND(&hWnd)); |
100 | 99 |
101 WINDOWPLACEMENT window_placement; | 100 WINDOWPLACEMENT window_placement; |
(...skipping 21 matching lines...) Expand all Loading... |
123 &right)); | 122 &right)); |
124 ASSERT_EQ(right, window_placement.rcNormalPosition.right); | 123 ASSERT_EQ(right, window_placement.rcNormalPosition.right); |
125 | 124 |
126 // Find if launched window is maximized | 125 // Find if launched window is maximized |
127 bool is_window_maximized = (window_placement.showCmd == SW_MAXIMIZE); | 126 bool is_window_maximized = (window_placement.showCmd == SW_MAXIMIZE); |
128 | 127 |
129 bool is_maximized = false; | 128 bool is_maximized = false; |
130 ASSERT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + L".maximized", | 129 ASSERT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + L".maximized", |
131 &is_maximized)); | 130 &is_maximized)); |
132 ASSERT_EQ(is_maximized, is_window_maximized); | 131 ASSERT_EQ(is_maximized, is_window_maximized); |
133 delete root; | |
134 } | 132 } |
135 | 133 |
OLD | NEW |