OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents( | 52 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents( |
53 model_associator_, change_processor_))); | 53 model_associator_, change_processor_))); |
54 } | 54 } |
55 | 55 |
56 void SetAssociateExpectations() { | 56 void SetAssociateExpectations() { |
57 EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). | 57 EXPECT_CALL(*model_associator_, CryptoReadyIfNecessary()). |
58 WillRepeatedly(Return(true)); | 58 WillRepeatedly(Return(true)); |
59 EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). | 59 EXPECT_CALL(*model_associator_, SyncModelHasUserCreatedNodes(_)). |
60 WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true))); | 60 WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true))); |
61 EXPECT_CALL(*model_associator_, AssociateModels()). | 61 EXPECT_CALL(*model_associator_, AssociateModels()). |
62 WillRepeatedly(Return(SyncError())); | 62 WillRepeatedly(Return(csync::SyncError())); |
63 } | 63 } |
64 | 64 |
65 void SetActivateExpectations() { | 65 void SetActivateExpectations() { |
66 EXPECT_CALL(service_, ActivateDataType(_, _, _)); | 66 EXPECT_CALL(service_, ActivateDataType(_, _, _)); |
67 } | 67 } |
68 | 68 |
69 void SetStopExpectations() { | 69 void SetStopExpectations() { |
70 EXPECT_CALL(service_, DeactivateDataType(_)); | 70 EXPECT_CALL(service_, DeactivateDataType(_)); |
71 EXPECT_CALL(*model_associator_, DisassociateModels()). | 71 EXPECT_CALL(*model_associator_, DisassociateModels()). |
72 WillOnce(Return(SyncError())); | 72 WillOnce(Return(csync::SyncError())); |
73 } | 73 } |
74 | 74 |
75 void PumpLoop() { | 75 void PumpLoop() { |
76 message_loop_.RunAllPending(); | 76 message_loop_.RunAllPending(); |
77 } | 77 } |
78 | 78 |
79 void Start() { | 79 void Start() { |
80 theme_dtc_->LoadModels( | 80 theme_dtc_->LoadModels( |
81 base::Bind(&ModelLoadCallbackMock::Run, | 81 base::Bind(&ModelLoadCallbackMock::Run, |
82 base::Unretained(&model_load_callback_))); | 82 base::Unretained(&model_load_callback_))); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true))); | 125 WillRepeatedly(DoAll(SetArgumentPointee<0>(true), Return(true))); |
126 | 126 |
127 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); | 127 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); |
128 Start(); | 128 Start(); |
129 } | 129 } |
130 | 130 |
131 TEST_F(SyncThemeDataTypeControllerTest, StartAssociationFailed) { | 131 TEST_F(SyncThemeDataTypeControllerTest, StartAssociationFailed) { |
132 SetStartExpectations(); | 132 SetStartExpectations(); |
133 SetAssociateExpectations(); | 133 SetAssociateExpectations(); |
134 EXPECT_CALL(*model_associator_, AssociateModels()). | 134 EXPECT_CALL(*model_associator_, AssociateModels()). |
135 WillRepeatedly(Return(SyncError(FROM_HERE, "Error", syncable::THEMES))); | 135 WillRepeatedly( |
| 136 Return(csync::SyncError(FROM_HERE, "Error", syncable::THEMES))); |
136 | 137 |
137 EXPECT_CALL(start_callback_, | 138 EXPECT_CALL(start_callback_, |
138 Run(DataTypeController::ASSOCIATION_FAILED, _)); | 139 Run(DataTypeController::ASSOCIATION_FAILED, _)); |
139 Start(); | 140 Start(); |
140 EXPECT_EQ(DataTypeController::DISABLED, theme_dtc_->state()); | 141 EXPECT_EQ(DataTypeController::DISABLED, theme_dtc_->state()); |
141 } | 142 } |
142 | 143 |
143 TEST_F(SyncThemeDataTypeControllerTest, | 144 TEST_F(SyncThemeDataTypeControllerTest, |
144 StartAssociationTriggersUnrecoverableError) { | 145 StartAssociationTriggersUnrecoverableError) { |
145 SetStartExpectations(); | 146 SetStartExpectations(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 WillOnce(InvokeWithoutArgs(theme_dtc_.get(), | 181 WillOnce(InvokeWithoutArgs(theme_dtc_.get(), |
181 &ThemeDataTypeController::Stop)); | 182 &ThemeDataTypeController::Stop)); |
182 SetStopExpectations(); | 183 SetStopExpectations(); |
183 | 184 |
184 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); | 185 EXPECT_CALL(start_callback_, Run(DataTypeController::OK, _)); |
185 Start(); | 186 Start(); |
186 // This should cause theme_dtc_->Stop() to be called. | 187 // This should cause theme_dtc_->Stop() to be called. |
187 theme_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); | 188 theme_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); |
188 PumpLoop(); | 189 PumpLoop(); |
189 } | 190 } |
OLD | NEW |