| 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 "chrome/browser/profiles/profile_info_cache_unittest.h" | 5 #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/prefs/pref_service_syncable.h" | 14 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 15 #include "chrome/browser/profiles/profile_info_cache.h" | 15 #include "chrome/browser/profiles/profile_info_cache.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/test/test_browser_thread_bundle.h" |
| 21 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 25 #include "ui/gfx/image/image_unittest_util.h" | 26 #include "ui/gfx/image/image_unittest_util.h" |
| 26 | 27 |
| 27 using content::BrowserThread; | 28 using content::BrowserThread; |
| 28 | 29 |
| 29 ProfileNameVerifierObserver::ProfileNameVerifierObserver( | 30 ProfileNameVerifierObserver::ProfileNameVerifierObserver( |
| 30 TestingProfileManager* testing_profile_manager) | 31 TestingProfileManager* testing_profile_manager) |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 testing_profile_manager_.CreateTestingProfile( | 453 testing_profile_manager_.CreateTestingProfile( |
| 453 "test1", scoped_ptr<PrefServiceSyncable>(), | 454 "test1", scoped_ptr<PrefServiceSyncable>(), |
| 454 managed_user_name, 0, "TEST_ID"); | 455 managed_user_name, 0, "TEST_ID"); |
| 455 for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) { | 456 for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) { |
| 456 bool is_managed = | 457 bool is_managed = |
| 457 GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name; | 458 GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name; |
| 458 EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); | 459 EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); |
| 459 std::string managed_user_id = is_managed ? "TEST_ID" : ""; | 460 std::string managed_user_id = is_managed ? "TEST_ID" : ""; |
| 460 EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i)); | 461 EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i)); |
| 461 } | 462 } |
| 463 |
| 464 // Managed profiles have a custom theme, which needs to be deleted on the FILE |
| 465 // thread. Reset the profile manager now so everything is deleted while we |
| 466 // still have a FILE thread. |
| 467 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL); |
| 462 } | 468 } |
| 463 | 469 |
| 464 TEST_F(ProfileInfoCacheTest, AddStubProfile) { | 470 TEST_F(ProfileInfoCacheTest, AddStubProfile) { |
| 465 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); | 471 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
| 466 | 472 |
| 467 // Add some profiles with and without a '.' in their paths. | 473 // Add some profiles with and without a '.' in their paths. |
| 468 const struct { | 474 const struct { |
| 469 const char* profile_path; | 475 const char* profile_path; |
| 470 const char* profile_name; | 476 const char* profile_name; |
| 471 } kTestCases[] = { | 477 } kTestCases[] = { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 488 | 494 |
| 489 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); | 495 ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); |
| 490 | 496 |
| 491 // Check that the profiles can be extracted from the local state. | 497 // Check that the profiles can be extracted from the local state. |
| 492 std::vector<string16> names = ProfileInfoCache::GetProfileNames(); | 498 std::vector<string16> names = ProfileInfoCache::GetProfileNames(); |
| 493 for (size_t i = 0; i < 4; i++) | 499 for (size_t i = 0; i < 4; i++) |
| 494 ASSERT_FALSE(names[i].empty()); | 500 ASSERT_FALSE(names[i].empty()); |
| 495 } | 501 } |
| 496 | 502 |
| 497 } // namespace | 503 } // namespace |
| OLD | NEW |