blob: 8c7bdc5d9ff723782a8a5524d9ae52a6b05bd747 [file] [log] [blame]
Alex Deymo391ad9f2014-01-29 14:36:20 -08001// Copyright (c) 2014 The Chromium OS 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#include <gtest/gtest.h>
6
Alex Deymo6e97bb22014-02-05 16:46:16 -08007#include "update_engine/policy_manager/variable.h"
Alex Deymo391ad9f2014-01-29 14:36:20 -08008
9using std::string;
10
11namespace chromeos_policy_manager {
12
13// Variable class that returns a value constructed with the default value.
14template <typename T>
15class DefaultVariable : public Variable<T> {
16 public:
17 DefaultVariable(const string& name) : Variable<T>(name) {}
18 virtual ~DefaultVariable() {}
19
20 protected:
21 virtual const T* GetValue(base::TimeDelta /* timeout */,
22 string* /* errmsg */) {
23 return new T();
24 }
25
26 private:
27 DISALLOW_COPY_AND_ASSIGN(DefaultVariable);
28};
29
30TEST(PmBaseVariableTest, GetNameTest) {
31 DefaultVariable<int> var("var");
32 EXPECT_EQ(var.GetName(), string("var"));
33}
34
35} // namespace chromeos_policy_manager