OLD | NEW |
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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 base::RunLoop run_loop; | 317 base::RunLoop run_loop; |
318 profile_manager->CreateProfileAsync( | 318 profile_manager->CreateProfileAsync( |
319 path_profile2, base::Bind(&OnUnblockOnProfileCreation, &run_loop), | 319 path_profile2, base::Bind(&OnUnblockOnProfileCreation, &run_loop), |
320 base::string16(), std::string(), std::string()); | 320 base::string16(), std::string(), std::string()); |
321 | 321 |
322 // Run the message loop to allow profile creation to take place; the loop is | 322 // Run the message loop to allow profile creation to take place; the loop is |
323 // terminated by OnUnblockOnProfileCreation when the profile is created. | 323 // terminated by OnUnblockOnProfileCreation when the profile is created. |
324 run_loop.Run(); | 324 run_loop.Run(); |
325 | 325 |
326 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 326 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
327 BrowserList* browser_list = BrowserList::GetInstance(desktop_type); | 327 BrowserList* browser_list = BrowserList::GetInstance(); |
328 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); | 328 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
329 EXPECT_EQ(1U, browser_list->size()); | 329 EXPECT_EQ(1U, browser_list->size()); |
330 | 330 |
331 // Open a browser window for the first profile. | 331 // Open a browser window for the first profile. |
332 profiles::SwitchToProfile(path_profile1, desktop_type, false, | 332 profiles::SwitchToProfile(path_profile1, desktop_type, false, |
333 kOnProfileSwitchDoNothing, | 333 kOnProfileSwitchDoNothing, |
334 ProfileMetrics::SWITCH_PROFILE_ICON); | 334 ProfileMetrics::SWITCH_PROFILE_ICON); |
335 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 335 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
336 EXPECT_EQ(1U, browser_list->size()); | 336 EXPECT_EQ(1U, browser_list->size()); |
337 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 337 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 profile_manager->GenerateNextProfileDirectoryPath(); | 386 profile_manager->GenerateNextProfileDirectoryPath(); |
387 profile_manager->CreateProfileAsync( | 387 profile_manager->CreateProfileAsync( |
388 path_profile2, | 388 path_profile2, |
389 base::Bind(&EphemeralProfileCreationComplete), | 389 base::Bind(&EphemeralProfileCreationComplete), |
390 base::string16(), std::string(), std::string()); | 390 base::string16(), std::string(), std::string()); |
391 | 391 |
392 // Spin to allow profile creation to take place. | 392 // Spin to allow profile creation to take place. |
393 content::RunMessageLoop(); | 393 content::RunMessageLoop(); |
394 | 394 |
395 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 395 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
396 BrowserList* browser_list = BrowserList::GetInstance(desktop_type); | 396 BrowserList* browser_list = BrowserList::GetInstance(); |
397 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); | 397 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
398 EXPECT_EQ(1U, browser_list->size()); | 398 EXPECT_EQ(1U, browser_list->size()); |
399 | 399 |
400 // Open a browser window for the second profile. | 400 // Open a browser window for the second profile. |
401 profiles::SwitchToProfile(path_profile2, desktop_type, false, | 401 profiles::SwitchToProfile(path_profile2, desktop_type, false, |
402 kOnProfileSwitchDoNothing, | 402 kOnProfileSwitchDoNothing, |
403 ProfileMetrics::SWITCH_PROFILE_ICON); | 403 ProfileMetrics::SWITCH_PROFILE_ICON); |
404 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); | 404 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
405 EXPECT_EQ(2U, browser_list->size()); | 405 EXPECT_EQ(2U, browser_list->size()); |
406 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 406 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 ASSERT_TRUE(profile_manager->IsValidProfile(incognito_profile)); | 487 ASSERT_TRUE(profile_manager->IsValidProfile(incognito_profile)); |
488 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); | 488 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); |
489 | 489 |
490 // Delete the incognito profile. | 490 // Delete the incognito profile. |
491 incognito_profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); | 491 incognito_profile->GetOriginalProfile()->DestroyOffTheRecordProfile(); |
492 | 492 |
493 EXPECT_FALSE(profile->HasOffTheRecordProfile()); | 493 EXPECT_FALSE(profile->HasOffTheRecordProfile()); |
494 EXPECT_FALSE(profile_manager->IsValidProfile(incognito_profile)); | 494 EXPECT_FALSE(profile_manager->IsValidProfile(incognito_profile)); |
495 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); | 495 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); |
496 } | 496 } |
OLD | NEW |