Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / recommendation_restorer_unittest.cc
blob90a21b8105551bfe749362ee611b002f45bfea21
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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/policy/recommendation_restorer.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/prefs/pref_notifier_impl.h"
9 #include "base/prefs/testing_pref_store.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/test/test_simple_task_runner.h"
12 #include "base/thread_task_runner_handle.h"
13 #include "base/time/time.h"
14 #include "base/values.h"
15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/chromeos/policy/recommendation_restorer_factory.h"
17 #include "chrome/browser/prefs/browser_prefs.h"
18 #include "chrome/browser/prefs/pref_service_syncable.h"
19 #include "chrome/common/chrome_constants.h"
20 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/testing_browser_process.h"
22 #include "chrome/test/base/testing_pref_service_syncable.h"
23 #include "chrome/test/base/testing_profile.h"
24 #include "chrome/test/base/testing_profile_manager.h"
25 #include "components/pref_registry/pref_registry_syncable.h"
26 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/notification_source.h"
29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "ui/chromeos/accessibility_types.h"
32 namespace policy {
34 namespace {
35 // The amount of idle time after which recommended values are restored.
36 const int kRestoreDelayInMs = 60 * 1000; // 1 minute.
37 } // namespace
39 class RecommendationRestorerTest : public testing::Test {
40 protected:
41 RecommendationRestorerTest();
43 // testing::Test:
44 void SetUp() override;
46 void RegisterUserProfilePrefs();
47 void RegisterLoginProfilePrefs();
49 void SetRecommendedValues();
50 void SetUserSettings();
52 void CreateLoginProfile();
53 void CreateUserProfile();
55 void NotifyOfSessionStart();
56 void NotifyOfUserActivity();
58 void VerifyPrefFollowsUser(const char* pref_name,
59 const base::Value& expected_value) const;
60 void VerifyPrefsFollowUser() const;
61 void VerifyPrefFollowsRecommendation(const char* pref_name,
62 const base::Value& expected_value) const;
63 void VerifyPrefsFollowRecommendations() const;
65 void VerifyNotListeningForNotifications() const;
66 void VerifyTimerIsStopped() const;
67 void VerifyTimerIsRunning() const;
69 TestingPrefStore* recommended_prefs_; // Not owned.
70 TestingPrefServiceSyncable* prefs_; // Not owned.
71 RecommendationRestorer* restorer_; // Not owned.
73 scoped_refptr<base::TestSimpleTaskRunner> runner_;
74 base::ThreadTaskRunnerHandle runner_handler_;
76 private:
77 scoped_ptr<PrefServiceSyncable> prefs_owner_;
79 TestingProfileManager profile_manager_;
81 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerTest);
84 RecommendationRestorerTest::RecommendationRestorerTest()
85 : recommended_prefs_(new TestingPrefStore),
86 prefs_(new TestingPrefServiceSyncable(
87 new TestingPrefStore,
88 new TestingPrefStore,
89 recommended_prefs_,
90 new user_prefs::PrefRegistrySyncable,
91 new PrefNotifierImpl)),
92 restorer_(NULL),
93 runner_(new base::TestSimpleTaskRunner),
94 runner_handler_(runner_),
95 prefs_owner_(prefs_),
96 profile_manager_(TestingBrowserProcess::GetGlobal()) {
99 void RecommendationRestorerTest::SetUp() {
100 testing::Test::SetUp();
101 ASSERT_TRUE(profile_manager_.SetUp());
104 void RecommendationRestorerTest::RegisterUserProfilePrefs() {
105 chrome::RegisterUserProfilePrefs(prefs_->registry());
108 void RecommendationRestorerTest::RegisterLoginProfilePrefs() {
109 chrome::RegisterLoginProfilePrefs(prefs_->registry());
112 void RecommendationRestorerTest::SetRecommendedValues() {
113 recommended_prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled,
114 false);
115 recommended_prefs_->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled,
116 false);
117 recommended_prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled,
118 false);
119 recommended_prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled,
120 false);
121 recommended_prefs_->SetInteger(prefs::kAccessibilityScreenMagnifierType, 0);
122 recommended_prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled,
123 false);
126 void RecommendationRestorerTest::SetUserSettings() {
127 prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, true);
128 prefs_->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, true);
129 prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled, true);
130 prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, true);
131 prefs_->SetInteger(prefs::kAccessibilityScreenMagnifierType,
132 ui::MAGNIFIER_FULL);
133 prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, true);
136 void RecommendationRestorerTest::CreateLoginProfile() {
137 ASSERT_FALSE(restorer_);
138 TestingProfile* profile = profile_manager_.CreateTestingProfile(
139 chrome::kInitialProfile, prefs_owner_.Pass(),
140 base::UTF8ToUTF16(chrome::kInitialProfile), 0, std::string(),
141 TestingProfile::TestingFactories());
142 restorer_ = RecommendationRestorerFactory::GetForProfile(profile);
143 EXPECT_TRUE(restorer_);
146 void RecommendationRestorerTest::CreateUserProfile() {
147 ASSERT_FALSE(restorer_);
148 TestingProfile* profile = profile_manager_.CreateTestingProfile(
149 "user", prefs_owner_.Pass(), base::UTF8ToUTF16("user"), 0, std::string(),
150 TestingProfile::TestingFactories());
151 restorer_ = RecommendationRestorerFactory::GetForProfile(profile);
152 EXPECT_TRUE(restorer_);
155 void RecommendationRestorerTest::NotifyOfSessionStart() {
156 ASSERT_TRUE(restorer_);
157 restorer_->Observe(chrome::NOTIFICATION_LOGIN_USER_CHANGED,
158 content::Source<RecommendationRestorerTest>(this),
159 content::NotificationService::NoDetails());
162 void RecommendationRestorerTest::NotifyOfUserActivity() {
163 ASSERT_TRUE(restorer_);
164 restorer_->OnUserActivity(NULL);
167 void RecommendationRestorerTest::VerifyPrefFollowsUser(
168 const char* pref_name,
169 const base::Value& expected_value) const {
170 const PrefServiceSyncable::Preference* pref =
171 prefs_->FindPreference(pref_name);
172 ASSERT_TRUE(pref);
173 EXPECT_TRUE(pref->HasUserSetting());
174 const base::Value* value = pref->GetValue();
175 ASSERT_TRUE(value);
176 EXPECT_TRUE(expected_value.Equals(value));
179 void RecommendationRestorerTest::VerifyPrefsFollowUser() const {
180 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled,
181 base::FundamentalValue(true));
182 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled,
183 base::FundamentalValue(true));
184 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled,
185 base::FundamentalValue(true));
186 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled,
187 base::FundamentalValue(true));
188 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType,
189 base::FundamentalValue(ui::MAGNIFIER_FULL));
190 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled,
191 base::FundamentalValue(true));
194 void RecommendationRestorerTest::VerifyPrefFollowsRecommendation(
195 const char* pref_name,
196 const base::Value& expected_value) const {
197 const PrefServiceSyncable::Preference* pref =
198 prefs_->FindPreference(pref_name);
199 ASSERT_TRUE(pref);
200 EXPECT_TRUE(pref->IsRecommended());
201 EXPECT_FALSE(pref->HasUserSetting());
202 const base::Value* value = pref->GetValue();
203 ASSERT_TRUE(value);
204 EXPECT_TRUE(expected_value.Equals(value));
207 void RecommendationRestorerTest::VerifyPrefsFollowRecommendations() const {
208 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled,
209 base::FundamentalValue(false));
210 VerifyPrefFollowsRecommendation(prefs::kAccessibilitySpokenFeedbackEnabled,
211 base::FundamentalValue(false));
212 VerifyPrefFollowsRecommendation(prefs::kAccessibilityHighContrastEnabled,
213 base::FundamentalValue(false));
214 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierEnabled,
215 base::FundamentalValue(false));
216 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierType,
217 base::FundamentalValue(0));
218 VerifyPrefFollowsRecommendation(prefs::kAccessibilityVirtualKeyboardEnabled,
219 base::FundamentalValue(false));
222 void RecommendationRestorerTest::VerifyNotListeningForNotifications() const {
223 ASSERT_TRUE(restorer_);
224 EXPECT_TRUE(restorer_->pref_change_registrar_.IsEmpty());
225 EXPECT_TRUE(restorer_->notification_registrar_.IsEmpty());
228 void RecommendationRestorerTest::VerifyTimerIsStopped() const {
229 ASSERT_TRUE(restorer_);
230 EXPECT_FALSE(restorer_->restore_timer_.IsRunning());
233 void RecommendationRestorerTest::VerifyTimerIsRunning() const {
234 ASSERT_TRUE(restorer_);
235 EXPECT_TRUE(restorer_->restore_timer_.IsRunning());
236 EXPECT_EQ(base::TimeDelta::FromMilliseconds(kRestoreDelayInMs),
237 restorer_->restore_timer_.GetCurrentDelay());
240 TEST_F(RecommendationRestorerTest, CreateForUserProfile) {
241 // Verifies that when a RecommendationRestorer is created for a user profile,
242 // it does not start listening for any notifications, does not clear user
243 // settings on initialization and does not start a timer that will clear user
244 // settings eventually.
245 RegisterUserProfilePrefs();
246 SetRecommendedValues();
247 SetUserSettings();
249 CreateUserProfile();
250 VerifyNotListeningForNotifications();
251 VerifyPrefsFollowUser();
252 VerifyTimerIsStopped();
255 TEST_F(RecommendationRestorerTest, NoRecommendations) {
256 // Verifies that when no recommended values have been set and a
257 // RecommendationRestorer is created for the login profile, it does not clear
258 // user settings on initialization and does not start a timer that will clear
259 // user settings eventually.
260 RegisterLoginProfilePrefs();
261 SetUserSettings();
263 CreateLoginProfile();
264 VerifyPrefsFollowUser();
265 VerifyTimerIsStopped();
268 TEST_F(RecommendationRestorerTest, RestoreOnStartup) {
269 // Verifies that when recommended values have been set and a
270 // RecommendationRestorer is created for the login profile, it clears user
271 // settings on initialization.
272 RegisterLoginProfilePrefs();
273 SetRecommendedValues();
274 SetUserSettings();
276 CreateLoginProfile();
277 VerifyPrefsFollowRecommendations();
278 VerifyTimerIsStopped();
281 TEST_F(RecommendationRestorerTest, RestoreOnRecommendationChangeOnLoginScreen) {
282 // Verifies that if recommended values change while the login screen is being
283 // shown, a timer is started that will clear user settings eventually.
284 RegisterLoginProfilePrefs();
285 SetUserSettings();
287 CreateLoginProfile();
289 VerifyTimerIsStopped();
290 recommended_prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled,
291 false);
292 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled,
293 base::FundamentalValue(true));
294 VerifyTimerIsRunning();
295 runner_->RunUntilIdle();
296 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled,
297 base::FundamentalValue(false));
299 VerifyTimerIsStopped();
300 recommended_prefs_->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled,
301 false);
302 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled,
303 base::FundamentalValue(true));
304 VerifyTimerIsRunning();
305 runner_->RunUntilIdle();
306 VerifyPrefFollowsRecommendation(prefs::kAccessibilitySpokenFeedbackEnabled,
307 base::FundamentalValue(false));
309 VerifyTimerIsStopped();
310 recommended_prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled,
311 false);
312 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled,
313 base::FundamentalValue(true));
314 VerifyTimerIsRunning();
315 runner_->RunUntilIdle();
316 VerifyPrefFollowsRecommendation(prefs::kAccessibilityHighContrastEnabled,
317 base::FundamentalValue(false));
319 VerifyTimerIsStopped();
320 recommended_prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled,
321 false);
322 recommended_prefs_->SetInteger(prefs::kAccessibilityScreenMagnifierType, 0);
323 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled,
324 base::FundamentalValue(true));
325 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType,
326 base::FundamentalValue(ui::MAGNIFIER_FULL));
327 VerifyTimerIsRunning();
328 runner_->RunUntilIdle();
329 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierEnabled,
330 base::FundamentalValue(false));
331 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierType,
332 base::FundamentalValue(0));
333 VerifyTimerIsStopped();
334 recommended_prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled,
335 false);
336 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled,
337 base::FundamentalValue(true));
338 VerifyTimerIsRunning();
339 runner_->RunUntilIdle();
340 VerifyPrefFollowsRecommendation(prefs::kAccessibilityVirtualKeyboardEnabled,
341 base::FundamentalValue(false));
342 VerifyTimerIsStopped();
345 TEST_F(RecommendationRestorerTest, RestoreOnRecommendationChangeInUserSession) {
346 // Verifies that if recommended values change while a user session is in
347 // progress, user settings are cleared immediately.
348 RegisterLoginProfilePrefs();
349 SetUserSettings();
351 CreateLoginProfile();
352 NotifyOfSessionStart();
354 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled,
355 base::FundamentalValue(true));
356 recommended_prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled,
357 false);
358 VerifyTimerIsStopped();
359 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled,
360 base::FundamentalValue(false));
362 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled,
363 base::FundamentalValue(true));
364 recommended_prefs_->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled,
365 false);
366 VerifyTimerIsStopped();
367 VerifyPrefFollowsRecommendation(prefs::kAccessibilitySpokenFeedbackEnabled,
368 base::FundamentalValue(false));
370 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled,
371 base::FundamentalValue(true));
372 recommended_prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled,
373 false);
374 VerifyTimerIsStopped();
375 VerifyPrefFollowsRecommendation(prefs::kAccessibilityHighContrastEnabled,
376 base::FundamentalValue(false));
378 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled,
379 base::FundamentalValue(true));
380 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType,
381 base::FundamentalValue(ui::MAGNIFIER_FULL));
382 recommended_prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled,
383 false);
384 recommended_prefs_->SetInteger(prefs::kAccessibilityScreenMagnifierType, 0);
385 VerifyTimerIsStopped();
386 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierEnabled,
387 base::FundamentalValue(false));
388 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierType,
389 base::FundamentalValue(0));
391 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled,
392 base::FundamentalValue(true));
393 recommended_prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled,
394 false);
395 VerifyTimerIsStopped();
396 VerifyPrefFollowsRecommendation(prefs::kAccessibilityVirtualKeyboardEnabled,
397 base::FundamentalValue(false));
400 TEST_F(RecommendationRestorerTest, DoNothingOnUserChange) {
401 // Verifies that if no recommended values have been set and user settings
402 // change, the user settings are not cleared immediately and no timer is
403 // started that will clear the user settings eventually.
404 RegisterLoginProfilePrefs();
405 CreateLoginProfile();
407 prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, true);
408 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled,
409 base::FundamentalValue(true));
410 VerifyTimerIsStopped();
412 prefs_->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, true);
413 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled,
414 base::FundamentalValue(true));
415 VerifyTimerIsStopped();
417 prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled, true);
418 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled,
419 base::FundamentalValue(true));
420 VerifyTimerIsStopped();
422 prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, true);
423 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled,
424 base::FundamentalValue(true));
425 VerifyTimerIsStopped();
427 prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, true);
428 prefs_->SetInteger(prefs::kAccessibilityScreenMagnifierType,
429 ui::MAGNIFIER_FULL);
430 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled,
431 base::FundamentalValue(true));
432 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType,
433 base::FundamentalValue(ui::MAGNIFIER_FULL));
434 VerifyTimerIsStopped();
436 prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, true);
437 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled,
438 base::FundamentalValue(true));
439 VerifyTimerIsStopped();
442 TEST_F(RecommendationRestorerTest, RestoreOnUserChange) {
443 // Verifies that if recommended values have been set and user settings change
444 // while the login screen is being shown, a timer is started that will clear
445 // the user settings eventually.
446 RegisterLoginProfilePrefs();
447 SetRecommendedValues();
449 CreateLoginProfile();
451 VerifyTimerIsStopped();
452 prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, true);
453 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled,
454 base::FundamentalValue(true));
455 VerifyTimerIsRunning();
456 runner_->RunUntilIdle();
457 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled,
458 base::FundamentalValue(false));
460 VerifyTimerIsStopped();
461 prefs_->SetBoolean(prefs::kAccessibilitySpokenFeedbackEnabled, true);
462 VerifyPrefFollowsUser(prefs::kAccessibilitySpokenFeedbackEnabled,
463 base::FundamentalValue(true));
464 VerifyTimerIsRunning();
465 runner_->RunUntilIdle();
466 VerifyPrefFollowsRecommendation(prefs::kAccessibilitySpokenFeedbackEnabled,
467 base::FundamentalValue(false));
469 VerifyTimerIsStopped();
470 prefs_->SetBoolean(prefs::kAccessibilityHighContrastEnabled, true);
471 VerifyPrefFollowsUser(prefs::kAccessibilityHighContrastEnabled,
472 base::FundamentalValue(true));
473 VerifyTimerIsRunning();
474 runner_->RunUntilIdle();
475 VerifyPrefFollowsRecommendation(prefs::kAccessibilityHighContrastEnabled,
476 base::FundamentalValue(false));
478 VerifyTimerIsStopped();
479 prefs_->SetBoolean(prefs::kAccessibilityScreenMagnifierEnabled, true);
480 prefs_->SetInteger(prefs::kAccessibilityScreenMagnifierType,
481 ui::MAGNIFIER_FULL);
482 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierEnabled,
483 base::FundamentalValue(true));
484 VerifyPrefFollowsUser(prefs::kAccessibilityScreenMagnifierType,
485 base::FundamentalValue(ui::MAGNIFIER_FULL));
486 VerifyTimerIsRunning();
487 runner_->RunUntilIdle();
488 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierEnabled,
489 base::FundamentalValue(false));
490 VerifyPrefFollowsRecommendation(prefs::kAccessibilityScreenMagnifierType,
491 base::FundamentalValue(0));
493 VerifyTimerIsStopped();
494 prefs_->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, true);
495 VerifyPrefFollowsUser(prefs::kAccessibilityVirtualKeyboardEnabled,
496 base::FundamentalValue(true));
497 VerifyTimerIsRunning();
498 runner_->RunUntilIdle();
499 VerifyPrefFollowsRecommendation(prefs::kAccessibilityVirtualKeyboardEnabled,
500 base::FundamentalValue(false));
502 VerifyTimerIsStopped();
505 TEST_F(RecommendationRestorerTest, RestoreOnSessionStart) {
506 // Verifies that if recommended values have been set, user settings have
507 // changed and a session is then started, the user settings are cleared
508 // immediately and the timer that would have cleared them eventually on the
509 // login screen is stopped.
510 RegisterLoginProfilePrefs();
511 SetRecommendedValues();
513 CreateLoginProfile();
514 SetUserSettings();
516 NotifyOfSessionStart();
517 VerifyPrefsFollowRecommendations();
518 VerifyTimerIsStopped();
521 TEST_F(RecommendationRestorerTest, DoNothingOnSessionStart) {
522 // Verifies that if recommended values have not been set, user settings have
523 // changed and a session is then started, the user settings are not cleared
524 // immediately.
525 RegisterLoginProfilePrefs();
526 CreateLoginProfile();
527 SetUserSettings();
529 NotifyOfSessionStart();
530 VerifyPrefsFollowUser();
531 VerifyTimerIsStopped();
534 TEST_F(RecommendationRestorerTest, UserActivityResetsTimer) {
535 // Verifies that user activity resets the timer which clears user settings.
536 RegisterLoginProfilePrefs();
538 recommended_prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled,
539 false);
541 CreateLoginProfile();
543 prefs_->SetBoolean(prefs::kAccessibilityLargeCursorEnabled, true);
544 VerifyTimerIsRunning();
546 // Notify that there is user activity, then fast forward until the originally
547 // set timer fires.
548 NotifyOfUserActivity();
549 runner_->RunPendingTasks();
550 VerifyPrefFollowsUser(prefs::kAccessibilityLargeCursorEnabled,
551 base::FundamentalValue(true));
553 // Fast forward until the reset timer fires.
554 VerifyTimerIsRunning();
555 runner_->RunUntilIdle();
556 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled,
557 base::FundamentalValue(false));
558 VerifyTimerIsStopped();
561 } // namespace policy