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

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

Issue 2269173003: Adjust scheduling for non-user requested items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // Check the request queue is as expected. 368 // Check the request queue is as expected.
369 EXPECT_EQ(1UL, last_requests().size()); 369 EXPECT_EQ(1UL, last_requests().size());
370 EXPECT_EQ(kUrl1, last_requests()[0].url()); 370 EXPECT_EQ(kUrl1, last_requests()[0].url());
371 EXPECT_EQ(kClientId1, last_requests()[0].client_id()); 371 EXPECT_EQ(kClientId1, last_requests()[0].client_id());
372 372
373 // Expect that the scheduler got notified. 373 // Expect that the scheduler got notified.
374 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>( 374 SchedulerStub* scheduler_stub = reinterpret_cast<SchedulerStub*>(
375 coordinator()->scheduler()); 375 coordinator()->scheduler());
376 EXPECT_TRUE(scheduler_stub->schedule_called()); 376 EXPECT_TRUE(scheduler_stub->schedule_called());
377 EXPECT_EQ(coordinator() 377 EXPECT_EQ(coordinator()
378 ->GetTriggerConditionsForUserRequest() 378 ->GetTriggerConditions(last_requests()[0].user_requested())
379 .minimum_battery_percentage, 379 .minimum_battery_percentage,
380 scheduler_stub->conditions()->minimum_battery_percentage); 380 scheduler_stub->conditions()->minimum_battery_percentage);
381 381
382 // Check that the observer got the notification that a page is available 382 // Check that the observer got the notification that a page is available
383 EXPECT_TRUE(observer().added_called()); 383 EXPECT_TRUE(observer().added_called());
384 } 384 }
385 385
386 TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceeded) { 386 TEST_F(RequestCoordinatorTest, OfflinerDoneRequestSucceeded) {
387 // Add a request to the queue, wait for callbacks to finish. 387 // Add a request to the queue, wait for callbacks to finish.
388 offline_pages::SavePageRequest request( 388 offline_pages::SavePageRequest request(
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 request_ids.push_back(kRequestId1); 769 request_ids.push_back(kRequestId1);
770 coordinator()->RemoveRequests(request_ids); 770 coordinator()->RemoveRequests(request_ids);
771 PumpLoop(); 771 PumpLoop();
772 772
773 EXPECT_TRUE(observer().completed_called()); 773 EXPECT_TRUE(observer().completed_called());
774 EXPECT_EQ(RequestCoordinator::SavePageStatus::REMOVED, 774 EXPECT_EQ(RequestCoordinator::SavePageStatus::REMOVED,
775 observer().last_status()); 775 observer().last_status());
776 } 776 }
777 777
778 } // namespace offline_pages 778 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698