Chromium Code Reviews| 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 "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/browser/value_store/value_store_frontend.h" | 10 #include "chrome/browser/value_store/value_store_frontend.h" |
| 11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using content::BrowserThread; | 15 using content::BrowserThread; |
| 16 | 16 |
| 17 // Test suite for CachingValueStore, using a test database with a few simple | |
| 18 // entries. | |
| 19 class ValueStoreFrontendTest : public testing::Test { | 17 class ValueStoreFrontendTest : public testing::Test { |
| 20 public: | 18 public: |
| 21 ValueStoreFrontendTest() | 19 ValueStoreFrontendTest() |
| 22 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), | 20 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), |
| 23 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) { | 21 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) { |
| 24 } | 22 } |
| 25 | 23 |
| 26 virtual void SetUp() { | 24 virtual void SetUp() { |
| 27 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 25 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 28 | 26 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 } | 86 } |
| 89 | 87 |
| 90 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { | 88 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { |
| 91 storage_->Set("key0", | 89 storage_->Set("key0", |
| 92 scoped_ptr<base::Value>(base::Value::CreateIntegerValue(0))); | 90 scoped_ptr<base::Value>(base::Value::CreateIntegerValue(0))); |
| 93 storage_->Set("key1", | 91 storage_->Set("key1", |
| 94 scoped_ptr<base::Value>(base::Value::CreateStringValue("new1"))); | 92 scoped_ptr<base::Value>(base::Value::CreateStringValue("new1"))); |
| 95 storage_->Remove("key2"); | 93 storage_->Remove("key2"); |
| 96 | 94 |
| 97 // Reload the DB and test our changes. | 95 // Reload the DB and test our changes. |
| 98 ResetStorage(); | 96 //ResetStorage(); |
|
Matt Perry
2013/09/06 20:07:30
?
not at google - send to devlin
2013/09/06 21:44:28
oh oops. Fixed.
| |
| 99 | 97 |
| 100 scoped_ptr<base::Value> value; | 98 scoped_ptr<base::Value> value; |
| 101 { | 99 { |
| 102 ASSERT_TRUE(Get("key0", &value)); | 100 ASSERT_TRUE(Get("key0", &value)); |
| 103 int result; | 101 int result; |
| 104 ASSERT_TRUE(value->GetAsInteger(&result)); | 102 ASSERT_TRUE(value->GetAsInteger(&result)); |
| 105 EXPECT_EQ(0, result); | 103 EXPECT_EQ(0, result); |
| 106 } | 104 } |
| 107 | 105 |
| 108 { | 106 { |
| 109 ASSERT_TRUE(Get("key1", &value)); | 107 ASSERT_TRUE(Get("key1", &value)); |
| 110 std::string result; | 108 std::string result; |
| 111 ASSERT_TRUE(value->GetAsString(&result)); | 109 ASSERT_TRUE(value->GetAsString(&result)); |
| 112 EXPECT_EQ("new1", result); | 110 EXPECT_EQ("new1", result); |
| 113 } | 111 } |
| 114 | 112 |
| 115 ASSERT_FALSE(Get("key2", &value)); | 113 ASSERT_FALSE(Get("key2", &value)); |
| 116 } | 114 } |
| OLD | NEW |