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/memory/ptr_util.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/test/scoped_task_environment.h" |
12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
13 #include "components/prefs/pref_registry_simple.h" | 14 #include "components/prefs/pref_registry_simple.h" |
14 #include "components/prefs/testing_pref_service.h" | 15 #include "components/prefs/testing_pref_service.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const char kBoolPref[] = "bool"; | 20 const char kBoolPref[] = "bool"; |
20 const char kIntPref[] = "int"; | 21 const char kIntPref[] = "int"; |
21 const char kDoublePref[] = "double"; | 22 const char kDoublePref[] = "double"; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 StringPrefMember str_; | 98 StringPrefMember str_; |
98 int observe_cnt_; | 99 int observe_cnt_; |
99 | 100 |
100 private: | 101 private: |
101 PrefService* prefs_; | 102 PrefService* prefs_; |
102 }; | 103 }; |
103 | 104 |
104 } // anonymous namespace | 105 } // anonymous namespace |
105 | 106 |
106 class PrefMemberTest : public testing::Test { | 107 class PrefMemberTest : public testing::Test { |
107 base::MessageLoop message_loop_; | 108 base::test::ScopedTaskEnvironment scoped_task_environment_; |
108 }; | 109 }; |
109 | 110 |
110 TEST_F(PrefMemberTest, BasicGetAndSet) { | 111 TEST_F(PrefMemberTest, BasicGetAndSet) { |
111 TestingPrefServiceSimple prefs; | 112 TestingPrefServiceSimple prefs; |
112 RegisterTestPrefs(prefs.registry()); | 113 RegisterTestPrefs(prefs.registry()); |
113 | 114 |
114 // Test bool | 115 // Test bool |
115 BooleanPrefMember boolean; | 116 BooleanPrefMember boolean; |
116 boolean.Init(kBoolPref, &prefs); | 117 boolean.Init(kBoolPref, &prefs); |
117 | 118 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 helper->FetchValue(); | 320 helper->FetchValue(); |
320 EXPECT_TRUE(helper->value()); | 321 EXPECT_TRUE(helper->value()); |
321 | 322 |
322 helper->Destroy(); | 323 helper->Destroy(); |
323 | 324 |
324 helper->FetchValue(); | 325 helper->FetchValue(); |
325 EXPECT_TRUE(helper->value()); | 326 EXPECT_TRUE(helper->value()); |
326 | 327 |
327 helper->StopThread(); | 328 helper->StopThread(); |
328 } | 329 } |
OLD | NEW |