Fix emulator build error
[platform/framework/web/chromium-efl.git] / components / prefs / mock_pref_change_callback.h
1 // Copyright 2011 The Chromium Authors
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 COMPONENTS_PREFS_MOCK_PREF_CHANGE_CALLBACK_H_
6 #define COMPONENTS_PREFS_MOCK_PREF_CHANGE_CALLBACK_H_
7
8 #include <string>
9
10 #include "base/memory/raw_ptr.h"
11 #include "base/memory/values_equivalent.h"
12 #include "components/prefs/pref_change_registrar.h"
13 #include "components/prefs/pref_service.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15
16 using testing::Pointee;
17 using testing::Property;
18 using testing::Truly;
19
20 // Matcher that checks whether the current value of the preference named
21 // |pref_name| in |prefs| matches |value|. If |value| is NULL, the matcher
22 // checks that the value is not set.
23 MATCHER_P3(PrefValueMatches, prefs, pref_name, value, "") {
24   const PrefService::Preference* pref = prefs->FindPreference(pref_name);
25   if (!pref)
26     return false;
27
28   return base::ValuesEquivalent(value, pref->GetValue());
29 }
30
31 // A mock for testing preference notifications and easy setup of expectations.
32 class MockPrefChangeCallback {
33  public:
34   explicit MockPrefChangeCallback(PrefService* prefs);
35   virtual ~MockPrefChangeCallback();
36
37   PrefChangeRegistrar::NamedChangeCallback GetCallback();
38
39   MOCK_METHOD1(OnPreferenceChanged, void(const std::string&));
40
41   void Expect(const std::string& pref_name,
42               const base::Value* value);
43
44  private:
45   raw_ptr<PrefService> prefs_;
46 };
47
48 #endif  // COMPONENTS_PREFS_MOCK_PREF_CHANGE_CALLBACK_H_