Alex Deymo | 391ad9f | 2014-01-29 14:36:20 -0800 | [diff] [blame] | 1 | // 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 Deymo | 6e97bb2 | 2014-02-05 16:46:16 -0800 | [diff] [blame^] | 7 | #include "update_engine/policy_manager/variable.h" |
Alex Deymo | 391ad9f | 2014-01-29 14:36:20 -0800 | [diff] [blame] | 8 | |
| 9 | using std::string; |
| 10 | |
| 11 | namespace chromeos_policy_manager { |
| 12 | |
| 13 | // Variable class that returns a value constructed with the default value. |
| 14 | template <typename T> |
| 15 | class 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 | |
| 30 | TEST(PmBaseVariableTest, GetNameTest) { |
| 31 | DefaultVariable<int> var("var"); |
| 32 | EXPECT_EQ(var.GetName(), string("var")); |
| 33 | } |
| 34 | |
| 35 | } // namespace chromeos_policy_manager |