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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 profile_manager->GenerateNextProfileDirectoryPath(); | 316 profile_manager->GenerateNextProfileDirectoryPath(); |
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(); | |
327 BrowserList* browser_list = BrowserList::GetInstance(); | 326 BrowserList* browser_list = BrowserList::GetInstance(); |
328 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); | 327 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
329 EXPECT_EQ(1U, browser_list->size()); | 328 EXPECT_EQ(1U, browser_list->size()); |
330 | 329 |
331 // Open a browser window for the first profile. | 330 // Open a browser window for the first profile. |
332 profiles::SwitchToProfile(path_profile1, desktop_type, false, | 331 profiles::SwitchToProfile(path_profile1, false, kOnProfileSwitchDoNothing, |
333 kOnProfileSwitchDoNothing, | |
334 ProfileMetrics::SWITCH_PROFILE_ICON); | 332 ProfileMetrics::SWITCH_PROFILE_ICON); |
335 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); | 333 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); |
336 EXPECT_EQ(1U, browser_list->size()); | 334 EXPECT_EQ(1U, browser_list->size()); |
337 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 335 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
338 | 336 |
339 // Open a browser window for the second profile. | 337 // Open a browser window for the second profile. |
340 profiles::SwitchToProfile(path_profile2, desktop_type, false, | 338 profiles::SwitchToProfile(path_profile2, false, kOnProfileSwitchDoNothing, |
341 kOnProfileSwitchDoNothing, | |
342 ProfileMetrics::SWITCH_PROFILE_ICON); | 339 ProfileMetrics::SWITCH_PROFILE_ICON); |
343 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); | 340 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
344 EXPECT_EQ(2U, browser_list->size()); | 341 EXPECT_EQ(2U, browser_list->size()); |
345 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 342 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
346 | 343 |
347 // Switch to the first profile without opening a new window. | 344 // Switch to the first profile without opening a new window. |
348 profiles::SwitchToProfile(path_profile1, desktop_type, false, | 345 profiles::SwitchToProfile(path_profile1, false, kOnProfileSwitchDoNothing, |
349 kOnProfileSwitchDoNothing, | |
350 ProfileMetrics::SWITCH_PROFILE_ICON); | 346 ProfileMetrics::SWITCH_PROFILE_ICON); |
351 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); | 347 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
352 EXPECT_EQ(2U, browser_list->size()); | 348 EXPECT_EQ(2U, browser_list->size()); |
353 | 349 |
354 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 350 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
355 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 351 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
356 } | 352 } |
357 | 353 |
358 // Flakes on Windows: http://crbug.com/314905 | 354 // Flakes on Windows: http://crbug.com/314905 |
359 #if defined(OS_WIN) | 355 #if defined(OS_WIN) |
(...skipping 25 matching lines...) Expand all Loading... |
385 base::FilePath path_profile2 = | 381 base::FilePath path_profile2 = |
386 profile_manager->GenerateNextProfileDirectoryPath(); | 382 profile_manager->GenerateNextProfileDirectoryPath(); |
387 profile_manager->CreateProfileAsync( | 383 profile_manager->CreateProfileAsync( |
388 path_profile2, | 384 path_profile2, |
389 base::Bind(&EphemeralProfileCreationComplete), | 385 base::Bind(&EphemeralProfileCreationComplete), |
390 base::string16(), std::string(), std::string()); | 386 base::string16(), std::string(), std::string()); |
391 | 387 |
392 // Spin to allow profile creation to take place. | 388 // Spin to allow profile creation to take place. |
393 content::RunMessageLoop(); | 389 content::RunMessageLoop(); |
394 | 390 |
395 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | |
396 BrowserList* browser_list = BrowserList::GetInstance(); | 391 BrowserList* browser_list = BrowserList::GetInstance(); |
397 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); | 392 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles()); |
398 EXPECT_EQ(1U, browser_list->size()); | 393 EXPECT_EQ(1U, browser_list->size()); |
399 | 394 |
400 // Open a browser window for the second profile. | 395 // Open a browser window for the second profile. |
401 profiles::SwitchToProfile(path_profile2, desktop_type, false, | 396 profiles::SwitchToProfile(path_profile2, false, kOnProfileSwitchDoNothing, |
402 kOnProfileSwitchDoNothing, | |
403 ProfileMetrics::SWITCH_PROFILE_ICON); | 397 ProfileMetrics::SWITCH_PROFILE_ICON); |
404 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); | 398 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
405 EXPECT_EQ(2U, browser_list->size()); | 399 EXPECT_EQ(2U, browser_list->size()); |
406 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 400 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
407 | 401 |
408 // Create a second window for the ephemeral profile. | 402 // Create a second window for the ephemeral profile. |
409 profiles::SwitchToProfile(path_profile2, desktop_type, true, | 403 profiles::SwitchToProfile(path_profile2, true, kOnProfileSwitchDoNothing, |
410 kOnProfileSwitchDoNothing, | |
411 ProfileMetrics::SWITCH_PROFILE_ICON); | 404 ProfileMetrics::SWITCH_PROFILE_ICON); |
412 EXPECT_EQ(3U, chrome::GetTotalBrowserCount()); | 405 EXPECT_EQ(3U, chrome::GetTotalBrowserCount()); |
413 EXPECT_EQ(3U, browser_list->size()); | 406 EXPECT_EQ(3U, browser_list->size()); |
414 | 407 |
415 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 408 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
416 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 409 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
417 EXPECT_EQ(path_profile2, browser_list->get(2)->profile()->GetPath()); | 410 EXPECT_EQ(path_profile2, browser_list->get(2)->profile()->GetPath()); |
418 | 411 |
419 // Closing the first window of the ephemeral profile should not delete it. | 412 // Closing the first window of the ephemeral profile should not delete it. |
420 CloseBrowserSynchronously(browser_list->get(2)); | 413 CloseBrowserSynchronously(browser_list->get(2)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 497 |
505 EXPECT_FALSE(profile->HasOffTheRecordProfile()); | 498 EXPECT_FALSE(profile->HasOffTheRecordProfile()); |
506 EXPECT_FALSE(profile_manager->IsValidProfile(incognito_profile)); | 499 EXPECT_FALSE(profile_manager->IsValidProfile(incognito_profile)); |
507 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); | 500 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); |
508 // After destroying the incognito profile incognito preferences should be | 501 // After destroying the incognito profile incognito preferences should be |
509 // cleared so the default save path should be taken from the main profile. | 502 // cleared so the default save path should be taken from the main profile. |
510 EXPECT_FALSE(profile->GetOffTheRecordPrefs() | 503 EXPECT_FALSE(profile->GetOffTheRecordPrefs() |
511 ->GetFilePath(prefs::kSaveFileDefaultDirectory) | 504 ->GetFilePath(prefs::kSaveFileDefaultDirectory) |
512 .empty()); | 505 .empty()); |
513 } | 506 } |
OLD | NEW |