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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.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 | 17 // Test suite for CachingValueStore, using a test database with a few simple |
18 // entries. | 18 // entries. |
19 class ValueStoreFrontendTest : public testing::Test { | 19 class ValueStoreFrontendTest : public testing::Test { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 protected: | 55 protected: |
56 void GetAndWait(scoped_ptr<base::Value>* output, | 56 void GetAndWait(scoped_ptr<base::Value>* output, |
57 scoped_ptr<base::Value> result) { | 57 scoped_ptr<base::Value> result) { |
58 *output = result.Pass(); | 58 *output = result.Pass(); |
59 MessageLoop::current()->Quit(); | 59 MessageLoop::current()->Quit(); |
60 } | 60 } |
61 | 61 |
62 scoped_ptr<ValueStoreFrontend> storage_; | 62 scoped_ptr<ValueStoreFrontend> storage_; |
63 ScopedTempDir temp_dir_; | 63 base::ScopedTempDir temp_dir_; |
64 FilePath db_path_; | 64 FilePath db_path_; |
65 MessageLoop message_loop_; | 65 MessageLoop message_loop_; |
66 content::TestBrowserThread ui_thread_; | 66 content::TestBrowserThread ui_thread_; |
67 content::TestBrowserThread file_thread_; | 67 content::TestBrowserThread file_thread_; |
68 }; | 68 }; |
69 | 69 |
70 TEST_F(ValueStoreFrontendTest, GetExistingData) { | 70 TEST_F(ValueStoreFrontendTest, GetExistingData) { |
71 scoped_ptr<base::Value> value(NULL); | 71 scoped_ptr<base::Value> value(NULL); |
72 ASSERT_FALSE(Get("key0", &value)); | 72 ASSERT_FALSE(Get("key0", &value)); |
73 | 73 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 { | 108 { |
109 ASSERT_TRUE(Get("key1", &value)); | 109 ASSERT_TRUE(Get("key1", &value)); |
110 std::string result; | 110 std::string result; |
111 ASSERT_TRUE(value->GetAsString(&result)); | 111 ASSERT_TRUE(value->GetAsString(&result)); |
112 EXPECT_EQ("new1", result); | 112 EXPECT_EQ("new1", result); |
113 } | 113 } |
114 | 114 |
115 ASSERT_FALSE(Get("key2", &value)); | 115 ASSERT_FALSE(Get("key2", &value)); |
116 } | 116 } |
OLD | NEW |