| 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" |
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 12 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
| 13 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 const char kWindowId[] = "windowid"; | 16 const char kWindowId[] = "windowid"; |
| 17 const char kWindowId2[] = "windowid2"; | 17 const char kWindowId2[] = "windowid2"; |
| 18 | 18 |
| 19 using content::BrowserThread; | 19 using content::BrowserThread; |
| 20 | 20 |
| 21 namespace apps { | 21 namespace apps { |
| 22 | 22 |
| 23 // Base class for tests. | 23 // Base class for tests. |
| 24 class ShellWindowGeometryCacheTest : public testing::Test { | 24 class ShellWindowGeometryCacheTest : public testing::Test { |
| 25 public: | 25 public: |
| 26 ShellWindowGeometryCacheTest() : | 26 ShellWindowGeometryCacheTest() : |
| 27 ui_thread_(BrowserThread::UI, &ui_message_loop_) { | 27 ui_thread_(BrowserThread::UI, &ui_message_loop_) { |
| 28 prefs_.reset(new extensions::TestExtensionPrefs( | 28 prefs_.reset(new extensions::TestExtensionPrefs( |
| 29 ui_message_loop_.message_loop_proxy().get())); | 29 ui_message_loop_.message_loop_proxy().get(), NULL)); |
| 30 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs())); | 30 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs())); |
| 31 cache_->SetSyncDelayForTests(0); | 31 cache_->SetSyncDelayForTests(0); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void AddGeometryAndLoadExtension( | 34 void AddGeometryAndLoadExtension( |
| 35 const std::string& extension_id, | 35 const std::string& extension_id, |
| 36 const std::string& window_id, | 36 const std::string& window_id, |
| 37 const gfx::Rect& bounds, | 37 const gfx::Rect& bounds, |
| 38 const gfx::Rect& screen_bounds, | 38 const gfx::Rect& screen_bounds, |
| 39 ui::WindowShowState state); | 39 ui::WindowShowState state); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // The first added window should no longer have cached geometry. | 329 // The first added window should no longer have cached geometry. |
| 330 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); | 330 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); |
| 331 // All other windows should still exist. | 331 // All other windows should still exist. |
| 332 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 332 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
| 333 std::string window_id = "window_" + base::IntToString(i); | 333 std::string window_id = "window_" + base::IntToString(i); |
| 334 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); | 334 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 } // namespace extensions | 338 } // namespace extensions |
| OLD | NEW |