Commit 2828c829 authored by daniimms's avatar daniimms Committed by Commit bot

Add unit tests for the 'disable-sync' flag

BUG=454940

Review URL: https://codereview.chromium.org/902443002

Cr-Commit-Position: refs/heads/master@{#314673}
parent 6d97ebda
// Copyright (c) 2015 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 "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
class ProfileSyncServiceFactoryTest : public testing::Test {
protected:
ProfileSyncServiceFactoryTest() {}
void SetUp() override {
profile_.reset(new TestingProfile());
}
scoped_ptr<Profile> profile_;
};
// Verify that the disable sync flag disables creation of the sync service.
TEST_F(ProfileSyncServiceFactoryTest, DisableSyncFlag) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
EXPECT_EQ(nullptr, ProfileSyncServiceFactory::GetForProfile(profile_.get()));
}
......@@ -639,5 +639,16 @@ TEST_F(ProfileSyncServiceTest, ClearLastSyncedTimeOnSignOut) {
service()->GetLastSyncedTimeString());
}
// Verify that the disable sync flag disables sync.
TEST_F(ProfileSyncServiceTest, DisableSyncFlag) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableSync);
EXPECT_FALSE(ProfileSyncService::IsSyncEnabled());
}
// Verify that no disable sync flag enables sync.
TEST_F(ProfileSyncServiceTest, NoDisableSyncFlag) {
EXPECT_TRUE(ProfileSyncService::IsSyncEnabled());
}
} // namespace
} // namespace browser_sync
......@@ -283,6 +283,7 @@
'browser/sync/profile_sync_service_android_unittest.cc',
'browser/sync/profile_sync_service_autofill_unittest.cc',
'browser/sync/profile_sync_service_bookmark_unittest.cc',
'browser/sync/profile_sync_service_factory_unittest.cc',
'browser/sync/profile_sync_service_startup_unittest.cc',
'browser/sync/profile_sync_service_typed_url_unittest.cc',
'browser/sync/profile_sync_service_unittest.cc',
......
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