Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: chrome/browser/extensions/settings/settings_quota_unittest.cc

Issue 9284013: Extension Storage API: expose storage quota information to extensions, via: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 ASSERT_EQ(256u, validate_sizes.size()); 42 ASSERT_EQ(256u, validate_sizes.size());
43 } 43 }
44 44
45 virtual void TearDown() OVERRIDE { 45 virtual void TearDown() OVERRIDE {
46 ASSERT_TRUE(storage_.get() != NULL); 46 ASSERT_TRUE(storage_.get() != NULL);
47 } 47 }
48 48
49 protected: 49 protected:
50 // Creates |storage_|. Must only be called once. 50 // Creates |storage_|. Must only be called once.
51 void CreateStorage( 51 void CreateStorage(
52 size_t quota_bytes, size_t quota_bytes_per_setting, size_t max_keys) { 52 size_t quota_bytes, size_t quota_bytes_per_item, size_t max_items) {
53 ASSERT_TRUE(storage_.get() == NULL); 53 ASSERT_TRUE(storage_.get() == NULL);
54 SettingsStorageQuotaEnforcer::Limits limits = 54 SettingsStorageQuotaEnforcer::Limits limits =
55 { quota_bytes, quota_bytes_per_setting, max_keys }; 55 { quota_bytes, quota_bytes_per_item, max_items };
56 storage_.reset(new SettingsStorageQuotaEnforcer(limits, delegate_)); 56 storage_.reset(new SettingsStorageQuotaEnforcer(limits, delegate_));
57 } 57 }
58 58
59 // Returns whether the settings in |storage_| and |delegate_| are the same as 59 // Returns whether the settings in |storage_| and |delegate_| are the same as
60 // |settings|. 60 // |settings|.
61 bool SettingsEqual(const DictionaryValue& settings) { 61 bool SettingsEqual(const DictionaryValue& settings) {
62 return settings.Equals(&storage_->Get().settings()) && 62 return settings.Equals(&storage_->Get().settings()) &&
63 settings.Equals(&delegate_->Get().settings()); 63 settings.Equals(&delegate_->Get().settings());
64 } 64 }
65 65
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 EXPECT_FALSE(storage_->Set(IGNORE_QUOTA, "c", *byte_value_16_).HasError()); 551 EXPECT_FALSE(storage_->Set(IGNORE_QUOTA, "c", *byte_value_16_).HasError());
552 settings.Set("c", byte_value_16_->DeepCopy()); 552 settings.Set("c", byte_value_16_->DeepCopy());
553 553
554 // ... except the last. Make sure it can still fail. 554 // ... except the last. Make sure it can still fail.
555 EXPECT_TRUE(storage_->Set(DEFAULTS, "c", *byte_value_256_).HasError()); 555 EXPECT_TRUE(storage_->Set(DEFAULTS, "c", *byte_value_256_).HasError());
556 556
557 EXPECT_TRUE(SettingsEqual(settings)); 557 EXPECT_TRUE(SettingsEqual(settings));
558 } 558 }
559 559
560 } // namespace extensions 560 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698