OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/install_static/install_util.h" | 5 #include "chrome/install_static/install_util.h" |
6 | 6 |
7 #include <tuple> | 7 #include <tuple> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 EXPECT_FALSE(MatchPattern(L"Foo", L"F*b")); | 32 EXPECT_FALSE(MatchPattern(L"Foo", L"F*b")); |
33 EXPECT_TRUE(MatchPattern(L"abcd", L"*c*d")); | 33 EXPECT_TRUE(MatchPattern(L"abcd", L"*c*d")); |
34 EXPECT_TRUE(MatchPattern(L"abcd", L"*?c*d")); | 34 EXPECT_TRUE(MatchPattern(L"abcd", L"*?c*d")); |
35 EXPECT_FALSE(MatchPattern(L"abcd", L"abcd*efgh")); | 35 EXPECT_FALSE(MatchPattern(L"abcd", L"abcd*efgh")); |
36 EXPECT_TRUE(MatchPattern(L"foobarabc", L"*bar*")); | 36 EXPECT_TRUE(MatchPattern(L"foobarabc", L"*bar*")); |
37 } | 37 } |
38 | 38 |
39 // Tests the install_static::GetSwitchValueFromCommandLine function. | 39 // Tests the install_static::GetSwitchValueFromCommandLine function. |
40 TEST(InstallStaticTest, GetSwitchValueFromCommandLineTest) { | 40 TEST(InstallStaticTest, GetSwitchValueFromCommandLineTest) { |
41 // Simple case with one switch. | 41 // Simple case with one switch. |
42 std::string value = | 42 std::wstring value = |
43 GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=bar", "type"); | 43 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=bar", L"type"); |
44 EXPECT_EQ("bar", value); | 44 EXPECT_EQ(L"bar", value); |
45 | 45 |
46 // Multiple switches with trailing spaces between them. | 46 // Multiple switches with trailing spaces between them. |
47 value = GetSwitchValueFromCommandLine( | 47 value = GetSwitchValueFromCommandLine( |
48 "c:\\temp\\bleh.exe --type=bar --abc=def bleh", "abc"); | 48 L"c:\\temp\\bleh.exe --type=bar --abc=def bleh", L"abc"); |
49 EXPECT_EQ("def", value); | 49 EXPECT_EQ(L"def", value); |
50 | 50 |
51 // Multiple switches with trailing spaces and tabs between them. | 51 // Multiple switches with trailing spaces and tabs between them. |
52 value = GetSwitchValueFromCommandLine( | 52 value = GetSwitchValueFromCommandLine( |
53 "c:\\temp\\bleh.exe --type=bar \t\t\t --abc=def bleh", "abc"); | 53 L"c:\\temp\\bleh.exe --type=bar \t\t\t --abc=def bleh", L"abc"); |
54 EXPECT_EQ("def", value); | 54 EXPECT_EQ(L"def", value); |
55 | 55 |
56 // Non existent switch. | 56 // Non existent switch. |
57 value = GetSwitchValueFromCommandLine( | 57 value = GetSwitchValueFromCommandLine( |
58 "c:\\temp\\bleh.exe --foo=bar --abc=def bleh", "type"); | 58 L"c:\\temp\\bleh.exe --foo=bar --abc=def bleh", L"type"); |
59 EXPECT_EQ("", value); | 59 EXPECT_EQ(L"", value); |
60 | 60 |
61 // Non existent switch. | 61 // Non existent switch. |
62 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe", "type"); | 62 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe", L"type"); |
63 EXPECT_EQ("", value); | 63 EXPECT_EQ(L"", value); |
64 | 64 |
65 // Non existent switch. | 65 // Non existent switch. |
66 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe type=bar", "type"); | 66 value = |
67 EXPECT_EQ("", value); | 67 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe type=bar", L"type"); |
| 68 EXPECT_EQ(L"", value); |
68 | 69 |
69 // Trailing spaces after the switch. | 70 // Trailing spaces after the switch. |
70 value = GetSwitchValueFromCommandLine( | 71 value = GetSwitchValueFromCommandLine( |
71 "c:\\temp\\bleh.exe --type=bar \t\t", "type"); | 72 L"c:\\temp\\bleh.exe --type=bar \t\t", L"type"); |
72 EXPECT_EQ("bar", value); | 73 EXPECT_EQ(L"bar", value); |
73 | 74 |
74 // Multiple switches with trailing spaces and tabs between them. | 75 // Multiple switches with trailing spaces and tabs between them. |
75 value = GetSwitchValueFromCommandLine( | 76 value = GetSwitchValueFromCommandLine( |
76 "c:\\temp\\bleh.exe --type=bar \t\t --foo=bleh", "foo"); | 77 L"c:\\temp\\bleh.exe --type=bar \t\t --foo=bleh", L"foo"); |
77 EXPECT_EQ("bleh", value); | 78 EXPECT_EQ(L"bleh", value); |
78 | 79 |
79 // Nothing after a switch. | 80 // Nothing after a switch. |
80 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=", "type"); | 81 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=", L"type"); |
81 EXPECT_TRUE(value.empty()); | 82 EXPECT_TRUE(value.empty()); |
82 | 83 |
83 // Whitespace after a switch. | 84 // Whitespace after a switch. |
84 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= ", "type"); | 85 value = |
| 86 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type= ", L"type"); |
85 EXPECT_TRUE(value.empty()); | 87 EXPECT_TRUE(value.empty()); |
86 | 88 |
87 // Just tabs after a switch. | 89 // Just tabs after a switch. |
88 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\t", | 90 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=\t\t\t", |
89 "type"); | 91 L"type"); |
90 EXPECT_TRUE(value.empty()); | 92 EXPECT_TRUE(value.empty()); |
91 | 93 |
92 // Whitespace after the "=" before the value. | 94 // Whitespace after the "=" before the value. |
93 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= bar", | 95 value = |
94 "type"); | 96 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type= bar", L"type"); |
95 EXPECT_EQ("bar", value); | 97 EXPECT_EQ(L"bar", value); |
96 | 98 |
97 // Tabs after the "=" before the value. | 99 // Tabs after the "=" before the value. |
98 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\tbar", | 100 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=\t\t\tbar", |
99 "type"); | 101 L"type"); |
100 EXPECT_EQ(value, "bar"); | 102 EXPECT_EQ(value, L"bar"); |
101 } | 103 } |
102 | 104 |
103 TEST(InstallStaticTest, BrowserProcessTest) { | 105 TEST(InstallStaticTest, BrowserProcessTest) { |
104 EXPECT_EQ(ProcessType::UNINITIALIZED, g_process_type); | 106 EXPECT_EQ(ProcessType::UNINITIALIZED, g_process_type); |
105 InitializeProcessType(); | 107 InitializeProcessType(); |
106 EXPECT_FALSE(IsNonBrowserProcess()); | 108 EXPECT_FALSE(IsNonBrowserProcess()); |
107 } | 109 } |
108 | 110 |
109 class InstallStaticUtilTest | 111 class InstallStaticUtilTest |
110 : public ::testing::TestWithParam< | 112 : public ::testing::TestWithParam< |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 std::wstring expected = default_channel(); | 270 std::wstring expected = default_channel(); |
269 if (multi_install()) { | 271 if (multi_install()) { |
270 if (expected.empty()) | 272 if (expected.empty()) |
271 expected = L"m"; | 273 expected = L"m"; |
272 else | 274 else |
273 expected += L"-m"; | 275 expected += L"-m"; |
274 } | 276 } |
275 EXPECT_EQ(expected, GetChromeChannelName(true)); | 277 EXPECT_EQ(expected, GetChromeChannelName(true)); |
276 } | 278 } |
277 | 279 |
278 TEST_P(InstallStaticUtilTest, GetDefaultUserDataDirectory) { | |
279 std::wstring user_data_directory; | |
280 ASSERT_TRUE(GetDefaultUserDataDirectory(&user_data_directory)); | |
281 } | |
282 | |
283 #if defined(GOOGLE_CHROME_BUILD) | 280 #if defined(GOOGLE_CHROME_BUILD) |
284 // Stable supports multi-install at user and system levels. | 281 // Stable supports multi-install at user and system levels. |
285 INSTANTIATE_TEST_CASE_P(Stable, | 282 INSTANTIATE_TEST_CASE_P(Stable, |
286 InstallStaticUtilTest, | 283 InstallStaticUtilTest, |
287 testing::Combine(testing::Values(STABLE_INDEX), | 284 testing::Combine(testing::Values(STABLE_INDEX), |
288 testing::Values("user", "system"), | 285 testing::Values("user", "system"), |
289 testing::Values("single", "multi"))); | 286 testing::Values("single", "multi"))); |
290 // Canary is single-only at user level. | 287 // Canary is single-only at user level. |
291 INSTANTIATE_TEST_CASE_P(Canary, | 288 INSTANTIATE_TEST_CASE_P(Canary, |
292 InstallStaticUtilTest, | 289 InstallStaticUtilTest, |
293 testing::Combine(testing::Values(CANARY_INDEX), | 290 testing::Combine(testing::Values(CANARY_INDEX), |
294 testing::Values("user"), | 291 testing::Values("user"), |
295 testing::Values("single"))); | 292 testing::Values("single"))); |
296 #else // GOOGLE_CHROME_BUILD | 293 #else // GOOGLE_CHROME_BUILD |
297 // Chromium supports multi-install at user and system levels. | 294 // Chromium supports multi-install at user and system levels. |
298 INSTANTIATE_TEST_CASE_P(Chromium, | 295 INSTANTIATE_TEST_CASE_P(Chromium, |
299 InstallStaticUtilTest, | 296 InstallStaticUtilTest, |
300 testing::Combine(testing::Values(CHROMIUM_INDEX), | 297 testing::Combine(testing::Values(CHROMIUM_INDEX), |
301 testing::Values("user", "system"), | 298 testing::Values("user", "system"), |
302 testing::Values("single", "multi"))); | 299 testing::Values("single", "multi"))); |
303 #endif // !GOOGLE_CHROME_BUILD | 300 #endif // !GOOGLE_CHROME_BUILD |
304 | 301 |
305 } // namespace install_static | 302 } // namespace install_static |
OLD | NEW |