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

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

Issue 2512563003: Convert enable_plugins to a buildflag header. (Closed)
Patch Set: Merge Created 4 years, 1 month 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_dispatcher_host_impl.h" 19 #include "content/browser/loader/resource_dispatcher_host_impl.h"
20 #include "content/browser/loader/test_resource_handler.h" 20 #include "content/browser/loader/test_resource_handler.h"
21 #include "content/public/browser/resource_controller.h" 21 #include "content/public/browser/resource_controller.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/resource_response.h" 24 #include "content/public/common/resource_response.h"
25 #include "content/public/common/webplugininfo.h" 25 #include "content/public/common/webplugininfo.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "content/public/test/test_utils.h" 27 #include "content/public/test/test_utils.h"
28 #include "content/test/fake_plugin_service.h" 28 #include "content/test/fake_plugin_service.h"
29 #include "net/url_request/url_request_context.h" 29 #include "net/url_request/url_request_context.h"
30 #include "ppapi/features/features.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 #include "url/gurl.h" 32 #include "url/gurl.h"
32 #include "url/origin.h" 33 #include "url/origin.h"
33 34
34 namespace content { 35 namespace content {
35 36
36 namespace { 37 namespace {
37 38
38 class TestResourceDispatcherHostDelegate 39 class TestResourceDispatcherHostDelegate
39 : public ResourceDispatcherHostDelegate { 40 : public ResourceDispatcherHostDelegate {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 net::URLRequestContext context; 662 net::URLRequestContext context;
662 std::unique_ptr<net::URLRequest> request(context.CreateRequest( 663 std::unique_ptr<net::URLRequest> request(context.CreateRequest(
663 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, nullptr)); 664 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, nullptr));
664 request->SetExtraRequestHeaderByName("Accept", "*", true); 665 request->SetExtraRequestHeaderByName("Accept", "*", true);
665 EXPECT_EQ("*", TestAcceptHeaderSettingWithURLRequest(RESOURCE_TYPE_XHR, 666 EXPECT_EQ("*", TestAcceptHeaderSettingWithURLRequest(RESOURCE_TYPE_XHR,
666 request.get())); 667 request.get()));
667 } 668 }
668 669
669 // Test that stream requests are correctly intercepted under the right 670 // Test that stream requests are correctly intercepted under the right
670 // circumstances. Test is not relevent when plugins are disabled. 671 // circumstances. Test is not relevent when plugins are disabled.
671 #if defined(ENABLE_PLUGINS) 672 #if BUILDFLAG(ENABLE_PLUGINS)
672 TEST_F(MimeSniffingResourceHandlerTest, StreamHandling) { 673 TEST_F(MimeSniffingResourceHandlerTest, StreamHandling) {
673 bool allow_download; 674 bool allow_download;
674 bool must_download; 675 bool must_download;
675 ResourceType resource_type; 676 ResourceType resource_type;
676 677
677 // Ensure the stream is handled by MaybeInterceptAsStream in the 678 // Ensure the stream is handled by MaybeInterceptAsStream in the
678 // ResourceDispatcherHost. 679 // ResourceDispatcherHost.
679 set_stream_has_handler(true); 680 set_stream_has_handler(true);
680 set_plugin_available(true); 681 set_plugin_available(true);
681 682
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // mime sniffing is disabled and the wrapped resource handler returns false 993 // mime sniffing is disabled and the wrapped resource handler returns false
993 // on OnResponseStarted. 994 // on OnResponseStarted.
994 EXPECT_FALSE( 995 EXPECT_FALSE(
995 mime_sniffing_handler->OnResponseStarted(response.get(), &defer)); 996 mime_sniffing_handler->OnResponseStarted(response.get(), &defer));
996 997
997 // Process all messages to ensure proper test teardown. 998 // Process all messages to ensure proper test teardown.
998 content::RunAllPendingInMessageLoop(); 999 content::RunAllPendingInMessageLoop();
999 } 1000 }
1000 1001
1001 } // namespace content 1002 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/mime_sniffing_resource_handler.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698