summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordaniimms <daniimms@amazon.com>2015-02-04 15:14:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-04 23:14:52 +0000
commit2828c829d001e239e66ba0f7313d37d0cb6e3352 (patch)
tree46c1e0a8f95fd6ad4f0f41ba0db5ab0be7c0cff8
parent6d97ebda5078f7f62e6dd47f316ad43fabb64d07 (diff)
downloadchromium_src-2828c829d001e239e66ba0f7313d37d0cb6e3352.zip
chromium_src-2828c829d001e239e66ba0f7313d37d0cb6e3352.tar.gz
chromium_src-2828c829d001e239e66ba0f7313d37d0cb6e3352.tar.bz2
Add unit tests for the 'disable-sync' flag
BUG=454940 Review URL: https://codereview.chromium.org/902443002 Cr-Commit-Position: refs/heads/master@{#314673}
-rw-r--r--chrome/browser/sync/profile_sync_service_factory_unittest.cc27
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc11
-rw-r--r--chrome/chrome_tests_unit.gypi1
3 files changed, 39 insertions, 0 deletions
diff --git a/chrome/browser/sync/profile_sync_service_factory_unittest.cc b/chrome/browser/sync/profile_sync_service_factory_unittest.cc
new file mode 100644
index 0000000..e3c2da1
--- /dev/null
+++ b/chrome/browser/sync/profile_sync_service_factory_unittest.cc
@@ -0,0 +1,27 @@
+// 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()));
+}
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index 566b369..044542c 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -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
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 73ea520..b1eda9a 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -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',