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

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

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 15 #include "base/run_loop.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/chromeos/settings/cros_settings.h" 22 #include "chrome/browser/chromeos/settings/cros_settings.h"
22 #include "chrome/browser/history/history_service_factory.h" 23 #include "chrome/browser/history/history_service_factory.h"
23 #include "chrome/browser/io_thread.h" 24 #include "chrome/browser/io_thread.h"
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 560
560 EXPECT_TRUE(last_used_profile->IsSameProfile(active_profile)); 561 EXPECT_TRUE(last_used_profile->IsSameProfile(active_profile));
561 } 562 }
562 #endif 563 #endif
563 564
564 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) { 565 TEST_F(ProfileManagerTest, AutoloadProfilesWithBackgroundApps) {
565 ProfileManager* profile_manager = g_browser_process->profile_manager(); 566 ProfileManager* profile_manager = g_browser_process->profile_manager();
566 ProfileAttributesStorage& storage = 567 ProfileAttributesStorage& storage =
567 profile_manager->GetProfileAttributesStorage(); 568 profile_manager->GetProfileAttributesStorage();
568 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, 569 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled,
569 new base::Value(true)); 570 base::MakeUnique<base::Value>(true));
570 571
571 // Setting a pref which is not applicable to a system (i.e., Android in this 572 // Setting a pref which is not applicable to a system (i.e., Android in this
572 // case) does not necessarily create it. Don't bother continuing with the 573 // case) does not necessarily create it. Don't bother continuing with the
573 // test if this pref doesn't exist because it will not load the profiles if 574 // test if this pref doesn't exist because it will not load the profiles if
574 // it cannot verify that the pref for background mode is enabled. 575 // it cannot verify that the pref for background mode is enabled.
575 if (!local_state_.Get()->HasPrefPath(prefs::kBackgroundModeEnabled)) 576 if (!local_state_.Get()->HasPrefPath(prefs::kBackgroundModeEnabled))
576 return; 577 return;
577 578
578 EXPECT_EQ(0u, storage.GetNumberOfProfiles()); 579 EXPECT_EQ(0u, storage.GetNumberOfProfiles());
579 580
(...skipping 14 matching lines...) Expand all
594 profile_manager->AutoloadProfiles(); 595 profile_manager->AutoloadProfiles();
595 596
596 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); 597 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size());
597 } 598 }
598 599
599 TEST_F(ProfileManagerTest, DoNotAutoloadProfilesIfBackgroundModeOff) { 600 TEST_F(ProfileManagerTest, DoNotAutoloadProfilesIfBackgroundModeOff) {
600 ProfileManager* profile_manager = g_browser_process->profile_manager(); 601 ProfileManager* profile_manager = g_browser_process->profile_manager();
601 ProfileAttributesStorage& storage = 602 ProfileAttributesStorage& storage =
602 profile_manager->GetProfileAttributesStorage(); 603 profile_manager->GetProfileAttributesStorage();
603 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled, 604 local_state_.Get()->SetUserPref(prefs::kBackgroundModeEnabled,
604 new base::Value(false)); 605 base::MakeUnique<base::Value>(false));
605 606
606 EXPECT_EQ(0u, storage.GetNumberOfProfiles()); 607 EXPECT_EQ(0u, storage.GetNumberOfProfiles());
607 608
608 storage.AddProfile(profile_manager->user_data_dir().AppendASCII("path_1"), 609 storage.AddProfile(profile_manager->user_data_dir().AppendASCII("path_1"),
609 ASCIIToUTF16("name_1"), "12345", base::string16(), 0, std::string()); 610 ASCIIToUTF16("name_1"), "12345", base::string16(), 0, std::string());
610 storage.AddProfile(profile_manager->user_data_dir().AppendASCII("path_2"), 611 storage.AddProfile(profile_manager->user_data_dir().AppendASCII("path_2"),
611 ASCIIToUTF16("name_2"), "23456", base::string16(), 0, std::string()); 612 ASCIIToUTF16("name_2"), "23456", base::string16(), 0, std::string());
612 613
613 EXPECT_EQ(2u, storage.GetNumberOfProfiles()); 614 EXPECT_EQ(2u, storage.GetNumberOfProfiles());
614 615
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 dest_path2.BaseName().MaybeAsASCII()); 1457 dest_path2.BaseName().MaybeAsASCII());
1457 profile_manager->ScheduleProfileForDeletion(dest_path2, 1458 profile_manager->ScheduleProfileForDeletion(dest_path2,
1458 ProfileManager::CreateCallback()); 1459 ProfileManager::CreateCallback());
1459 // Spin the message loop so that all the callbacks can finish running. 1460 // Spin the message loop so that all the callbacks can finish running.
1460 base::RunLoop().RunUntilIdle(); 1461 base::RunLoop().RunUntilIdle();
1461 1462
1462 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1463 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1463 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1464 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1464 } 1465 }
1465 #endif // !defined(OS_MACOSX) 1466 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698