| Index: chrome/browser/policy/device_policy_cache_test_base.h
|
| diff --git a/chrome/browser/policy/device_policy_cache_test_base.h b/chrome/browser/policy/device_policy_cache_test_base.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2ddfc7c9f57194b38e952aa8d4cf61279cc4e7c0
|
| --- /dev/null
|
| +++ b/chrome/browser/policy/device_policy_cache_test_base.h
|
| @@ -0,0 +1,87 @@
|
| +// 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_POLICY_DEVICE_POLICY_CACHE_TEST_BASE_H_
|
| +#define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_TEST_BASE_H_
|
| +#pragma once
|
| +
|
| +#include "chrome/browser/policy/device_policy_cache.h"
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "chrome/browser/chromeos/cros/cryptohome_library.h"
|
| +#include "chrome/browser/chromeos/login/mock_signed_settings_helper.h"
|
| +#include "chrome/browser/policy/cloud_policy_data_store.h"
|
| +#include "chrome/browser/policy/enterprise_install_attributes.h"
|
| +
|
| +namespace policy {
|
| +
|
| +// A class that sets up a DevicePolicyCache for tests, and provides helper
|
| +// methods to inject policies.
|
| +class DevicePolicyCacheTestHelper {
|
| + public:
|
| + // Test registration user name.
|
| + static const char kTestUser[];
|
| +
|
| + DevicePolicyCacheTestHelper();
|
| + ~DevicePolicyCacheTestHelper();
|
| +
|
| + DevicePolicyCache* cache() { return cache_; }
|
| +
|
| + // Marks the device as an enterprise device. Returns true on success.
|
| + bool MakeEnterpriseDevice();
|
| +
|
| + // Clears all device policies currently set in the protobuf. Use LoadPolicy()
|
| + // to make the cache read them.
|
| + void ResetPolicy();
|
| +
|
| + // Sets the refresh rate policy in the protobuf.
|
| + void SetRefreshRatePolicy(int refresh_rate);
|
| +
|
| + // Sets the proxy policy in the protobuf.
|
| + void SetProxyPolicy(const std::string& proxy_mode,
|
| + const std::string& proxy_server,
|
| + const std::string& proxy_pac_url,
|
| + const std::string& proxy_bypass_list);
|
| +
|
| + // Directly overrides all the device policies in the protobuf.
|
| + void SetSettings(
|
| + const enterprise_management::ChromeDeviceSettingsProto& proto);
|
| +
|
| + // Sets the username that should be used in the next LoadPolicy() or
|
| + // SetPolicy() call. This is reset to |kTestUser| on ResetPolicy(), which is
|
| + // the default. Does not take ownership of |username|.
|
| + void SetUsername(const char* username) { username_ = username; }
|
| +
|
| + // Makes the cache load the current protobuf from the mocked signed settings.
|
| + // Returns true on success.
|
| + bool LoadPolicy();
|
| +
|
| + // Sets the current protobuf directly into the cache. Returns true on success.
|
| + // |expect_store| indicates whether it is expected that the store will be
|
| + // performed or not.
|
| + bool SetPolicy(bool expect_store);
|
| +
|
| + private:
|
| + // Helper for LoadPolicy() and SetPolicy().
|
| + bool SerializePolicy();
|
| +
|
| + scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_;
|
| + EnterpriseInstallAttributes install_attributes_;
|
| + scoped_ptr<CloudPolicyDataStore> data_store_;
|
| + chromeos::MockSignedSettingsHelper signed_settings_helper_;
|
| + scoped_ptr<DevicePolicyCache> scoped_cache_;
|
| + DevicePolicyCache* cache_;
|
| +
|
| + enterprise_management::PolicyFetchResponse policy_;
|
| + enterprise_management::ChromeDeviceSettingsProto settings_;
|
| +
|
| + const char* username_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTestHelper);
|
| +};
|
| +
|
| +} // namespace policy
|
| +
|
| +#endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_TEST_BASE_H_
|
|
|