| 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 12 matching lines...) Expand all Loading... |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 | 24 |
| 25 namespace apps { | 25 namespace apps { |
| 26 | 26 |
| 27 // Base class for tests. | 27 // Base class for tests. |
| 28 class ShellWindowGeometryCacheTest : public testing::Test { | 28 class ShellWindowGeometryCacheTest : public testing::Test { |
| 29 public: | 29 public: |
| 30 ShellWindowGeometryCacheTest() : | 30 ShellWindowGeometryCacheTest() : |
| 31 ui_thread_(BrowserThread::UI, &ui_message_loop_) { | 31 ui_thread_(BrowserThread::UI, &ui_message_loop_) { |
| 32 prefs_.reset(new extensions::TestExtensionPrefs( | 32 prefs_.reset(new extensions::TestExtensionPrefs( |
| 33 ui_message_loop_.message_loop_proxy())); | 33 ui_message_loop_.message_loop_proxy().get())); |
| 34 cache_.reset( | 34 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs())); |
| 35 new ShellWindowGeometryCache(&profile_, prefs_->prefs())); | |
| 36 cache_->SetSyncDelayForTests(0); | 35 cache_->SetSyncDelayForTests(0); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void AddGeometryAndLoadExtension( | 38 void AddGeometryAndLoadExtension( |
| 40 const std::string& extension_id, | 39 const std::string& extension_id, |
| 41 const std::string& window_id, | 40 const std::string& window_id, |
| 42 const gfx::Rect& bounds, | 41 const gfx::Rect& bounds, |
| 43 ui::WindowShowState state); | 42 ui::WindowShowState state); |
| 44 | 43 |
| 45 // Spins the UI threads' message loops to make sure any task | 44 // Spins the UI threads' message loops to make sure any task |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // The first added window should no longer have cached geometry. | 246 // The first added window should no longer have cached geometry. |
| 248 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL)); | 247 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL)); |
| 249 // All other windows should still exist. | 248 // All other windows should still exist. |
| 250 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 249 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
| 251 std::string window_id = "window_" + base::IntToString(i); | 250 std::string window_id = "window_" + base::IntToString(i); |
| 252 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL)); | 251 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL)); |
| 253 } | 252 } |
| 254 } | 253 } |
| 255 | 254 |
| 256 } // namespace extensions | 255 } // namespace extensions |
| OLD | NEW |