| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/offline_pages/client_policy_controller.h" | 5 #include "components/offline_pages/client_policy_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "components/offline_pages/client_namespace_constants.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; | 12 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; |
| 12 | 13 |
| 13 namespace offline_pages { | 14 namespace offline_pages { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 const char kBookmarkNamespace[] = "bookmark"; | |
| 17 const char kLastNNamespace[] = "last_n"; | |
| 18 const char kUndefinedNamespace[] = "undefined"; | 17 const char kUndefinedNamespace[] = "undefined"; |
| 19 | 18 |
| 20 bool isTemporary(const OfflinePageClientPolicy& policy) { | 19 bool isTemporary(const OfflinePageClientPolicy& policy) { |
| 21 // Check if policy has a expire period > 0 or a limited number | 20 // Check if policy has a expire period > 0 or a limited number |
| 22 // of pages allowed. | 21 // of pages allowed. |
| 23 return (policy.lifetime_policy.page_limit > kUnlimitedPages || | 22 return (policy.lifetime_policy.page_limit > kUnlimitedPages || |
| 24 !policy.lifetime_policy.expiration_period.is_zero()); | 23 !policy.lifetime_policy.expiration_period.is_zero()); |
| 25 } | 24 } |
| 26 | 25 |
| 27 } // namespace | 26 } // namespace |
| (...skipping 30 matching lines...) Expand all Loading... |
| 58 EXPECT_TRUE(isTemporary(policy)); | 57 EXPECT_TRUE(isTemporary(policy)); |
| 59 } | 58 } |
| 60 | 59 |
| 61 TEST_F(ClientPolicyControllerTest, CheckLastNDefined) { | 60 TEST_F(ClientPolicyControllerTest, CheckLastNDefined) { |
| 62 OfflinePageClientPolicy policy = controller()->GetPolicy(kLastNNamespace); | 61 OfflinePageClientPolicy policy = controller()->GetPolicy(kLastNNamespace); |
| 63 EXPECT_EQ(policy.name_space, kLastNNamespace); | 62 EXPECT_EQ(policy.name_space, kLastNNamespace); |
| 64 EXPECT_TRUE(isTemporary(policy)); | 63 EXPECT_TRUE(isTemporary(policy)); |
| 65 } | 64 } |
| 66 | 65 |
| 67 } // namespace offline_pages | 66 } // namespace offline_pages |
| OLD | NEW |