Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/browser/chromeos/policy/recommendation_restorer_unittest.cc

Issue 2342523002: Forcibly clear worker ref counts on shutdown. (Closed)
Patch Set: more bundles Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 12 matching lines...) Expand all
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/syncable_prefs/pref_service_syncable.h"
29 #include "components/syncable_prefs/testing_pref_service_syncable.h" 29 #include "components/syncable_prefs/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 "extensions/browser/quota_service.h" 34 #include "extensions/browser/quota_service.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 36
36 namespace policy { 37 namespace policy {
37 38
38 namespace { 39 namespace {
39 // The amount of idle time after which recommended values are restored. 40 // The amount of idle time after which recommended values are restored.
40 const int kRestoreDelayInMs = 60 * 1000; // 1 minute. 41 const int kRestoreDelayInMs = 60 * 1000; // 1 minute.
41 } // namespace 42 } // namespace
42 43
(...skipping 20 matching lines...) Expand all
63 const base::Value& expected_value) const; 64 const base::Value& expected_value) const;
64 void VerifyPrefsFollowUser() const; 65 void VerifyPrefsFollowUser() const;
65 void VerifyPrefFollowsRecommendation(const char* pref_name, 66 void VerifyPrefFollowsRecommendation(const char* pref_name,
66 const base::Value& expected_value) const; 67 const base::Value& expected_value) const;
67 void VerifyPrefsFollowRecommendations() const; 68 void VerifyPrefsFollowRecommendations() const;
68 69
69 void VerifyNotListeningForNotifications() const; 70 void VerifyNotListeningForNotifications() const;
70 void VerifyTimerIsStopped() const; 71 void VerifyTimerIsStopped() const;
71 void VerifyTimerIsRunning() const; 72 void VerifyTimerIsRunning() const;
72 73
74 content::TestBrowserThreadBundle thread_bundle_;
73 extensions::QuotaService::ScopedDisablePurgeForTesting 75 extensions::QuotaService::ScopedDisablePurgeForTesting
74 disable_purge_for_testing_; 76 disable_purge_for_testing_;
75 77
76 TestingPrefStore* recommended_prefs_; // Not owned. 78 TestingPrefStore* recommended_prefs_; // Not owned.
77 syncable_prefs::TestingPrefServiceSyncable* prefs_; // Not owned. 79 syncable_prefs::TestingPrefServiceSyncable* prefs_; // Not owned.
78 RecommendationRestorer* restorer_; // Not owned. 80 RecommendationRestorer* restorer_; // Not owned.
79 81
80 scoped_refptr<base::TestSimpleTaskRunner> runner_; 82 scoped_refptr<base::TestSimpleTaskRunner> runner_;
81 base::ThreadTaskRunnerHandle runner_handler_;
82 83
83 private: 84 private:
84 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs_owner_; 85 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs_owner_;
85 86
86 TestingProfileManager profile_manager_; 87 TestingProfileManager profile_manager_;
87 88
88 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerTest); 89 DISALLOW_COPY_AND_ASSIGN(RecommendationRestorerTest);
89 }; 90 };
90 91
91 RecommendationRestorerTest::RecommendationRestorerTest() 92 RecommendationRestorerTest::RecommendationRestorerTest()
92 : recommended_prefs_(new TestingPrefStore), 93 : recommended_prefs_(new TestingPrefStore),
93 prefs_(new syncable_prefs::TestingPrefServiceSyncable( 94 prefs_(new syncable_prefs::TestingPrefServiceSyncable(
94 new TestingPrefStore, 95 new TestingPrefStore,
95 new TestingPrefStore, 96 new TestingPrefStore,
96 recommended_prefs_, 97 recommended_prefs_,
97 new user_prefs::PrefRegistrySyncable, 98 new user_prefs::PrefRegistrySyncable,
98 new PrefNotifierImpl)), 99 new PrefNotifierImpl)),
99 restorer_(NULL), 100 restorer_(NULL),
100 runner_(new base::TestSimpleTaskRunner), 101 runner_(new base::TestSimpleTaskRunner),
101 runner_handler_(runner_),
102 prefs_owner_(prefs_), 102 prefs_owner_(prefs_),
103 profile_manager_(TestingBrowserProcess::GetGlobal()) {} 103 profile_manager_(TestingBrowserProcess::GetGlobal()) {}
104 104
105 void RecommendationRestorerTest::SetUp() { 105 void RecommendationRestorerTest::SetUp() {
106 testing::Test::SetUp(); 106 testing::Test::SetUp();
107 base::MessageLoop::current()->SetTaskRunner(runner_);
107 ASSERT_TRUE(profile_manager_.SetUp()); 108 ASSERT_TRUE(profile_manager_.SetUp());
108 } 109 }
109 110
110 void RecommendationRestorerTest::RegisterUserProfilePrefs() { 111 void RecommendationRestorerTest::RegisterUserProfilePrefs() {
111 chrome::RegisterUserProfilePrefs(prefs_->registry()); 112 chrome::RegisterUserProfilePrefs(prefs_->registry());
112 } 113 }
113 114
114 void RecommendationRestorerTest::RegisterLoginProfilePrefs() { 115 void RecommendationRestorerTest::RegisterLoginProfilePrefs() {
115 chrome::RegisterLoginProfilePrefs(prefs_->registry()); 116 chrome::RegisterLoginProfilePrefs(prefs_->registry());
116 } 117 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 559
559 // Fast forward until the reset timer fires. 560 // Fast forward until the reset timer fires.
560 VerifyTimerIsRunning(); 561 VerifyTimerIsRunning();
561 runner_->RunUntilIdle(); 562 runner_->RunUntilIdle();
562 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled, 563 VerifyPrefFollowsRecommendation(prefs::kAccessibilityLargeCursorEnabled,
563 base::FundamentalValue(false)); 564 base::FundamentalValue(false));
564 VerifyTimerIsStopped(); 565 VerifyTimerIsStopped();
565 } 566 }
566 567
567 } // namespace policy 568 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698