| 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" | |
| 11 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
| 12 #include "extensions/browser/value_store/value_store_frontend.h" | 11 #include "extensions/browser/value_store/value_store_frontend.h" |
| 12 #include "extensions/common/extension_paths.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 class ValueStoreFrontendTest : public testing::Test { | 17 class ValueStoreFrontendTest : public testing::Test { |
| 18 public: | 18 public: |
| 19 ValueStoreFrontendTest() | 19 ValueStoreFrontendTest() |
| 20 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), | 20 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), |
| 21 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) { | 21 file_thread_(BrowserThread::FILE, base::MessageLoop::current()) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 virtual void SetUp() { | 24 virtual void SetUp() { |
| 25 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 25 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 26 | 26 |
| 27 base::FilePath test_data_dir; | 27 base::FilePath test_data_dir; |
| 28 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir)); | 28 ASSERT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &test_data_dir)); |
| 29 base::FilePath src_db(test_data_dir.AppendASCII("value_store_db")); | 29 base::FilePath src_db(test_data_dir.AppendASCII("value_store_db")); |
| 30 db_path_ = temp_dir_.path().AppendASCII("temp_db"); | 30 db_path_ = temp_dir_.path().AppendASCII("temp_db"); |
| 31 base::CopyDirectory(src_db, db_path_, true); | 31 base::CopyDirectory(src_db, db_path_, true); |
| 32 | 32 |
| 33 ResetStorage(); | 33 ResetStorage(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual void TearDown() { | 36 virtual void TearDown() { |
| 37 base::MessageLoop::current()->RunUntilIdle(); // wait for storage to delete | 37 base::MessageLoop::current()->RunUntilIdle(); // wait for storage to delete |
| 38 storage_.reset(); | 38 storage_.reset(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 { | 104 { |
| 105 ASSERT_TRUE(Get("key1", &value)); | 105 ASSERT_TRUE(Get("key1", &value)); |
| 106 std::string result; | 106 std::string result; |
| 107 ASSERT_TRUE(value->GetAsString(&result)); | 107 ASSERT_TRUE(value->GetAsString(&result)); |
| 108 EXPECT_EQ("new1", result); | 108 EXPECT_EQ("new1", result); |
| 109 } | 109 } |
| 110 | 110 |
| 111 ASSERT_FALSE(Get("key2", &value)); | 111 ASSERT_FALSE(Get("key2", &value)); |
| 112 } | 112 } |
| OLD | NEW |