| 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> | 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( |
| 25 TestingProfileManager* testing_profile_manager); |
| 25 virtual ~ProfileNameVerifierObserver(); | 26 virtual ~ProfileNameVerifierObserver(); |
| 26 | 27 |
| 27 // ProfileInfoCacheObserver overrides: | 28 // ProfileInfoCacheObserver overrides: |
| 28 virtual void OnProfileAdded( | 29 virtual void OnProfileAdded(const FilePath& profile_path) OVERRIDE; |
| 29 const string16& profile_name, | 30 virtual void OnProfileWillBeRemoved( |
| 30 const string16& profile_base_dir, | 31 const FilePath& profile_path) OVERRIDE; |
| 32 virtual void OnProfileWasRemoved( |
| 31 const FilePath& profile_path, | 33 const FilePath& profile_path, |
| 32 const gfx::Image* avatar_image) OVERRIDE; | |
| 33 virtual void OnProfileWillBeRemoved( | |
| 34 const string16& profile_name) OVERRIDE; | |
| 35 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, | |
| 39 const string16& new_profile_name) OVERRIDE; | |
| 40 virtual void OnProfileAvatarChanged( | |
| 41 const string16& profile_name, | |
| 42 const string16& profile_base_dir, | |
| 43 const FilePath& profile_path, | 36 const FilePath& profile_path, |
| 44 const gfx::Image* avatar_image) OVERRIDE; | 37 const string16& old_profile_name) OVERRIDE; |
| 38 virtual void OnProfileAvatarChanged(const FilePath& profile_path) OVERRIDE; |
| 45 | 39 |
| 46 private: | 40 private: |
| 41 ProfileInfoCache* GetCache(); |
| 47 std::set<string16> profile_names_; | 42 std::set<string16> profile_names_; |
| 43 TestingProfileManager* testing_profile_manager_; |
| 48 DISALLOW_COPY_AND_ASSIGN(ProfileNameVerifierObserver); | 44 DISALLOW_COPY_AND_ASSIGN(ProfileNameVerifierObserver); |
| 49 }; | 45 }; |
| 50 | 46 |
| 51 class ProfileInfoCacheTest : public testing::Test { | 47 class ProfileInfoCacheTest : public testing::Test { |
| 52 protected: | 48 protected: |
| 53 ProfileInfoCacheTest(); | 49 ProfileInfoCacheTest(); |
| 54 virtual ~ProfileInfoCacheTest(); | 50 virtual ~ProfileInfoCacheTest(); |
| 55 | 51 |
| 56 virtual void SetUp() OVERRIDE; | 52 virtual void SetUp() OVERRIDE; |
| 57 virtual void TearDown() OVERRIDE; | 53 virtual void TearDown() OVERRIDE; |
| 58 | 54 |
| 59 ProfileInfoCache* GetCache(); | 55 ProfileInfoCache* GetCache(); |
| 60 FilePath GetProfilePath(const std::string& base_name); | 56 FilePath GetProfilePath(const std::string& base_name); |
| 61 void ResetCache(); | 57 void ResetCache(); |
| 62 | 58 |
| 63 protected: | 59 protected: |
| 64 TestingProfileManager testing_profile_manager_; | 60 TestingProfileManager testing_profile_manager_; |
| 65 | 61 |
| 66 private: | 62 private: |
| 67 MessageLoopForUI ui_loop_; | 63 MessageLoopForUI ui_loop_; |
| 68 content::TestBrowserThread ui_thread_; | 64 content::TestBrowserThread ui_thread_; |
| 69 content::TestBrowserThread file_thread_; | 65 content::TestBrowserThread file_thread_; |
| 70 ProfileNameVerifierObserver name_observer_; | 66 ProfileNameVerifierObserver name_observer_; |
| 71 }; | 67 }; |
| 72 | 68 |
| 73 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_ | 69 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_ |
| OLD | NEW |