| 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/value_store/value_store_frontend.h" | 5 #include "extensions/browser/value_store/value_store_frontend.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 { | 89 { |
| 90 ASSERT_TRUE(Get("key2", &value)); | 90 ASSERT_TRUE(Get("key2", &value)); |
| 91 int result; | 91 int result; |
| 92 ASSERT_TRUE(value->GetAsInteger(&result)); | 92 ASSERT_TRUE(value->GetAsInteger(&result)); |
| 93 EXPECT_EQ(2, result); | 93 EXPECT_EQ(2, result); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { | 97 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { |
| 98 storage_->Set("key0", | 98 storage_->Set("key0", std::unique_ptr<base::Value>(new base::Value(0))); |
| 99 std::unique_ptr<base::Value>(new base::FundamentalValue(0))); | |
| 100 storage_->Set("key1", | 99 storage_->Set("key1", |
| 101 std::unique_ptr<base::Value>(new base::StringValue("new1"))); | 100 std::unique_ptr<base::Value>(new base::StringValue("new1"))); |
| 102 storage_->Remove("key2"); | 101 storage_->Remove("key2"); |
| 103 | 102 |
| 104 // Reload the DB and test our changes. | 103 // Reload the DB and test our changes. |
| 105 ResetStorage(); | 104 ResetStorage(); |
| 106 | 105 |
| 107 std::unique_ptr<base::Value> value; | 106 std::unique_ptr<base::Value> value; |
| 108 { | 107 { |
| 109 ASSERT_TRUE(Get("key0", &value)); | 108 ASSERT_TRUE(Get("key0", &value)); |
| 110 int result; | 109 int result; |
| 111 ASSERT_TRUE(value->GetAsInteger(&result)); | 110 ASSERT_TRUE(value->GetAsInteger(&result)); |
| 112 EXPECT_EQ(0, result); | 111 EXPECT_EQ(0, result); |
| 113 } | 112 } |
| 114 | 113 |
| 115 { | 114 { |
| 116 ASSERT_TRUE(Get("key1", &value)); | 115 ASSERT_TRUE(Get("key1", &value)); |
| 117 std::string result; | 116 std::string result; |
| 118 ASSERT_TRUE(value->GetAsString(&result)); | 117 ASSERT_TRUE(value->GetAsString(&result)); |
| 119 EXPECT_EQ("new1", result); | 118 EXPECT_EQ("new1", result); |
| 120 } | 119 } |
| 121 | 120 |
| 122 ASSERT_FALSE(Get("key2", &value)); | 121 ASSERT_FALSE(Get("key2", &value)); |
| 123 } | 122 } |
| OLD | NEW |