| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_window_geometry_cache.h" | 5 #include "extensions/browser/app_window/app_window_geometry_cache.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
| 15 #include "components/prefs/mock_pref_change_callback.h" | 16 #include "components/prefs/mock_pref_change_callback.h" |
| 16 #include "components/prefs/pref_service_factory.h" | 17 #include "components/prefs/pref_service_factory.h" |
| 17 #include "components/prefs/testing_pref_store.h" | 18 #include "components/prefs/testing_pref_store.h" |
| 18 #include "content/public/test/test_browser_context.h" | 19 #include "content/public/test/test_browser_context.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
| 20 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 21 #include "extensions/browser/extension_pref_value_map.h" | 22 #include "extensions/browser/extension_pref_value_map.h" |
| 22 #include "extensions/browser/extension_prefs.h" | 23 #include "extensions/browser/extension_prefs.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 114 |
| 114 ExtensionsTest::TearDown(); | 115 ExtensionsTest::TearDown(); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void AppWindowGeometryCacheTest::AddGeometryAndLoadExtension( | 118 void AppWindowGeometryCacheTest::AddGeometryAndLoadExtension( |
| 118 const std::string& extension_id, | 119 const std::string& extension_id, |
| 119 const std::string& window_id, | 120 const std::string& window_id, |
| 120 const gfx::Rect& bounds, | 121 const gfx::Rect& bounds, |
| 121 const gfx::Rect& screen_bounds, | 122 const gfx::Rect& screen_bounds, |
| 122 ui::WindowShowState state) { | 123 ui::WindowShowState state) { |
| 123 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 124 std::unique_ptr<base::DictionaryValue> dict = |
| 124 base::DictionaryValue* value = new base::DictionaryValue; | 125 base::MakeUnique<base::DictionaryValue>(); |
| 126 std::unique_ptr<base::DictionaryValue> value = |
| 127 base::MakeUnique<base::DictionaryValue>(); |
| 125 value->SetInteger("x", bounds.x()); | 128 value->SetInteger("x", bounds.x()); |
| 126 value->SetInteger("y", bounds.y()); | 129 value->SetInteger("y", bounds.y()); |
| 127 value->SetInteger("w", bounds.width()); | 130 value->SetInteger("w", bounds.width()); |
| 128 value->SetInteger("h", bounds.height()); | 131 value->SetInteger("h", bounds.height()); |
| 129 value->SetInteger("screen_bounds_x", screen_bounds.x()); | 132 value->SetInteger("screen_bounds_x", screen_bounds.x()); |
| 130 value->SetInteger("screen_bounds_y", screen_bounds.y()); | 133 value->SetInteger("screen_bounds_y", screen_bounds.y()); |
| 131 value->SetInteger("screen_bounds_w", screen_bounds.width()); | 134 value->SetInteger("screen_bounds_w", screen_bounds.width()); |
| 132 value->SetInteger("screen_bounds_h", screen_bounds.height()); | 135 value->SetInteger("screen_bounds_h", screen_bounds.height()); |
| 133 value->SetInteger("state", state); | 136 value->SetInteger("state", state); |
| 134 dict->SetWithoutPathExpansion(window_id, value); | 137 dict->SetWithoutPathExpansion(window_id, std::move(value)); |
| 135 extension_prefs_->SetGeometryCache(extension_id, std::move(dict)); | 138 extension_prefs_->SetGeometryCache(extension_id, std::move(dict)); |
| 136 LoadExtension(extension_id); | 139 LoadExtension(extension_id); |
| 137 } | 140 } |
| 138 | 141 |
| 139 void AppWindowGeometryCacheTest::WaitForSync() { | 142 void AppWindowGeometryCacheTest::WaitForSync() { |
| 140 content::RunAllPendingInMessageLoop(); | 143 content::RunAllPendingInMessageLoop(); |
| 141 } | 144 } |
| 142 | 145 |
| 143 void AppWindowGeometryCacheTest::LoadExtension( | 146 void AppWindowGeometryCacheTest::LoadExtension( |
| 144 const std::string& extension_id) { | 147 const std::string& extension_id) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // The first added window should no longer have cached geometry. | 427 // The first added window should no longer have cached geometry. |
| 425 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); | 428 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); |
| 426 // All other windows should still exist. | 429 // All other windows should still exist. |
| 427 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 430 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
| 428 std::string window_id = "window_" + base::SizeTToString(i); | 431 std::string window_id = "window_" + base::SizeTToString(i); |
| 429 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); | 432 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); |
| 430 } | 433 } |
| 431 } | 434 } |
| 432 | 435 |
| 433 } // namespace extensions | 436 } // namespace extensions |
| OLD | NEW |