OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "sync/test/engine/mock_update_handler.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "sync/internal_api/public/base/model_type.h" | |
10 | |
11 namespace syncer { | |
12 | |
13 MockUpdateHandler::MockUpdateHandler(ModelType type) | |
14 : apply_updates_count_(0), | |
15 passive_apply_updates_count_(0) { | |
16 progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type)); | |
17 const std::string& token_str = | |
18 std::string("Mock token: ") + std::string(ModelTypeToString(type)); | |
19 progress_marker_.set_token(token_str); | |
20 } | |
21 | |
22 MockUpdateHandler::~MockUpdateHandler() {} | |
23 | |
24 bool MockUpdateHandler::IsInitialSyncEnded() const { | |
25 return false; | |
26 } | |
27 | |
28 void MockUpdateHandler::GetDownloadProgress( | |
29 sync_pb::DataTypeProgressMarker* progress_marker) const { | |
30 progress_marker->CopyFrom(progress_marker_); | |
31 } | |
32 | |
33 void MockUpdateHandler::GetDataTypeContext( | |
34 sync_pb::DataTypeContext* context) const { | |
35 context->Clear(); | |
36 } | |
37 | |
38 SyncerError MockUpdateHandler::ProcessGetUpdatesResponse( | |
39 const sync_pb::DataTypeProgressMarker& progress_marker, | |
40 const sync_pb::DataTypeContext& mutated_context, | |
41 const SyncEntityList& applicable_updates, | |
42 sessions::StatusController* status) { | |
43 progress_marker_.CopyFrom(progress_marker); | |
44 return syncer::SYNCER_OK; | |
45 } | |
46 | |
47 void MockUpdateHandler::ApplyUpdates(sessions::StatusController* status) { | |
48 apply_updates_count_++; | |
49 } | |
50 | |
51 void MockUpdateHandler::PassiveApplyUpdates( | |
52 sessions::StatusController* status) { | |
53 passive_apply_updates_count_++; | |
54 } | |
55 | |
56 int MockUpdateHandler::GetApplyUpdatesCount() { | |
57 return apply_updates_count_; | |
58 } | |
59 | |
60 int MockUpdateHandler::GetPassiveApplyUpdatesCount() { | |
61 return passive_apply_updates_count_; | |
62 } | |
63 | |
64 } // namespace syncer | |
OLD | NEW |