OLD | NEW |
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 "components/sync_driver/non_ui_data_type_controller.h" | 5 #include "components/sync_driver/non_ui_data_type_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
17 #include "components/sync_driver/data_type_controller_mock.h" | 17 #include "components/sync_driver/data_type_controller_mock.h" |
18 #include "components/sync_driver/generic_change_processor_factory.h" | 18 #include "components/sync_driver/generic_change_processor_factory.h" |
19 #include "components/sync_driver/non_ui_data_type_controller_mock.h" | 19 #include "components/sync_driver/non_ui_data_type_controller_mock.h" |
20 #include "sync/api/fake_syncable_service.h" | 20 #include "sync/api/fake_syncable_service.h" |
21 #include "sync/api/sync_change.h" | 21 #include "sync/api/sync_change.h" |
22 #include "sync/internal_api/public/engine/model_safe_worker.h" | 22 #include "sync/internal_api/public/engine/model_safe_worker.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace browser_sync { | 26 namespace sync_driver { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 using base::WaitableEvent; | 30 using base::WaitableEvent; |
31 using syncer::AUTOFILL_PROFILE; | 31 using syncer::AUTOFILL_PROFILE; |
32 using testing::_; | 32 using testing::_; |
33 using testing::AtLeast; | 33 using testing::AtLeast; |
34 using testing::DoAll; | 34 using testing::DoAll; |
35 using testing::InvokeWithoutArgs; | 35 using testing::InvokeWithoutArgs; |
36 using testing::Mock; | 36 using testing::Mock; |
(...skipping 17 matching lines...) Expand all Loading... |
54 // Have to do this within an Action to ensure it's not evaluated on the wrong | 54 // Have to do this within an Action to ensure it's not evaluated on the wrong |
55 // thread. | 55 // thread. |
56 return syncable_service->AsWeakPtr(); | 56 return syncable_service->AsWeakPtr(); |
57 } | 57 } |
58 | 58 |
59 class SharedChangeProcessorMock : public SharedChangeProcessor { | 59 class SharedChangeProcessorMock : public SharedChangeProcessor { |
60 public: | 60 public: |
61 SharedChangeProcessorMock() {} | 61 SharedChangeProcessorMock() {} |
62 | 62 |
63 MOCK_METHOD6(Connect, base::WeakPtr<syncer::SyncableService>( | 63 MOCK_METHOD6(Connect, base::WeakPtr<syncer::SyncableService>( |
64 browser_sync::SyncApiComponentFactory*, | 64 SyncApiComponentFactory*, |
65 GenericChangeProcessorFactory*, | 65 GenericChangeProcessorFactory*, |
66 syncer::UserShare*, | 66 syncer::UserShare*, |
67 DataTypeErrorHandler*, | 67 DataTypeErrorHandler*, |
68 syncer::ModelType, | 68 syncer::ModelType, |
69 const base::WeakPtr<syncer::SyncMergeResult>&)); | 69 const base::WeakPtr<syncer::SyncMergeResult>&)); |
70 MOCK_METHOD0(Disconnect, bool()); | 70 MOCK_METHOD0(Disconnect, bool()); |
71 MOCK_METHOD2(ProcessSyncChanges, | 71 MOCK_METHOD2(ProcessSyncChanges, |
72 syncer::SyncError(const tracked_objects::Location&, | 72 syncer::SyncError(const tracked_objects::Location&, |
73 const syncer::SyncChangeList&)); | 73 const syncer::SyncChangeList&)); |
74 MOCK_CONST_METHOD2(GetAllSyncDataReturnError, | 74 MOCK_CONST_METHOD2(GetAllSyncDataReturnError, |
(...skipping 11 matching lines...) Expand all Loading... |
86 const std::string&)); | 86 const std::string&)); |
87 | 87 |
88 private: | 88 private: |
89 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessorMock); | 89 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessorMock); |
90 }; | 90 }; |
91 | 91 |
92 class NonUIDataTypeControllerFake | 92 class NonUIDataTypeControllerFake |
93 : public NonUIDataTypeController { | 93 : public NonUIDataTypeController { |
94 public: | 94 public: |
95 NonUIDataTypeControllerFake( | 95 NonUIDataTypeControllerFake( |
96 browser_sync::SyncApiComponentFactory* sync_factory, | 96 SyncApiComponentFactory* sync_factory, |
97 NonUIDataTypeControllerMock* mock, | 97 NonUIDataTypeControllerMock* mock, |
98 SharedChangeProcessor* change_processor, | 98 SharedChangeProcessor* change_processor, |
99 const DisableTypeCallback& disable_callback, | 99 const DisableTypeCallback& disable_callback, |
100 scoped_refptr<base::MessageLoopProxy> backend_loop) | 100 scoped_refptr<base::MessageLoopProxy> backend_loop) |
101 : NonUIDataTypeController( | 101 : NonUIDataTypeController( |
102 base::MessageLoopProxy::current(), | 102 base::MessageLoopProxy::current(), |
103 base::Closure(), | 103 base::Closure(), |
104 disable_callback, | 104 disable_callback, |
105 sync_factory), | 105 sync_factory), |
106 blocked_(false), | 106 blocked_(false), |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 non_ui_dtc_.get(), | 513 non_ui_dtc_.get(), |
514 FROM_HERE, | 514 FROM_HERE, |
515 std::string("Test"))); | 515 std::string("Test"))); |
516 WaitForDTC(); | 516 WaitForDTC(); |
517 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); | 517 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); |
518 EXPECT_TRUE(disable_callback_invoked_); | 518 EXPECT_TRUE(disable_callback_invoked_); |
519 } | 519 } |
520 | 520 |
521 } // namespace | 521 } // namespace |
522 | 522 |
523 } // namespace browser_sync | 523 } // namespace sync_driver |
OLD | NEW |