Index: src/default_policy_unittest.cc |
diff --git a/src/default_policy_unittest.cc b/src/default_policy_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b616d0a4129f2c3fda587d5fd15b5925e6717118 |
--- /dev/null |
+++ b/src/default_policy_unittest.cc |
@@ -0,0 +1,62 @@ |
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <gtest/gtest.h> |
+ |
+#include "src/default_policy.h" |
+ |
+namespace cashew { |
+ |
+// test fixture for DefaultPolicy unit tests |
+class DefaultPolicyTest: public ::testing::Test { |
+ protected: |
+ DefaultPolicyTest() : policy_(NULL) {} |
+ |
+ virtual ~DefaultPolicyTest() { |
+ EXPECT_TRUE(policy_ == NULL); |
+ EXPECT_TRUE(old_plans_.empty()); |
+ EXPECT_TRUE(plans_.empty()); |
+ } |
+ |
+ virtual void SetUp() { |
+ EXPECT_TRUE(policy_ == NULL); |
+ policy_ = new(std::nothrow) DefaultPolicy(kTestCarrierName); |
+ ASSERT_TRUE(policy_ != NULL); |
+ } |
+ |
+ virtual void TearDown() { |
+ delete policy_; |
+ policy_ = NULL; |
+ } |
+ |
+ static const char *kTestCarrierName; |
+ |
+ DefaultPolicy *policy_; |
+ DataPlanList old_plans_; |
+ DataPlanList plans_; |
+}; |
+ |
+const char *DefaultPolicyTest::kTestCarrierName = "Test Carrier"; |
+ |
+TEST_F(DefaultPolicyTest, GetUpdateTimerIdleSecs) { |
+ // we expect the default timer value to be 10 mins = 600 secs |
+ // unconditionally (i.e., independent of value of |plans_|) for now |
+ EXPECT_EQ(600, policy_->GetUpdateTimerIdleSecs(plans_)); |
+} |
+ |
+TEST_F(DefaultPolicyTest, ShouldEmitDataPlansUpdate) { |
+ // we expect the result to be true unconditionally (i.e., independent of the |
+ // values of |old_plans_| and |plans_|) for now |
+ EXPECT_TRUE(policy_->ShouldEmitDataPlansUpdate(old_plans_, plans_)); |
+} |
+ |
+TEST_F(DefaultPolicyTest, UsageRequestsMustBeSentOTA) { |
+ EXPECT_TRUE(policy_->UsageRequestsMustBeSentOTA()); |
+} |
+ |
+TEST_F(DefaultPolicyTest, ZonelessTimeStringsAreLocal) { |
+ EXPECT_TRUE(policy_->ZonelessTimeStringsAreLocal()); |
+} |
+ |
+} // namespace cashew |