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

Side by Side Diff: chrome/browser/shell_integration_linux_unittest.cc

Issue 13864015: Move app launcher and chrome apps shortcut strings into the installer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@migrate_app_id_fix
Patch Set: fix linux unit tests Created 7 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_linux.h" 5 #include "chrome/browser/shell_integration_linux.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <map> 9 #include <map>
10 10
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 base::MessageLoop message_loop; 163 base::MessageLoop message_loop;
164 content::TestBrowserThread file_thread(BrowserThread::FILE, &message_loop); 164 content::TestBrowserThread file_thread(BrowserThread::FILE, &message_loop);
165 165
166 // No existing shortcuts. 166 // No existing shortcuts.
167 { 167 {
168 MockEnvironment env; 168 MockEnvironment env;
169 ShellIntegration::ShortcutLocations result = 169 ShellIntegration::ShortcutLocations result =
170 ShellIntegrationLinux::GetExistingShortcutLocations( 170 ShellIntegrationLinux::GetExistingShortcutLocations(
171 &env, kProfilePath, kExtensionId); 171 &env, kProfilePath, kExtensionId);
172 EXPECT_FALSE(result.on_desktop); 172 EXPECT_FALSE(result.on_desktop);
173 EXPECT_FALSE(result.in_applications_menu); 173 EXPECT_FALSE(result.in_applications_menu_chrome_apps_subdir);
174 string16 GetAppListShortcutName() {
gab 2013/10/03 17:22:49 Why define this inline here and below?? Does this
calamity 2013/10/14 02:24:25 Whoa, how did that happen. removed.
175 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
176 if (channel == chrome::VersionInfo::CHANNEL_CANARY)
177 return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY);
178 return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME);
179 }
180
174 EXPECT_FALSE(result.in_quick_launch_bar); 181 EXPECT_FALSE(result.in_quick_launch_bar);
175 EXPECT_FALSE(result.hidden); 182 EXPECT_FALSE(result.hidden);
176 } 183 }
177 184
178 // Shortcut on desktop. 185 // Shortcut on desktop.
179 { 186 {
180 base::ScopedTempDir temp_dir; 187 base::ScopedTempDir temp_dir;
181 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 188 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
182 base::FilePath desktop_path = temp_dir.path(); 189 base::FilePath desktop_path = temp_dir.path();
183 190
184 MockEnvironment env; 191 MockEnvironment env;
185 ASSERT_TRUE(file_util::CreateDirectory(desktop_path)); 192 ASSERT_TRUE(file_util::CreateDirectory(desktop_path));
186 ASSERT_FALSE(file_util::WriteFile( 193 ASSERT_FALSE(file_util::WriteFile(
187 desktop_path.AppendASCII(kTemplateFilename), 194 desktop_path.AppendASCII(kTemplateFilename),
188 "", 0)); 195 "", 0));
189 ShellIntegration::ShortcutLocations result = 196 ShellIntegration::ShortcutLocations result =
190 ShellIntegrationLinux::GetExistingShortcutLocations( 197 ShellIntegrationLinux::GetExistingShortcutLocations(
191 &env, kProfilePath, kExtensionId, desktop_path); 198 &env, kProfilePath, kExtensionId, desktop_path);
192 EXPECT_TRUE(result.on_desktop); 199 EXPECT_TRUE(result.on_desktop);
193 EXPECT_FALSE(result.in_applications_menu); 200 EXPECT_FALSE(result.in_applications_menu_chrome_apps_subdir);
201 string16 GetAppListShortcutName() {
202 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
203 if (channel == chrome::VersionInfo::CHANNEL_CANARY)
204 return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY);
205 return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME);
206 }
207
194 EXPECT_FALSE(result.in_quick_launch_bar); 208 EXPECT_FALSE(result.in_quick_launch_bar);
195 EXPECT_FALSE(result.hidden); 209 EXPECT_FALSE(result.hidden);
196 } 210 }
197 211
198 // Shortcut in applications directory. 212 // Shortcut in applications directory.
199 { 213 {
200 base::ScopedTempDir temp_dir; 214 base::ScopedTempDir temp_dir;
201 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 215 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
202 base::FilePath apps_path = temp_dir.path().AppendASCII("applications"); 216 base::FilePath apps_path = temp_dir.path().AppendASCII("applications");
203 217
204 MockEnvironment env; 218 MockEnvironment env;
205 env.Set("XDG_DATA_HOME", temp_dir.path().value()); 219 env.Set("XDG_DATA_HOME", temp_dir.path().value());
206 ASSERT_TRUE(file_util::CreateDirectory(apps_path)); 220 ASSERT_TRUE(file_util::CreateDirectory(apps_path));
207 ASSERT_FALSE(file_util::WriteFile( 221 ASSERT_FALSE(file_util::WriteFile(
208 apps_path.AppendASCII(kTemplateFilename), 222 apps_path.AppendASCII(kTemplateFilename),
209 "", 0)); 223 "", 0));
210 ShellIntegration::ShortcutLocations result = 224 ShellIntegration::ShortcutLocations result =
211 ShellIntegrationLinux::GetExistingShortcutLocations( 225 ShellIntegrationLinux::GetExistingShortcutLocations(
212 &env, kProfilePath, kExtensionId); 226 &env, kProfilePath, kExtensionId);
213 EXPECT_FALSE(result.on_desktop); 227 EXPECT_FALSE(result.on_desktop);
214 EXPECT_TRUE(result.in_applications_menu); 228 EXPECT_TRUE(result.in_applications_menu_chrome_apps_subdir);
229 string16 GetAppListShortcutName() {
230 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
231 if (channel == chrome::VersionInfo::CHANNEL_CANARY)
232 return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY);
233 return l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME);
234 }
235
215 EXPECT_FALSE(result.in_quick_launch_bar); 236 EXPECT_FALSE(result.in_quick_launch_bar);
216 EXPECT_FALSE(result.hidden); 237 EXPECT_FALSE(result.hidden);
217 } 238 }
218 239
219 // Shortcut in applications directory with NoDisplay=true. 240 // Shortcut in applications directory with NoDisplay=true.
220 { 241 {
221 base::ScopedTempDir temp_dir; 242 base::ScopedTempDir temp_dir;
222 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 243 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
223 base::FilePath apps_path = temp_dir.path().AppendASCII("applications"); 244 base::FilePath apps_path = temp_dir.path().AppendASCII("applications");
224 245
225 MockEnvironment env; 246 MockEnvironment env;
226 env.Set("XDG_DATA_HOME", temp_dir.path().value()); 247 env.Set("XDG_DATA_HOME", temp_dir.path().value());
227 ASSERT_TRUE(file_util::CreateDirectory(apps_path)); 248 ASSERT_TRUE(file_util::CreateDirectory(apps_path));
228 ASSERT_TRUE(file_util::WriteFile( 249 ASSERT_TRUE(file_util::WriteFile(
229 apps_path.AppendASCII(kTemplateFilename), 250 apps_path.AppendASCII(kTemplateFilename),
230 kNoDisplayDesktopFile, strlen(kNoDisplayDesktopFile))); 251 kNoDisplayDesktopFile, strlen(kNoDisplayDesktopFile)));
231 ShellIntegration::ShortcutLocations result = 252 ShellIntegration::ShortcutLocations result =
232 ShellIntegrationLinux::GetExistingShortcutLocations( 253 ShellIntegrationLinux::GetExistingShortcutLocations(
233 &env, kProfilePath, kExtensionId); 254 &env, kProfilePath, kExtensionId);
234 // Doesn't count as being in applications menu. 255 // Doesn't count as being in applications menu.
235 EXPECT_FALSE(result.on_desktop); 256 EXPECT_FALSE(result.on_desktop);
236 EXPECT_FALSE(result.in_applications_menu); 257 EXPECT_FALSE(result.in_applications_menu_chrome_apps_subdir);
237 EXPECT_FALSE(result.in_quick_launch_bar); 258 EXPECT_FALSE(result.in_quick_launch_bar);
238 EXPECT_TRUE(result.hidden); 259 EXPECT_TRUE(result.hidden);
239 } 260 }
240 261
241 // Shortcut on desktop and in applications directory. 262 // Shortcut on desktop and in applications directory.
242 { 263 {
243 base::ScopedTempDir temp_dir1; 264 base::ScopedTempDir temp_dir1;
244 ASSERT_TRUE(temp_dir1.CreateUniqueTempDir()); 265 ASSERT_TRUE(temp_dir1.CreateUniqueTempDir());
245 base::FilePath desktop_path = temp_dir1.path(); 266 base::FilePath desktop_path = temp_dir1.path();
246 267
247 base::ScopedTempDir temp_dir2; 268 base::ScopedTempDir temp_dir2;
248 ASSERT_TRUE(temp_dir2.CreateUniqueTempDir()); 269 ASSERT_TRUE(temp_dir2.CreateUniqueTempDir());
249 base::FilePath apps_path = temp_dir2.path().AppendASCII("applications"); 270 base::FilePath apps_path = temp_dir2.path().AppendASCII("applications");
250 271
251 MockEnvironment env; 272 MockEnvironment env;
252 ASSERT_TRUE(file_util::CreateDirectory(desktop_path)); 273 ASSERT_TRUE(file_util::CreateDirectory(desktop_path));
253 ASSERT_FALSE(file_util::WriteFile( 274 ASSERT_FALSE(file_util::WriteFile(
254 desktop_path.AppendASCII(kTemplateFilename), 275 desktop_path.AppendASCII(kTemplateFilename),
255 "", 0)); 276 "", 0));
256 env.Set("XDG_DATA_HOME", temp_dir2.path().value()); 277 env.Set("XDG_DATA_HOME", temp_dir2.path().value());
257 ASSERT_TRUE(file_util::CreateDirectory(apps_path)); 278 ASSERT_TRUE(file_util::CreateDirectory(apps_path));
258 ASSERT_FALSE(file_util::WriteFile( 279 ASSERT_FALSE(file_util::WriteFile(
259 apps_path.AppendASCII(kTemplateFilename), 280 apps_path.AppendASCII(kTemplateFilename),
260 "", 0)); 281 "", 0));
261 ShellIntegration::ShortcutLocations result = 282 ShellIntegration::ShortcutLocations result =
262 ShellIntegrationLinux::GetExistingShortcutLocations( 283 ShellIntegrationLinux::GetExistingShortcutLocations(
263 &env, kProfilePath, kExtensionId, desktop_path); 284 &env, kProfilePath, kExtensionId, desktop_path);
264 EXPECT_TRUE(result.on_desktop); 285 EXPECT_TRUE(result.on_desktop);
265 EXPECT_TRUE(result.in_applications_menu); 286 EXPECT_TRUE(result.in_applications_menu_chrome_apps_subdir);
266 EXPECT_FALSE(result.in_quick_launch_bar); 287 EXPECT_FALSE(result.in_quick_launch_bar);
267 EXPECT_FALSE(result.hidden); 288 EXPECT_FALSE(result.hidden);
268 } 289 }
269 } 290 }
270 291
271 TEST(ShellIntegrationTest, GetExistingShortcutContents) { 292 TEST(ShellIntegrationTest, GetExistingShortcutContents) {
272 const char kTemplateFilename[] = "shortcut-test.desktop"; 293 const char kTemplateFilename[] = "shortcut-test.desktop";
273 base::FilePath kTemplateFilepath(kTemplateFilename); 294 base::FilePath kTemplateFilepath(kTemplateFilename);
274 const char kTestData1[] = "a magical testing string"; 295 const char kTestData1[] = "a magical testing string";
275 const char kTestData2[] = "a different testing string"; 296 const char kTestData2[] = "a different testing string";
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 620
600 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { 621 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) {
601 SCOPED_TRACE(i); 622 SCOPED_TRACE(i);
602 EXPECT_EQ( 623 EXPECT_EQ(
603 test_cases[i].expected_output, 624 test_cases[i].expected_output,
604 ShellIntegrationLinux::GetDirectoryFileContents( 625 ShellIntegrationLinux::GetDirectoryFileContents(
605 ASCIIToUTF16(test_cases[i].title), 626 ASCIIToUTF16(test_cases[i].title),
606 test_cases[i].icon_name)); 627 test_cases[i].icon_name));
607 } 628 }
608 } 629 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698