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 "extensions/browser/api/declarative/rules_registry.h" | 5 #include "extensions/browser/api/declarative/rules_registry.h" |
6 | 6 |
7 // Here we test the TestRulesRegistry which is the simplest possible | 7 // Here we test the TestRulesRegistry which is the simplest possible |
8 // implementation of RulesRegistryWithCache as a proxy for | 8 // implementation of RulesRegistryWithCache as a proxy for |
9 // RulesRegistryWithCache. | 9 // RulesRegistryWithCache. |
10 | 10 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 extension_prefs->UpdateExtensionPref( | 249 extension_prefs->UpdateExtensionPref( |
250 extension1_->id(), rules_stored_key, new base::FundamentalValue(true)); | 250 extension1_->id(), rules_stored_key, new base::FundamentalValue(true)); |
251 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); | 251 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); |
252 | 252 |
253 // 2. Test writing behavior. | 253 // 2. Test writing behavior. |
254 int write_count = store->write_count(); | 254 int write_count = store->write_count(); |
255 | 255 |
256 scoped_ptr<base::ListValue> value(new base::ListValue); | 256 scoped_ptr<base::ListValue> value(new base::ListValue); |
257 value->AppendBoolean(true); | 257 value->AppendBoolean(true); |
258 cache_delegate->WriteToStorage(extension1_->id(), value.Pass()); | 258 cache_delegate->WriteToStorage(extension1_->id(), std::move(value)); |
259 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); | 259 EXPECT_TRUE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); |
260 base::RunLoop().RunUntilIdle(); | 260 base::RunLoop().RunUntilIdle(); |
261 EXPECT_EQ(write_count + 1, store->write_count()); | 261 EXPECT_EQ(write_count + 1, store->write_count()); |
262 write_count = store->write_count(); | 262 write_count = store->write_count(); |
263 | 263 |
264 value.reset(new base::ListValue); | 264 value.reset(new base::ListValue); |
265 cache_delegate->WriteToStorage(extension1_->id(), value.Pass()); | 265 cache_delegate->WriteToStorage(extension1_->id(), std::move(value)); |
266 EXPECT_FALSE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); | 266 EXPECT_FALSE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); |
267 base::RunLoop().RunUntilIdle(); | 267 base::RunLoop().RunUntilIdle(); |
268 // No rules currently, but previously there were, so we expect a write. | 268 // No rules currently, but previously there were, so we expect a write. |
269 EXPECT_EQ(write_count + 1, store->write_count()); | 269 EXPECT_EQ(write_count + 1, store->write_count()); |
270 write_count = store->write_count(); | 270 write_count = store->write_count(); |
271 | 271 |
272 value.reset(new base::ListValue); | 272 value.reset(new base::ListValue); |
273 cache_delegate->WriteToStorage(extension1_->id(), value.Pass()); | 273 cache_delegate->WriteToStorage(extension1_->id(), std::move(value)); |
274 EXPECT_FALSE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); | 274 EXPECT_FALSE(cache_delegate->GetDeclarativeRulesStored(extension1_->id())); |
275 base::RunLoop().RunUntilIdle(); | 275 base::RunLoop().RunUntilIdle(); |
276 EXPECT_EQ(write_count, store->write_count()); | 276 EXPECT_EQ(write_count, store->write_count()); |
277 | 277 |
278 // 3. Test reading behavior. | 278 // 3. Test reading behavior. |
279 int read_count = store->read_count(); | 279 int read_count = store->read_count(); |
280 | 280 |
281 cache_delegate->SetDeclarativeRulesStored(extension1_->id(), false); | 281 cache_delegate->SetDeclarativeRulesStored(extension1_->id(), false); |
282 cache_delegate->ReadFromStorage(extension1_->id()); | 282 cache_delegate->ReadFromStorage(extension1_->id()); |
283 base::RunLoop().RunUntilIdle(); | 283 base::RunLoop().RunUntilIdle(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 382 |
383 int write_count = store->write_count(); | 383 int write_count = store->write_count(); |
384 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); | 384 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); |
385 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id)); | 385 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id)); |
386 env_.GetExtensionSystem()->SetReady(); | 386 env_.GetExtensionSystem()->SetReady(); |
387 base::RunLoop().RunUntilIdle(); | 387 base::RunLoop().RunUntilIdle(); |
388 EXPECT_EQ(write_count + 2, store->write_count()); | 388 EXPECT_EQ(write_count + 2, store->write_count()); |
389 } | 389 } |
390 | 390 |
391 } // namespace extensions | 391 } // namespace extensions |
OLD | NEW |