| 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 28 matching lines...) Expand all Loading... |
| 39 public: | 39 public: |
| 40 FrontendDataTypeControllerFake( | 40 FrontendDataTypeControllerFake( |
| 41 ProfileSyncComponentsFactory* profile_sync_factory, | 41 ProfileSyncComponentsFactory* profile_sync_factory, |
| 42 Profile* profile, | 42 Profile* profile, |
| 43 ProfileSyncService* sync_service, | 43 ProfileSyncService* sync_service, |
| 44 FrontendDataTypeControllerMock* mock) | 44 FrontendDataTypeControllerMock* mock) |
| 45 : FrontendDataTypeController(profile_sync_factory, | 45 : FrontendDataTypeController(profile_sync_factory, |
| 46 profile, | 46 profile, |
| 47 sync_service), | 47 sync_service), |
| 48 mock_(mock) {} | 48 mock_(mock) {} |
| 49 virtual syncer::ModelType type() const { return syncer::BOOKMARKS; } | 49 virtual syncer::ModelType type() const OVERRIDE { return syncer::BOOKMARKS; } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 virtual void CreateSyncComponents() { | 52 virtual void CreateSyncComponents() OVERRIDE { |
| 53 ProfileSyncComponentsFactory::SyncComponents sync_components = | 53 ProfileSyncComponentsFactory::SyncComponents sync_components = |
| 54 profile_sync_factory_-> | 54 profile_sync_factory_-> |
| 55 CreateBookmarkSyncComponents(sync_service_, this); | 55 CreateBookmarkSyncComponents(sync_service_, this); |
| 56 model_associator_.reset(sync_components.model_associator); | 56 model_associator_.reset(sync_components.model_associator); |
| 57 change_processor_.reset(sync_components.change_processor); | 57 change_processor_.reset(sync_components.change_processor); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // We mock the following methods because their default implementations do | 60 // We mock the following methods because their default implementations do |
| 61 // nothing, but we still want to make sure they're called appropriately. | 61 // nothing, but we still want to make sure they're called appropriately. |
| 62 virtual bool StartModels() { | 62 virtual bool StartModels() OVERRIDE { |
| 63 return mock_->StartModels(); | 63 return mock_->StartModels(); |
| 64 } | 64 } |
| 65 virtual void CleanUpState() { | 65 virtual void CleanUpState() OVERRIDE { |
| 66 mock_->CleanUpState(); | 66 mock_->CleanUpState(); |
| 67 } | 67 } |
| 68 virtual void RecordUnrecoverableError( | 68 virtual void RecordUnrecoverableError( |
| 69 const tracked_objects::Location& from_here, | 69 const tracked_objects::Location& from_here, |
| 70 const std::string& message) { | 70 const std::string& message) OVERRIDE { |
| 71 mock_->RecordUnrecoverableError(from_here, message); | 71 mock_->RecordUnrecoverableError(from_here, message); |
| 72 } | 72 } |
| 73 virtual void RecordAssociationTime(base::TimeDelta time) { | 73 virtual void RecordAssociationTime(base::TimeDelta time) OVERRIDE { |
| 74 mock_->RecordAssociationTime(time); | 74 mock_->RecordAssociationTime(time); |
| 75 } | 75 } |
| 76 virtual void RecordStartFailure(DataTypeController::StartResult result) { | 76 virtual void RecordStartFailure( |
| 77 DataTypeController::StartResult result) OVERRIDE { |
| 77 mock_->RecordStartFailure(result); | 78 mock_->RecordStartFailure(result); |
| 78 } | 79 } |
| 79 private: | 80 private: |
| 80 virtual ~FrontendDataTypeControllerFake() {} | 81 virtual ~FrontendDataTypeControllerFake() {} |
| 81 FrontendDataTypeControllerMock* mock_; | 82 FrontendDataTypeControllerMock* mock_; |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 class SyncFrontendDataTypeControllerTest : public testing::Test { | 85 class SyncFrontendDataTypeControllerTest : public testing::Test { |
| 85 public: | 86 public: |
| 86 SyncFrontendDataTypeControllerTest() | 87 SyncFrontendDataTypeControllerTest() |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 &FrontendDataTypeController::Stop)); | 267 &FrontendDataTypeController::Stop)); |
| 267 SetStopExpectations(); | 268 SetStopExpectations(); |
| 268 EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); | 269 EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
| 269 Start(); | 270 Start(); |
| 270 EXPECT_EQ(DataTypeController::RUNNING, frontend_dtc_->state()); | 271 EXPECT_EQ(DataTypeController::RUNNING, frontend_dtc_->state()); |
| 271 // This should cause frontend_dtc_->Stop() to be called. | 272 // This should cause frontend_dtc_->Stop() to be called. |
| 272 frontend_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); | 273 frontend_dtc_->OnSingleDatatypeUnrecoverableError(FROM_HERE, "Test"); |
| 273 PumpLoop(); | 274 PumpLoop(); |
| 274 EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); | 275 EXPECT_EQ(DataTypeController::NOT_RUNNING, frontend_dtc_->state()); |
| 275 } | 276 } |
| OLD | NEW |