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

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

Issue 375023002: sync: Support nudges from non-blocking sync types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SYNC_EXPORT 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
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/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
9 #include "sync/engine/model_type_sync_proxy_impl.h" 9 #include "sync/engine/model_type_sync_proxy_impl.h"
10 #include "sync/internal_api/public/base/model_type.h" 10 #include "sync/internal_api/public/base/model_type.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 "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace syncer { 17 namespace syncer {
17 18
18 class SyncContextProxyImplTest : public ::testing::Test { 19 class SyncContextProxyImplTest : public ::testing::Test {
19 public: 20 public:
20 SyncContextProxyImplTest() 21 SyncContextProxyImplTest()
21 : sync_task_runner_(base::MessageLoopProxy::current()), 22 : sync_task_runner_(base::MessageLoopProxy::current()),
22 type_task_runner_(base::MessageLoopProxy::current()), 23 type_task_runner_(base::MessageLoopProxy::current()),
23 registry_(new ModelTypeRegistry()), 24 registry_(new ModelTypeRegistry(workers_, NULL, &nudge_handler_)),
stanisc 2014/07/09 22:35:25 Consider adding a comment explaining what this NUL
rlarocque 2014/07/10 00:12:29 It's probably better to just use a real directory.
24 context_proxy_(sync_task_runner_, registry_->AsWeakPtr()) {} 25 context_proxy_(sync_task_runner_, registry_->AsWeakPtr()) {}
25 26
26 // The sync thread could be shut down at any time without warning. This 27 // The sync thread could be shut down at any time without warning. This
27 // function simulates such an event. 28 // function simulates such an event.
28 void DisableSync() { registry_.reset(); } 29 void DisableSync() { registry_.reset(); }
29 30
30 scoped_ptr<SyncContextProxy> GetProxy() { return context_proxy_.Clone(); } 31 scoped_ptr<SyncContextProxy> GetProxy() { return context_proxy_.Clone(); }
31 32
32 private: 33 private:
33 base::MessageLoop loop_; 34 base::MessageLoop loop_;
34 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_; 35 scoped_refptr<base::SequencedTaskRunner> sync_task_runner_;
35 scoped_refptr<base::SequencedTaskRunner> type_task_runner_; 36 scoped_refptr<base::SequencedTaskRunner> type_task_runner_;
37
38 std::vector<scoped_refptr<ModelSafeWorker> > workers_;
39 MockNudgeHandler nudge_handler_;
36 scoped_ptr<ModelTypeRegistry> registry_; 40 scoped_ptr<ModelTypeRegistry> registry_;
41
37 SyncContextProxyImpl context_proxy_; 42 SyncContextProxyImpl context_proxy_;
38 }; 43 };
39 44
40 // Try to connect a type to a SyncContext that has already shut down. 45 // Try to connect a type to a SyncContext that has already shut down.
41 TEST_F(SyncContextProxyImplTest, FailToConnect1) { 46 TEST_F(SyncContextProxyImplTest, FailToConnect1) {
42 ModelTypeSyncProxyImpl themes_sync_proxy(syncer::THEMES); 47 ModelTypeSyncProxyImpl themes_sync_proxy(syncer::THEMES);
43 DisableSync(); 48 DisableSync();
44 themes_sync_proxy.Enable(GetProxy()); 49 themes_sync_proxy.Enable(GetProxy());
45 50
46 base::RunLoop run_loop_; 51 base::RunLoop run_loop_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 themes_sync_proxy->Enable(GetProxy()); 84 themes_sync_proxy->Enable(GetProxy());
80 85
81 base::RunLoop run_loop_; 86 base::RunLoop run_loop_;
82 run_loop_.RunUntilIdle(); 87 run_loop_.RunUntilIdle();
83 88
84 EXPECT_TRUE(themes_sync_proxy->IsConnected()); 89 EXPECT_TRUE(themes_sync_proxy->IsConnected());
85 DisableSync(); 90 DisableSync();
86 } 91 }
87 92
88 } // namespace syncer 93 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698