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 "apps/shell_window_geometry_cache.h" | 5 #include "apps/shell_window_geometry_cache.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/prefs/mock_pref_change_callback.h" | 7 #include "base/prefs/mock_pref_change_callback.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "chrome/browser/extensions/extension_prefs.h" | 9 #include "chrome/browser/extensions/extension_prefs.h" |
10 #include "chrome/browser/extensions/test_extension_prefs.h" | 10 #include "chrome/browser/extensions/test_extension_prefs.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 prefs_.reset(new extensions::TestExtensionPrefs( | 32 prefs_.reset(new extensions::TestExtensionPrefs( |
33 ui_message_loop_.message_loop_proxy().get())); | 33 ui_message_loop_.message_loop_proxy().get())); |
34 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs())); | 34 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs())); |
35 cache_->SetSyncDelayForTests(0); | 35 cache_->SetSyncDelayForTests(0); |
36 } | 36 } |
37 | 37 |
38 void AddGeometryAndLoadExtension( | 38 void AddGeometryAndLoadExtension( |
39 const std::string& extension_id, | 39 const std::string& extension_id, |
40 const std::string& window_id, | 40 const std::string& window_id, |
41 const gfx::Rect& bounds, | 41 const gfx::Rect& bounds, |
| 42 const gfx::Rect& screen_bounds, |
42 ui::WindowShowState state); | 43 ui::WindowShowState state); |
43 | 44 |
44 // Spins the UI threads' message loops to make sure any task | 45 // Spins the UI threads' message loops to make sure any task |
45 // posted to sync the geometry to the value store gets a chance to run. | 46 // posted to sync the geometry to the value store gets a chance to run. |
46 void WaitForSync(); | 47 void WaitForSync(); |
47 | 48 |
48 void LoadExtension(const std::string& extension_id); | 49 void LoadExtension(const std::string& extension_id); |
49 void UnloadExtension(const std::string& extension_id); | 50 void UnloadExtension(const std::string& extension_id); |
50 | 51 |
51 protected: | 52 protected: |
52 TestingProfile profile_; | 53 TestingProfile profile_; |
53 base::MessageLoopForUI ui_message_loop_; | 54 base::MessageLoopForUI ui_message_loop_; |
54 content::TestBrowserThread ui_thread_; | 55 content::TestBrowserThread ui_thread_; |
55 scoped_ptr<extensions::TestExtensionPrefs> prefs_; | 56 scoped_ptr<extensions::TestExtensionPrefs> prefs_; |
56 scoped_ptr<ShellWindowGeometryCache> cache_; | 57 scoped_ptr<ShellWindowGeometryCache> cache_; |
57 }; | 58 }; |
58 | 59 |
59 void ShellWindowGeometryCacheTest::AddGeometryAndLoadExtension( | 60 void ShellWindowGeometryCacheTest::AddGeometryAndLoadExtension( |
60 const std::string& extension_id, | 61 const std::string& extension_id, |
61 const std::string& window_id, | 62 const std::string& window_id, |
62 const gfx::Rect& bounds, | 63 const gfx::Rect& bounds, |
| 64 const gfx::Rect& screen_bounds, |
63 ui::WindowShowState state) { | 65 ui::WindowShowState state) { |
64 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 66 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
65 base::DictionaryValue* value = new base::DictionaryValue; | 67 base::DictionaryValue* value = new base::DictionaryValue; |
66 value->SetInteger("x", bounds.x()); | 68 value->SetInteger("x", bounds.x()); |
67 value->SetInteger("y", bounds.y()); | 69 value->SetInteger("y", bounds.y()); |
68 value->SetInteger("w", bounds.width()); | 70 value->SetInteger("w", bounds.width()); |
69 value->SetInteger("h", bounds.height()); | 71 value->SetInteger("h", bounds.height()); |
| 72 value->SetInteger("screen_bounds_x", screen_bounds.x()); |
| 73 value->SetInteger("screen_bounds_y", screen_bounds.y()); |
| 74 value->SetInteger("screen_bounds_w", screen_bounds.width()); |
| 75 value->SetInteger("screen_bounds_h", screen_bounds.height()); |
70 value->SetInteger("state", state); | 76 value->SetInteger("state", state); |
71 dict->SetWithoutPathExpansion(window_id, value); | 77 dict->SetWithoutPathExpansion(window_id, value); |
72 prefs_->prefs()->SetGeometryCache(extension_id, dict.Pass()); | 78 prefs_->prefs()->SetGeometryCache(extension_id, dict.Pass()); |
73 LoadExtension(extension_id); | 79 LoadExtension(extension_id); |
74 } | 80 } |
75 | 81 |
76 void ShellWindowGeometryCacheTest::WaitForSync() { | 82 void ShellWindowGeometryCacheTest::WaitForSync() { |
77 content::RunAllPendingInMessageLoop(); | 83 content::RunAllPendingInMessageLoop(); |
78 } | 84 } |
79 | 85 |
80 void ShellWindowGeometryCacheTest::LoadExtension( | 86 void ShellWindowGeometryCacheTest::LoadExtension( |
81 const std::string& extension_id) { | 87 const std::string& extension_id) { |
82 cache_->LoadGeometryFromStorage(extension_id); | 88 cache_->LoadGeometryFromStorage(extension_id); |
83 WaitForSync(); | 89 WaitForSync(); |
84 } | 90 } |
85 | 91 |
86 void ShellWindowGeometryCacheTest::UnloadExtension( | 92 void ShellWindowGeometryCacheTest::UnloadExtension( |
87 const std::string& extension_id) { | 93 const std::string& extension_id) { |
88 cache_->OnExtensionUnloaded(extension_id); | 94 cache_->OnExtensionUnloaded(extension_id); |
89 WaitForSync(); | 95 WaitForSync(); |
90 } | 96 } |
91 | 97 |
92 // Test getting geometry from an empty store. | 98 // Test getting geometry from an empty store. |
93 TEST_F(ShellWindowGeometryCacheTest, GetGeometryEmptyStore) { | 99 TEST_F(ShellWindowGeometryCacheTest, GetGeometryEmptyStore) { |
94 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); | 100 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); |
95 ASSERT_FALSE(cache_->GetGeometry(extension_id, kWindowId, NULL, NULL)); | 101 ASSERT_FALSE(cache_->GetGeometry(extension_id, kWindowId, NULL, NULL, NULL)); |
96 } | 102 } |
97 | 103 |
98 // Test getting geometry for an unknown extension. | 104 // Test getting geometry for an unknown extension. |
99 TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownExtension) { | 105 TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownExtension) { |
100 const std::string extension_id1 = prefs_->AddExtensionAndReturnId("ext1"); | 106 const std::string extension_id1 = prefs_->AddExtensionAndReturnId("ext1"); |
101 const std::string extension_id2 = prefs_->AddExtensionAndReturnId("ext2"); | 107 const std::string extension_id2 = prefs_->AddExtensionAndReturnId("ext2"); |
102 AddGeometryAndLoadExtension(extension_id1, kWindowId, | 108 AddGeometryAndLoadExtension(extension_id1, kWindowId, |
103 gfx::Rect(4, 5, 31, 43), | 109 gfx::Rect(4, 5, 31, 43), |
| 110 gfx::Rect(0, 0, 1600, 900), |
104 ui::SHOW_STATE_DEFAULT); | 111 ui::SHOW_STATE_DEFAULT); |
105 ASSERT_FALSE(cache_->GetGeometry(extension_id2, kWindowId, NULL, NULL)); | 112 ASSERT_FALSE(cache_->GetGeometry(extension_id2, kWindowId, NULL, NULL, NULL)); |
106 } | 113 } |
107 | 114 |
108 // Test getting geometry for an unknown window in a known extension. | 115 // Test getting geometry for an unknown window in a known extension. |
109 TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownWindow) { | 116 TEST_F(ShellWindowGeometryCacheTest, GetGeometryUnkownWindow) { |
110 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); | 117 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); |
111 AddGeometryAndLoadExtension(extension_id, kWindowId, | 118 AddGeometryAndLoadExtension(extension_id, kWindowId, |
112 gfx::Rect(4, 5, 31, 43), | 119 gfx::Rect(4, 5, 31, 43), |
| 120 gfx::Rect(0, 0, 1600, 900), |
113 ui::SHOW_STATE_DEFAULT); | 121 ui::SHOW_STATE_DEFAULT); |
114 ASSERT_FALSE(cache_->GetGeometry(extension_id, kWindowId2, NULL, NULL)); | 122 ASSERT_FALSE(cache_->GetGeometry(extension_id, kWindowId2, NULL, NULL, NULL)); |
115 } | 123 } |
116 | 124 |
117 // Test that loading geometry and state from the store works correctly. | 125 // Test that loading geometry, screen_bounds and state from the store works |
| 126 // correctly. |
118 TEST_F(ShellWindowGeometryCacheTest, GetGeometryAndStateFromStore) { | 127 TEST_F(ShellWindowGeometryCacheTest, GetGeometryAndStateFromStore) { |
119 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); | 128 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); |
120 gfx::Rect bounds(4, 5, 31, 43); | 129 gfx::Rect bounds(4, 5, 31, 43); |
| 130 gfx::Rect screen_bounds(0, 0, 1600, 900); |
121 ui::WindowShowState state = ui::SHOW_STATE_NORMAL; | 131 ui::WindowShowState state = ui::SHOW_STATE_NORMAL; |
122 AddGeometryAndLoadExtension(extension_id, kWindowId, bounds, state); | 132 AddGeometryAndLoadExtension(extension_id, kWindowId, bounds, |
| 133 screen_bounds, state); |
123 gfx::Rect new_bounds; | 134 gfx::Rect new_bounds; |
| 135 gfx::Rect new_screen_bounds; |
124 ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT; | 136 ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT; |
125 ASSERT_TRUE(cache_->GetGeometry( | 137 ASSERT_TRUE(cache_->GetGeometry( |
126 extension_id, kWindowId, &new_bounds, &new_state)); | 138 extension_id, kWindowId, &new_bounds, &new_screen_bounds, &new_state)); |
127 ASSERT_EQ(bounds, new_bounds); | 139 ASSERT_EQ(bounds, new_bounds); |
| 140 ASSERT_EQ(screen_bounds, new_screen_bounds); |
128 ASSERT_EQ(state, new_state); | 141 ASSERT_EQ(state, new_state); |
129 } | 142 } |
130 | 143 |
131 // Test saving geometry and state to the cache and state store, and reading | 144 // Test saving geometry, screen_bounds and state to the cache and state store, |
132 // it back. | 145 // and reading it back. |
133 TEST_F(ShellWindowGeometryCacheTest, SaveGeometryAndStateToStore) { | 146 TEST_F(ShellWindowGeometryCacheTest, SaveGeometryAndStateToStore) { |
134 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); | 147 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); |
135 const std::string window_id(kWindowId); | 148 const std::string window_id(kWindowId); |
136 | 149 |
137 // inform cache of extension | 150 // inform cache of extension |
138 LoadExtension(extension_id); | 151 LoadExtension(extension_id); |
139 | 152 |
140 // update geometry stored in cache | 153 // update geometry stored in cache |
141 gfx::Rect bounds(4, 5, 31, 43); | 154 gfx::Rect bounds(4, 5, 31, 43); |
| 155 gfx::Rect screen_bounds(0, 0, 1600, 900); |
142 ui::WindowShowState state = ui::SHOW_STATE_NORMAL; | 156 ui::WindowShowState state = ui::SHOW_STATE_NORMAL; |
143 cache_->SaveGeometry(extension_id, window_id, bounds, state); | 157 cache_->SaveGeometry(extension_id, window_id, bounds, screen_bounds, state); |
144 | 158 |
145 // make sure that immediately reading back geometry works | 159 // make sure that immediately reading back geometry works |
146 gfx::Rect new_bounds; | 160 gfx::Rect new_bounds; |
| 161 gfx::Rect new_screen_bounds; |
147 ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT; | 162 ui::WindowShowState new_state = ui::SHOW_STATE_DEFAULT; |
148 ASSERT_TRUE(cache_->GetGeometry( | 163 ASSERT_TRUE(cache_->GetGeometry( |
149 extension_id, window_id, &new_bounds, &new_state)); | 164 extension_id, window_id, &new_bounds, &new_screen_bounds, &new_state)); |
150 ASSERT_EQ(bounds, new_bounds); | 165 ASSERT_EQ(bounds, new_bounds); |
| 166 ASSERT_EQ(screen_bounds, new_screen_bounds); |
151 ASSERT_EQ(state, new_state); | 167 ASSERT_EQ(state, new_state); |
152 | 168 |
153 // unload extension to force cache to save data to the state store | 169 // unload extension to force cache to save data to the state store |
154 UnloadExtension(extension_id); | 170 UnloadExtension(extension_id); |
155 | 171 |
156 // check if geometry got stored correctly in the state store | 172 // check if geometry got stored correctly in the state store |
157 const base::DictionaryValue* dict = | 173 const base::DictionaryValue* dict = |
158 prefs_->prefs()->GetGeometryCache(extension_id); | 174 prefs_->prefs()->GetGeometryCache(extension_id); |
159 ASSERT_TRUE(dict); | 175 ASSERT_TRUE(dict); |
160 | 176 |
161 ASSERT_TRUE(dict->HasKey(window_id)); | 177 ASSERT_TRUE(dict->HasKey(window_id)); |
162 int v; | 178 int v; |
163 ASSERT_TRUE(dict->GetInteger(window_id + ".x", &v)); | 179 ASSERT_TRUE(dict->GetInteger(window_id + ".x", &v)); |
164 ASSERT_EQ(bounds.x(), v); | 180 ASSERT_EQ(bounds.x(), v); |
165 ASSERT_TRUE(dict->GetInteger(window_id + ".y", &v)); | 181 ASSERT_TRUE(dict->GetInteger(window_id + ".y", &v)); |
166 ASSERT_EQ(bounds.y(), v); | 182 ASSERT_EQ(bounds.y(), v); |
167 ASSERT_TRUE(dict->GetInteger(window_id + ".w", &v)); | 183 ASSERT_TRUE(dict->GetInteger(window_id + ".w", &v)); |
168 ASSERT_EQ(bounds.width(), v); | 184 ASSERT_EQ(bounds.width(), v); |
169 ASSERT_TRUE(dict->GetInteger(window_id + ".h", &v)); | 185 ASSERT_TRUE(dict->GetInteger(window_id + ".h", &v)); |
170 ASSERT_EQ(bounds.height(), v); | 186 ASSERT_EQ(bounds.height(), v); |
| 187 ASSERT_TRUE(dict->GetInteger(window_id + ".screen_bounds_x", &v)); |
| 188 ASSERT_EQ(screen_bounds.x(), v); |
| 189 ASSERT_TRUE(dict->GetInteger(window_id + ".screen_bounds_y", &v)); |
| 190 ASSERT_EQ(screen_bounds.y(), v); |
| 191 ASSERT_TRUE(dict->GetInteger(window_id + ".screen_bounds_w", &v)); |
| 192 ASSERT_EQ(screen_bounds.width(), v); |
| 193 ASSERT_TRUE(dict->GetInteger(window_id + ".screen_bounds_h", &v)); |
| 194 ASSERT_EQ(screen_bounds.height(), v); |
171 ASSERT_TRUE(dict->GetInteger(window_id + ".state", &v)); | 195 ASSERT_TRUE(dict->GetInteger(window_id + ".state", &v)); |
172 ASSERT_EQ(state, v); | 196 ASSERT_EQ(state, v); |
173 | 197 |
174 // reload extension | 198 // reload extension |
175 LoadExtension(extension_id); | 199 LoadExtension(extension_id); |
176 // and make sure the geometry got reloaded properly too | 200 // and make sure the geometry got reloaded properly too |
177 ASSERT_TRUE(cache_->GetGeometry( | 201 ASSERT_TRUE(cache_->GetGeometry( |
178 extension_id, window_id, &new_bounds, &new_state)); | 202 extension_id, window_id, &new_bounds, &new_screen_bounds, &new_state)); |
179 ASSERT_EQ(bounds, new_bounds); | 203 ASSERT_EQ(bounds, new_bounds); |
| 204 ASSERT_EQ(screen_bounds, new_screen_bounds); |
180 ASSERT_EQ(state, new_state); | 205 ASSERT_EQ(state, new_state); |
181 } | 206 } |
182 | 207 |
183 // Tests that we won't do writes to the state store for SaveGeometry calls | 208 // Tests that we won't do writes to the state store for SaveGeometry calls |
184 // which don't change the state we already have. | 209 // which don't change the state we already have. |
185 TEST_F(ShellWindowGeometryCacheTest, NoDuplicateWrites) { | 210 TEST_F(ShellWindowGeometryCacheTest, NoDuplicateWrites) { |
186 using testing::_; | 211 using testing::_; |
187 using testing::Mock; | 212 using testing::Mock; |
188 | 213 |
189 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); | 214 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); |
190 gfx::Rect bounds1(100, 200, 300, 400); | 215 gfx::Rect bounds1(100, 200, 300, 400); |
191 gfx::Rect bounds2(200, 400, 600, 800); | 216 gfx::Rect bounds2(200, 400, 600, 800); |
192 gfx::Rect bounds2_duplicate(200, 400, 600, 800); | 217 gfx::Rect bounds2_duplicate(200, 400, 600, 800); |
193 | 218 |
| 219 gfx::Rect screen_bounds1(0, 0, 1600, 900); |
| 220 gfx::Rect screen_bounds2(0, 0, 1366, 768); |
| 221 gfx::Rect screen_bounds2_duplicate(0, 0, 1366, 768); |
| 222 |
194 MockPrefChangeCallback observer(prefs_->pref_service()); | 223 MockPrefChangeCallback observer(prefs_->pref_service()); |
195 PrefChangeRegistrar registrar; | 224 PrefChangeRegistrar registrar; |
196 registrar.Init(prefs_->pref_service()); | 225 registrar.Init(prefs_->pref_service()); |
197 registrar.Add("extensions.settings", observer.GetCallback()); | 226 registrar.Add("extensions.settings", observer.GetCallback()); |
198 | 227 |
199 // Write the first bounds - it should do > 0 writes. | 228 // Write the first bounds - it should do > 0 writes. |
200 EXPECT_CALL(observer, OnPreferenceChanged(_)); | 229 EXPECT_CALL(observer, OnPreferenceChanged(_)); |
201 cache_->SaveGeometry(extension_id, kWindowId, bounds1, | 230 cache_->SaveGeometry(extension_id, kWindowId, bounds1, |
202 ui::SHOW_STATE_DEFAULT); | 231 screen_bounds1, ui::SHOW_STATE_DEFAULT); |
203 WaitForSync(); | 232 WaitForSync(); |
204 Mock::VerifyAndClearExpectations(&observer); | 233 Mock::VerifyAndClearExpectations(&observer); |
205 | 234 |
206 // Write a different bounds - it should also do > 0 writes. | 235 // Write a different bounds - it should also do > 0 writes. |
207 EXPECT_CALL(observer, OnPreferenceChanged(_)); | 236 EXPECT_CALL(observer, OnPreferenceChanged(_)); |
208 cache_->SaveGeometry(extension_id, kWindowId, bounds2, | 237 cache_->SaveGeometry(extension_id, kWindowId, bounds2, |
209 ui::SHOW_STATE_DEFAULT); | 238 screen_bounds1, ui::SHOW_STATE_DEFAULT); |
| 239 WaitForSync(); |
| 240 Mock::VerifyAndClearExpectations(&observer); |
| 241 |
| 242 // Write a different screen bounds - it should also do > 0 writes. |
| 243 EXPECT_CALL(observer, OnPreferenceChanged(_)); |
| 244 cache_->SaveGeometry(extension_id, kWindowId, bounds2, |
| 245 screen_bounds2, ui::SHOW_STATE_DEFAULT); |
210 WaitForSync(); | 246 WaitForSync(); |
211 Mock::VerifyAndClearExpectations(&observer); | 247 Mock::VerifyAndClearExpectations(&observer); |
212 | 248 |
213 // Write a different state - it should also do > 0 writes. | 249 // Write a different state - it should also do > 0 writes. |
214 EXPECT_CALL(observer, OnPreferenceChanged(_)); | 250 EXPECT_CALL(observer, OnPreferenceChanged(_)); |
215 cache_->SaveGeometry(extension_id, kWindowId, bounds2, | 251 cache_->SaveGeometry(extension_id, kWindowId, bounds2, |
216 ui::SHOW_STATE_NORMAL); | 252 screen_bounds2, ui::SHOW_STATE_NORMAL); |
217 WaitForSync(); | 253 WaitForSync(); |
218 Mock::VerifyAndClearExpectations(&observer); | 254 Mock::VerifyAndClearExpectations(&observer); |
219 | 255 |
220 // Write a bounds and state that's a duplicate of what we already have. | 256 // Write a bounds, screen bounds and state that's a duplicate of what we |
221 // This should not do any writes. | 257 // already have. This should not do any writes. |
222 EXPECT_CALL(observer, OnPreferenceChanged(_)).Times(0); | 258 EXPECT_CALL(observer, OnPreferenceChanged(_)).Times(0); |
223 cache_->SaveGeometry(extension_id, kWindowId, bounds2_duplicate, | 259 cache_->SaveGeometry(extension_id, kWindowId, bounds2_duplicate, |
224 ui::SHOW_STATE_NORMAL); | 260 screen_bounds2_duplicate, ui::SHOW_STATE_NORMAL); |
225 WaitForSync(); | 261 WaitForSync(); |
226 Mock::VerifyAndClearExpectations(&observer); | 262 Mock::VerifyAndClearExpectations(&observer); |
227 } | 263 } |
228 | 264 |
229 // Tests that no more than kMaxCachedWindows windows will be cached. | 265 // Tests that no more than kMaxCachedWindows windows will be cached. |
230 TEST_F(ShellWindowGeometryCacheTest, MaxWindows) { | 266 TEST_F(ShellWindowGeometryCacheTest, MaxWindows) { |
231 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); | 267 const std::string extension_id = prefs_->AddExtensionAndReturnId("ext1"); |
232 // inform cache of extension | 268 // inform cache of extension |
233 LoadExtension(extension_id); | 269 LoadExtension(extension_id); |
234 | 270 |
235 gfx::Rect bounds(4, 5, 31, 43); | 271 gfx::Rect bounds(4, 5, 31, 43); |
| 272 gfx::Rect screen_bounds(0, 0, 1600, 900); |
236 for (size_t i = 0; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 273 for (size_t i = 0; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
237 std::string window_id = "window_" + base::IntToString(i); | 274 std::string window_id = "window_" + base::IntToString(i); |
238 cache_->SaveGeometry(extension_id, window_id, bounds, | 275 cache_->SaveGeometry(extension_id, window_id, bounds, |
239 ui::SHOW_STATE_DEFAULT); | 276 screen_bounds, ui::SHOW_STATE_DEFAULT); |
240 } | 277 } |
241 | 278 |
242 // The first added window should no longer have cached geometry. | 279 // The first added window should no longer have cached geometry. |
243 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL)); | 280 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); |
244 // All other windows should still exist. | 281 // All other windows should still exist. |
245 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 282 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
246 std::string window_id = "window_" + base::IntToString(i); | 283 std::string window_id = "window_" + base::IntToString(i); |
247 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL)); | 284 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); |
248 } | 285 } |
249 } | 286 } |
250 | 287 |
251 } // namespace extensions | 288 } // namespace extensions |
OLD | NEW |