OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/chromeos/policy/recommendation_restorer.h" | 5 #include "chrome/browser/chromeos/policy/recommendation_restorer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/test/test_simple_task_runner.h" | 13 #include "base/test/test_simple_task_runner.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" | 18 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h" |
19 #include "chrome/browser/prefs/browser_prefs.h" | 19 #include "chrome/browser/prefs/browser_prefs.h" |
20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
24 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
25 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
26 #include "components/prefs/pref_notifier_impl.h" | 26 #include "components/prefs/pref_notifier_impl.h" |
27 #include "components/prefs/testing_pref_store.h" | 27 #include "components/prefs/testing_pref_store.h" |
28 #include "components/syncable_prefs/pref_service_syncable.h" | 28 #include "components/sync_preferences/pref_service_syncable.h" |
29 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 29 #include "components/sync_preferences/testing_pref_service_syncable.h" |
30 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
32 #include "content/public/browser/notification_source.h" | 32 #include "content/public/browser/notification_source.h" |
33 #include "content/public/test/test_browser_thread_bundle.h" | 33 #include "content/public/test/test_browser_thread_bundle.h" |
34 #include "extensions/browser/quota_service.h" | 34 #include "extensions/browser/quota_service.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
36 | 36 |
37 namespace policy { | 37 namespace policy { |
38 | 38 |
39 namespace { | 39 namespace { |
(...skipping 29 matching lines...) Expand all Loading... |
69 | 69 |
70 void VerifyNotListeningForNotifications() const; | 70 void VerifyNotListeningForNotifications() const; |
71 void VerifyTimerIsStopped() const; | 71 void VerifyTimerIsStopped() const; |
72 void VerifyTimerIsRunning() const; | 72 void VerifyTimerIsRunning() const; |
73 | 73 |
74 content::TestBrowserThreadBundle thread_bundle_; | 74 content::TestBrowserThreadBundle thread_bundle_; |
75 extensions::QuotaService::ScopedDisablePurgeForTesting | 75 extensions::QuotaService::ScopedDisablePurgeForTesting |
76 disable_purge_for_testing_; | 76 disable_purge_for_testing_; |
77 | 77 |
78 TestingPrefStore* recommended_prefs_; // Not owned. | 78 TestingPrefStore* recommended_prefs_; // Not owned. |
79 syncable_prefs::TestingPrefServiceSyncable* prefs_; // Not owned. | 79 sync_preferences::TestingPrefServiceSyncable* prefs_; // Not owned. |
80 RecommendationRestorer* restorer_; // Not owned. | 80 RecommendationRestorer* restorer_; // Not owned. |
81 | 81 |
82 scoped_refptr<base::TestSimpleTaskRunner> runner_; | 82 scoped_refptr<base::TestSimpleTaskRunner> runner_; |
83 | 83 |
84 private: | 84 private: |
85 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs_owner_; | 85 std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs_owner_; |
86 | 86 |
87 TestingProfileManager profile_manager_; | 87 TestingProfileManager profile_manager_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerTest); | 89 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerTest); |
90 }; | 90 }; |
91 | 91 |
92 RecommendationRestorerTest::RecommendationRestorerTest() | 92 RecommendationRestorerTest::RecommendationRestorerTest() |
93 : recommended_prefs_(new TestingPrefStore), | 93 : recommended_prefs_(new TestingPrefStore), |
94 prefs_(new syncable_prefs::TestingPrefServiceSyncable( | 94 prefs_(new sync_preferences::TestingPrefServiceSyncable( |
95 new TestingPrefStore, | 95 new TestingPrefStore, |
96 new TestingPrefStore, | 96 new TestingPrefStore, |
97 recommended_prefs_, | 97 recommended_prefs_, |
98 new user_prefs::PrefRegistrySyncable, | 98 new user_prefs::PrefRegistrySyncable, |
99 new PrefNotifierImpl)), | 99 new PrefNotifierImpl)), |
100 restorer_(NULL), | 100 restorer_(NULL), |
101 runner_(new base::TestSimpleTaskRunner), | 101 runner_(new base::TestSimpleTaskRunner), |
102 prefs_owner_(prefs_), | 102 prefs_owner_(prefs_), |
103 profile_manager_(TestingBrowserProcess::GetGlobal()) {} | 103 profile_manager_(TestingBrowserProcess::GetGlobal()) {} |
104 | 104 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 | 168 |
169 void RecommendationRestorerTest::NotifyOfUserActivity() { | 169 void RecommendationRestorerTest::NotifyOfUserActivity() { |
170 ASSERT_TRUE(restorer_); | 170 ASSERT_TRUE(restorer_); |
171 restorer_->OnUserActivity(NULL); | 171 restorer_->OnUserActivity(NULL); |
172 } | 172 } |
173 | 173 |
174 void RecommendationRestorerTest::VerifyPrefFollowsUser( | 174 void RecommendationRestorerTest::VerifyPrefFollowsUser( |
175 const char* pref_name, | 175 const char* pref_name, |
176 const base::Value& expected_value) const { | 176 const base::Value& expected_value) const { |
177 const syncable_prefs::PrefServiceSyncable::Preference* pref = | 177 const sync_preferences::PrefServiceSyncable::Preference* pref = |
178 prefs_->FindPreference(pref_name); | 178 prefs_->FindPreference(pref_name); |
179 ASSERT_TRUE(pref); | 179 ASSERT_TRUE(pref); |
180 EXPECT_TRUE(pref->HasUserSetting()); | 180 EXPECT_TRUE(pref->HasUserSetting()); |
181 const base::Value* value = pref->GetValue(); | 181 const base::Value* value = pref->GetValue(); |
182 ASSERT_TRUE(value); | 182 ASSERT_TRUE(value); |
183 EXPECT_TRUE(expected_value.Equals(value)); | 183 EXPECT_TRUE(expected_value.Equals(value)); |
184 } | 184 } |
185 | 185 |
186 void RecommendationRestorerTest::VerifyPrefsFollowUser() const { | 186 void RecommendationRestorerTest::VerifyPrefsFollowUser() const { |
187 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled, | 187 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled, |
188 base::FundamentalValue(true)); | 188 base::FundamentalValue(true)); |
189 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled, | 189 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled, |
190 base::FundamentalValue(true)); | 190 base::FundamentalValue(true)); |
191 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled, | 191 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled, |
192 base::FundamentalValue(true)); | 192 base::FundamentalValue(true)); |
193 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled, | 193 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled, |
194 base::FundamentalValue(true)); | 194 base::FundamentalValue(true)); |
195 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType, | 195 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType, |
196 base::FundamentalValue(ash::MAGNIFIER_FULL)); | 196 base::FundamentalValue(ash::MAGNIFIER_FULL)); |
197 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled, | 197 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled, |
198 base::FundamentalValue(true)); | 198 base::FundamentalValue(true)); |
199 } | 199 } |
200 | 200 |
201 void RecommendationRestorerTest::VerifyPrefFollowsRecommendation( | 201 void RecommendationRestorerTest::VerifyPrefFollowsRecommendation( |
202 const char* pref_name, | 202 const char* pref_name, |
203 const base::Value& expected_value) const { | 203 const base::Value& expected_value) const { |
204 const syncable_prefs::PrefServiceSyncable::Preference* pref = | 204 const sync_preferences::PrefServiceSyncable::Preference* pref = |
205 prefs_->FindPreference(pref_name); | 205 prefs_->FindPreference(pref_name); |
206 ASSERT_TRUE(pref); | 206 ASSERT_TRUE(pref); |
207 EXPECT_TRUE(pref->IsRecommended()); | 207 EXPECT_TRUE(pref->IsRecommended()); |
208 EXPECT_FALSE(pref->HasUserSetting()); | 208 EXPECT_FALSE(pref->HasUserSetting()); |
209 const base::Value* value = pref->GetValue(); | 209 const base::Value* value = pref->GetValue(); |
210 ASSERT_TRUE(value); | 210 ASSERT_TRUE(value); |
211 EXPECT_TRUE(expected_value.Equals(value)); | 211 EXPECT_TRUE(expected_value.Equals(value)); |
212 } | 212 } |
213 | 213 |
214 void RecommendationRestorerTest::VerifyPrefsFollowRecommendations() const { | 214 void RecommendationRestorerTest::VerifyPrefsFollowRecommendations() const { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 559 |
560 // Fast forward until the reset timer fires. | 560 // Fast forward until the reset timer fires. |
561 VerifyTimerIsRunning(); | 561 VerifyTimerIsRunning(); |
562 runner_->RunUntilIdle(); | 562 runner_->RunUntilIdle(); |
563 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled, | 563 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled, |
564 base::FundamentalValue(false)); | 564 base::FundamentalValue(false)); |
565 VerifyTimerIsStopped(); | 565 VerifyTimerIsStopped(); |
566 } | 566 } |
567 | 567 |
568 } // namespace policy | 568 } // namespace policy |
OLD | NEW |