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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 // Get a semblance of coverage for both extension and app settings by | 90 // Get a semblance of coverage for both extension and app settings by |
91 // alternating in each test. | 91 // alternating in each test. |
92 // TODO(kalman): explicitly test the two interact correctly. | 92 // TODO(kalman): explicitly test the two interact correctly. |
93 | 93 |
94 TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) { | 94 TEST_F(ExtensionSettingsFrontendTest, SettingsPreservedAcrossReconstruction) { |
95 const std::string id = "ext"; | 95 const std::string id = "ext"; |
96 ExtensionServiceInterface* esi = | 96 ExtensionServiceInterface* esi = |
97 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 97 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
98 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 98 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
99 AddExtensionWithId(id, Extension::TYPE_EXTENSION); | 99 AddExtensionWithId(id, Manifest::TYPE_EXTENSION); |
100 | 100 |
101 ValueStore* storage = util::GetStorage(id, frontend_.get()); | 101 ValueStore* storage = util::GetStorage(id, frontend_.get()); |
102 | 102 |
103 // The correctness of Get/Set/Remove/Clear is tested elsewhere so no need to | 103 // The correctness of Get/Set/Remove/Clear is tested elsewhere so no need to |
104 // be too rigorous. | 104 // be too rigorous. |
105 { | 105 { |
106 StringValue bar("bar"); | 106 StringValue bar("bar"); |
107 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 107 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
108 ASSERT_FALSE(result->HasError()); | 108 ASSERT_FALSE(result->HasError()); |
109 } | 109 } |
(...skipping 12 matching lines...) Expand all Loading... |
122 ASSERT_FALSE(result->HasError()); | 122 ASSERT_FALSE(result->HasError()); |
123 EXPECT_FALSE(result->settings()->empty()); | 123 EXPECT_FALSE(result->settings()->empty()); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) { | 127 TEST_F(ExtensionSettingsFrontendTest, SettingsClearedOnUninstall) { |
128 const std::string id = "ext"; | 128 const std::string id = "ext"; |
129 ExtensionServiceInterface* esi = | 129 ExtensionServiceInterface* esi = |
130 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 130 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
131 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 131 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
132 AddExtensionWithId(id, Extension::TYPE_LEGACY_PACKAGED_APP); | 132 AddExtensionWithId(id, Manifest::TYPE_LEGACY_PACKAGED_APP); |
133 | 133 |
134 ValueStore* storage = util::GetStorage(id, frontend_.get()); | 134 ValueStore* storage = util::GetStorage(id, frontend_.get()); |
135 | 135 |
136 { | 136 { |
137 StringValue bar("bar"); | 137 StringValue bar("bar"); |
138 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 138 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
139 ASSERT_FALSE(result->HasError()); | 139 ASSERT_FALSE(result->HasError()); |
140 } | 140 } |
141 | 141 |
142 // This would be triggered by extension uninstall via a DataDeleter. | 142 // This would be triggered by extension uninstall via a DataDeleter. |
143 frontend_->DeleteStorageSoon(id); | 143 frontend_->DeleteStorageSoon(id); |
144 MessageLoop::current()->RunUntilIdle(); | 144 MessageLoop::current()->RunUntilIdle(); |
145 | 145 |
146 // The storage area may no longer be valid post-uninstall, so re-request. | 146 // The storage area may no longer be valid post-uninstall, so re-request. |
147 storage = util::GetStorage(id, frontend_.get()); | 147 storage = util::GetStorage(id, frontend_.get()); |
148 { | 148 { |
149 ValueStore::ReadResult result = storage->Get(); | 149 ValueStore::ReadResult result = storage->Get(); |
150 ASSERT_FALSE(result->HasError()); | 150 ASSERT_FALSE(result->HasError()); |
151 EXPECT_TRUE(result->settings()->empty()); | 151 EXPECT_TRUE(result->settings()->empty()); |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) { | 155 TEST_F(ExtensionSettingsFrontendTest, LeveldbDatabaseDeletedFromDiskOnClear) { |
156 const std::string id = "ext"; | 156 const std::string id = "ext"; |
157 ExtensionServiceInterface* esi = | 157 ExtensionServiceInterface* esi = |
158 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 158 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
159 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 159 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
160 AddExtensionWithId(id, Extension::TYPE_EXTENSION); | 160 AddExtensionWithId(id, Manifest::TYPE_EXTENSION); |
161 | 161 |
162 ValueStore* storage = util::GetStorage(id, frontend_.get()); | 162 ValueStore* storage = util::GetStorage(id, frontend_.get()); |
163 | 163 |
164 { | 164 { |
165 StringValue bar("bar"); | 165 StringValue bar("bar"); |
166 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); | 166 ValueStore::WriteResult result = storage->Set(DEFAULTS, "foo", bar); |
167 ASSERT_FALSE(result->HasError()); | 167 ASSERT_FALSE(result->HasError()); |
168 EXPECT_TRUE(file_util::PathExists(temp_dir_.path())); | 168 EXPECT_TRUE(file_util::PathExists(temp_dir_.path())); |
169 } | 169 } |
170 | 170 |
(...skipping 17 matching lines...) Expand all Loading... |
188 // Failing on vista dbg. http://crbug.com/111100, http://crbug.com/108724 | 188 // Failing on vista dbg. http://crbug.com/111100, http://crbug.com/108724 |
189 #define QuotaLimitsEnforcedCorrectlyForSyncAndLocal \ | 189 #define QuotaLimitsEnforcedCorrectlyForSyncAndLocal \ |
190 DISABLED_QuotaLimitsEnforcedCorrectlyForSyncAndLocal | 190 DISABLED_QuotaLimitsEnforcedCorrectlyForSyncAndLocal |
191 #endif | 191 #endif |
192 TEST_F(ExtensionSettingsFrontendTest, | 192 TEST_F(ExtensionSettingsFrontendTest, |
193 QuotaLimitsEnforcedCorrectlyForSyncAndLocal) { | 193 QuotaLimitsEnforcedCorrectlyForSyncAndLocal) { |
194 const std::string id = "ext"; | 194 const std::string id = "ext"; |
195 ExtensionServiceInterface* esi = | 195 ExtensionServiceInterface* esi = |
196 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 196 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
197 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 197 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
198 AddExtensionWithId(id, Extension::TYPE_EXTENSION); | 198 AddExtensionWithId(id, Manifest::TYPE_EXTENSION); |
199 | 199 |
200 ValueStore* sync_storage = | 200 ValueStore* sync_storage = |
201 util::GetStorage(id, settings::SYNC, frontend_.get()); | 201 util::GetStorage(id, settings::SYNC, frontend_.get()); |
202 ValueStore* local_storage = | 202 ValueStore* local_storage = |
203 util::GetStorage(id, settings::LOCAL, frontend_.get()); | 203 util::GetStorage(id, settings::LOCAL, frontend_.get()); |
204 | 204 |
205 // Sync storage should run out after ~100K. | 205 // Sync storage should run out after ~100K. |
206 scoped_ptr<Value> kilobyte = CreateKilobyte(); | 206 scoped_ptr<Value> kilobyte = CreateKilobyte(); |
207 for (int i = 0; i < 100; ++i) { | 207 for (int i = 0; i < 100; ++i) { |
208 sync_storage->Set( | 208 sync_storage->Set( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 #define UnlimitedStorageForLocalButNotSync DISABLED_UnlimitedStorageForLocalButN
otSync | 267 #define UnlimitedStorageForLocalButNotSync DISABLED_UnlimitedStorageForLocalButN
otSync |
268 #endif | 268 #endif |
269 TEST_F(ExtensionSettingsFrontendTest, | 269 TEST_F(ExtensionSettingsFrontendTest, |
270 UnlimitedStorageForLocalButNotSync) { | 270 UnlimitedStorageForLocalButNotSync) { |
271 const std::string id = "ext"; | 271 const std::string id = "ext"; |
272 std::set<std::string> permissions; | 272 std::set<std::string> permissions; |
273 permissions.insert("unlimitedStorage"); | 273 permissions.insert("unlimitedStorage"); |
274 ExtensionServiceInterface* esi = | 274 ExtensionServiceInterface* esi = |
275 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); | 275 extensions::ExtensionSystem::Get(profile_.get())->extension_service(); |
276 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> | 276 static_cast<extensions::settings_test_util::MockExtensionService*>(esi)-> |
277 AddExtensionWithIdAndPermissions(id, Extension::TYPE_EXTENSION, | 277 AddExtensionWithIdAndPermissions(id, Manifest::TYPE_EXTENSION, |
278 permissions); | 278 permissions); |
279 | 279 |
280 frontend_->RunWithStorage( | 280 frontend_->RunWithStorage( |
281 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); | 281 id, settings::SYNC, base::Bind(&UnlimitedSyncStorageTestCallback)); |
282 frontend_->RunWithStorage( | 282 frontend_->RunWithStorage( |
283 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); | 283 id, settings::LOCAL, base::Bind(&UnlimitedLocalStorageTestCallback)); |
284 | 284 |
285 MessageLoop::current()->RunUntilIdle(); | 285 MessageLoop::current()->RunUntilIdle(); |
286 } | 286 } |
287 | 287 |
288 } // namespace extensions | 288 } // namespace extensions |
OLD | NEW |