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

Unified Diff: headless/public/util/expedited_dispatcher_test.cc

Issue 2687083002: Headless: make URLRequestDispatcher aware of navigations (Closed)
Patch Set: Address nits Created 3 years, 10 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
« no previous file with comments | « headless/public/util/expedited_dispatcher.cc ('k') | headless/public/util/navigation_request.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/util/expedited_dispatcher_test.cc
diff --git a/headless/public/util/expedited_dispatcher_test.cc b/headless/public/util/expedited_dispatcher_test.cc
index 5ef6301ba1d34b1026b35b88a1a8802facb7d990..54f5249b6503cc26c1317acd7bd3218e193cfa86 100644
--- a/headless/public/util/expedited_dispatcher_test.cc
+++ b/headless/public/util/expedited_dispatcher_test.cc
@@ -8,8 +8,10 @@
#include <string>
#include <vector>
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "headless/public/util/navigation_request.h"
#include "headless/public/util/testing/fake_managed_dispatch_url_request_job.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -83,4 +85,51 @@ TEST_F(ExpeditedDispatcherTest, ErrorsAndDataReadyDispatchedInCallOrder) {
"id: 2 OK", "id: 1 OK"));
}
+namespace {
+class NavigationRequestForTest : public NavigationRequest {
+ public:
+ explicit NavigationRequestForTest(base::Closure* done_closure)
+ : done_closure_(done_closure) {}
+
+ ~NavigationRequestForTest() override {}
+
+ // NavigationRequest implementation:
+ void StartProcessing(base::Closure done_callback) override {
+ *done_closure_ = std::move(done_callback);
+ }
+
+ private:
+ base::Closure* done_closure_; // NOT OWNED
+};
+} // namespace
+
+TEST_F(ExpeditedDispatcherTest, NavigationDoesNotBlockUrlRequests) {
+ std::vector<std::string> notifications;
+ std::unique_ptr<FakeManagedDispatchURLRequestJob> job1(
+ new FakeManagedDispatchURLRequestJob(expedited_dispatcher_.get(), 1,
+ &notifications));
+ base::Closure navigation_done_closure;
+ expedited_dispatcher_->NavigationRequested(
+ base::MakeUnique<NavigationRequestForTest>(&navigation_done_closure));
+ std::unique_ptr<FakeManagedDispatchURLRequestJob> job2(
+ new FakeManagedDispatchURLRequestJob(expedited_dispatcher_.get(), 2,
+ &notifications));
+ std::unique_ptr<FakeManagedDispatchURLRequestJob> job3(
+ new FakeManagedDispatchURLRequestJob(expedited_dispatcher_.get(), 3,
+ &notifications));
+ std::unique_ptr<FakeManagedDispatchURLRequestJob> job4(
+ new FakeManagedDispatchURLRequestJob(expedited_dispatcher_.get(), 4,
+ &notifications));
+ job1->DispatchHeadersComplete();
+ job2->DispatchHeadersComplete();
+ job3->DispatchHeadersComplete();
+ job4->DispatchHeadersComplete();
+
+ EXPECT_TRUE(notifications.empty());
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_THAT(notifications,
+ ElementsAre("id: 1 OK", "id: 2 OK", "id: 3 OK", "id: 4 OK"));
+}
+
} // namespace headless
« no previous file with comments | « headless/public/util/expedited_dispatcher.cc ('k') | headless/public/util/navigation_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698