| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 { | 80 { |
| 81 ASSERT_TRUE(Get("key2", &value)); | 81 ASSERT_TRUE(Get("key2", &value)); |
| 82 int result; | 82 int result; |
| 83 ASSERT_TRUE(value->GetAsInteger(&result)); | 83 ASSERT_TRUE(value->GetAsInteger(&result)); |
| 84 EXPECT_EQ(2, result); | 84 EXPECT_EQ(2, result); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { | 88 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { |
| 89 storage_->Set("key0", | 89 storage_->Set("key0", scoped_ptr<base::Value>(new base::FundamentalValue(0))); |
| 90 scoped_ptr<base::Value>(base::Value::CreateIntegerValue(0))); | |
| 91 storage_->Set("key1", scoped_ptr<base::Value>(new base::StringValue("new1"))); | 90 storage_->Set("key1", scoped_ptr<base::Value>(new base::StringValue("new1"))); |
| 92 storage_->Remove("key2"); | 91 storage_->Remove("key2"); |
| 93 | 92 |
| 94 // Reload the DB and test our changes. | 93 // Reload the DB and test our changes. |
| 95 ResetStorage(); | 94 ResetStorage(); |
| 96 | 95 |
| 97 scoped_ptr<base::Value> value; | 96 scoped_ptr<base::Value> value; |
| 98 { | 97 { |
| 99 ASSERT_TRUE(Get("key0", &value)); | 98 ASSERT_TRUE(Get("key0", &value)); |
| 100 int result; | 99 int result; |
| 101 ASSERT_TRUE(value->GetAsInteger(&result)); | 100 ASSERT_TRUE(value->GetAsInteger(&result)); |
| 102 EXPECT_EQ(0, result); | 101 EXPECT_EQ(0, result); |
| 103 } | 102 } |
| 104 | 103 |
| 105 { | 104 { |
| 106 ASSERT_TRUE(Get("key1", &value)); | 105 ASSERT_TRUE(Get("key1", &value)); |
| 107 std::string result; | 106 std::string result; |
| 108 ASSERT_TRUE(value->GetAsString(&result)); | 107 ASSERT_TRUE(value->GetAsString(&result)); |
| 109 EXPECT_EQ("new1", result); | 108 EXPECT_EQ("new1", result); |
| 110 } | 109 } |
| 111 | 110 |
| 112 ASSERT_FALSE(Get("key2", &value)); | 111 ASSERT_FALSE(Get("key2", &value)); |
| 113 } | 112 } |
| OLD | NEW |