Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: components/offline_pages/client_policy_controller_unittest.cc

Issue 2111653002: [Offline Pages] Adding metadatas for namespace async_loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing tests. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/offline_pages/client_namespace_constants.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType; 12 using LifetimeType = offline_pages::LifetimePolicy::LifetimeType;
13 13
14 namespace offline_pages { 14 namespace offline_pages {
15 15
16 namespace { 16 namespace {
17 const char kUndefinedNamespace[] = "undefined"; 17 const char kUndefinedNamespace[] = "undefined";
18 18
19 bool isTemporary(const OfflinePageClientPolicy& policy) { 19 bool isTemporary(const OfflinePageClientPolicy& policy) {
20 // Check if policy has a expire period > 0 or a limited number 20 return policy.lifetime_policy.lifetime_type == LifetimeType::TEMPORARY;
21 // of pages allowed.
22 return (policy.lifetime_policy.page_limit > kUnlimitedPages ||
23 !policy.lifetime_policy.expiration_period.is_zero());
24 } 21 }
25
26 } // namespace 22 } // namespace
27 23
28 class ClientPolicyControllerTest : public testing::Test { 24 class ClientPolicyControllerTest : public testing::Test {
29 public: 25 public:
30 ClientPolicyController* controller() { return controller_.get(); } 26 ClientPolicyController* controller() { return controller_.get(); }
31 27
32 // testing::Test 28 // testing::Test
33 void SetUp() override; 29 void SetUp() override;
34 void TearDown() override; 30 void TearDown() override;
35 31
(...skipping 20 matching lines...) Expand all
56 EXPECT_EQ(policy.name_space, kBookmarkNamespace); 52 EXPECT_EQ(policy.name_space, kBookmarkNamespace);
57 EXPECT_TRUE(isTemporary(policy)); 53 EXPECT_TRUE(isTemporary(policy));
58 } 54 }
59 55
60 TEST_F(ClientPolicyControllerTest, CheckLastNDefined) { 56 TEST_F(ClientPolicyControllerTest, CheckLastNDefined) {
61 OfflinePageClientPolicy policy = controller()->GetPolicy(kLastNNamespace); 57 OfflinePageClientPolicy policy = controller()->GetPolicy(kLastNNamespace);
62 EXPECT_EQ(policy.name_space, kLastNNamespace); 58 EXPECT_EQ(policy.name_space, kLastNNamespace);
63 EXPECT_TRUE(isTemporary(policy)); 59 EXPECT_TRUE(isTemporary(policy));
64 } 60 }
65 61
62 TEST_F(ClientPolicyControllerTest, CheckAsyncDefined) {
63 OfflinePageClientPolicy policy = controller()->GetPolicy(kAsyncNamespace);
64 EXPECT_EQ(policy.name_space, kAsyncNamespace);
65 EXPECT_FALSE(isTemporary(policy));
66 }
67
66 } // namespace offline_pages 68 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/client_policy_controller.cc ('k') | components/offline_pages/offline_page_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698