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

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

Issue 9020013: Refactor ProfileInfoCacheObserver interface and usage thereof. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: init 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 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_ 5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_ 6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "chrome/browser/profiles/profile_info_cache_observer.h" 12 #include "chrome/browser/profiles/profile_info_cache_observer.h"
13 #include "chrome/test/base/testing_profile_manager.h" 13 #include "chrome/test/base/testing_profile_manager.h"
14 #include "content/test/test_browser_thread.h" 14 #include "content/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 class FilePath; 17 class FilePath;
18 class ProfileInfoCache; 18 class ProfileInfoCache;
19 19
20 // Class used to test that ProfileInfoCache does not try to access any 20 // Class used to test that ProfileInfoCache does not try to access any
21 // unexpected profile names. 21 // unexpected profile names.
22 class ProfileNameVerifierObserver : public ProfileInfoCacheObserver { 22 class ProfileNameVerifierObserver : public ProfileInfoCacheObserver {
23 public: 23 public:
24 ProfileNameVerifierObserver(); 24 explicit ProfileNameVerifierObserver(ProfileInfoCache* cache);
25 virtual ~ProfileNameVerifierObserver(); 25 virtual ~ProfileNameVerifierObserver();
26 26
27 // ProfileInfoCacheObserver overrides: 27 // ProfileInfoCacheObserver overrides:
28 virtual void OnProfileAdded( 28 virtual void OnProfileAdded(
29 const string16& profile_name,
30 const string16& profile_base_dir,
31 const FilePath& profile_path, 29 const FilePath& profile_path,
32 const gfx::Image* avatar_image) OVERRIDE; 30 const string16& profile_base_dir) OVERRIDE;
33 virtual void OnProfileWillBeRemoved( 31 virtual void OnProfileWillBeRemoved(
34 const string16& profile_name) OVERRIDE; 32 const string16& profile_name) OVERRIDE;
35 virtual void OnProfileWasRemoved( 33 virtual void OnProfileWasRemoved(
36 const string16& profile_name) OVERRIDE; 34 const string16& profile_name) OVERRIDE;
37 virtual void OnProfileNameChanged( 35 virtual void OnProfileNameChanged(
38 const string16& old_profile_name, 36 const string16& old_profile_name,
39 const string16& new_profile_name) OVERRIDE; 37 const string16& new_profile_name) OVERRIDE;
40 virtual void OnProfileAvatarChanged( 38 virtual void OnProfileAvatarChanged(
41 const string16& profile_name,
42 const string16& profile_base_dir,
43 const FilePath& profile_path, 39 const FilePath& profile_path,
44 const gfx::Image* avatar_image) OVERRIDE; 40 const string16& profile_base_dir) OVERRIDE;
45 41
46 private: 42 private:
43 ProfileInfoCache* cache_;
47 std::set<string16> profile_names_; 44 std::set<string16> profile_names_;
48 DISALLOW_COPY_AND_ASSIGN(ProfileNameVerifierObserver); 45 DISALLOW_COPY_AND_ASSIGN(ProfileNameVerifierObserver);
49 }; 46 };
50 47
51 class ProfileInfoCacheTest : public testing::Test { 48 class ProfileInfoCacheTest : public testing::Test {
52 protected: 49 protected:
53 ProfileInfoCacheTest(); 50 ProfileInfoCacheTest();
54 virtual ~ProfileInfoCacheTest(); 51 virtual ~ProfileInfoCacheTest();
55 52
56 virtual void SetUp() OVERRIDE; 53 virtual void SetUp() OVERRIDE;
57 virtual void TearDown() OVERRIDE; 54 virtual void TearDown() OVERRIDE;
58 55
59 ProfileInfoCache* GetCache(); 56 ProfileInfoCache* GetCache();
60 FilePath GetProfilePath(const std::string& base_name); 57 FilePath GetProfilePath(const std::string& base_name);
61 void ResetCache(); 58 void ResetCache();
62 59
63 protected: 60 protected:
64 TestingProfileManager testing_profile_manager_; 61 TestingProfileManager testing_profile_manager_;
65 62
66 private: 63 private:
67 MessageLoopForUI ui_loop_; 64 MessageLoopForUI ui_loop_;
68 content::TestBrowserThread ui_thread_; 65 content::TestBrowserThread ui_thread_;
69 content::TestBrowserThread file_thread_; 66 content::TestBrowserThread file_thread_;
70 ProfileNameVerifierObserver name_observer_; 67 ProfileNameVerifierObserver name_observer_;
71 }; 68 };
72 69
73 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_ 70 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698