summaryrefslogtreecommitdiffstats
path: root/chromium/components/policy/core/browser/configuration_policy_pref_store_test.h
blob: 98421dfee41dc328a6f21fe04c49df776b4b55f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2014 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 COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_PREF_STORE_TEST_H_
#define COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_PREF_STORE_TEST_H_

#include <memory>

#include "base/memory/ref_counted.h"
#include "base/test/task_environment.h"
#include "components/policy/core/browser/configuration_policy_handler_list.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_service_impl.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace policy {

struct PolicyHandlerParameters;
class PolicyMap;
class ConfigurationPolicyPrefStore;

class ConfigurationPolicyPrefStoreTest : public testing::Test {
 public:
  ConfigurationPolicyPrefStoreTest(const ConfigurationPolicyPrefStoreTest&) =
      delete;
  ConfigurationPolicyPrefStoreTest& operator=(
      const ConfigurationPolicyPrefStoreTest&) = delete;

 protected:
  ConfigurationPolicyPrefStoreTest();
  ~ConfigurationPolicyPrefStoreTest() override;
  void TearDown() override;
  void UpdateProviderPolicy(const PolicyMap& policy);

  // A unit test can override this method to populate the policy handler
  // parameters as suited to its needs.
  virtual void PopulatePolicyHandlerParameters(
      PolicyHandlerParameters* parameters);

  PolicyServiceImpl::Providers providers_;
  ConfigurationPolicyHandlerList handler_list_;
  testing::NiceMock<MockConfigurationPolicyProvider> provider_;
  std::unique_ptr<PolicyServiceImpl> policy_service_;
  scoped_refptr<ConfigurationPolicyPrefStore> store_;
  base::test::SingleThreadTaskEnvironment task_environment_;
};

}  // namespace policy

#endif  // COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_PREF_STORE_TEST_H_