1// Copyright (c) 2010 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#include "chrome/browser/preferences_mock_mac.h"
6
7MockPreferences::MockPreferences() {
8  values_.reset(CFDictionaryCreateMutable(kCFAllocatorDefault,
9                                          0,
10                                          &kCFTypeDictionaryKeyCallBacks,
11                                          &kCFTypeDictionaryValueCallBacks));
12  forced_.reset(CFSetCreateMutable(kCFAllocatorDefault,
13                                   0,
14                                   &kCFTypeSetCallBacks));
15}
16
17MockPreferences::~MockPreferences() {
18}
19
20Boolean MockPreferences::AppSynchronize(CFStringRef applicationID) {
21  return true;
22}
23
24CFPropertyListRef 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;
34}
35
36Boolean MockPreferences::AppValueIsForced(CFStringRef key,
37                                          CFStringRef applicationID) {
38  return CFSetContainsValue(forced_, key);
39}
40
41void MockPreferences::AddTestItem(CFStringRef key,
42                                  CFPropertyListRef value,
43                                  bool is_forced) {
44  CFDictionarySetValue(values_, key, value);
45  if (is_forced)
46    CFSetAddValue(forced_, key);
47}
48