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

Side by Side Diff: sync/internal_api/sync_context_proxy_impl_unittest.cc

Issue 1382743004: [Sync] Move ModelTypeProcessor* and rename *Impl to Shared*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: also the test Created 5 years, 2 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 unified diff | Download patch
OLDNEW
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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/sequenced_task_runner.h" 7 #include "base/sequenced_task_runner.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "sync/engine/model_type_processor_impl.h"
10 #include "sync/internal_api/public/base/model_type.h" 9 #include "sync/internal_api/public/base/model_type.h"
10 #include "sync/internal_api/public/shared_model_type_processor.h"
11 #include "sync/internal_api/public/sync_context.h" 11 #include "sync/internal_api/public/sync_context.h"
12 #include "sync/internal_api/sync_context_proxy_impl.h" 12 #include "sync/internal_api/sync_context_proxy_impl.h"
13 #include "sync/sessions/model_type_registry.h" 13 #include "sync/sessions/model_type_registry.h"
14 #include "sync/test/engine/mock_nudge_handler.h" 14 #include "sync/test/engine/mock_nudge_handler.h"
15 #include "sync/test/engine/test_directory_setter_upper.h" 15 #include "sync/test/engine/test_directory_setter_upper.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace syncer_v2 { 18 namespace syncer_v2 {
19 19
20 class SyncContextProxyImplTest : public ::testing::Test { 20 class SyncContextProxyImplTest : public ::testing::Test {
(...skipping 30 matching lines...) Expand all
51 std::vector<scoped_refptr<syncer::ModelSafeWorker>> workers_; 51 std::vector<scoped_refptr<syncer::ModelSafeWorker>> workers_;
52 syncer::TestDirectorySetterUpper dir_maker_; 52 syncer::TestDirectorySetterUpper dir_maker_;
53 syncer::MockNudgeHandler nudge_handler_; 53 syncer::MockNudgeHandler nudge_handler_;
54 scoped_ptr<syncer::ModelTypeRegistry> registry_; 54 scoped_ptr<syncer::ModelTypeRegistry> registry_;
55 55
56 scoped_ptr<SyncContextProxyImpl> context_proxy_; 56 scoped_ptr<SyncContextProxyImpl> context_proxy_;
57 }; 57 };
58 58
59 // Try to connect a type to a SyncContext that has already shut down. 59 // Try to connect a type to a SyncContext that has already shut down.
60 TEST_F(SyncContextProxyImplTest, FailToConnect1) { 60 TEST_F(SyncContextProxyImplTest, FailToConnect1) {
61 ModelTypeProcessorImpl themes_sync_proxy(syncer::THEMES, 61 SharedModelTypeProcessor themes_sync_proxy(syncer::THEMES,
62 base::WeakPtr<ModelTypeStore>()); 62 base::WeakPtr<ModelTypeStore>());
63 DisableSync(); 63 DisableSync();
64 themes_sync_proxy.Enable(GetProxy()); 64 themes_sync_proxy.Enable(GetProxy());
65 65
66 base::RunLoop run_loop_; 66 base::RunLoop run_loop_;
67 run_loop_.RunUntilIdle(); 67 run_loop_.RunUntilIdle();
68 EXPECT_FALSE(themes_sync_proxy.IsConnected()); 68 EXPECT_FALSE(themes_sync_proxy.IsConnected());
69 } 69 }
70 70
71 // Try to connect a type to a SyncContext as it shuts down. 71 // Try to connect a type to a SyncContext as it shuts down.
72 TEST_F(SyncContextProxyImplTest, FailToConnect2) { 72 TEST_F(SyncContextProxyImplTest, FailToConnect2) {
73 ModelTypeProcessorImpl themes_sync_proxy(syncer::THEMES, 73 SharedModelTypeProcessor themes_sync_proxy(syncer::THEMES,
74 base::WeakPtr<ModelTypeStore>()); 74 base::WeakPtr<ModelTypeStore>());
75 themes_sync_proxy.Enable(GetProxy()); 75 themes_sync_proxy.Enable(GetProxy());
76 DisableSync(); 76 DisableSync();
77 77
78 base::RunLoop run_loop_; 78 base::RunLoop run_loop_;
79 run_loop_.RunUntilIdle(); 79 run_loop_.RunUntilIdle();
80 EXPECT_FALSE(themes_sync_proxy.IsConnected()); 80 EXPECT_FALSE(themes_sync_proxy.IsConnected());
81 } 81 }
82 82
83 // Tests the case where the type's sync proxy shuts down first. 83 // Tests the case where the type's sync proxy shuts down first.
84 TEST_F(SyncContextProxyImplTest, TypeDisconnectsFirst) { 84 TEST_F(SyncContextProxyImplTest, TypeDisconnectsFirst) {
85 scoped_ptr<ModelTypeProcessorImpl> themes_sync_proxy( 85 scoped_ptr<SharedModelTypeProcessor> themes_sync_proxy(
86 new ModelTypeProcessorImpl(syncer::THEMES, 86 new SharedModelTypeProcessor(syncer::THEMES,
87 base::WeakPtr<ModelTypeStore>())); 87 base::WeakPtr<ModelTypeStore>()));
88 themes_sync_proxy->Enable(GetProxy()); 88 themes_sync_proxy->Enable(GetProxy());
89 89
90 base::RunLoop run_loop_; 90 base::RunLoop run_loop_;
91 run_loop_.RunUntilIdle(); 91 run_loop_.RunUntilIdle();
92 92
93 EXPECT_TRUE(themes_sync_proxy->IsConnected()); 93 EXPECT_TRUE(themes_sync_proxy->IsConnected());
94 themes_sync_proxy.reset(); 94 themes_sync_proxy.reset();
95 } 95 }
96 96
97 // Tests the case where the sync thread shuts down first. 97 // Tests the case where the sync thread shuts down first.
98 TEST_F(SyncContextProxyImplTest, SyncDisconnectsFirst) { 98 TEST_F(SyncContextProxyImplTest, SyncDisconnectsFirst) {
99 scoped_ptr<ModelTypeProcessorImpl> themes_sync_proxy( 99 scoped_ptr<SharedModelTypeProcessor> themes_sync_proxy(
100 new ModelTypeProcessorImpl(syncer::THEMES, 100 new SharedModelTypeProcessor(syncer::THEMES,
101 base::WeakPtr<ModelTypeStore>())); 101 base::WeakPtr<ModelTypeStore>()));
102 themes_sync_proxy->Enable(GetProxy()); 102 themes_sync_proxy->Enable(GetProxy());
103 103
104 base::RunLoop run_loop_; 104 base::RunLoop run_loop_;
105 run_loop_.RunUntilIdle(); 105 run_loop_.RunUntilIdle();
106 106
107 EXPECT_TRUE(themes_sync_proxy->IsConnected()); 107 EXPECT_TRUE(themes_sync_proxy->IsConnected());
108 DisableSync(); 108 DisableSync();
109 } 109 }
110 110
111 } // namespace syncer 111 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698