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

Side by Side Diff: components/sync/api/model_type_service_unittest.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 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
« no previous file with comments | « components/sync/api/model_type_service.cc ('k') | components/sync/api/model_type_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "components/sync/api/data_type_error_handler_mock.h" 9 #include "components/sync/api/data_type_error_handler_mock.h"
10 #include "components/sync/api/fake_model_type_change_processor.h" 10 #include "components/sync/api/fake_model_type_change_processor.h"
11 #include "components/sync/api/stub_model_type_service.h" 11 #include "components/sync/api/stub_model_type_service.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace syncer { 14 namespace syncer_v2 {
15 15
16 // A mock MTCP that lets us know when DisableSync is called. 16 // A mock MTCP that lets us know when DisableSync is called.
17 class MockModelTypeChangeProcessor : public FakeModelTypeChangeProcessor { 17 class MockModelTypeChangeProcessor : public FakeModelTypeChangeProcessor {
18 public: 18 public:
19 explicit MockModelTypeChangeProcessor(const base::Closure& disabled_callback) 19 explicit MockModelTypeChangeProcessor(const base::Closure& disabled_callback)
20 : disabled_callback_(disabled_callback) {} 20 : disabled_callback_(disabled_callback) {}
21 ~MockModelTypeChangeProcessor() override {} 21 ~MockModelTypeChangeProcessor() override {}
22 22
23 void DisableSync() override { disabled_callback_.Run(); } 23 void DisableSync() override { disabled_callback_.Run(); }
24 24
(...skipping 16 matching lines...) Expand all
41 } 41 }
42 42
43 bool on_processor_set_called() const { return on_processor_set_called_; } 43 bool on_processor_set_called() const { return on_processor_set_called_; }
44 void clear_on_processor_set_called() { on_processor_set_called_ = false; } 44 void clear_on_processor_set_called() { on_processor_set_called_ = false; }
45 bool processor_disable_sync_called() const { 45 bool processor_disable_sync_called() const {
46 return processor_disable_sync_called_; 46 return processor_disable_sync_called_;
47 } 47 }
48 48
49 private: 49 private:
50 std::unique_ptr<ModelTypeChangeProcessor> CreateProcessor( 50 std::unique_ptr<ModelTypeChangeProcessor> CreateProcessor(
51 ModelType type, 51 syncer::ModelType type,
52 ModelTypeService* service) { 52 ModelTypeService* service) {
53 return base::MakeUnique<MockModelTypeChangeProcessor>(base::Bind( 53 return base::MakeUnique<MockModelTypeChangeProcessor>(base::Bind(
54 &MockModelTypeService::OnProcessorDisableSync, base::Unretained(this))); 54 &MockModelTypeService::OnProcessorDisableSync, base::Unretained(this)));
55 } 55 }
56 56
57 void OnChangeProcessorSet() override { on_processor_set_called_ = true; } 57 void OnChangeProcessorSet() override { on_processor_set_called_ = true; }
58 58
59 void OnProcessorDisableSync() { processor_disable_sync_called_ = true; } 59 void OnProcessorDisableSync() { processor_disable_sync_called_ = true; }
60 60
61 bool on_processor_set_called_ = false; 61 bool on_processor_set_called_ = false;
62 bool processor_disable_sync_called_ = false; 62 bool processor_disable_sync_called_ = false;
63 }; 63 };
64 64
65 class ModelTypeServiceTest : public ::testing::Test { 65 class ModelTypeServiceTest : public ::testing::Test {
66 public: 66 public:
67 ModelTypeServiceTest() {} 67 ModelTypeServiceTest() {}
68 ~ModelTypeServiceTest() override {} 68 ~ModelTypeServiceTest() override {}
69 69
70 void OnSyncStarting() { 70 void OnSyncStarting() {
71 service_.OnSyncStarting( 71 service_.OnSyncStarting(
72 base::MakeUnique<DataTypeErrorHandlerMock>(), 72 base::MakeUnique<syncer::DataTypeErrorHandlerMock>(),
73 base::Bind(&ModelTypeServiceTest::OnProcessorStarted, 73 base::Bind(&ModelTypeServiceTest::OnProcessorStarted,
74 base::Unretained(this))); 74 base::Unretained(this)));
75 } 75 }
76 76
77 bool start_callback_called() const { return start_callback_called_; } 77 bool start_callback_called() const { return start_callback_called_; }
78 MockModelTypeService* service() { return &service_; } 78 MockModelTypeService* service() { return &service_; }
79 79
80 private: 80 private:
81 void OnProcessorStarted( 81 void OnProcessorStarted(
82 SyncError error, 82 syncer::SyncError error,
83 std::unique_ptr<ActivationContext> activation_context) { 83 std::unique_ptr<ActivationContext> activation_context) {
84 start_callback_called_ = true; 84 start_callback_called_ = true;
85 } 85 }
86 86
87 bool start_callback_called_; 87 bool start_callback_called_;
88 MockModelTypeService service_; 88 MockModelTypeService service_;
89 }; 89 };
90 90
91 // CreateChangeProcessor should construct a processor and call 91 // CreateChangeProcessor should construct a processor and call
92 // OnChangeProcessorSet if and only if one doesn't already exist. 92 // OnChangeProcessorSet if and only if one doesn't already exist.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 EXPECT_EQ(ConflictResolution::USE_REMOTE, 145 EXPECT_EQ(ConflictResolution::USE_REMOTE,
146 service()->ResolveConflict(local_data, remote_data).type()); 146 service()->ResolveConflict(local_data, remote_data).type());
147 147
148 local_data.specifics.clear_preference(); 148 local_data.specifics.clear_preference();
149 EXPECT_TRUE(local_data.is_deleted()); 149 EXPECT_TRUE(local_data.is_deleted());
150 EXPECT_FALSE(remote_data.is_deleted()); 150 EXPECT_FALSE(remote_data.is_deleted());
151 EXPECT_EQ(ConflictResolution::USE_REMOTE, 151 EXPECT_EQ(ConflictResolution::USE_REMOTE,
152 service()->ResolveConflict(local_data, remote_data).type()); 152 service()->ResolveConflict(local_data, remote_data).type());
153 } 153 }
154 154
155 } // namespace syncer 155 } // namespace syncer_v2
OLDNEW
« no previous file with comments | « components/sync/api/model_type_service.cc ('k') | components/sync/api/model_type_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698