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

Side by Side Diff: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc

Issue 18332014: Move Copy* into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows Created 7 years, 5 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 | Annotate | Revision Log
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 <objbase.h> // For CoInitialize(). 5 #include <objbase.h> // For CoInitialize().
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 511 }
512 512
513 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) { 513 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) {
514 SetupAndCreateTwoShortcuts(FROM_HERE); 514 SetupAndCreateTwoShortcuts(FROM_HERE);
515 515
516 const base::FilePath profile_2_shortcut_path_1 = 516 const base::FilePath profile_2_shortcut_path_1 =
517 GetDefaultShortcutPathForProfile(profile_2_name_); 517 GetDefaultShortcutPathForProfile(profile_2_name_);
518 const base::FilePath profile_2_shortcut_path_2 = 518 const base::FilePath profile_2_shortcut_path_2 =
519 GetUserShortcutsDirectory().Append(L"MyChrome.lnk"); 519 GetUserShortcutsDirectory().Append(L"MyChrome.lnk");
520 // Make a copy of the shortcut. 520 // Make a copy of the shortcut.
521 ASSERT_TRUE(file_util::CopyFile(profile_2_shortcut_path_1, 521 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1,
522 profile_2_shortcut_path_2)); 522 profile_2_shortcut_path_2));
523 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, 523 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1,
524 profile_2_path_); 524 profile_2_path_);
525 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, 525 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2,
526 profile_2_path_); 526 profile_2_path_);
527 527
528 // Also, copy the shortcut for the first user and ensure it gets preserved. 528 // Also, copy the shortcut for the first user and ensure it gets preserved.
529 const base::FilePath preserved_profile_1_shortcut_path = 529 const base::FilePath preserved_profile_1_shortcut_path =
530 GetUserShortcutsDirectory().Append(L"Preserved.lnk"); 530 GetUserShortcutsDirectory().Append(L"Preserved.lnk");
531 ASSERT_TRUE(file_util::CopyFile( 531 ASSERT_TRUE(base::CopyFile(
532 GetDefaultShortcutPathForProfile(profile_1_name_), 532 GetDefaultShortcutPathForProfile(profile_1_name_),
533 preserved_profile_1_shortcut_path)); 533 preserved_profile_1_shortcut_path));
534 EXPECT_TRUE(file_util::PathExists(preserved_profile_1_shortcut_path)); 534 EXPECT_TRUE(file_util::PathExists(preserved_profile_1_shortcut_path));
535 535
536 // Delete the profile and ensure both shortcuts were also deleted. 536 // Delete the profile and ensure both shortcuts were also deleted.
537 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); 537 profile_info_cache_->DeleteProfileFromCache(profile_2_path_);
538 RunPendingTasks(); 538 RunPendingTasks();
539 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_1)); 539 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_1));
540 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_2)); 540 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path_2));
541 ValidateNonProfileShortcutAtPath(FROM_HERE, 541 ValidateNonProfileShortcutAtPath(FROM_HERE,
542 preserved_profile_1_shortcut_path); 542 preserved_profile_1_shortcut_path);
543 } 543 }
544 544
545 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsAfterProfileRename) { 545 TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsAfterProfileRename) {
546 SetupAndCreateTwoShortcuts(FROM_HERE); 546 SetupAndCreateTwoShortcuts(FROM_HERE);
547 547
548 const base::FilePath profile_2_shortcut_path_1 = 548 const base::FilePath profile_2_shortcut_path_1 =
549 GetDefaultShortcutPathForProfile(profile_2_name_); 549 GetDefaultShortcutPathForProfile(profile_2_name_);
550 const base::FilePath profile_2_shortcut_path_2 = 550 const base::FilePath profile_2_shortcut_path_2 =
551 GetUserShortcutsDirectory().Append(L"MyChrome.lnk"); 551 GetUserShortcutsDirectory().Append(L"MyChrome.lnk");
552 // Make a copy of the shortcut. 552 // Make a copy of the shortcut.
553 ASSERT_TRUE(file_util::CopyFile(profile_2_shortcut_path_1, 553 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1,
554 profile_2_shortcut_path_2)); 554 profile_2_shortcut_path_2));
555 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1, 555 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1,
556 profile_2_path_); 556 profile_2_path_);
557 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, 557 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2,
558 profile_2_path_); 558 profile_2_path_);
559 559
560 // Now, rename the profile. 560 // Now, rename the profile.
561 const string16 new_profile_2_name = L"New profile"; 561 const string16 new_profile_2_name = L"New profile";
562 RenameProfile(FROM_HERE, profile_2_path_, new_profile_2_name); 562 RenameProfile(FROM_HERE, profile_2_path_, new_profile_2_name);
563 563
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 const base::FilePath profile_1_shortcut_path_1 = 616 const base::FilePath profile_1_shortcut_path_1 =
617 GetDefaultShortcutPathForProfile(profile_1_name_); 617 GetDefaultShortcutPathForProfile(profile_1_name_);
618 const base::FilePath profile_2_shortcut_path_1 = 618 const base::FilePath profile_2_shortcut_path_1 =
619 GetDefaultShortcutPathForProfile(profile_2_name_); 619 GetDefaultShortcutPathForProfile(profile_2_name_);
620 620
621 // Make copies of the shortcuts for both profiles. 621 // Make copies of the shortcuts for both profiles.
622 const base::FilePath profile_1_shortcut_path_2 = 622 const base::FilePath profile_1_shortcut_path_2 =
623 GetUserShortcutsDirectory().Append(L"Copied1.lnk"); 623 GetUserShortcutsDirectory().Append(L"Copied1.lnk");
624 const base::FilePath profile_2_shortcut_path_2 = 624 const base::FilePath profile_2_shortcut_path_2 =
625 GetUserShortcutsDirectory().Append(L"Copied2.lnk"); 625 GetUserShortcutsDirectory().Append(L"Copied2.lnk");
626 ASSERT_TRUE(file_util::CopyFile(profile_1_shortcut_path_1, 626 ASSERT_TRUE(base::CopyFile(profile_1_shortcut_path_1,
627 profile_1_shortcut_path_2)); 627 profile_1_shortcut_path_2));
628 ASSERT_TRUE(file_util::CopyFile(profile_2_shortcut_path_1, 628 ASSERT_TRUE(base::CopyFile(profile_2_shortcut_path_1,
629 profile_2_shortcut_path_2)); 629 profile_2_shortcut_path_2));
630 ValidateProfileShortcutAtPath(FROM_HERE, profile_1_shortcut_path_2, 630 ValidateProfileShortcutAtPath(FROM_HERE, profile_1_shortcut_path_2,
631 profile_1_path_); 631 profile_1_path_);
632 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2, 632 ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2,
633 profile_2_path_); 633 profile_2_path_);
634 634
635 // Delete shortcuts for profile 1 and ensure that they got deleted while the 635 // Delete shortcuts for profile 1 and ensure that they got deleted while the
636 // shortcuts for profile 2 were kept. 636 // shortcuts for profile 2 were kept.
637 profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_); 637 profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_);
638 RunPendingTasks(); 638 RunPendingTasks();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 profile_info_cache_->DeleteProfileFromCache(profile_2_path_); 765 profile_info_cache_->DeleteProfileFromCache(profile_2_path_);
766 RunPendingTasks(); 766 RunPendingTasks();
767 767
768 // Verify that only the system-level shortcut still exists. 768 // Verify that only the system-level shortcut still exists.
769 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path)); 769 EXPECT_TRUE(file_util::PathExists(system_level_shortcut_path));
770 EXPECT_FALSE(file_util::PathExists( 770 EXPECT_FALSE(file_util::PathExists(
771 GetDefaultShortcutPathForProfile(string16()))); 771 GetDefaultShortcutPathForProfile(string16())));
772 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); 772 EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path));
773 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); 773 EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path));
774 } 774 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/printing_layout_browsertest.cc ('k') | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698