Commit 200318d5 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

SyncDisableObserverTest: Use TestSyncService instead of FakeSyncService

syncer::TestSyncService already supports most of the state that's
required here, so this lets us remove a bunch of boilerplate.

Bug: 859874
Change-Id: I3c45e341f31c199176dd8173b6a858a8c704c15f
Reviewed-on: https://chromium-review.googlesource.com/c/1335582
Commit-Queue: Ilya Sherman <isherman@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608506}
parent 346efa24
......@@ -5,8 +5,8 @@
#include "components/ukm/observers/sync_disable_observer.h"
#include "base/observer_list.h"
#include "components/sync/driver/fake_sync_service.h"
#include "components/sync/driver/sync_token_status.h"
#include "components/sync/driver/test_sync_service.h"
#include "components/sync/engine/connection_status.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/unified_consent/pref_names.h"
......@@ -21,18 +21,18 @@ namespace ukm {
namespace {
class MockSyncService : public syncer::FakeSyncService {
class MockSyncService : public syncer::TestSyncService {
public:
MockSyncService() {}
MockSyncService() { SetTransportState(TransportState::INITIALIZING); }
~MockSyncService() override { Shutdown(); }
void SetStatus(bool has_passphrase, bool history_enabled) {
initialized_ = true;
has_passphrase_ = has_passphrase;
preferred_data_types_ =
SetTransportState(TransportState::ACTIVE);
SetIsUsingSecondaryPassphrase(has_passphrase);
SetPreferredDataTypes(
history_enabled
? syncer::ModelTypeSet(syncer::HISTORY_DELETE_DIRECTIVES)
: syncer::ModelTypeSet();
: syncer::ModelTypeSet());
NotifyObserversOfStateChanged();
}
......@@ -54,30 +54,20 @@ class MockSyncService : public syncer::FakeSyncService {
}
private:
// syncer::FakeSyncService:
// syncer::TestSyncService:
void AddObserver(syncer::SyncServiceObserver* observer) override {
observers_.AddObserver(observer);
}
void RemoveObserver(syncer::SyncServiceObserver* observer) override {
observers_.RemoveObserver(observer);
}
TransportState GetTransportState() const override {
return initialized_ ? TransportState::ACTIVE : TransportState::INITIALIZING;
}
bool IsUsingSecondaryPassphrase() const override { return has_passphrase_; }
syncer::ModelTypeSet GetPreferredDataTypes() const override {
return preferred_data_types_;
}
syncer::SyncTokenStatus GetSyncTokenStatus() const override {
syncer::SyncTokenStatus status;
status.connection_status = connection_status_;
return status;
}
bool initialized_ = false;
bool has_passphrase_ = false;
syncer::ConnectionStatus connection_status_ = syncer::CONNECTION_OK;
syncer::ModelTypeSet preferred_data_types_;
// The list of observers of the SyncService state.
base::ObserverList<syncer::SyncServiceObserver>::Unchecked observers_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment