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

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: Oops. Created 8 years, 4 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 "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.
pastarmovj 2012/07/30 12:19:19 Working around the "true mocks are bad for your he
Mattias Nissler (ping if slow) 2012/07/31 13:02:15 In this case they are, I actually had the gmock ve
22 class DeviceSettingsTestHelper : public SessionManagerClient {
23 public:
24 // Wraps a device settings service instance for testing.
25 DeviceSettingsTestHelper();
26 virtual ~DeviceSettingsTestHelper();
27
28 // Runs all pending store callbacks. Returns false if nothing is pending.
pastarmovj 2012/07/30 12:19:19 Returns false from a void fnc?
Mattias Nissler (ping if slow) 2012/07/31 13:02:15 Done.
29 void FlushStore();
30
31 // Runs all pending retrieve callbacks. Returns false if nothing is pending.
pastarmovj 2012/07/30 12:19:19 Returns false from a void fnc?
Mattias Nissler (ping if slow) 2012/07/31 13:02:15 Done.
32 void FlushRetrieve();
33
34 // Flushes all pending operations.
35 void Flush();
36
37 bool store_result() {
38 return store_result_;
39 }
40 void set_store_result(bool store_result) {
41 store_result_ = store_result;
42 }
43
44 const std::string& policy_blob() {
45 return policy_blob_;
46 }
47 void set_policy_blob(const std::string& policy_blob) {
48 policy_blob_ = policy_blob;
49 }
50
51 // SessionManagerClient:
52 virtual void AddObserver(Observer* observer) OVERRIDE;
53 virtual void RemoveObserver(Observer* observer) OVERRIDE;
54 virtual bool HasObserver(Observer* observer) OVERRIDE;
55 virtual void EmitLoginPromptReady() OVERRIDE;
56 virtual void EmitLoginPromptVisible() OVERRIDE;
57 virtual void RestartJob(int pid, const std::string& command_line) OVERRIDE;
58 virtual void RestartEntd() OVERRIDE;
59 virtual void StartSession(const std::string& user_email) OVERRIDE;
60 virtual void StopSession() OVERRIDE;
61 virtual void RequestLockScreen() OVERRIDE;
62 virtual void RequestUnlockScreen() OVERRIDE;
63 virtual bool GetIsScreenLocked() OVERRIDE;
64 virtual void RetrieveDevicePolicy(
65 const RetrievePolicyCallback& callback) OVERRIDE;
66 virtual void RetrieveUserPolicy(
67 const RetrievePolicyCallback& callback) OVERRIDE;
68 virtual void StoreDevicePolicy(const std::string& policy_blob,
69 const StorePolicyCallback& callback) OVERRIDE;
70 virtual void StoreUserPolicy(const std::string& policy_blob,
71 const StorePolicyCallback& callback) OVERRIDE;
72
73 private:
74 void FlushLoops();
75
76 bool store_result_;
77 std::string policy_blob_;
78
79 std::vector<StorePolicyCallback> store_callbacks_;
80 std::vector<RetrievePolicyCallback> retrieve_callbacks_;
81
82 DISALLOW_COPY_AND_ASSIGN(DeviceSettingsTestHelper);
83 };
84
85 // Wraps the singleton device settings and initializes it to the point where it
86 // reports OWNERSHIP_NONE for the ownership status.
87 class ScopedDeviceSettingsTestHelper : public DeviceSettingsTestHelper {
88 public:
89 ScopedDeviceSettingsTestHelper();
90 virtual ~ScopedDeviceSettingsTestHelper();
91
92 private:
93 DISALLOW_COPY_AND_ASSIGN(ScopedDeviceSettingsTestHelper);
94 };
95
96 } // namespace chromeos
97
98 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_DEVICE_SETTINGS_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698