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

Unified Diff: components/offline_pages/background/request_coordinator_unittest.cc

Issue 1971033002: Call scheduler when we get a save page later request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/background/request_coordinator_unittest.cc
diff --git a/components/offline_pages/background/request_coordinator_unittest.cc b/components/offline_pages/background/request_coordinator_unittest.cc
index a589e08ba5d3e28d23b02d132849ef1ec8ac47a7..3fbb6ff6f334d550f3b5b5e3452d502cb6ba9627 100644
--- a/components/offline_pages/background/request_coordinator_unittest.cc
+++ b/components/offline_pages/background/request_coordinator_unittest.cc
@@ -15,6 +15,7 @@
#include "components/offline_pages/background/request_queue.h"
#include "components/offline_pages/background/request_queue_in_memory_store.h"
#include "components/offline_pages/background/save_page_request.h"
+#include "components/offline_pages/background/scheduler.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace offline_pages {
@@ -25,6 +26,31 @@ const GURL kUrl("http://universe.com/everything");
const ClientId kClientId("bookmark", "42");
} // namespace
+class SchedulerStub : public Scheduler {
+ public:
+ SchedulerStub() {
+ schedule_called_ = false;
fgorski 2016/05/12 14:32:35 C++ again, use initializer list, please.
Pete Williamson 2016/05/12 17:21:19 Done.
+ unschedule_called_ = false;
+ }
+
+ void Schedule(const TriggerCondition& trigger_condition) override {
+ schedule_called_ = true;
+ }
+
+ // Unschedules the currently scheduled task, if any.
+ void Unschedule() override {
+ unschedule_called_ = true;
+ }
+
+ bool WasScheduleCalled() { return schedule_called_; }
fgorski 2016/05/12 14:32:35 can this be a const method? Did you consider simpl
Pete Williamson 2016/05/12 17:21:19 Done.
+
+ bool WasUnscheduleCalled() { return unschedule_called_; }
fgorski 2016/05/12 14:32:35 ditto.
Pete Williamson 2016/05/12 17:21:19 Done.
+
+ private:
+ bool schedule_called_;
+ bool unschedule_called_;
+};
+
class RequestCoordinatorTest
: public testing::Test {
public:
@@ -76,8 +102,10 @@ void RequestCoordinatorTest::SetUp() {
std::unique_ptr<RequestQueueInMemoryStore>
store(new RequestQueueInMemoryStore());
std::unique_ptr<RequestQueue> queue(new RequestQueue(std::move(store)));
+ std::unique_ptr<Scheduler> schedulerStub(new SchedulerStub());
fgorski 2016/05/12 14:32:35 nit: alignment
dougarnett 2016/05/12 15:33:33 scheduler_stub I suppose
Pete Williamson 2016/05/12 17:21:18 Done.
Pete Williamson 2016/05/12 17:21:19 Done.
coordinator_.reset(new RequestCoordinator(
- std::move(policy), std::move(factory), std::move(queue)));
+ std::move(policy), std::move(factory), std::move(queue),
+ std::move(schedulerStub)));
}
@@ -116,7 +144,11 @@ TEST_F(RequestCoordinatorTest, SavePageLater) {
EXPECT_EQ(kUrl, last_requests()[0].url());
EXPECT_EQ(kClientId, last_requests()[0].client_id());
- // TODO(petewil): Expect that the scheduler got notified.
+ // Expect that the scheduler got notified.
+ SchedulerStub* stub = reinterpret_cast<SchedulerStub*>(
+ getCoordinator()->GetSchedulerForTesting());
+ EXPECT_TRUE(stub->WasScheduleCalled());
+
fgorski 2016/05/12 14:32:35 nit: empty lines.
Pete Williamson 2016/05/12 17:21:19 Done.
}
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698