Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: chrome/browser/value_store/value_store_frontend_unittest.cc

Issue 10537116: Revert 141514 - Remove CachingValueStore in favor of an async ValueStoreFrontend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/value_store/value_store_frontend.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/value_store/value_store_frontend_unittest.cc
===================================================================
--- chrome/browser/value_store/value_store_frontend_unittest.cc (revision 141602)
+++ chrome/browser/value_store/value_store_frontend_unittest.cc (working copy)
@@ -1,116 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/file_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop.h"
-#include "base/path_service.h"
-#include "base/scoped_temp_dir.h"
-#include "chrome/browser/value_store/value_store_frontend.h"
-#include "chrome/common/chrome_paths.h"
-#include "content/public/test/test_browser_thread.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using content::BrowserThread;
-
-// Test suite for CachingValueStore, using a test database with a few simple
-// entries.
-class ValueStoreFrontendTest : public testing::Test {
- public:
- ValueStoreFrontendTest()
- : ui_thread_(BrowserThread::UI, MessageLoop::current()),
- file_thread_(BrowserThread::FILE, MessageLoop::current()) {
- }
-
- virtual void SetUp() {
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
-
- FilePath test_data_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
- FilePath src_db(test_data_dir.AppendASCII("value_store_db"));
- db_path_ = temp_dir_.path().AppendASCII("temp_db");
- file_util::CopyDirectory(src_db, db_path_, true);
-
- ResetStorage();
- }
-
- virtual void TearDown() {
- MessageLoop::current()->RunAllPending(); // wait for storage to delete
- storage_.reset();
- }
-
- // Reset the value store, reloading the DB from disk.
- void ResetStorage() {
- storage_.reset(new ValueStoreFrontend(db_path_));
- }
-
- bool Get(const std::string& key, scoped_ptr<base::Value>* output) {
- storage_->Get(key, base::Bind(&ValueStoreFrontendTest::GetAndWait,
- base::Unretained(this), output));
- MessageLoop::current()->Run(); // wait for GetAndWait
- return !!output->get();
- }
-
- protected:
- void GetAndWait(scoped_ptr<base::Value>* output,
- scoped_ptr<base::Value> result) {
- *output = result.Pass();
- MessageLoop::current()->Quit();
- }
-
- scoped_ptr<ValueStoreFrontend> storage_;
- ScopedTempDir temp_dir_;
- FilePath db_path_;
- MessageLoop message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_thread_;
-};
-
-TEST_F(ValueStoreFrontendTest, GetExistingData) {
- scoped_ptr<base::Value> value(NULL);
- ASSERT_FALSE(Get("key0", &value));
-
- // Test existing keys in the DB.
- {
- ASSERT_TRUE(Get("key1", &value));
- std::string result;
- ASSERT_TRUE(value->GetAsString(&result));
- EXPECT_EQ("value1", result);
- }
-
- {
- ASSERT_TRUE(Get("key2", &value));
- int result;
- ASSERT_TRUE(value->GetAsInteger(&result));
- EXPECT_EQ(2, result);
- }
-}
-
-TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) {
- storage_->Set("key0",
- scoped_ptr<base::Value>(base::Value::CreateIntegerValue(0)));
- storage_->Set("key1",
- scoped_ptr<base::Value>(base::Value::CreateStringValue("new1")));
- storage_->Remove("key2");
-
- // Reload the DB and test our changes.
- ResetStorage();
-
- scoped_ptr<base::Value> value(NULL);
- {
- ASSERT_TRUE(Get("key0", &value));
- int result;
- ASSERT_TRUE(value->GetAsInteger(&result));
- EXPECT_EQ(0, result);
- }
-
- {
- ASSERT_TRUE(Get("key1", &value));
- std::string result;
- ASSERT_TRUE(value->GetAsString(&result));
- EXPECT_EQ("new1", result);
- }
-
- ASSERT_FALSE(Get("key2", &value));
-}
« no previous file with comments | « chrome/browser/value_store/value_store_frontend.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698