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

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

Issue 351523003: sync: Mass rename of non-blocking sync classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const ref some smart pointers Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sync/internal_api/sync_core_proxy_impl.cc ('k') | sync/internal_api/sync_manager_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/message_loop/message_loop.h"
6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/run_loop.h"
8 #include "base/sequenced_task_runner.h"
9 #include "sync/engine/non_blocking_type_processor.h"
10 #include "sync/internal_api/public/base/model_type.h"
11 #include "sync/internal_api/sync_core.h"
12 #include "sync/internal_api/sync_core_proxy_impl.h"
13 #include "sync/sessions/model_type_registry.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace syncer {
17
18 class SyncCoreProxyImplTest : public ::testing::Test {
19 public:
20 SyncCoreProxyImplTest()
21 : sync_task_runner_(base::MessageLoopProxy::current()),
22 type_task_runner_(base::MessageLoopProxy::current()),
23 core_(new SyncCore(&registry_)),
24 core_proxy_(
25 sync_task_runner_,
26 core_->AsWeakPtr()) {}
27
28 // The sync thread could be shut down at any time without warning. This
29 // function simulates such an event.
30 void DisableSync() {
31 core_.reset();
32 }
33
34 scoped_ptr<SyncCoreProxy> GetProxy() { return core_proxy_.Clone(); }
35
36 private:
37 base::MessageLoop loop_;
38 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
39 scoped_refptr<base::SequencedTaskRunner> type_task_runner_;
40 ModelTypeRegistry registry_;
41 scoped_ptr<SyncCore> core_;
42 SyncCoreProxyImpl core_proxy_;
43 };
44
45 // Try to connect a type to a SyncCore that has already shut down.
46 TEST_F(SyncCoreProxyImplTest, FailToConnect1) {
47 NonBlockingTypeProcessor themes_processor(syncer::THEMES);
48 DisableSync();
49 themes_processor.Enable(GetProxy());
50
51 base::RunLoop run_loop_;
52 run_loop_.RunUntilIdle();
53 EXPECT_FALSE(themes_processor.IsConnected());
54 }
55
56 // Try to connect a type to a SyncCore as it shuts down.
57 TEST_F(SyncCoreProxyImplTest, FailToConnect2) {
58 NonBlockingTypeProcessor themes_processor(syncer::THEMES);
59 themes_processor.Enable(GetProxy());
60 DisableSync();
61
62 base::RunLoop run_loop_;
63 run_loop_.RunUntilIdle();
64 EXPECT_FALSE(themes_processor.IsConnected());
65 }
66
67 // Tests the case where the type's processor shuts down first.
68 TEST_F(SyncCoreProxyImplTest, TypeDisconnectsFirst) {
69 scoped_ptr<NonBlockingTypeProcessor> themes_processor
70 (new NonBlockingTypeProcessor(syncer::THEMES));
71 themes_processor->Enable(GetProxy());
72
73 base::RunLoop run_loop_;
74 run_loop_.RunUntilIdle();
75
76 EXPECT_TRUE(themes_processor->IsConnected());
77 themes_processor.reset();
78 }
79
80 // Tests the case where the sync thread shuts down first.
81 TEST_F(SyncCoreProxyImplTest, SyncDisconnectsFirst) {
82 scoped_ptr<NonBlockingTypeProcessor> themes_processor
83 (new NonBlockingTypeProcessor(syncer::THEMES));
84 themes_processor->Enable(GetProxy());
85
86 base::RunLoop run_loop_;
87 run_loop_.RunUntilIdle();
88
89 EXPECT_TRUE(themes_processor->IsConnected());
90 DisableSync();
91 }
92
93 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_core_proxy_impl.cc ('k') | sync/internal_api/sync_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698