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

Side by Side Diff: components/offline_pages/background/request_coordinator_unittest.cc

Issue 2280713002: [OfflinePages] Clear busy flag in StopPrerendering() in Request Coordinator. (Closed)
Patch Set: Spelling fix Created 4 years, 3 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
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 net::NetworkChangeNotifier::CONNECTION_3G); 600 net::NetworkChangeNotifier::CONNECTION_3G);
601 base::Callback<void(bool)> callback = 601 base::Callback<void(bool)> callback =
602 base::Bind( 602 base::Bind(
603 &RequestCoordinatorTest::EmptyCallbackFunction, 603 &RequestCoordinatorTest::EmptyCallbackFunction,
604 base::Unretained(this)); 604 base::Unretained(this));
605 EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback)); 605 EXPECT_TRUE(coordinator()->StartProcessing(device_conditions, callback));
606 606
607 // Let all the async parts of the start processing pipeline run to completion. 607 // Let all the async parts of the start processing pipeline run to completion.
608 PumpLoop(); 608 PumpLoop();
609 609
610 // Coordinator should now be busy.
611 EXPECT_TRUE(is_busy());
612
610 // Now we cancel it while the prerenderer is busy. 613 // Now we cancel it while the prerenderer is busy.
611 coordinator()->StopProcessing(); 614 coordinator()->StopProcessing();
612 615
613 // Let the async callbacks in the cancel run. 616 // Let the async callbacks in the cancel run.
614 PumpLoop(); 617 PumpLoop();
615 618
619 EXPECT_FALSE(is_busy());
620
616 // OfflinerDoneCallback will not end up getting called with status SAVED, 621 // OfflinerDoneCallback will not end up getting called with status SAVED,
617 // since we cancelled the event before the LoadAndSave completed. 622 // since we cancelled the event before the LoadAndSave completed.
618 EXPECT_EQ(Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED, 623 EXPECT_EQ(Offliner::RequestStatus::REQUEST_COORDINATOR_CANCELED,
619 last_offlining_status()); 624 last_offlining_status());
620 625
621 // Since offliner was started, it will have seen cancel call. 626 // Since offliner was started, it will have seen cancel call.
622 EXPECT_TRUE(OfflinerWasCanceled()); 627 EXPECT_TRUE(OfflinerWasCanceled());
623 } 628 }
624 629
625 // This tests that canceling a request will result in TryNextRequest() getting 630 // This tests that canceling a request will result in TryNextRequest() getting
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 PumpLoop(); 833 PumpLoop();
829 834
830 EXPECT_TRUE(observer().completed_called()); 835 EXPECT_TRUE(observer().completed_called());
831 EXPECT_EQ(RequestCoordinator::SavePageStatus::REMOVED, 836 EXPECT_EQ(RequestCoordinator::SavePageStatus::REMOVED,
832 observer().last_status()); 837 observer().last_status());
833 EXPECT_EQ(1UL, last_remove_results().size()); 838 EXPECT_EQ(1UL, last_remove_results().size());
834 EXPECT_EQ(kRequestId1, std::get<0>(last_remove_results().at(0))); 839 EXPECT_EQ(kRequestId1, std::get<0>(last_remove_results().at(0)));
835 } 840 }
836 841
837 } // namespace offline_pages 842 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/request_coordinator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698