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

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

Issue 1198313003: Fix the browser match rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_ptr<Browser> instead. Created 5 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
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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 TestingProfile* profile2 = 616 TestingProfile* profile2 =
617 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2)); 617 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2));
618 ASSERT_TRUE(profile2); 618 ASSERT_TRUE(profile2);
619 619
620 std::vector<Profile*> last_opened_profiles = 620 std::vector<Profile*> last_opened_profiles =
621 profile_manager->GetLastOpenedProfiles(); 621 profile_manager->GetLastOpenedProfiles();
622 ASSERT_EQ(0U, last_opened_profiles.size()); 622 ASSERT_EQ(0U, last_opened_profiles.size());
623 623
624 // Create a browser for profile1. 624 // Create a browser for profile1.
625 Browser::CreateParams profile1_params(profile1, chrome::GetActiveDesktop()); 625 Browser::CreateParams profile1_params(profile1, chrome::GetActiveDesktop());
626 scoped_ptr<Browser> browser1a( 626 scoped_ptr<Browser> browser1a =
627 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); 627 chrome::CreateBrowserWithTestWindowForParams(&profile1_params);
628 628
629 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 629 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
630 ASSERT_EQ(1U, last_opened_profiles.size()); 630 ASSERT_EQ(1U, last_opened_profiles.size());
631 EXPECT_EQ(profile1, last_opened_profiles[0]); 631 EXPECT_EQ(profile1, last_opened_profiles[0]);
632 632
633 // And for profile2. 633 // And for profile2.
634 Browser::CreateParams profile2_params(profile2, chrome::GetActiveDesktop()); 634 Browser::CreateParams profile2_params(profile2, chrome::GetActiveDesktop());
635 scoped_ptr<Browser> browser2( 635 scoped_ptr<Browser> browser2 =
636 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); 636 chrome::CreateBrowserWithTestWindowForParams(&profile2_params);
637 637
638 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 638 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
639 ASSERT_EQ(2U, last_opened_profiles.size()); 639 ASSERT_EQ(2U, last_opened_profiles.size());
640 EXPECT_EQ(profile1, last_opened_profiles[0]); 640 EXPECT_EQ(profile1, last_opened_profiles[0]);
641 EXPECT_EQ(profile2, last_opened_profiles[1]); 641 EXPECT_EQ(profile2, last_opened_profiles[1]);
642 642
643 // Adding more browsers doesn't change anything. 643 // Adding more browsers doesn't change anything.
644 scoped_ptr<Browser> browser1b( 644 scoped_ptr<Browser> browser1b =
645 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); 645 chrome::CreateBrowserWithTestWindowForParams(&profile1_params);
646 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 646 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
647 ASSERT_EQ(2U, last_opened_profiles.size()); 647 ASSERT_EQ(2U, last_opened_profiles.size());
648 EXPECT_EQ(profile1, last_opened_profiles[0]); 648 EXPECT_EQ(profile1, last_opened_profiles[0]);
649 EXPECT_EQ(profile2, last_opened_profiles[1]); 649 EXPECT_EQ(profile2, last_opened_profiles[1]);
650 650
651 // Close the browsers. 651 // Close the browsers.
652 browser1a.reset(); 652 browser1a.reset();
653 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); 653 last_opened_profiles = profile_manager->GetLastOpenedProfiles();
654 ASSERT_EQ(2U, last_opened_profiles.size()); 654 ASSERT_EQ(2U, last_opened_profiles.size());
655 EXPECT_EQ(profile1, last_opened_profiles[0]); 655 EXPECT_EQ(profile1, last_opened_profiles[0]);
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 dest_path2.BaseName().MaybeAsASCII()); 1354 dest_path2.BaseName().MaybeAsASCII());
1355 profile_manager->ScheduleProfileForDeletion(dest_path2, 1355 profile_manager->ScheduleProfileForDeletion(dest_path2,
1356 ProfileManager::CreateCallback()); 1356 ProfileManager::CreateCallback());
1357 // Spin the message loop so that all the callbacks can finish running. 1357 // Spin the message loop so that all the callbacks can finish running.
1358 base::RunLoop().RunUntilIdle(); 1358 base::RunLoop().RunUntilIdle();
1359 1359
1360 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1360 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1361 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1361 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1362 } 1362 }
1363 #endif // !defined(OS_MACOSX) 1363 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698