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