| Index: chrome/browser/chromeos/login/device_settings_test_helper.h
|
| diff --git a/chrome/browser/chromeos/login/device_settings_test_helper.h b/chrome/browser/chromeos/login/device_settings_test_helper.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f9fabf32092a82a05bab77e44c178ba96bb7871e
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/login/device_settings_test_helper.h
|
| @@ -0,0 +1,84 @@
|
| +// 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.
|
| +
|
| +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "chromeos/dbus/session_manager_client.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +// A helper class for tests mocking out session_manager's device settings
|
| +// interface. The pattern is to initialize DeviceSettingsService with the helper
|
| +// for the SessionManagerClient pointer. The helper records calls made by
|
| +// DeviceSettingsService. The test can then verify state, after which it should
|
| +// call one of the Flush() variants that will resume processing.
|
| +class DeviceSettingsTestHelper : public SessionManagerClient {
|
| + public:
|
| + // Wraps a device settings service instance for testing.
|
| + DeviceSettingsTestHelper();
|
| + virtual ~DeviceSettingsTestHelper();
|
| +
|
| + // Runs all pending store callbacks. Returns false if nothing is pending.
|
| + void FlushStore();
|
| +
|
| + // Runs all pending retrieve callbacks. Returns false if nothing is pending.
|
| + void FlushRetrieve();
|
| +
|
| + // Flushes all pending operations.
|
| + void Flush();
|
| +
|
| + bool store_result() {
|
| + return store_result_;
|
| + }
|
| + void set_store_result(bool store_result) {
|
| + store_result_ = store_result;
|
| + }
|
| +
|
| + const std::string& policy_blob() {
|
| + return policy_blob_;
|
| + }
|
| + void set_policy_blob(const std::string& policy_blob) {
|
| + policy_blob_ = policy_blob;
|
| + }
|
| +
|
| + // SessionManagerClient:
|
| + virtual void AddObserver(Observer* observer);
|
| + virtual void RemoveObserver(Observer* observer);
|
| + virtual bool HasObserver(Observer* observer);
|
| + virtual void EmitLoginPromptReady();
|
| + virtual void EmitLoginPromptVisible();
|
| + virtual void RestartJob(int pid, const std::string& command_line);
|
| + virtual void RestartEntd();
|
| + virtual void StartSession(const std::string& user_email);
|
| + virtual void StopSession();
|
| + virtual void RequestLockScreen();
|
| + virtual void RequestUnlockScreen();
|
| + virtual bool GetIsScreenLocked();
|
| + virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback);
|
| + virtual void RetrieveUserPolicy(const RetrievePolicyCallback& callback);
|
| + virtual void StoreDevicePolicy(const std::string& policy_blob,
|
| + const StorePolicyCallback& callback);
|
| + virtual void StoreUserPolicy(const std::string& policy_blob,
|
| + const StorePolicyCallback& callback);
|
| +
|
| + private:
|
| + void FlushLoops();
|
| +
|
| + bool store_result_;
|
| + std::string policy_blob_;
|
| +
|
| + std::vector<StorePolicyCallback> store_callbacks_;
|
| + std::vector<RetrievePolicyCallback> retrieve_callbacks_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper);
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
|
|
|