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

Unified Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 2390983003: Implement Mojo SyncLoad (Closed)
Patch Set: +tests Created 4 years, 2 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: content/browser/loader/resource_dispatcher_host_unittest.cc
diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
index 91f332d045833acb60c0fd21cd67c60c739ff092..68574f6b602e115676cf603eabb0320309880a89 100644
--- a/content/browser/loader/resource_dispatcher_host_unittest.cc
+++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
@@ -3696,6 +3696,72 @@ TEST_P(ResourceDispatcherHostTest, ThrottleMustProcessResponseBeforeRead) {
base::RunLoop().RunUntilIdle();
}
+namespace {
+
+void StoreSyncLoadResult(bool* called,
+ bool* was_null,
+ SyncLoadResult* result_out,
+ const SyncLoadResult* result) {
+ *called = true;
+ *was_null = !result;
+
+ if (result)
+ *result_out = *result;
+}
+
+} // namespace
+
+TEST_P(ResourceDispatcherHostTest, SyncLoadWithMojoSuccess) {
+ ResourceRequest request = CreateResourceRequest(
+ "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_1());
+ request.priority = net::MAXIMUM_PRIORITY;
+
+ bool called = false;
+ bool was_null = false;
+ SyncLoadResult result;
+ host_.OnSyncLoadWithMojo(0, 1, request, filter_.get(),
+ base::Bind(&StoreSyncLoadResult,
+ &called, &was_null, &result));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(called);
+ EXPECT_FALSE(was_null);
+ EXPECT_EQ(net::OK, result.error_code);
+}
+
+TEST_P(ResourceDispatcherHostTest, SyncLoadWithMojoError) {
+ ResourceRequest request = CreateResourceRequest(
+ "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error());
+ request.priority = net::MAXIMUM_PRIORITY;
+
+ bool called = false;
+ bool was_null = false;
+ SyncLoadResult result;
+ host_.OnSyncLoadWithMojo(0, 1, request, filter_.get(),
+ base::Bind(&StoreSyncLoadResult,
+ &called, &was_null, &result));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(called);
+ EXPECT_FALSE(was_null);
+ EXPECT_EQ(net::ERR_INVALID_URL, result.error_code);
+}
+
+TEST_P(ResourceDispatcherHostTest, SyncLoadWithMojoCancel) {
+ ResourceRequest request = CreateResourceRequest(
+ "GET", RESOURCE_TYPE_XHR, net::URLRequestTestJob::test_url_error());
+ request.priority = net::MAXIMUM_PRIORITY;
+
+ bool called = false;
+ bool was_null = false;
+ SyncLoadResult result;
+ host_.OnSyncLoadWithMojo(0, 1, request, filter_.get(),
+ base::Bind(&StoreSyncLoadResult,
+ &called, &was_null, &result));
+ host_.CancelRequestsForProcess(filter_->child_id());
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(called);
+ EXPECT_TRUE(was_null);
+}
+
// A URLRequestTestJob that sets a test certificate on the |ssl_info|
// field of the response.
class TestHTTPSURLRequestJob : public net::URLRequestTestJob {
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/url_loader_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698