Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / policy / core / common / preferences_mock_mac.cc
blobbc51c9a3523cba0b3cff3e3caf465a495c7b2b6c
1 // Copyright 2013 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 #include "components/policy/core/common/preferences_mock_mac.h"
7 MockPreferences::MockPreferences() {
8 values_.reset(CFDictionaryCreateMutable(kCFAllocatorDefault,
9 0,
10 &kCFTypeDictionaryKeyCallBacks,
11 &kCFTypeDictionaryValueCallBacks));
12 forced_.reset(CFSetCreateMutable(kCFAllocatorDefault,
14 &kCFTypeSetCallBacks));
17 MockPreferences::~MockPreferences() {
20 Boolean MockPreferences::AppSynchronize(CFStringRef applicationID) {
21 return true;
24 CFPropertyListRef MockPreferences::CopyAppValue(CFStringRef key,
25 CFStringRef applicationID) {
26 CFPropertyListRef value;
27 Boolean found = CFDictionaryGetValueIfPresent(values_,
28 key,
29 &value);
30 if (!found || !value)
31 return NULL;
32 CFRetain(value);
33 return value;
36 Boolean MockPreferences::AppValueIsForced(CFStringRef key,
37 CFStringRef applicationID) {
38 return CFSetContainsValue(forced_, key);
41 void MockPreferences::AddTestItem(CFStringRef key,
42 CFPropertyListRef value,
43 bool is_forced) {
44 CFDictionarySetValue(values_, key, value);
45 if (is_forced)
46 CFSetAddValue(forced_, key);