OLD | NEW |
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 "chrome/common/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 "chrome/common/chrome_switches.h" |
10 #include "chrome/common/chrome_version_info.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "url/gurl.h" | 11 #include "url/gurl.h" |
13 | 12 |
14 namespace { | 13 namespace { |
15 | 14 |
16 TEST(SyncUtilTest, GetSyncServiceURLWithoutCommandLineSwitch) { | 15 TEST(SyncUtilTest, GetSyncServiceURLWithoutCommandLineSwitch) { |
17 // 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 |
18 // on the channel (e.g. beta). | 17 // on the channel (e.g. beta). |
19 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 18 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
20 std::string url = GetSyncServiceURL(command_line).spec(); | 19 std::string url = GetSyncServiceURL(command_line).spec(); |
(...skipping 11 matching lines...) Expand all Loading... |
32 TEST(SyncUtilTest, GetSyncServiceURLWithBadCommandLineSwitch) { | 31 TEST(SyncUtilTest, GetSyncServiceURLWithBadCommandLineSwitch) { |
33 // If the command line value is not a valid url it is ignored. | 32 // If the command line value is not a valid url it is ignored. |
34 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 33 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
35 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "invalid_url"); | 34 command_line.AppendSwitchASCII(switches::kSyncServiceURL, "invalid_url"); |
36 std::string url = GetSyncServiceURL(command_line).spec(); | 35 std::string url = GetSyncServiceURL(command_line).spec(); |
37 ASSERT_TRUE(internal::kSyncServerUrl == url || | 36 ASSERT_TRUE(internal::kSyncServerUrl == url || |
38 internal::kSyncDevServerUrl == url); | 37 internal::kSyncDevServerUrl == url); |
39 } | 38 } |
40 | 39 |
41 TEST(SyncUtilTest, MakeUserAgentForSync) { | 40 TEST(SyncUtilTest, MakeUserAgentForSync) { |
42 chrome::VersionInfo version_info; | 41 std::string user_agent = MakeUserAgentForSync("TEST"); |
43 std::string user_agent = MakeUserAgentForSync(version_info, "TEST"); | |
44 ASSERT_TRUE(base::StartsWith(user_agent, "Chrome TEST", | 42 ASSERT_TRUE(base::StartsWith(user_agent, "Chrome TEST", |
45 base::CompareCase::SENSITIVE)); | 43 base::CompareCase::SENSITIVE)); |
46 } | 44 } |
47 | 45 |
48 } // namespace | 46 } // namespace |
OLD | NEW |