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