| 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 "components/prefs/pref_member.h" | 5 #include "components/prefs/pref_member.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 10 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 12 #include "components/prefs/pref_registry_simple.h" | 13 #include "components/prefs/pref_registry_simple.h" |
| 13 #include "components/prefs/testing_pref_service.h" | 14 #include "components/prefs/testing_pref_service.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 const char kBoolPref[] = "bool"; | 19 const char kBoolPref[] = "bool"; |
| 19 const char kIntPref[] = "int"; | 20 const char kIntPref[] = "int"; |
| 20 const char kDoublePref[] = "double"; | 21 const char kDoublePref[] = "double"; |
| 21 const char kStringPref[] = "string"; | 22 const char kStringPref[] = "string"; |
| 22 const char kStringListPref[] = "string_list"; | 23 const char kStringListPref[] = "string_list"; |
| 23 | 24 |
| 24 void RegisterTestPrefs(PrefRegistrySimple* registry) { | 25 void RegisterTestPrefs(PrefRegistrySimple* registry) { |
| 25 registry->RegisterBooleanPref(kBoolPref, false); | 26 registry->RegisterBooleanPref(kBoolPref, false); |
| 26 registry->RegisterIntegerPref(kIntPref, 0); | 27 registry->RegisterIntegerPref(kIntPref, 0); |
| 27 registry->RegisterDoublePref(kDoublePref, 0.0); | 28 registry->RegisterDoublePref(kDoublePref, 0.0); |
| 28 registry->RegisterStringPref(kStringPref, "default"); | 29 registry->RegisterStringPref(kStringPref, "default"); |
| 29 registry->RegisterListPref(kStringListPref, new base::ListValue()); | 30 registry->RegisterListPref(kStringListPref, |
| 31 base::MakeUnique<base::ListValue>()); |
| 30 } | 32 } |
| 31 | 33 |
| 32 class GetPrefValueHelper | 34 class GetPrefValueHelper |
| 33 : public base::RefCountedThreadSafe<GetPrefValueHelper> { | 35 : public base::RefCountedThreadSafe<GetPrefValueHelper> { |
| 34 public: | 36 public: |
| 35 GetPrefValueHelper() : value_(false), pref_thread_("pref thread") { | 37 GetPrefValueHelper() : value_(false), pref_thread_("pref thread") { |
| 36 pref_thread_.Start(); | 38 pref_thread_.Start(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 void Init(const std::string& pref_name, PrefService* prefs) { | 41 void Init(const std::string& pref_name, PrefService* prefs) { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 helper->FetchValue(); | 319 helper->FetchValue(); |
| 318 EXPECT_TRUE(helper->value()); | 320 EXPECT_TRUE(helper->value()); |
| 319 | 321 |
| 320 helper->Destroy(); | 322 helper->Destroy(); |
| 321 | 323 |
| 322 helper->FetchValue(); | 324 helper->FetchValue(); |
| 323 EXPECT_TRUE(helper->value()); | 325 EXPECT_TRUE(helper->value()); |
| 324 | 326 |
| 325 helper->StopThread(); | 327 helper->StopThread(); |
| 326 } | 328 } |
| OLD | NEW |