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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/profiles/profile_info_cache.h" | 9 #include "chrome/browser/profiles/profile_info_cache.h" |
10 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 10 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 // by OnUnblockOnProfileCreation when the profile is created. | 271 // by OnUnblockOnProfileCreation when the profile is created. |
272 content::RunMessageLoop(); | 272 content::RunMessageLoop(); |
273 | 273 |
274 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 274 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
275 BrowserList* browser_list = BrowserList::GetInstance(desktop_type); | 275 BrowserList* browser_list = BrowserList::GetInstance(desktop_type); |
276 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); | 276 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); |
277 EXPECT_EQ(1U, browser_list->size()); | 277 EXPECT_EQ(1U, browser_list->size()); |
278 | 278 |
279 // Open a browser window for the first profile. | 279 // Open a browser window for the first profile. |
280 profiles::SwitchToProfile(path_profile1, desktop_type, false, | 280 profiles::SwitchToProfile(path_profile1, desktop_type, false, |
281 kOnProfileSwitchDoNothing); | 281 kOnProfileSwitchDoNothing, |
| 282 ProfileMetrics::SWITCH_PROFILE_ICON); |
282 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); | 283 EXPECT_EQ(chrome::GetTotalBrowserCount(), 1U); |
283 EXPECT_EQ(1U, browser_list->size()); | 284 EXPECT_EQ(1U, browser_list->size()); |
284 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 285 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
285 | 286 |
286 // Open a browser window for the second profile. | 287 // Open a browser window for the second profile. |
287 profiles::SwitchToProfile(path_profile2, desktop_type, false, | 288 profiles::SwitchToProfile(path_profile2, desktop_type, false, |
288 kOnProfileSwitchDoNothing); | 289 kOnProfileSwitchDoNothing, |
| 290 ProfileMetrics::SWITCH_PROFILE_ICON); |
289 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); | 291 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); |
290 EXPECT_EQ(2U, browser_list->size()); | 292 EXPECT_EQ(2U, browser_list->size()); |
291 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 293 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
292 | 294 |
293 // Switch to the first profile without opening a new window. | 295 // Switch to the first profile without opening a new window. |
294 profiles::SwitchToProfile(path_profile1, desktop_type, false, | 296 profiles::SwitchToProfile(path_profile1, desktop_type, false, |
295 kOnProfileSwitchDoNothing); | 297 kOnProfileSwitchDoNothing, |
| 298 ProfileMetrics::SWITCH_PROFILE_ICON); |
296 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); | 299 EXPECT_EQ(chrome::GetTotalBrowserCount(), 2U); |
297 EXPECT_EQ(2U, browser_list->size()); | 300 EXPECT_EQ(2U, browser_list->size()); |
298 | 301 |
299 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 302 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
300 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 303 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
301 } | 304 } |
302 | 305 |
303 // This test used to be flakily timing out on Windows: http://crbug.com/314905. | 306 // This test used to be flakily timing out on Windows: http://crbug.com/314905. |
304 // If this happens again please make it a MAYBE_ test and reopen that bug. | 307 // If this happens again please make it a MAYBE_ test and reopen that bug. |
305 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, EphemeralProfile) { | 308 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, EphemeralProfile) { |
(...skipping 25 matching lines...) Expand all Loading... |
331 // Spin to allow profile creation to take place. | 334 // Spin to allow profile creation to take place. |
332 content::RunMessageLoop(); | 335 content::RunMessageLoop(); |
333 | 336 |
334 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 337 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
335 BrowserList* browser_list = BrowserList::GetInstance(desktop_type); | 338 BrowserList* browser_list = BrowserList::GetInstance(desktop_type); |
336 ASSERT_EQ(2U, cache.GetNumberOfProfiles()); | 339 ASSERT_EQ(2U, cache.GetNumberOfProfiles()); |
337 EXPECT_EQ(1U, browser_list->size()); | 340 EXPECT_EQ(1U, browser_list->size()); |
338 | 341 |
339 // Open a browser window for the second profile. | 342 // Open a browser window for the second profile. |
340 profiles::SwitchToProfile(path_profile2, desktop_type, false, | 343 profiles::SwitchToProfile(path_profile2, desktop_type, false, |
341 kOnProfileSwitchDoNothing); | 344 kOnProfileSwitchDoNothing, |
| 345 ProfileMetrics::SWITCH_PROFILE_ICON); |
342 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); | 346 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); |
343 EXPECT_EQ(2U, browser_list->size()); | 347 EXPECT_EQ(2U, browser_list->size()); |
344 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 348 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
345 | 349 |
346 // Create a second window for the ephemeral profile. | 350 // Create a second window for the ephemeral profile. |
347 profiles::SwitchToProfile(path_profile2, desktop_type, true, | 351 profiles::SwitchToProfile(path_profile2, desktop_type, true, |
348 kOnProfileSwitchDoNothing); | 352 kOnProfileSwitchDoNothing, |
| 353 ProfileMetrics::SWITCH_PROFILE_ICON); |
349 EXPECT_EQ(3U, chrome::GetTotalBrowserCount()); | 354 EXPECT_EQ(3U, chrome::GetTotalBrowserCount()); |
350 EXPECT_EQ(3U, browser_list->size()); | 355 EXPECT_EQ(3U, browser_list->size()); |
351 | 356 |
352 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 357 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
353 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 358 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
354 EXPECT_EQ(path_profile2, browser_list->get(2)->profile()->GetPath()); | 359 EXPECT_EQ(path_profile2, browser_list->get(2)->profile()->GetPath()); |
355 | 360 |
356 // Closing the first window of the ephemeral profile should not delete it. | 361 // Closing the first window of the ephemeral profile should not delete it. |
357 browser_list->get(2)->window()->Close(); | 362 browser_list->get(2)->window()->Close(); |
358 content::RunAllPendingInMessageLoop(); | 363 content::RunAllPendingInMessageLoop(); |
359 EXPECT_EQ(2U, browser_list->size()); | 364 EXPECT_EQ(2U, browser_list->size()); |
360 ASSERT_EQ(2U, cache.GetNumberOfProfiles()); | 365 ASSERT_EQ(2U, cache.GetNumberOfProfiles()); |
361 | 366 |
362 // The second should though. | 367 // The second should though. |
363 browser_list->get(1)->window()->Close(); | 368 browser_list->get(1)->window()->Close(); |
364 content::RunAllPendingInMessageLoop(); | 369 content::RunAllPendingInMessageLoop(); |
365 EXPECT_EQ(1U, browser_list->size()); | 370 EXPECT_EQ(1U, browser_list->size()); |
366 ASSERT_EQ(1U, cache.GetNumberOfProfiles()); | 371 ASSERT_EQ(1U, cache.GetNumberOfProfiles()); |
367 } | 372 } |
OLD | NEW |