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