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.
5 #ifndef COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_
6 #define COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_
8 #include "components/sync_driver/generic_change_processor.h"
10 #include "components/sync_driver/generic_change_processor_factory.h"
11 #include "components/sync_driver/sync_api_component_factory.h"
12 #include "sync/api/sync_error.h"
14 namespace browser_sync
{
16 // A fake GenericChangeProcessor that can return arbitrary values.
17 class FakeGenericChangeProcessor
: public GenericChangeProcessor
{
19 FakeGenericChangeProcessor(SyncApiComponentFactory
* sync_factory
);
20 virtual ~FakeGenericChangeProcessor();
22 // Setters for GenericChangeProcessor implementation results.
23 void set_sync_model_has_user_created_nodes(bool has_nodes
);
24 void set_sync_model_has_user_created_nodes_success(bool success
);
26 // GenericChangeProcessor implementations.
27 virtual syncer::SyncError
ProcessSyncChanges(
28 const tracked_objects::Location
& from_here
,
29 const syncer::SyncChangeList
& change_list
) OVERRIDE
;
30 virtual syncer::SyncError
GetAllSyncDataReturnError(
31 syncer::ModelType type
,
32 syncer::SyncDataList
* data
) const OVERRIDE
;
33 virtual bool GetDataTypeContext(syncer::ModelType type
,
34 std::string
* context
) const OVERRIDE
;
35 virtual int GetSyncCountForType(syncer::ModelType type
) OVERRIDE
;
36 virtual bool SyncModelHasUserCreatedNodes(syncer::ModelType type
,
37 bool* has_nodes
) OVERRIDE
;
38 virtual bool CryptoReadyIfNecessary(syncer::ModelType type
) OVERRIDE
;
41 bool sync_model_has_user_created_nodes_
;
42 bool sync_model_has_user_created_nodes_success_
;
45 // Define a factory for FakeGenericChangeProcessor for convenience.
46 class FakeGenericChangeProcessorFactory
: public GenericChangeProcessorFactory
{
48 explicit FakeGenericChangeProcessorFactory(
49 scoped_ptr
<FakeGenericChangeProcessor
> processor
);
50 virtual ~FakeGenericChangeProcessorFactory();
51 virtual scoped_ptr
<GenericChangeProcessor
> CreateGenericChangeProcessor(
52 syncer::UserShare
* user_share
,
53 browser_sync::DataTypeErrorHandler
* error_handler
,
54 const base::WeakPtr
<syncer::SyncableService
>& local_service
,
55 const base::WeakPtr
<syncer::SyncMergeResult
>& merge_result
,
56 SyncApiComponentFactory
* sync_factory
) OVERRIDE
;
59 scoped_ptr
<FakeGenericChangeProcessor
> processor_
;
60 DISALLOW_COPY_AND_ASSIGN(FakeGenericChangeProcessorFactory
);
63 } // namespace browser_sync
65 #endif // COMPONENTS_SYNC_DRIVER_FAKE_GENERIC_CHANGE_PROCESSOR_H_