| Index: components/wifi_sync/wifi_credential_syncable_service_unittest.cc
|
| diff --git a/components/wifi_sync/wifi_credential_syncable_service_unittest.cc b/components/wifi_sync/wifi_credential_syncable_service_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7169b4f6076789e45f53668ede4a96259b308806
|
| --- /dev/null
|
| +++ b/components/wifi_sync/wifi_credential_syncable_service_unittest.cc
|
| @@ -0,0 +1,81 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/wifi_sync/wifi_credential_syncable_service.h"
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "sync/api/fake_sync_change_processor.h"
|
| +#include "sync/api/sync_error_factory_mock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace wifi_sync {
|
| +
|
| +class WifiCredentialSyncableServiceTest : public testing::Test {
|
| + void SetUp() {
|
| + syncable_service_.reset(new WifiCredentialSyncableService(nullptr));
|
| + sync_change_processor_ = nullptr;
|
| + sync_error_factory_ = nullptr;
|
| + }
|
| +
|
| + protected:
|
| + void StartSyncing() {
|
| + auto change_processor =
|
| + make_scoped_ptr(new syncer::FakeSyncChangeProcessor());
|
| + auto error_factory = make_scoped_ptr(new syncer::SyncErrorFactoryMock());
|
| + sync_change_processor_ = change_processor.get();
|
| + sync_error_factory_ = error_factory.get();
|
| + syncable_service_->MergeDataAndStartSyncing(
|
| + WifiCredentialSyncableService::kModelType,
|
| + syncer::SyncDataList(),
|
| + make_scoped_ptr(change_processor.release()),
|
| + make_scoped_ptr(error_factory.release()));
|
| + }
|
| +
|
| + void StopSyncing() {
|
| + syncable_service_->StopSyncing(WifiCredentialSyncableService::kModelType);
|
| + }
|
| +
|
| + const WifiCredentialSyncableService &GetSyncableService() {
|
| + return *syncable_service_;
|
| + }
|
| +
|
| + syncer::SyncChangeProcessor* GetSyncChangeProcessor() {
|
| + return syncable_service_->sync_processor_.get();
|
| + }
|
| +
|
| + syncer::SyncErrorFactory* GetSyncErrorFactory() {
|
| + return syncable_service_->sync_error_handler_.get();
|
| + }
|
| +
|
| + const syncer::FakeSyncChangeProcessor* sync_change_processor() const {
|
| + return sync_change_processor_;
|
| + }
|
| +
|
| + const syncer::SyncErrorFactoryMock* sync_error_factory() const {
|
| + return sync_error_factory_;
|
| + }
|
| +
|
| + private:
|
| + scoped_ptr<WifiCredentialSyncableService> syncable_service_;
|
| + // When non-null, |fake_sync_change_processor_| and
|
| + // |sync_error_factory_mock_| are owned by |syncable_service_|.
|
| + syncer::FakeSyncChangeProcessor* sync_change_processor_;
|
| + syncer::SyncErrorFactoryMock* sync_error_factory_;
|
| +};
|
| +
|
| +TEST_F(WifiCredentialSyncableServiceTest,
|
| + StartSyncingSetsChangeProcessorAndErrorHandler) {
|
| + StartSyncing();
|
| + EXPECT_EQ(sync_change_processor(), GetSyncChangeProcessor());
|
| + EXPECT_EQ(sync_error_factory(), GetSyncErrorFactory());
|
| +}
|
| +
|
| +TEST_F(WifiCredentialSyncableServiceTest, StopSyncingClearsNonConstFields) {
|
| + StartSyncing();
|
| + StopSyncing();
|
| + EXPECT_EQ(nullptr, GetSyncChangeProcessor());
|
| + EXPECT_EQ(nullptr, GetSyncErrorFactory());
|
| +}
|
| +
|
| +} // namespace wifi_sync
|
|
|