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

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

Issue 1586143002: Cleanup dual_mode handling in ShellIntegrationWin after Metro removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a1_cleanup_scottmg
Patch Set: nits Created 4 years, 11 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 (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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // chrome app id. 195 // chrome app id.
196 temp_properties.set_target(chrome_exe_); 196 temp_properties.set_target(chrome_exe_);
197 temp_properties.set_app_id(L"Dumbo"); 197 temp_properties.set_app_id(L"Dumbo");
198 temp_properties.set_arguments( 198 temp_properties.set_arguments(
199 L"--app-id=" + extension_id_ + 199 L"--app-id=" + extension_id_ +
200 L" --profile-directory=" + non_default_profile_); 200 L" --profile-directory=" + non_default_profile_);
201 ASSERT_NO_FATAL_FAILURE( 201 ASSERT_NO_FATAL_FAILURE(
202 AddTestShortcutAndResetProperties(&temp_properties)); 202 AddTestShortcutAndResetProperties(&temp_properties));
203 203
204 // Shortcut 11 points to chrome.exe, already has the right appid, and has 204 // Shortcut 11 points to chrome.exe, already has the right appid, and has
205 // dual_mode set and thus should only be migrated if dual_mode is checked 205 // dual_mode set and thus should only be migrated if dual_mode is being
206 // and not desired for this OS version. 206 // cleared.
207 temp_properties.set_target(chrome_exe_); 207 temp_properties.set_target(chrome_exe_);
208 temp_properties.set_app_id(chrome_app_id_); 208 temp_properties.set_app_id(chrome_app_id_);
209 temp_properties.set_dual_mode(true); 209 temp_properties.set_dual_mode(true);
210 ASSERT_NO_FATAL_FAILURE( 210 ASSERT_NO_FATAL_FAILURE(
211 AddTestShortcutAndResetProperties(&temp_properties)); 211 AddTestShortcutAndResetProperties(&temp_properties));
212 212
213 // Shortcut 12 is similar to 11 but with dual_mode explicitly set to false. 213 // Shortcut 12 is similar to 11 but with dual_mode explicitly set to false.
214 temp_properties.set_target(chrome_exe_); 214 temp_properties.set_target(chrome_exe_);
215 temp_properties.set_app_id(chrome_app_id_); 215 temp_properties.set_app_id(chrome_app_id_);
216 temp_properties.set_dual_mode(false); 216 temp_properties.set_dual_mode(false);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 // The app id of the example app for the non-default profile. 262 // The app id of the example app for the non-default profile.
263 base::string16 non_default_profile_extension_app_id_; 263 base::string16 non_default_profile_extension_app_id_;
264 264
265 private: 265 private:
266 DISALLOW_COPY_AND_ASSIGN(ShellIntegrationWinMigrateShortcutTest); 266 DISALLOW_COPY_AND_ASSIGN(ShellIntegrationWinMigrateShortcutTest);
267 }; 267 };
268 268
269 } // namespace 269 } // namespace
270 270
271 // Test migration when not checking for dual mode. 271 // Test migration when not clearing dual mode.
272 TEST_F(ShellIntegrationWinMigrateShortcutTest, DontCheckDualMode) { 272 TEST_F(ShellIntegrationWinMigrateShortcutTest, DontClearDualMode) {
273 if (base::win::GetVersion() < base::win::VERSION_WIN7) 273 if (base::win::GetVersion() < base::win::VERSION_WIN7)
274 return; 274 return;
275 275
276 EXPECT_EQ(9, 276 EXPECT_EQ(9,
277 ShellIntegration::MigrateShortcutsInPathInternal( 277 ShellIntegration::MigrateShortcutsInPathInternal(
278 chrome_exe_, temp_dir_.path(), false)); 278 chrome_exe_, temp_dir_.path(), false));
279 279
280 // Only shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have been migrated. 280 // Only shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have been migrated.
281 shortcuts_[1].properties.set_app_id(chrome_app_id_); 281 shortcuts_[1].properties.set_app_id(chrome_app_id_);
282 shortcuts_[3].properties.set_app_id(chrome_app_id_); 282 shortcuts_[3].properties.set_app_id(chrome_app_id_);
283 shortcuts_[4].properties.set_app_id(chrome_app_id_); 283 shortcuts_[4].properties.set_app_id(chrome_app_id_);
284 shortcuts_[5].properties.set_app_id(chrome_app_id_); 284 shortcuts_[5].properties.set_app_id(chrome_app_id_);
285 shortcuts_[6].properties.set_app_id(non_default_profile_chrome_app_id_); 285 shortcuts_[6].properties.set_app_id(non_default_profile_chrome_app_id_);
286 shortcuts_[7].properties.set_app_id(non_default_user_data_dir_chrome_app_id_); 286 shortcuts_[7].properties.set_app_id(non_default_user_data_dir_chrome_app_id_);
287 shortcuts_[8].properties.set_app_id( 287 shortcuts_[8].properties.set_app_id(
288 non_default_user_data_dir_and_profile_chrome_app_id_); 288 non_default_user_data_dir_and_profile_chrome_app_id_);
289 shortcuts_[9].properties.set_app_id(extension_app_id_); 289 shortcuts_[9].properties.set_app_id(extension_app_id_);
290 shortcuts_[10].properties.set_app_id(non_default_profile_extension_app_id_); 290 shortcuts_[10].properties.set_app_id(non_default_profile_extension_app_id_);
291 291
292 // Explicitly set the dual_mode expectations on all shortcuts to ensure 292 // Explicitly set the dual_mode expectations on all shortcuts that didn't have
293 // ValidateShortcut verifies it. 293 // it to ensure ValidateShortcut verifies it. Those that had it should remain
294 // unchanged per |clear_dual_mode| being false above.
294 for (size_t i = 0; i < shortcuts_.size(); ++i) { 295 for (size_t i = 0; i < shortcuts_.size(); ++i) {
295 if (!(shortcuts_[i].properties.options & 296 if (!(shortcuts_[i].properties.options &
296 base::win::ShortcutProperties::PROPERTIES_DUAL_MODE)) { 297 base::win::ShortcutProperties::PROPERTIES_DUAL_MODE)) {
297 shortcuts_[i].properties.set_dual_mode(false); 298 shortcuts_[i].properties.set_dual_mode(false);
298 } 299 }
299 } 300 }
300 301
301 for (size_t i = 0; i < shortcuts_.size(); ++i) { 302 for (size_t i = 0; i < shortcuts_.size(); ++i) {
302 SCOPED_TRACE(i); 303 SCOPED_TRACE(i);
303 base::win::ValidateShortcut(shortcuts_[i].path, shortcuts_[i].properties); 304 base::win::ValidateShortcut(shortcuts_[i].path, shortcuts_[i].properties);
304 } 305 }
305 306
306 // Make sure shortcuts are not re-migrated. 307 // Make sure shortcuts are not re-migrated.
307 EXPECT_EQ(0, 308 EXPECT_EQ(0,
308 ShellIntegration::MigrateShortcutsInPathInternal( 309 ShellIntegration::MigrateShortcutsInPathInternal(
309 chrome_exe_, temp_dir_.path(), false)); 310 chrome_exe_, temp_dir_.path(), false));
310 } 311 }
311 312
312 // Test migration when also checking for dual mode. 313 // Test migration when also clearing dual mode.
313 TEST_F(ShellIntegrationWinMigrateShortcutTest, CheckDualMode) { 314 TEST_F(ShellIntegrationWinMigrateShortcutTest, ClearDualMode) {
314 if (base::win::GetVersion() < base::win::VERSION_WIN7) 315 if (base::win::GetVersion() < base::win::VERSION_WIN7)
315 return; 316 return;
316 317
317 // 9 shortcuts should have their app id updated below. 318 // 9 shortcuts should have their app id updated below and shortcut 11 should
318 319 // be migrated away from dual_mode for a total of 10 shortcuts migrated.
319 // shortcut 11 should be migrate away from dual_mode for a total of 10
320 // shortcuts migrated.
321 EXPECT_EQ(10, ShellIntegration::MigrateShortcutsInPathInternal( 320 EXPECT_EQ(10, ShellIntegration::MigrateShortcutsInPathInternal(
322 chrome_exe_, temp_dir_.path(), true)); 321 chrome_exe_, temp_dir_.path(), true));
323 322
324 // Shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have had both their app_id 323 // Shortcut 1, 3, 4, 5, 6, 7, 8, 9, and 10 should have had their app_id fixed.
325 // fixed and shortcut 1, 2, 3, 4, and 5 should also have had their dual_mode
326 // property added if it is desired (or 11 should have had it removed if it is
327 // not).
328 shortcuts_[1].properties.set_app_id(chrome_app_id_); 324 shortcuts_[1].properties.set_app_id(chrome_app_id_);
329 shortcuts_[3].properties.set_app_id(chrome_app_id_); 325 shortcuts_[3].properties.set_app_id(chrome_app_id_);
330 shortcuts_[4].properties.set_app_id(chrome_app_id_); 326 shortcuts_[4].properties.set_app_id(chrome_app_id_);
331 shortcuts_[5].properties.set_app_id(chrome_app_id_); 327 shortcuts_[5].properties.set_app_id(chrome_app_id_);
332 shortcuts_[6].properties.set_app_id(non_default_profile_chrome_app_id_); 328 shortcuts_[6].properties.set_app_id(non_default_profile_chrome_app_id_);
333 shortcuts_[7].properties.set_app_id(non_default_user_data_dir_chrome_app_id_); 329 shortcuts_[7].properties.set_app_id(non_default_user_data_dir_chrome_app_id_);
334 shortcuts_[8].properties.set_app_id( 330 shortcuts_[8].properties.set_app_id(
335 non_default_user_data_dir_and_profile_chrome_app_id_); 331 non_default_user_data_dir_and_profile_chrome_app_id_);
336 shortcuts_[9].properties.set_app_id(extension_app_id_); 332 shortcuts_[9].properties.set_app_id(extension_app_id_);
337 shortcuts_[10].properties.set_app_id(non_default_profile_extension_app_id_); 333 shortcuts_[10].properties.set_app_id(non_default_profile_extension_app_id_);
338 334
339 // Explicitly flag the expected dual_mode properties. 335 // No shortcut should still have the dual_mode property.
340 shortcuts_[0].properties.set_dual_mode(false); 336 for (size_t i = 0; i < shortcuts_.size(); ++i)
341 shortcuts_[11].properties.set_dual_mode(false); 337 shortcuts_[i].properties.set_dual_mode(false);
342 shortcuts_[6].properties.set_dual_mode(false);
343 shortcuts_[7].properties.set_dual_mode(false);
344 shortcuts_[8].properties.set_dual_mode(false);
345 shortcuts_[9].properties.set_dual_mode(false);
346 shortcuts_[10].properties.set_dual_mode(false);
347 338
348 for (size_t i = 0; i < shortcuts_.size(); ++i) { 339 for (size_t i = 0; i < shortcuts_.size(); ++i) {
349 SCOPED_TRACE(i); 340 SCOPED_TRACE(i);
350 base::win::ValidateShortcut(shortcuts_[i].path, shortcuts_[i].properties); 341 base::win::ValidateShortcut(shortcuts_[i].path, shortcuts_[i].properties);
351 } 342 }
352 343
353 // Make sure shortcuts are not re-migrated. 344 // Make sure shortcuts are not re-migrated.
354 EXPECT_EQ(0, 345 EXPECT_EQ(0,
355 ShellIntegration::MigrateShortcutsInPathInternal( 346 ShellIntegration::MigrateShortcutsInPathInternal(
356 chrome_exe_, temp_dir_.path(), false)); 347 chrome_exe_, temp_dir_.path(), false));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 default_profile_path)); 395 default_profile_path));
405 396
406 // Non-default profile path should get chrome::kBrowserAppID + AppList joined 397 // Non-default profile path should get chrome::kBrowserAppID + AppList joined
407 // with profile info. 398 // with profile info.
408 base::FilePath profile_path(FILE_PATH_LITERAL("root")); 399 base::FilePath profile_path(FILE_PATH_LITERAL("root"));
409 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); 400 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd"));
410 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); 401 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test"));
411 EXPECT_EQ(base_app_id + L".udd.UserDataTest", 402 EXPECT_EQ(base_app_id + L".udd.UserDataTest",
412 ShellIntegration::GetAppListAppModelIdForProfile(profile_path)); 403 ShellIntegration::GetAppListAppModelIdForProfile(profile_path));
413 } 404 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_win.cc ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698