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

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

Issue 9020013: Refactor ProfileInfoCacheObserver interface and usage thereof. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixed notification in SetIsUsingGAIAPicture Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/common/chrome_notification_types.h" 12 #include "chrome/common/chrome_notification_types.h"
13 #include "chrome/test/base/testing_browser_process.h" 13 #include "chrome/test/base/testing_browser_process.h"
14 #include "chrome/test/base/testing_pref_service.h" 14 #include "chrome/test/base/testing_pref_service.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/image/image_unittest_util.h" 22 #include "ui/gfx/image/image_unittest_util.h"
23 23
24 using content::BrowserThread; 24 using content::BrowserThread;
25 25
26 ProfileNameVerifierObserver::ProfileNameVerifierObserver() { 26 ProfileNameVerifierObserver::ProfileNameVerifierObserver(
27 TestingProfileManager* testing_profile_manager)
28 : testing_profile_manager_(testing_profile_manager) {
29 DCHECK(testing_profile_manager_);
27 } 30 }
28 31
29 ProfileNameVerifierObserver::~ProfileNameVerifierObserver() { 32 ProfileNameVerifierObserver::~ProfileNameVerifierObserver() {
30 } 33 }
31 34
32 void ProfileNameVerifierObserver::OnProfileAdded( 35 void ProfileNameVerifierObserver::OnProfileAdded(
33 const string16& profile_name, 36 const FilePath& profile_path) {
34 const string16& profile_base_dir, 37 string16 profile_name = GetCache()->GetNameOfProfileAtIndex(
35 const FilePath& profile_path, 38 GetCache()->GetIndexOfProfileWithPath(profile_path));
36 const gfx::Image* avatar_image) {
37 EXPECT_TRUE(profile_names_.find(profile_name) == profile_names_.end()); 39 EXPECT_TRUE(profile_names_.find(profile_name) == profile_names_.end());
38 profile_names_.insert(profile_name); 40 profile_names_.insert(profile_name);
39 } 41 }
40 42
41 void ProfileNameVerifierObserver::OnProfileWillBeRemoved( 43 void ProfileNameVerifierObserver::OnProfileWillBeRemoved(
42 const string16& profile_name) { 44 const FilePath& profile_path) {
45 string16 profile_name = GetCache()->GetNameOfProfileAtIndex(
46 GetCache()->GetIndexOfProfileWithPath(profile_path));
43 EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end()); 47 EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end());
44 profile_names_.erase(profile_name); 48 profile_names_.erase(profile_name);
45 } 49 }
46 50
47 void ProfileNameVerifierObserver::OnProfileWasRemoved( 51 void ProfileNameVerifierObserver::OnProfileWasRemoved(
52 const FilePath& profile_path,
48 const string16& profile_name) { 53 const string16& profile_name) {
49 EXPECT_TRUE(profile_names_.find(profile_name) == profile_names_.end()); 54 EXPECT_TRUE(profile_names_.find(profile_name) == profile_names_.end());
50 } 55 }
51 56
52 void ProfileNameVerifierObserver::OnProfileNameChanged( 57 void ProfileNameVerifierObserver::OnProfileNameChanged(
53 const string16& old_profile_name, 58 const FilePath& profile_path,
54 const string16& new_profile_name) { 59 const string16& old_profile_name) {
60 string16 new_profile_name = GetCache()->GetNameOfProfileAtIndex(
61 GetCache()->GetIndexOfProfileWithPath(profile_path));
55 EXPECT_TRUE(profile_names_.find(old_profile_name) != profile_names_.end()); 62 EXPECT_TRUE(profile_names_.find(old_profile_name) != profile_names_.end());
56 EXPECT_TRUE(profile_names_.find(new_profile_name) == profile_names_.end()); 63 EXPECT_TRUE(profile_names_.find(new_profile_name) == profile_names_.end());
57 profile_names_.erase(old_profile_name); 64 profile_names_.erase(old_profile_name);
58 profile_names_.insert(new_profile_name); 65 profile_names_.insert(new_profile_name);
59 } 66 }
60 67
61 void ProfileNameVerifierObserver::OnProfileAvatarChanged( 68 void ProfileNameVerifierObserver::OnProfileAvatarChanged(
62 const string16& profile_name, 69 const FilePath& profile_path) {
63 const string16& profile_base_dir, 70 string16 profile_name = GetCache()->GetNameOfProfileAtIndex(
64 const FilePath& profile_path, 71 GetCache()->GetIndexOfProfileWithPath(profile_path));
65 const gfx::Image* avatar_image) {
66 EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end()); 72 EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end());
67 } 73 }
68 74
75 ProfileInfoCache* ProfileNameVerifierObserver::GetCache() {
76 return testing_profile_manager_->profile_info_cache();
77 }
78
69 ProfileInfoCacheTest::ProfileInfoCacheTest() 79 ProfileInfoCacheTest::ProfileInfoCacheTest()
70 : testing_profile_manager_( 80 : testing_profile_manager_(
71 static_cast<TestingBrowserProcess*>(g_browser_process)), 81 static_cast<TestingBrowserProcess*>(g_browser_process)),
72 ui_thread_(BrowserThread::UI, &ui_loop_), 82 ui_thread_(BrowserThread::UI, &ui_loop_),
73 file_thread_(BrowserThread::FILE, &ui_loop_) { 83 file_thread_(BrowserThread::FILE, &ui_loop_),
84 name_observer_(&testing_profile_manager_) {
74 } 85 }
75 86
76 ProfileInfoCacheTest::~ProfileInfoCacheTest() { 87 ProfileInfoCacheTest::~ProfileInfoCacheTest() {
77 } 88 }
78 89
79 void ProfileInfoCacheTest::SetUp() { 90 void ProfileInfoCacheTest::SetUp() {
80 ASSERT_TRUE(testing_profile_manager_.SetUp()); 91 ASSERT_TRUE(testing_profile_manager_.SetUp());
81 testing_profile_manager_.profile_info_cache()->AddObserver(&name_observer_); 92 testing_profile_manager_.profile_info_cache()->AddObserver(&name_observer_);
82 } 93 }
83 94
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(0, true); 403 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(0, true);
393 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(0, true); 404 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(0, true);
394 405
395 // Verify that the profile name and picture are not empty. 406 // Verify that the profile name and picture are not empty.
396 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(0)); 407 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(0));
397 EXPECT_TRUE(gfx::test::IsEqual( 408 EXPECT_TRUE(gfx::test::IsEqual(
398 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0))); 409 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0)));
399 } 410 }
400 411
401 } // namespace 412 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_info_cache_unittest.h ('k') | chrome/browser/profiles/profile_shortcut_manager_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698