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 <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/prefs/mock_pref_change_callback.h" | |
14 #include "base/prefs/pref_service_factory.h" | |
15 #include "base/prefs/testing_pref_store.h" | |
16 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
17 #include "components/pref_registry/pref_registry_syncable.h" | 14 #include "components/pref_registry/pref_registry_syncable.h" |
| 15 #include "components/prefs/mock_pref_change_callback.h" |
| 16 #include "components/prefs/pref_service_factory.h" |
| 17 #include "components/prefs/testing_pref_store.h" |
18 #include "content/public/test/test_browser_context.h" | 18 #include "content/public/test/test_browser_context.h" |
19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
20 #include "content/public/test/test_utils.h" | 20 #include "content/public/test/test_utils.h" |
21 #include "extensions/browser/extension_pref_value_map.h" | 21 #include "extensions/browser/extension_pref_value_map.h" |
22 #include "extensions/browser/extension_prefs.h" | 22 #include "extensions/browser/extension_prefs.h" |
23 #include "extensions/browser/extensions_test.h" | 23 #include "extensions/browser/extensions_test.h" |
24 #include "extensions/common/extension_builder.h" | 24 #include "extensions/common/extension_builder.h" |
25 #include "extensions/common/value_builder.h" | 25 #include "extensions/common/value_builder.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 scoped_ptr<PrefService> pref_service_; | 78 scoped_ptr<PrefService> pref_service_; |
79 scoped_ptr<ExtensionPrefs> extension_prefs_; | 79 scoped_ptr<ExtensionPrefs> extension_prefs_; |
80 scoped_ptr<AppWindowGeometryCache> cache_; | 80 scoped_ptr<AppWindowGeometryCache> cache_; |
81 }; | 81 }; |
82 | 82 |
83 void AppWindowGeometryCacheTest::SetUp() { | 83 void AppWindowGeometryCacheTest::SetUp() { |
84 ExtensionsTest::SetUp(); | 84 ExtensionsTest::SetUp(); |
85 | 85 |
86 // Set up all the dependencies of ExtensionPrefs. | 86 // Set up all the dependencies of ExtensionPrefs. |
87 extension_pref_value_map_.reset(new ExtensionPrefValueMap); | 87 extension_pref_value_map_.reset(new ExtensionPrefValueMap); |
88 base::PrefServiceFactory factory; | 88 PrefServiceFactory factory; |
89 factory.set_user_prefs(new TestingPrefStore); | 89 factory.set_user_prefs(new TestingPrefStore); |
90 factory.set_extension_prefs(new TestingPrefStore); | 90 factory.set_extension_prefs(new TestingPrefStore); |
91 user_prefs::PrefRegistrySyncable* pref_registry = | 91 user_prefs::PrefRegistrySyncable* pref_registry = |
92 new user_prefs::PrefRegistrySyncable; | 92 new user_prefs::PrefRegistrySyncable; |
93 // Prefs should be registered before the PrefService is created. | 93 // Prefs should be registered before the PrefService is created. |
94 ExtensionPrefs::RegisterProfilePrefs(pref_registry); | 94 ExtensionPrefs::RegisterProfilePrefs(pref_registry); |
95 pref_service_ = factory.Create(pref_registry); | 95 pref_service_ = factory.Create(pref_registry); |
96 | 96 |
97 extension_prefs_.reset(ExtensionPrefs::Create( | 97 extension_prefs_.reset(ExtensionPrefs::Create( |
98 browser_context(), pref_service_.get(), | 98 browser_context(), pref_service_.get(), |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 // The first added window should no longer have cached geometry. | 422 // The first added window should no longer have cached geometry. |
423 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); | 423 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); |
424 // All other windows should still exist. | 424 // All other windows should still exist. |
425 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 425 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
426 std::string window_id = "window_" + base::SizeTToString(i); | 426 std::string window_id = "window_" + base::SizeTToString(i); |
427 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); | 427 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 } // namespace extensions | 431 } // namespace extensions |
OLD | NEW |