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