Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: components/sync_driver/sync_util_unittest.cc

Issue 1308313003: Componentize chrome/common/sync_util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/sync_util.h" 5 #include "components/sync_driver/sync_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "components/sync_driver/sync_driver_switches.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace { 13 namespace {
14 14
15 TEST(SyncUtilTest, GetSyncServiceURLWithoutCommandLineSwitch) { 15 TEST(SyncUtilTest, GetSyncServiceURLWithoutCommandLineSwitch) {
16 // If the command line is not set the url is one of two constants chosen based 16 // If the command line is not set the url is one of two constants chosen based
17 // on the channel (e.g. beta). 17 // on the channel (e.g. beta).
18 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 18 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
19 std::string url = GetSyncServiceURL(command_line).spec(); 19 std::string url =
20 GetSyncServiceURL(command_line, version_info::Channel::BETA).spec();
20 ASSERT_TRUE(internal::kSyncServerUrl == url || 21 ASSERT_TRUE(internal::kSyncServerUrl == url ||
21 internal::kSyncDevServerUrl == url); 22 internal::kSyncDevServerUrl == url);
22 } 23 }
23 24
24 TEST(SyncUtilTest, GetSyncServiceURLWithCommandLineSwitch) { 25 TEST(SyncUtilTest, GetSyncServiceURLWithCommandLineSwitch) {
25 // See that we can set the URL via the command line. 26 // See that we can set the URL via the command line.
26 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 27 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
27 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar"); 28 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "https://foo/bar");
28 ASSERT_EQ("https://foo/bar", GetSyncServiceURL(command_line).spec()); 29 ASSERT_EQ(
30 "https://foo/bar",
31 GetSyncServiceURL(command_line, version_info::Channel::UNKNOWN).spec());
29 } 32 }
30 33
31 TEST(SyncUtilTest, GetSyncServiceURLWithBadCommandLineSwitch) { 34 TEST(SyncUtilTest, GetSyncServiceURLWithBadCommandLineSwitch) {
32 // If the command line value is not a valid url it is ignored. 35 // If the command line value is not a valid url it is ignored.
33 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); 36 base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
34 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "invalid_url"); 37 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "invalid_url");
35 std::string url = GetSyncServiceURL(command_line).spec(); 38 std::string url =
39 GetSyncServiceURL(command_line, version_info::Channel::UNKNOWN).spec();
36 ASSERT_TRUE(internal::kSyncServerUrl == url || 40 ASSERT_TRUE(internal::kSyncServerUrl == url ||
37 internal::kSyncDevServerUrl == url); 41 internal::kSyncDevServerUrl == url);
38 } 42 }
39 43
40 TEST(SyncUtilTest, MakeUserAgentForSync) { 44 TEST(SyncUtilTest, MakeUserAgentForSync) {
41 std::string user_agent = MakeUserAgentForSync("TEST"); 45 std::string user_agent =
46 MakeUserAgentForSync("TEST", version_info::Channel::UNKNOWN);
42 ASSERT_TRUE(base::StartsWith(user_agent, "Chrome TEST", 47 ASSERT_TRUE(base::StartsWith(user_agent, "Chrome TEST",
43 base::CompareCase::SENSITIVE)); 48 base::CompareCase::SENSITIVE));
44 } 49 }
45 50
46 } // namespace 51 } // namespace
OLDNEW
« components/sync_driver/sync_util.cc ('K') | « components/sync_driver/sync_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698