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 "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/mock_pref_change_callback.h" | 9 #include "base/prefs/mock_pref_change_callback.h" |
10 #include "base/prefs/pref_service_factory.h" | 10 #include "base/prefs/pref_service_factory.h" |
11 #include "base/prefs/testing_pref_store.h" | 11 #include "base/prefs/testing_pref_store.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "components/pref_registry/pref_registry_syncable.h" | 13 #include "components/pref_registry/pref_registry_syncable.h" |
14 #include "content/public/test/test_browser_context.h" | 14 #include "content/public/test/test_browser_context.h" |
15 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
16 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
17 #include "extensions/browser/extension_pref_value_map.h" | 17 #include "extensions/browser/extension_pref_value_map.h" |
18 #include "extensions/browser/extension_prefs.h" | 18 #include "extensions/browser/extension_prefs.h" |
19 #include "extensions/browser/extensions_test.h" | 19 #include "extensions/browser/extensions_test.h" |
20 #include "extensions/browser/null_app_sorting.h" | |
21 #include "extensions/common/extension_builder.h" | 20 #include "extensions/common/extension_builder.h" |
22 #include "extensions/common/value_builder.h" | 21 #include "extensions/common/value_builder.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 | 23 |
25 using content::BrowserThread; | 24 using content::BrowserThread; |
26 | 25 |
27 namespace extensions { | 26 namespace extensions { |
28 | 27 |
29 namespace { | 28 namespace { |
30 const char kWindowId[] = "windowid"; | 29 const char kWindowId[] = "windowid"; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 base::PrefServiceFactory factory; | 84 base::PrefServiceFactory factory; |
86 factory.set_user_prefs(new TestingPrefStore); | 85 factory.set_user_prefs(new TestingPrefStore); |
87 factory.set_extension_prefs(new TestingPrefStore); | 86 factory.set_extension_prefs(new TestingPrefStore); |
88 user_prefs::PrefRegistrySyncable* pref_registry = | 87 user_prefs::PrefRegistrySyncable* pref_registry = |
89 new user_prefs::PrefRegistrySyncable; | 88 new user_prefs::PrefRegistrySyncable; |
90 // Prefs should be registered before the PrefService is created. | 89 // Prefs should be registered before the PrefService is created. |
91 ExtensionPrefs::RegisterProfilePrefs(pref_registry); | 90 ExtensionPrefs::RegisterProfilePrefs(pref_registry); |
92 pref_service_ = factory.Create(pref_registry).Pass(); | 91 pref_service_ = factory.Create(pref_registry).Pass(); |
93 | 92 |
94 extension_prefs_.reset(ExtensionPrefs::Create( | 93 extension_prefs_.reset(ExtensionPrefs::Create( |
95 pref_service_.get(), | 94 browser_context(), pref_service_.get(), |
96 browser_context()->GetPath().AppendASCII("Extensions"), | 95 browser_context()->GetPath().AppendASCII("Extensions"), |
97 extension_pref_value_map_.get(), | 96 extension_pref_value_map_.get(), false /* extensions_disabled */, |
98 scoped_ptr<AppSorting>(new NullAppSorting), | |
99 false /* extensions_disabled */, | |
100 std::vector<ExtensionPrefsObserver*>())); | 97 std::vector<ExtensionPrefsObserver*>())); |
101 | 98 |
102 cache_.reset( | 99 cache_.reset( |
103 new AppWindowGeometryCache(browser_context(), extension_prefs_.get())); | 100 new AppWindowGeometryCache(browser_context(), extension_prefs_.get())); |
104 cache_->SetSyncDelayForTests(0); | 101 cache_->SetSyncDelayForTests(0); |
105 } | 102 } |
106 | 103 |
107 void AppWindowGeometryCacheTest::TearDown() { | 104 void AppWindowGeometryCacheTest::TearDown() { |
108 cache_.reset(); | 105 cache_.reset(); |
109 extension_prefs_.reset(); | 106 extension_prefs_.reset(); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // The first added window should no longer have cached geometry. | 418 // The first added window should no longer have cached geometry. |
422 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); | 419 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); |
423 // All other windows should still exist. | 420 // All other windows should still exist. |
424 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 421 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
425 std::string window_id = "window_" + base::IntToString(i); | 422 std::string window_id = "window_" + base::IntToString(i); |
426 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); | 423 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); |
427 } | 424 } |
428 } | 425 } |
429 | 426 |
430 } // namespace extensions | 427 } // namespace extensions |
OLD | NEW |