| 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 "base/json/json_writer.h" | 5 #include "base/json/json_writer.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" | 9 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" |
| 10 #include "extensions/browser/value_store/testing_value_store.h" | 10 #include "extensions/browser/value_store/testing_value_store.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 void ValidateByteValues() { | 37 void ValidateByteValues() { |
| 38 std::string validate_sizes; | 38 std::string validate_sizes; |
| 39 base::JSONWriter::Write(byte_value_1_.get(), &validate_sizes); | 39 base::JSONWriter::Write(byte_value_1_.get(), &validate_sizes); |
| 40 ASSERT_EQ(1u, validate_sizes.size()); | 40 ASSERT_EQ(1u, validate_sizes.size()); |
| 41 base::JSONWriter::Write(byte_value_16_.get(), &validate_sizes); | 41 base::JSONWriter::Write(byte_value_16_.get(), &validate_sizes); |
| 42 ASSERT_EQ(16u, validate_sizes.size()); | 42 ASSERT_EQ(16u, validate_sizes.size()); |
| 43 base::JSONWriter::Write(byte_value_256_.get(), &validate_sizes); | 43 base::JSONWriter::Write(byte_value_256_.get(), &validate_sizes); |
| 44 ASSERT_EQ(256u, validate_sizes.size()); | 44 ASSERT_EQ(256u, validate_sizes.size()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual void TearDown() OVERRIDE { | 47 virtual void TearDown() override { |
| 48 ASSERT_TRUE(storage_.get() != NULL); | 48 ASSERT_TRUE(storage_.get() != NULL); |
| 49 } | 49 } |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 // Creates |storage_|. Must only be called once. | 52 // Creates |storage_|. Must only be called once. |
| 53 void CreateStorage( | 53 void CreateStorage( |
| 54 size_t quota_bytes, size_t quota_bytes_per_item, size_t max_items) { | 54 size_t quota_bytes, size_t quota_bytes_per_item, size_t max_items) { |
| 55 ASSERT_TRUE(storage_.get() == NULL); | 55 ASSERT_TRUE(storage_.get() == NULL); |
| 56 SettingsStorageQuotaEnforcer::Limits limits = | 56 SettingsStorageQuotaEnforcer::Limits limits = |
| 57 { quota_bytes, quota_bytes_per_item, max_items }; | 57 { quota_bytes, quota_bytes_per_item, max_items }; |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 storage_->Set(DEFAULTS, "c", *byte_value_1_); | 589 storage_->Set(DEFAULTS, "c", *byte_value_1_); |
| 590 | 590 |
| 591 EXPECT_EQ(6u, storage_->GetBytesInUse()); | 591 EXPECT_EQ(6u, storage_->GetBytesInUse()); |
| 592 EXPECT_EQ(2u, storage_->GetBytesInUse("a")); | 592 EXPECT_EQ(2u, storage_->GetBytesInUse("a")); |
| 593 EXPECT_EQ(2u, storage_->GetBytesInUse("b")); | 593 EXPECT_EQ(2u, storage_->GetBytesInUse("b")); |
| 594 EXPECT_EQ(4u, storage_->GetBytesInUse(ab)); | 594 EXPECT_EQ(4u, storage_->GetBytesInUse(ab)); |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace extensions | 597 } // namespace extensions |
| OLD | NEW |