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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_
6 #define CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_
10 #include "base/message_loop.h"
11 #include "chrome/browser/profiles/profile_info_cache_observer.h"
12 #include "chrome/test/base/testing_profile_manager.h"
13 #include "content/public/test/test_browser_thread.h"
14 #include "testing/gtest/include/gtest/gtest.h"
17 class ProfileInfoCache
;
19 // Class used to test that ProfileInfoCache does not try to access any
20 // unexpected profile names.
21 class ProfileNameVerifierObserver
: public ProfileInfoCacheObserver
{
23 explicit ProfileNameVerifierObserver(
24 TestingProfileManager
* testing_profile_manager
);
25 virtual ~ProfileNameVerifierObserver();
27 // ProfileInfoCacheObserver overrides:
28 virtual void OnProfileAdded(const FilePath
& profile_path
) OVERRIDE
;
29 virtual void OnProfileWillBeRemoved(
30 const FilePath
& profile_path
) OVERRIDE
;
31 virtual void OnProfileWasRemoved(
32 const FilePath
& profile_path
,
33 const string16
& profile_name
) OVERRIDE
;
34 virtual void OnProfileNameChanged(
35 const FilePath
& profile_path
,
36 const string16
& old_profile_name
) OVERRIDE
;
37 virtual void OnProfileAvatarChanged(const FilePath
& profile_path
) OVERRIDE
;
40 ProfileInfoCache
* GetCache();
41 std::set
<string16
> profile_names_
;
42 TestingProfileManager
* testing_profile_manager_
;
43 DISALLOW_COPY_AND_ASSIGN(ProfileNameVerifierObserver
);
46 class ProfileInfoCacheTest
: public testing::Test
{
48 ProfileInfoCacheTest();
49 virtual ~ProfileInfoCacheTest();
51 virtual void SetUp() OVERRIDE
;
52 virtual void TearDown() OVERRIDE
;
54 ProfileInfoCache
* GetCache();
55 FilePath
GetProfilePath(const std::string
& base_name
);
59 TestingProfileManager testing_profile_manager_
;
62 MessageLoopForUI ui_loop_
;
63 content::TestBrowserThread ui_thread_
;
64 content::TestBrowserThread file_thread_
;
65 ProfileNameVerifierObserver name_observer_
;
68 #endif // CHROME_BROWSER_PROFILES_PROFILE_INFO_CACHE_UNITTEST_H_