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

Unified Diff: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc

Issue 2211473003: Remove calls to deprecated MessageLoop methods on Windows and Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
index b97b53586cfaf68b8945ac628b338abaf829c32b..eae01266174e5464a98bd663266d487405e3c2d2 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -76,7 +76,7 @@ class ProfileShortcutManagerTest : public testing::Test {
const base::FilePath profile_path = entry->GetPath();
base::string16 profile_name = entry->GetName();
profile_attributes_storage_->RemoveProfile(profile_path);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name));
// The icon file is not deleted until the profile directory is deleted.
const base::FilePath icon_path =
@@ -93,12 +93,6 @@ class ProfileShortcutManagerTest : public testing::Test {
return profile_path;
}
- void RunPendingTasks() {
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
- base::MessageLoop::current()->Run();
- }
-
void SetupDefaultProfileShortcut(const tracked_objects::Location& location) {
ASSERT_EQ(0u, profile_attributes_storage_->GetNumberOfProfiles())
<< location.ToString();
@@ -110,7 +104,7 @@ class ProfileShortcutManagerTest : public testing::Test {
// Also create a non-badged shortcut for Chrome, which is conveniently done
// by |CreateProfileShortcut()| since there is only one profile.
profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
// Verify that there's now a shortcut with no profile information.
ValidateNonProfileShortcut(location);
}
@@ -197,7 +191,7 @@ class ProfileShortcutManagerTest : public testing::Test {
std::string(), base::string16(), 0,
std::string());
profile_shortcut_manager_->CreateProfileShortcut(profile_path);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
ValidateProfileShortcut(location, profile_name, profile_path);
}
@@ -247,7 +241,7 @@ class ProfileShortcutManagerTest : public testing::Test {
GetProfileAttributesWithPath(profile_path, &entry));
ASSERT_NE(entry->GetName(), new_profile_name);
entry->SetName(new_profile_name);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
}
BrowserDistribution* GetDistribution() {
@@ -368,7 +362,7 @@ TEST_F(ProfileShortcutManagerTest, CreateSecondProfileBadgesFirstShortcut) {
profile_attributes_storage_->AddProfile(profile_2_path_, profile_2_name_,
std::string(), base::string16(), 0,
std::string());
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
// Ensure that the second profile doesn't have a shortcut and that the first
// profile's shortcut got renamed and badged.
@@ -382,7 +376,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsDeleteSecondToLast) {
// Delete one shortcut.
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_));
// Verify that the profile name has been removed from the remaining shortcut.
@@ -407,7 +401,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithoutShortcut) {
// Delete the profile that doesn't have a shortcut.
profile_attributes_storage_->RemoveProfile(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
// Verify that the remaining shortcut does not have a profile name.
ValidateNonProfileShortcut(FROM_HERE);
@@ -431,7 +425,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithShortcut) {
// Delete the profile that has a shortcut.
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
// Verify that the remaining shortcut does not have a profile name.
ValidateNonProfileShortcut(FROM_HERE);
@@ -466,7 +460,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteOnlyProfileWithShortcuts) {
// Delete the third profile and check that its shortcut is gone and no
// shortcuts have been re-created.
profile_attributes_storage_->RemoveProfile(profile_3_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
ASSERT_FALSE(base::PathExists(profile_1_shortcut_path));
ASSERT_FALSE(base::PathExists(profile_2_shortcut_path));
ASSERT_FALSE(base::PathExists(profile_3_shortcut_path));
@@ -478,7 +472,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) {
// Delete one shortcut.
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
// Verify that a default shortcut exists (no profile name/avatar).
ValidateNonProfileShortcut(FROM_HERE);
@@ -507,7 +501,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcuts) {
// Ensure that a new shortcut does not get made if the old one was renamed.
profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_));
ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_2,
profile_2_path_);
@@ -516,7 +510,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcuts) {
ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path_2, false));
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2));
profile_shortcut_manager_->CreateProfileShortcut(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
}
@@ -545,7 +539,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) {
// Delete the profile and ensure both shortcuts were also deleted.
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_1));
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2));
ValidateNonProfileShortcutAtPath(FROM_HERE,
@@ -643,7 +637,7 @@ TEST_F(ProfileShortcutManagerTest, RemoveProfileShortcuts) {
// Delete shortcuts for profile 1 and ensure that they got deleted while the
// shortcuts for profile 2 were kept.
profile_shortcut_manager_->RemoveProfileShortcuts(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_1));
EXPECT_FALSE(base::PathExists(profile_1_shortcut_path_2));
ValidateProfileShortcutAtPath(FROM_HERE, profile_2_shortcut_path_1,
@@ -666,7 +660,7 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) {
// Profile 2 should have a shortcut initially.
profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_TRUE(result.has_shortcuts);
// Delete the shortcut and check that the function returns false.
@@ -675,7 +669,7 @@ TEST_F(ProfileShortcutManagerTest, HasProfileShortcuts) {
ASSERT_TRUE(base::DeleteFile(profile_2_shortcut_path, false));
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path));
profile_shortcut_manager_->HasProfileShortcuts(profile_2_path_, callback);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(result.has_shortcuts);
}
@@ -687,7 +681,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
profile_attributes_storage_->AddProfile(profile_1_path_, profile_1_name_,
std::string(), base::string16(), 0,
std::string());
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
ASSERT_EQ(1u, profile_attributes_storage_->GetNumberOfProfiles());
// Ensure system-level continues to exist and user-level was not created.
@@ -706,7 +700,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
profile_attributes_storage_->AddProfile(profile_3_path_, profile_3_name_,
std::string(), base::string16(), 0,
std::string());
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
// Ensure that changing the avatar icon and the name does not result in a
@@ -715,12 +709,12 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
ASSERT_TRUE(profile_attributes_storage_->
GetProfileAttributesWithPath(profile_3_path_, &entry_3));
entry_3->SetAvatarIconIndex(3u);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
const base::string16 new_profile_3_name = L"New Name 3";
entry_3->SetName(new_profile_3_name);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_));
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_3_name));
@@ -730,7 +724,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) {
ASSERT_TRUE(profile_attributes_storage_->
GetProfileAttributesWithPath(profile_2_path_, &entry_2));
entry_2->SetName(new_profile_2_name);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_));
ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_);
}
@@ -745,7 +739,7 @@ TEST_F(ProfileShortcutManagerTest,
// Delete a profile and verify that only the system-level shortcut still
// exists.
profile_attributes_storage_->RemoveProfile(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_TRUE(base::PathExists(system_level_shortcut_path));
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(base::string16()));
@@ -774,7 +768,7 @@ TEST_F(ProfileShortcutManagerTest,
// shortcut creation path in |DeleteDesktopShortcuts()|, which is
// not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test.
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
// Verify that only the system-level shortcut still exists.
EXPECT_TRUE(base::PathExists(system_level_shortcut_path));
@@ -795,7 +789,7 @@ TEST_F(ProfileShortcutManagerTest, CreateProfileIcon) {
EXPECT_FALSE(base::PathExists(icon_path));
profile_shortcut_manager_->CreateOrUpdateProfileIcon(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_TRUE(base::PathExists(icon_path));
}
@@ -826,7 +820,7 @@ TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) {
// Deleting the default profile will unbadge the new profile's icon and should
// result in an icon that is identical to the unbadged default profile icon.
profile_attributes_storage_->RemoveProfile(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
std::string unbadged_icon_2;
EXPECT_TRUE(base::ReadFileToString(icon_path_2, &unbadged_icon_2));
@@ -853,7 +847,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) {
ASSERT_TRUE(profile_attributes_storage_->
GetProfileAttributesWithPath(profile_1_path_, &entry_1));
entry_1->SetAvatarIconIndex(1u);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
std::string new_badged_icon_1;
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &new_badged_icon_1));
@@ -861,7 +855,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) {
// Ensure the new icon is not the unbadged icon.
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
std::string unbadged_icon_1;
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1));
@@ -869,7 +863,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) {
// Ensure the icon doesn't change on avatar change without 2 profiles.
entry_1->SetAvatarIconIndex(1u);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
std::string unbadged_icon_1_a;
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a));
@@ -1015,7 +1009,7 @@ TEST_F(ProfileShortcutManagerTest, ShortcutsForProfilesWithIdenticalNames) {
// Delete profile1.
profile_attributes_storage_->RemoveProfile(profile_1_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_1_name));
// Check that nothing is changed for profile2 and profile3.
ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
@@ -1028,7 +1022,7 @@ TEST_F(ProfileShortcutManagerTest, ShortcutsForProfilesWithIdenticalNames) {
GetDefaultShortcutPathForProfile(profile_2_name_)));
EXPECT_TRUE(base::PathExists(profile_3_shortcut_path));
profile_attributes_storage_->RemoveProfile(profile_2_path_);
- RunPendingTasks();
+ base::RunLoop().RunUntilIdle();
EXPECT_FALSE(base::PathExists(
GetDefaultShortcutPathForProfile(profile_2_name_)));
// Only profile3 exists. There should be non-profile shortcut only.

Powered by Google App Engine
This is Rietveld 408576698