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

Side by Side Diff: content/browser/loader/mime_sniffing_resource_handler_unittest.cc

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: fix ContentResourceProviderTest Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/loader/mime_sniffing_resource_handler.h" 5 #include "content/browser/loader/mime_sniffing_resource_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "content/browser/loader/intercepting_resource_handler.h" 18 #include "content/browser/loader/intercepting_resource_handler.h"
19 #include "content/browser/loader/resource_controller.h" 19 #include "content/browser/loader/resource_controller.h"
20 #include "content/browser/loader/resource_dispatcher_host_impl.h" 20 #include "content/browser/loader/resource_dispatcher_host_impl.h"
21 #include "content/browser/loader/test_resource_handler.h" 21 #include "content/browser/loader/test_resource_handler.h"
22 #include "content/public/browser/resource_dispatcher_host_delegate.h" 22 #include "content/public/browser/resource_dispatcher_host_delegate.h"
23 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
24 #include "content/public/common/previews_state.h"
24 #include "content/public/common/resource_response.h" 25 #include "content/public/common/resource_response.h"
25 #include "content/public/common/webplugininfo.h" 26 #include "content/public/common/webplugininfo.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 27 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "content/public/test/test_utils.h" 28 #include "content/public/test/test_utils.h"
28 #include "content/test/fake_plugin_service.h" 29 #include "content/test/fake_plugin_service.h"
29 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
30 #include "ppapi/features/features.h" 31 #include "ppapi/features/features.h"
31 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 #include "url/origin.h" 34 #include "url/origin.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 MimeSniffingResourceHandlerTest::TestAcceptHeaderSettingWithURLRequest( 242 MimeSniffingResourceHandlerTest::TestAcceptHeaderSettingWithURLRequest(
242 ResourceType request_resource_type, 243 ResourceType request_resource_type,
243 net::URLRequest* request) { 244 net::URLRequest* request) {
244 bool is_main_frame = request_resource_type == RESOURCE_TYPE_MAIN_FRAME; 245 bool is_main_frame = request_resource_type == RESOURCE_TYPE_MAIN_FRAME;
245 ResourceRequestInfo::AllocateForTesting(request, request_resource_type, 246 ResourceRequestInfo::AllocateForTesting(request, request_resource_type,
246 nullptr, // context 247 nullptr, // context
247 0, // render_process_id 248 0, // render_process_id
248 0, // render_view_id 249 0, // render_view_id
249 0, // render_frame_id 250 0, // render_frame_id
250 is_main_frame, // is_main_frame 251 is_main_frame, // is_main_frame
251 false, // parent_is_main_frame 252 false, // parent_is_main_frame
252 false, // allow_download 253 false, // allow_download
253 true, // is_async 254 true, // is_async
254 false); // is_using_lofi 255 PREVIEWS_OFF); // previews_state
255 256
256 std::unique_ptr<TestResourceHandler> scoped_test_handler( 257 std::unique_ptr<TestResourceHandler> scoped_test_handler(
257 new TestResourceHandler()); 258 new TestResourceHandler());
258 scoped_test_handler->set_on_response_started_result(false); 259 scoped_test_handler->set_on_response_started_result(false);
259 260
260 std::unique_ptr<ResourceHandler> mime_sniffing_handler( 261 std::unique_ptr<ResourceHandler> mime_sniffing_handler(
261 new MimeSniffingResourceHandler(std::move(scoped_test_handler), nullptr, 262 new MimeSniffingResourceHandler(std::move(scoped_test_handler), nullptr,
262 nullptr, nullptr, request, 263 nullptr, nullptr, request,
263 REQUEST_CONTEXT_TYPE_UNSPECIFIED)); 264 REQUEST_CONTEXT_TYPE_UNSPECIFIED));
264 265
(...skipping 16 matching lines...) Expand all
281 bool is_main_frame = request_resource_type == RESOURCE_TYPE_MAIN_FRAME; 282 bool is_main_frame = request_resource_type == RESOURCE_TYPE_MAIN_FRAME;
282 ResourceRequestInfo::AllocateForTesting(request.get(), request_resource_type, 283 ResourceRequestInfo::AllocateForTesting(request.get(), request_resource_type,
283 nullptr, // context 284 nullptr, // context
284 0, // render_process_id 285 0, // render_process_id
285 0, // render_view_id 286 0, // render_view_id
286 0, // render_frame_id 287 0, // render_frame_id
287 is_main_frame, // is_main_frame 288 is_main_frame, // is_main_frame
288 false, // parent_is_main_frame 289 false, // parent_is_main_frame
289 allow_download, // allow_download 290 allow_download, // allow_download
290 true, // is_async 291 true, // is_async
291 false); // is_using_lofi 292 PREVIEWS_OFF); // previews_state
292 293
293 TestResourceDispatcherHost host(stream_has_handler_); 294 TestResourceDispatcherHost host(stream_has_handler_);
294 TestResourceDispatcherHostDelegate host_delegate(must_download); 295 TestResourceDispatcherHostDelegate host_delegate(must_download);
295 host.SetDelegate(&host_delegate); 296 host.SetDelegate(&host_delegate);
296 297
297 TestFakePluginService plugin_service(plugin_available_, plugin_stale_); 298 TestFakePluginService plugin_service(plugin_available_, plugin_stale_);
298 299
299 std::unique_ptr<InterceptingResourceHandler> intercepting_handler( 300 std::unique_ptr<InterceptingResourceHandler> intercepting_handler(
300 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(), 301 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(),
301 nullptr)); 302 nullptr));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 ResourceRequestInfo::AllocateForTesting(request.get(), 340 ResourceRequestInfo::AllocateForTesting(request.get(),
340 RESOURCE_TYPE_MAIN_FRAME, 341 RESOURCE_TYPE_MAIN_FRAME,
341 nullptr, // context 342 nullptr, // context
342 0, // render_process_id 343 0, // render_process_id
343 0, // render_view_id 344 0, // render_view_id
344 0, // render_frame_id 345 0, // render_frame_id
345 true, // is_main_frame 346 true, // is_main_frame
346 false, // parent_is_main_frame 347 false, // parent_is_main_frame
347 false, // allow_download 348 false, // allow_download
348 true, // is_async 349 true, // is_async
349 false); // is_using_lofi 350 PREVIEWS_OFF); // previews_state
350 351
351 TestResourceDispatcherHost host(false); 352 TestResourceDispatcherHost host(false);
352 TestResourceDispatcherHostDelegate host_delegate(false); 353 TestResourceDispatcherHostDelegate host_delegate(false);
353 host.SetDelegate(&host_delegate); 354 host.SetDelegate(&host_delegate);
354 355
355 TestFakePluginService plugin_service(plugin_available_, plugin_stale_); 356 TestFakePluginService plugin_service(plugin_available_, plugin_stale_);
356 std::unique_ptr<InterceptingResourceHandler> intercepting_handler( 357 std::unique_ptr<InterceptingResourceHandler> intercepting_handler(
357 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(), 358 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(),
358 nullptr)); 359 nullptr));
359 360
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 ResourceRequestInfo::AllocateForTesting(request.get(), 505 ResourceRequestInfo::AllocateForTesting(request.get(),
505 RESOURCE_TYPE_MAIN_FRAME, 506 RESOURCE_TYPE_MAIN_FRAME,
506 nullptr, // context 507 nullptr, // context
507 0, // render_process_id 508 0, // render_process_id
508 0, // render_view_id 509 0, // render_view_id
509 0, // render_frame_id 510 0, // render_frame_id
510 true, // is_main_frame 511 true, // is_main_frame
511 false, // parent_is_main_frame 512 false, // parent_is_main_frame
512 false, // allow_download 513 false, // allow_download
513 true, // is_async 514 true, // is_async
514 false); // is_using_lofi 515 PREVIEWS_OFF); // previews_state
515 516
516 TestResourceDispatcherHost host(false); 517 TestResourceDispatcherHost host(false);
517 TestResourceDispatcherHostDelegate host_delegate(false); 518 TestResourceDispatcherHostDelegate host_delegate(false);
518 host.SetDelegate(&host_delegate); 519 host.SetDelegate(&host_delegate);
519 520
520 TestFakePluginService plugin_service(plugin_available_, plugin_stale_); 521 TestFakePluginService plugin_service(plugin_available_, plugin_stale_);
521 std::unique_ptr<InterceptingResourceHandler> intercepting_handler( 522 std::unique_ptr<InterceptingResourceHandler> intercepting_handler(
522 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(), 523 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(),
523 nullptr)); 524 nullptr));
524 525
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 ResourceRequestInfo::AllocateForTesting(request.get(), 902 ResourceRequestInfo::AllocateForTesting(request.get(),
902 RESOURCE_TYPE_MAIN_FRAME, 903 RESOURCE_TYPE_MAIN_FRAME,
903 nullptr, // context 904 nullptr, // context
904 0, // render_process_id 905 0, // render_process_id
905 0, // render_view_id 906 0, // render_view_id
906 0, // render_frame_id 907 0, // render_frame_id
907 true, // is_main_frame 908 true, // is_main_frame
908 false, // parent_is_main_frame 909 false, // parent_is_main_frame
909 true, // allow_download 910 true, // allow_download
910 true, // is_async 911 true, // is_async
911 false); // is_using_lofi 912 PREVIEWS_OFF); // previews_state
912 913
913 TestResourceDispatcherHost host(false); 914 TestResourceDispatcherHost host(false);
914 TestResourceDispatcherHostDelegate host_delegate(false); 915 TestResourceDispatcherHostDelegate host_delegate(false);
915 host.SetDelegate(&host_delegate); 916 host.SetDelegate(&host_delegate);
916 917
917 TestFakePluginService plugin_service(false, false); 918 TestFakePluginService plugin_service(false, false);
918 std::unique_ptr<ResourceHandler> intercepting_handler( 919 std::unique_ptr<ResourceHandler> intercepting_handler(
919 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(), 920 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(),
920 nullptr)); 921 nullptr));
921 std::unique_ptr<ResourceHandler> mime_handler(new MimeSniffingResourceHandler( 922 std::unique_ptr<ResourceHandler> mime_handler(new MimeSniffingResourceHandler(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 ResourceRequestInfo::AllocateForTesting(request.get(), 955 ResourceRequestInfo::AllocateForTesting(request.get(),
955 RESOURCE_TYPE_MAIN_FRAME, 956 RESOURCE_TYPE_MAIN_FRAME,
956 nullptr, // context 957 nullptr, // context
957 0, // render_process_id 958 0, // render_process_id
958 0, // render_view_id 959 0, // render_view_id
959 0, // render_frame_id 960 0, // render_frame_id
960 true, // is_main_frame 961 true, // is_main_frame
961 false, // parent_is_main_frame 962 false, // parent_is_main_frame
962 false, // allow_download 963 false, // allow_download
963 true, // is_async 964 true, // is_async
964 false); // is_using_lofi 965 PREVIEWS_OFF); // previews_state
965 966
966 TestResourceDispatcherHost host(false); 967 TestResourceDispatcherHost host(false);
967 968
968 TestFakePluginService plugin_service(false, false); 969 TestFakePluginService plugin_service(false, false);
969 std::unique_ptr<InterceptingResourceHandler> intercepting_handler( 970 std::unique_ptr<InterceptingResourceHandler> intercepting_handler(
970 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(), 971 new InterceptingResourceHandler(base::MakeUnique<TestResourceHandler>(),
971 nullptr)); 972 nullptr));
972 973
973 std::unique_ptr<TestResourceHandler> scoped_test_handler( 974 std::unique_ptr<TestResourceHandler> scoped_test_handler(
974 new TestResourceHandler()); 975 new TestResourceHandler());
(...skipping 18 matching lines...) Expand all
993 // mime sniffing is disabled and the wrapped resource handler returns false 994 // mime sniffing is disabled and the wrapped resource handler returns false
994 // on OnResponseStarted. 995 // on OnResponseStarted.
995 EXPECT_FALSE( 996 EXPECT_FALSE(
996 mime_sniffing_handler->OnResponseStarted(response.get(), &defer)); 997 mime_sniffing_handler->OnResponseStarted(response.get(), &defer));
997 998
998 // Process all messages to ensure proper test teardown. 999 // Process all messages to ensure proper test teardown.
999 content::RunAllPendingInMessageLoop(); 1000 content::RunAllPendingInMessageLoop();
1000 } 1001 }
1001 1002
1002 } // namespace content 1003 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698