| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/prefs/pref_member.h" | 5 #include "chrome/browser/prefs/pref_member.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "chrome/browser/prefs/pref_value_store.h" | 8 #include "chrome/browser/prefs/pref_value_store.h" |
| 9 #include "chrome/test/testing_pref_service.h" | 9 #include "chrome/test/testing_pref_service.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| 11 #include "content/common/notification_details.h" | 11 #include "content/common/notification_details.h" |
| 12 #include "content/common/notification_source.h" | 12 #include "content/common/notification_source.h" |
| 13 #include "content/common/notification_type.h" | 13 #include "content/common/notification_type.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const char kBoolPref[] = "bool"; | 18 const char kBoolPref[] = "bool"; |
| 19 const char kIntPref[] = "int"; | 19 const char kIntPref[] = "int"; |
| 20 const char kDoublePref[] = "double"; | 20 const char kDoublePref[] = "double"; |
| 21 const char kStringPref[] = "string"; | 21 const char kStringPref[] = "string"; |
| 22 const char kListPref[] = "list"; | 22 const char kListPref[] = "list"; |
| 23 | 23 |
| 24 void RegisterTestPrefs(PrefService* prefs) { | 24 void RegisterTestPrefs(PrefService* prefs) { |
| 25 prefs->RegisterBooleanPref(kBoolPref, false); | 25 prefs->RegisterBooleanPref(kBoolPref, false, false /* don't sync pref */); |
| 26 prefs->RegisterIntegerPref(kIntPref, 0); | 26 prefs->RegisterIntegerPref(kIntPref, 0, false /* don't sync pref */); |
| 27 prefs->RegisterDoublePref(kDoublePref, 0.0); | 27 prefs->RegisterDoublePref(kDoublePref, 0.0, false /* don't sync pref */); |
| 28 prefs->RegisterStringPref(kStringPref, "default"); | 28 prefs->RegisterStringPref(kStringPref, |
| 29 prefs->RegisterListPref(kListPref); | 29 "default", |
| 30 false /* don't sync pref */); |
| 31 prefs->RegisterListPref(kListPref, |
| 32 false /* don't sync pref */); |
| 30 } | 33 } |
| 31 | 34 |
| 32 class GetPrefValueCallback | 35 class GetPrefValueCallback |
| 33 : public base::RefCountedThreadSafe<GetPrefValueCallback> { | 36 : public base::RefCountedThreadSafe<GetPrefValueCallback> { |
| 34 public: | 37 public: |
| 35 GetPrefValueCallback() : value_(false) {} | 38 GetPrefValueCallback() : value_(false) {} |
| 36 | 39 |
| 37 void Init(const char* pref_name, PrefService* prefs) { | 40 void Init(const char* pref_name, PrefService* prefs) { |
| 38 pref_.Init(pref_name, prefs, NULL); | 41 pref_.Init(pref_name, prefs, NULL); |
| 39 pref_.MoveToThread(BrowserThread::IO); | 42 pref_.MoveToThread(BrowserThread::IO); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 callback->Init(kBoolPref, &prefs); | 287 callback->Init(kBoolPref, &prefs); |
| 285 | 288 |
| 286 ASSERT_TRUE(callback->FetchValue()); | 289 ASSERT_TRUE(callback->FetchValue()); |
| 287 EXPECT_FALSE(callback->value()); | 290 EXPECT_FALSE(callback->value()); |
| 288 | 291 |
| 289 prefs.SetBoolean(kBoolPref, true); | 292 prefs.SetBoolean(kBoolPref, true); |
| 290 | 293 |
| 291 ASSERT_TRUE(callback->FetchValue()); | 294 ASSERT_TRUE(callback->FetchValue()); |
| 292 EXPECT_TRUE(callback->value()); | 295 EXPECT_TRUE(callback->value()); |
| 293 } | 296 } |
| OLD | NEW |