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

Unified Diff: chrome/browser/chromeos/login/device_settings_test_helper.cc

Issue 10828032: Add DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/device_settings_test_helper.cc
diff --git a/chrome/browser/chromeos/login/device_settings_test_helper.cc b/chrome/browser/chromeos/login/device_settings_test_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c264f1cd4edbb16a903850e1a5068db0078b4fcc
--- /dev/null
+++ b/chrome/browser/chromeos/login/device_settings_test_helper.cc
@@ -0,0 +1,111 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/device_settings_test_helper.h"
+
+#include "base/message_loop.h"
+#include "base/threading/sequenced_worker_pool.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace chromeos {
+
+DeviceSettingsTestHelper::DeviceSettingsTestHelper()
+ : store_result_(true) {}
+
+DeviceSettingsTestHelper::~DeviceSettingsTestHelper() {}
+
+void DeviceSettingsTestHelper::FlushStore() {
+ do {
+ FlushLoops();
+ std::vector<StorePolicyCallback> callbacks;
+ callbacks.swap(store_callbacks_);
+ for (std::vector<StorePolicyCallback>::iterator cb(callbacks.begin());
+ cb != callbacks.end(); ++cb) {
+ cb->Run(store_result_);
+ FlushLoops();
+ }
+ } while (!store_callbacks_.empty());
+}
+
+void DeviceSettingsTestHelper::FlushRetrieve() {
+ do {
+ FlushLoops();
+ std::vector<RetrievePolicyCallback> callbacks;
+ callbacks.swap(retrieve_callbacks_);
+ for (std::vector<RetrievePolicyCallback>::iterator cb(callbacks.begin());
+ cb != callbacks.end(); ++cb) {
+ cb->Run(policy_blob_);
+ FlushLoops();
+ }
+ } while (!retrieve_callbacks_.empty());
+}
+
+void DeviceSettingsTestHelper::Flush() {
+ do {
+ FlushStore();
+ FlushRetrieve();
+ } while (!store_callbacks_.empty());
+}
+
+void DeviceSettingsTestHelper::FlushLoops() {
+ // DeviceSettingsService may trigger operations that hop back and forth
+ // between the message loop and the blocking pool. 2 iterations are currently
+ // sufficient (key loading, signing).
+ for (int i = 0; i < 2; ++i) {
+ MessageLoop::current()->RunAllPending();
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
+ }
+ MessageLoop::current()->RunAllPending();
+}
+
+void DeviceSettingsTestHelper::AddObserver(Observer* observer) {}
+
+void DeviceSettingsTestHelper::RemoveObserver(Observer* observer) {}
+
+bool DeviceSettingsTestHelper::HasObserver(Observer* observer) {
+ return false;
+}
+
+void DeviceSettingsTestHelper::EmitLoginPromptReady() {}
+
+void DeviceSettingsTestHelper::EmitLoginPromptVisible() {}
+
+void DeviceSettingsTestHelper::RestartJob(int pid,
+ const std::string& command_line) {}
+
+void DeviceSettingsTestHelper::RestartEntd() {}
+
+void DeviceSettingsTestHelper::StartSession(const std::string& user_email) {}
+
+void DeviceSettingsTestHelper::StopSession() {}
+
+void DeviceSettingsTestHelper::RequestLockScreen() {}
+
+void DeviceSettingsTestHelper::RequestUnlockScreen() {}
+
+bool DeviceSettingsTestHelper::GetIsScreenLocked() {
+ return false;
+}
+
+void DeviceSettingsTestHelper::RetrieveDevicePolicy(
+ const RetrievePolicyCallback& callback) {
+ retrieve_callbacks_.push_back(callback);
+}
+
+void DeviceSettingsTestHelper::RetrieveUserPolicy(
+ const RetrievePolicyCallback& callback) {
+}
+
+void DeviceSettingsTestHelper::StoreDevicePolicy(
+ const std::string& policy_blob,
+ const StorePolicyCallback& callback) {
+ policy_blob_ = policy_blob;
+ store_callbacks_.push_back(callback);
+}
+
+void DeviceSettingsTestHelper::StoreUserPolicy(
+ const std::string& policy_blob,
+ const StorePolicyCallback& callback) {}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698