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/background/request_coordinator.h" | 5 #include "components/offline_pages/background/request_coordinator.h" |
6 | 6 |
| 7 #include <memory> |
| 8 #include <utility> |
| 9 |
7 #include "base/bind.h" | 10 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 11 #include "components/offline_pages/background/offliner_factory.h" |
| 12 #include "components/offline_pages/background/offliner_policy.h" |
9 #include "components/offline_pages/background/save_page_request.h" | 13 #include "components/offline_pages/background/save_page_request.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
11 | 15 |
12 namespace offline_pages { | 16 namespace offline_pages { |
13 | 17 |
14 namespace { | 18 namespace { |
15 // put test constants here | 19 // put test constants here |
16 const int64_t kRequestId = 42; | 20 const int64_t kRequestId = 42; |
17 const GURL kUrl("http://universe.com/everything"); | 21 const GURL kUrl("http://universe.com/everything"); |
18 const ClientId kClientId("bookmark", "1234"); | 22 const ClientId kClientId("bookmark", "1234"); |
(...skipping 11 matching lines...) Expand all Loading... |
30 | 34 |
31 RequestCoordinatorTest::RequestCoordinatorTest() {} | 35 RequestCoordinatorTest::RequestCoordinatorTest() {} |
32 | 36 |
33 RequestCoordinatorTest::~RequestCoordinatorTest() {} | 37 RequestCoordinatorTest::~RequestCoordinatorTest() {} |
34 | 38 |
35 TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { | 39 TEST_F(RequestCoordinatorTest, StartProcessingWithNoRequests) { |
36 RequestCoordinator::ProcessingDoneCallback callback = | 40 RequestCoordinator::ProcessingDoneCallback callback = |
37 base::Bind( | 41 base::Bind( |
38 &RequestCoordinatorTest::CallbackFunction, | 42 &RequestCoordinatorTest::CallbackFunction, |
39 base::Unretained(this)); | 43 base::Unretained(this)); |
40 RequestCoordinator coordinator; | 44 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); |
| 45 std::unique_ptr<OfflinerFactory> factory; |
| 46 RequestCoordinator coordinator(std::move(policy), std::move(factory)); |
41 EXPECT_FALSE(coordinator.StartProcessing(callback)); | 47 EXPECT_FALSE(coordinator.StartProcessing(callback)); |
42 } | 48 } |
43 | 49 |
44 TEST_F(RequestCoordinatorTest, SavePageLater) { | 50 TEST_F(RequestCoordinatorTest, SavePageLater) { |
45 RequestCoordinator coordinator; | 51 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy()); |
| 52 std::unique_ptr<OfflinerFactory> factory; |
| 53 RequestCoordinator coordinator(std::move(policy), std::move(factory)); |
46 SavePageRequest request(kRequestId, kUrl, kClientId, base::Time::Now()); | 54 SavePageRequest request(kRequestId, kUrl, kClientId, base::Time::Now()); |
47 EXPECT_TRUE(coordinator.SavePageLater(request)); | 55 EXPECT_TRUE(coordinator.SavePageLater(request)); |
48 } | 56 } |
49 | 57 |
50 } // namespace offline_pages | 58 } // namespace offline_pages |
OLD | NEW |