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

Unified Diff: sync/internal_api/model_type_store_impl_unittest.cc

Issue 1421833004: [Sync] Add ModelTypeStore implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@USS.StoreInterface
Patch Set: Addressing comment. Created 5 years, 1 month 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 | « sync/internal_api/model_type_store_impl.cc ('k') | sync/internal_api/public/model_type_store_backend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/model_type_store_impl_unittest.cc
diff --git a/sync/internal_api/model_type_store_impl_unittest.cc b/sync/internal_api/model_type_store_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9bba03123074f20da7ba5aa2a77ec48aff42deea
--- /dev/null
+++ b/sync/internal_api/model_type_store_impl_unittest.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 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 "sync/internal_api/public/model_type_store_impl.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace syncer_v2 {
+
+class ModelTypeStoreImplTest : public testing::Test {
+ public:
+ void TearDown() override {
+ if (store_) {
+ store_.reset();
+ PumpLoop();
+ }
+ }
+
+ ModelTypeStore* store() { return store_.get(); }
+
+ void OnInitDone(ModelTypeStore::Result result,
+ scoped_ptr<ModelTypeStore> store) {
+ ASSERT_EQ(ModelTypeStore::Result::SUCCESS, result);
+ store_ = store.Pass();
+ }
+
+ void PumpLoop() {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+
+ private:
+ base::MessageLoop message_loop_;
+ scoped_ptr<ModelTypeStore> store_;
+};
+
+// Test that CreateInMemoryStoreForTest triggers store initialization that
+// results with callback being calleds with valid store pointer.
+TEST_F(ModelTypeStoreImplTest, CreateInMemoryStore) {
+ ModelTypeStore::CreateInMemoryStoreForTest(
+ base::Bind(&ModelTypeStoreImplTest::OnInitDone, base::Unretained(this)));
+ ASSERT_EQ(nullptr, store());
+ PumpLoop();
+ ASSERT_NE(nullptr, store());
+}
+
+} // namespace syncer_v2
« no previous file with comments | « sync/internal_api/model_type_store_impl.cc ('k') | sync/internal_api/public/model_type_store_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698