| 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> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 PumpLoop(); | 941 PumpLoop(); |
| 942 | 942 |
| 943 // Since offliner was started, it will have seen cancel call. | 943 // Since offliner was started, it will have seen cancel call. |
| 944 EXPECT_TRUE(OfflinerWasCanceled()); | 944 EXPECT_TRUE(OfflinerWasCanceled()); |
| 945 } | 945 } |
| 946 | 946 |
| 947 TEST_F(RequestCoordinatorTest, MarkRequestCompleted) { | 947 TEST_F(RequestCoordinatorTest, MarkRequestCompleted) { |
| 948 // Add a request to the queue. | 948 // Add a request to the queue. |
| 949 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, | 949 offline_pages::SavePageRequest request1(kRequestId1, kUrl1, kClientId1, |
| 950 base::Time::Now(), kUserRequested); | 950 base::Time::Now(), kUserRequested); |
| 951 coordinator()->queue()->AddRequest( | 951 int64_t request_id = coordinator()->SavePageLater( |
| 952 request1, base::Bind(&RequestCoordinatorTest::AddRequestDone, | 952 kUrl1, kClientId1, kUserRequested, |
| 953 base::Unretained(this))); | 953 RequestCoordinator::RequestAvailability::DISABLED_FOR_OFFLINER); |
| 954 PumpLoop(); | 954 PumpLoop(); |
| 955 EXPECT_NE(request_id, 0l); |
| 955 | 956 |
| 956 // Ensure the start processing request stops before the completion callback. | 957 // Ensure the start processing request stops before the completion callback. |
| 957 EnableOfflinerCallback(false); | 958 EnableOfflinerCallback(false); |
| 958 | 959 |
| 959 DeviceConditions device_conditions(false, 75, | 960 DeviceConditions device_conditions(false, 75, |
| 960 net::NetworkChangeNotifier::CONNECTION_3G); | 961 net::NetworkChangeNotifier::CONNECTION_3G); |
| 961 base::Callback<void(bool)> callback = base::Bind( | 962 base::Callback<void(bool)> callback = base::Bind( |
| 962 &RequestCoordinatorTest::EmptyCallbackFunction, base::Unretained(this)); | 963 &RequestCoordinatorTest::EmptyCallbackFunction, base::Unretained(this)); |
| 963 EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback)); | 964 EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback)); |
| 964 | 965 |
| 965 // Call the method under test, making sure we send SUCCESS to the observer. | 966 // Call the method under test, making sure we send SUCCESS to the observer. |
| 966 coordinator()->MarkRequestCompleted(kRequestId1); | 967 coordinator()->MarkRequestCompleted(request_id); |
| 967 PumpLoop(); | 968 PumpLoop(); |
| 968 | 969 |
| 969 // Our observer should have seen SUCCESS instead of REMOVED. | 970 // Our observer should have seen SUCCESS instead of REMOVED. |
| 970 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::SUCCESS, | 971 EXPECT_EQ(RequestCoordinator::BackgroundSavePageResult::SUCCESS, |
| 971 observer().last_status()); | 972 observer().last_status()); |
| 972 EXPECT_TRUE(observer().completed_called()); | 973 EXPECT_TRUE(observer().completed_called()); |
| 973 } | 974 } |
| 974 | 975 |
| 975 TEST_F(RequestCoordinatorTest, WatchdogTimeout) { | 976 TEST_F(RequestCoordinatorTest, WatchdogTimeout) { |
| 976 // Build a request to use with the pre-renderer, and put it on the queue. | 977 // Build a request to use with the pre-renderer, and put it on the queue. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 // Now whether processing triggered immediately depends on whether test | 1229 // Now whether processing triggered immediately depends on whether test |
| 1229 // is run on svelte device or not. | 1230 // is run on svelte device or not. |
| 1230 if (base::SysInfo::IsLowEndDevice()) { | 1231 if (base::SysInfo::IsLowEndDevice()) { |
| 1231 EXPECT_FALSE(is_busy()); | 1232 EXPECT_FALSE(is_busy()); |
| 1232 } else { | 1233 } else { |
| 1233 EXPECT_TRUE(is_busy()); | 1234 EXPECT_TRUE(is_busy()); |
| 1234 } | 1235 } |
| 1235 } | 1236 } |
| 1236 | 1237 |
| 1237 } // namespace offline_pages | 1238 } // namespace offline_pages |
| OLD | NEW |