| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 13 #include "chromeos/dbus/session_manager_client.h" |
| 14 |
| 15 namespace chromeos { |
| 16 |
| 17 // A helper class for tests mocking out session_manager's device settings |
| 18 // interface. The pattern is to initialize DeviceSettingsService with the helper |
| 19 // for the SessionManagerClient pointer. The helper records calls made by |
| 20 // DeviceSettingsService. The test can then verify state, after which it should |
| 21 // call one of the Flush() variants that will resume processing. |
| 22 class DeviceSettingsTestHelper : public SessionManagerClient { |
| 23 public: |
| 24 // Wraps a device settings service instance for testing. |
| 25 DeviceSettingsTestHelper(); |
| 26 virtual ~DeviceSettingsTestHelper(); |
| 27 |
| 28 // Flushes operations on the current message loop and the blocking pool. |
| 29 void FlushLoops(); |
| 30 |
| 31 // Runs all pending store callbacks. |
| 32 void FlushStore(); |
| 33 |
| 34 // Runs all pending retrieve callbacks. |
| 35 void FlushRetrieve(); |
| 36 |
| 37 // Flushes all pending operations. |
| 38 void Flush(); |
| 39 |
| 40 bool store_result() { |
| 41 return store_result_; |
| 42 } |
| 43 void set_store_result(bool store_result) { |
| 44 store_result_ = store_result; |
| 45 } |
| 46 |
| 47 const std::string& policy_blob() { |
| 48 return policy_blob_; |
| 49 } |
| 50 void set_policy_blob(const std::string& policy_blob) { |
| 51 policy_blob_ = policy_blob; |
| 52 } |
| 53 |
| 54 // SessionManagerClient: |
| 55 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 56 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 57 virtual bool HasObserver(Observer* observer) OVERRIDE; |
| 58 virtual void EmitLoginPromptReady() OVERRIDE; |
| 59 virtual void EmitLoginPromptVisible() OVERRIDE; |
| 60 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE; |
| 61 virtual void RestartEntd() OVERRIDE; |
| 62 virtual void StartSession(const std::string& user_email) OVERRIDE; |
| 63 virtual void StopSession() OVERRIDE; |
| 64 virtual void RequestLockScreen() OVERRIDE; |
| 65 virtual void RequestUnlockScreen() OVERRIDE; |
| 66 virtual bool GetIsScreenLocked() OVERRIDE; |
| 67 virtual void RetrieveDevicePolicy( |
| 68 const RetrievePolicyCallback& callback) OVERRIDE; |
| 69 virtual void RetrieveUserPolicy( |
| 70 const RetrievePolicyCallback& callback) OVERRIDE; |
| 71 virtual void StoreDevicePolicy(const std::string& policy_blob, |
| 72 const StorePolicyCallback& callback) OVERRIDE; |
| 73 virtual void StoreUserPolicy(const std::string& policy_blob, |
| 74 const StorePolicyCallback& callback) OVERRIDE; |
| 75 |
| 76 private: |
| 77 bool store_result_; |
| 78 std::string policy_blob_; |
| 79 |
| 80 std::vector<StorePolicyCallback> store_callbacks_; |
| 81 std::vector<RetrievePolicyCallback> retrieve_callbacks_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper); |
| 84 }; |
| 85 |
| 86 // Wraps the singleton device settings and initializes it to the point where it |
| 87 // reports OWNERSHIP_NONE for the ownership status. |
| 88 class ScopedDeviceSettingsTestHelper : public DeviceSettingsTestHelper { |
| 89 public: |
| 90 ScopedDeviceSettingsTestHelper(); |
| 91 virtual ~ScopedDeviceSettingsTestHelper(); |
| 92 |
| 93 private: |
| 94 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper); |
| 95 }; |
| 96 |
| 97 } // namespace chromeos |
| 98 |
| 99 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_ |
| OLD | NEW |