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

Side by Side Diff: chrome/browser/chromeos/login/device_settings_test_helper.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "chromeos/dbus/session_manager_client.h"
13
14 namespace chromeos {
15
16 // A helper class for tests mocking out session_manager's device settings
17 // interface. The pattern is to initialize DeviceSettingsService with the helper
18 // for the SessionManagerClient pointer. The helper records calls made by
19 // DeviceSettingsService. The test can then verify state, after which it should
20 // call one of the Flush() variants that will resume processing.
21 class DeviceSettingsTestHelper : public SessionManagerClient {
22 public:
23 // Wraps a device settings service instance for testing.
24 DeviceSettingsTestHelper();
25 virtual ~DeviceSettingsTestHelper();
26
27 // Runs all pending store callbacks. Returns false if nothing is pending.
28 void FlushStore();
29
30 // Runs all pending retrieve callbacks. Returns false if nothing is pending.
31 void FlushRetrieve();
32
33 // Flushes all pending operations.
34 void Flush();
35
36 bool store_result() {
37 return store_result_;
38 }
39 void set_store_result(bool store_result) {
40 store_result_ = store_result;
41 }
42
43 const std::string& policy_blob() {
44 return policy_blob_;
45 }
46 void set_policy_blob(const std::string& policy_blob) {
47 policy_blob_ = policy_blob;
48 }
49
50 // SessionManagerClient:
51 virtual void AddObserver(Observer* observer);
52 virtual void RemoveObserver(Observer* observer);
53 virtual bool HasObserver(Observer* observer);
54 virtual void EmitLoginPromptReady();
55 virtual void EmitLoginPromptVisible();
56 virtual void RestartJob(int pid, const std::string& command_line);
57 virtual void RestartEntd();
58 virtual void StartSession(const std::string& user_email);
59 virtual void StopSession();
60 virtual void RequestLockScreen();
61 virtual void RequestUnlockScreen();
62 virtual bool GetIsScreenLocked();
63 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback);
64 virtual void RetrieveUserPolicy(const RetrievePolicyCallback& callback);
65 virtual void StoreDevicePolicy(const std::string& policy_blob,
66 const StorePolicyCallback& callback);
67 virtual void StoreUserPolicy(const std::string& policy_blob,
68 const StorePolicyCallback& callback);
69
70 private:
71 void FlushLoops();
72
73 bool store_result_;
74 std::string policy_blob_;
75
76 std::vector<StorePolicyCallback> store_callbacks_;
77 std::vector<RetrievePolicyCallback> retrieve_callbacks_;
78
79 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper);
80 };
81
82 } // namespace chromeos
83
84 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698