OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 temp_dir.path().AppendASCII("applications") | 132 temp_dir.path().AppendASCII("applications") |
133 .AppendASCII(kTemplateFilename), | 133 .AppendASCII(kTemplateFilename), |
134 kTestData2, strlen(kTestData2))); | 134 kTestData2, strlen(kTestData2))); |
135 std::string contents; | 135 std::string contents; |
136 ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env, | 136 ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env, |
137 &contents)); | 137 &contents)); |
138 EXPECT_EQ(kTestData1, contents); | 138 EXPECT_EQ(kTestData1, contents); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 TEST(ShellIntegrationTest, GetDesktopShortcutFilename) { | 142 TEST(ShellIntegrationTest, GetWebShortcutFilename) { |
143 const struct { | 143 const struct { |
144 const FilePath::CharType* path; | 144 const FilePath::CharType* path; |
145 const char* url; | 145 const char* url; |
146 } test_cases[] = { | 146 } test_cases[] = { |
147 { FPL("http___foo_.desktop"), "http://foo" }, | 147 { FPL("http___foo_.desktop"), "http://foo" }, |
148 { FPL("http___foo_bar_.desktop"), "http://foo/bar/" }, | 148 { FPL("http___foo_bar_.desktop"), "http://foo/bar/" }, |
149 { FPL("http___foo_bar_a=b&c=d.desktop"), "http://foo/bar?a=b&c=d" }, | 149 { FPL("http___foo_bar_a=b&c=d.desktop"), "http://foo/bar?a=b&c=d" }, |
150 | 150 |
151 // Now we're starting to be more evil... | 151 // Now we're starting to be more evil... |
152 { FPL("http___foo_.desktop"), "http://foo/bar/baz/../../../../../" }, | 152 { FPL("http___foo_.desktop"), "http://foo/bar/baz/../../../../../" }, |
153 { FPL("http___foo_.desktop"), "http://foo/bar/././../baz/././../" }, | 153 { FPL("http___foo_.desktop"), "http://foo/bar/././../baz/././../" }, |
154 { FPL("http___.._.desktop"), "http://../../../../" }, | 154 { FPL("http___.._.desktop"), "http://../../../../" }, |
155 }; | 155 }; |
156 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { | 156 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { |
157 EXPECT_EQ(std::string(chrome::kBrowserProcessExecutableName) + "-" + | 157 EXPECT_EQ(std::string(chrome::kBrowserProcessExecutableName) + "-" + |
158 test_cases[i].path, | 158 test_cases[i].path, |
159 ShellIntegrationLinux::GetDesktopShortcutFilename( | 159 ShellIntegrationLinux::GetWebShortcutFilename( |
160 GURL(test_cases[i].url)).value()) << | 160 GURL(test_cases[i].url)).value()) << |
161 " while testing " << test_cases[i].url; | 161 " while testing " << test_cases[i].url; |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 TEST(ShellIntegrationTest, GetDesktopFileContents) { | 165 TEST(ShellIntegrationTest, GetDesktopFileContents) { |
166 const struct { | 166 const struct { |
167 const char* url; | 167 const char* url; |
168 const char* title; | 168 const char* title; |
169 const char* icon_name; | 169 const char* icon_name; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // Non-default profile path should get chrome::kBrowserAppID joined with | 387 // Non-default profile path should get chrome::kBrowserAppID joined with |
388 // profile info. | 388 // profile info. |
389 FilePath profile_path(FILE_PATH_LITERAL("root")); | 389 FilePath profile_path(FILE_PATH_LITERAL("root")); |
390 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); | 390 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); |
391 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); | 391 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); |
392 EXPECT_EQ(base_app_id + L".udd.UserDataTest", | 392 EXPECT_EQ(base_app_id + L".udd.UserDataTest", |
393 ShellIntegration::GetAppModelIdForProfile(base_app_id, | 393 ShellIntegration::GetAppModelIdForProfile(base_app_id, |
394 profile_path)); | 394 profile_path)); |
395 } | 395 } |
396 #endif | 396 #endif |
OLD | NEW |