Chromium Code Reviews| Index: content/browser/loader/buffered_resource_handler_unittest.cc |
| diff --git a/content/browser/loader/buffered_resource_handler_unittest.cc b/content/browser/loader/buffered_resource_handler_unittest.cc |
| index 97b9668c88c5cbfaba4bb1e6427e781733623761..1a15aa36dcb02f6853db71ab82c3e6914b741d41 100644 |
| --- a/content/browser/loader/buffered_resource_handler_unittest.cc |
| +++ b/content/browser/loader/buffered_resource_handler_unittest.cc |
| @@ -99,6 +99,7 @@ class TestResourceDispatcherHost : public ResourceDispatcherHostImpl { |
| } |
| scoped_ptr<ResourceHandler> MaybeInterceptAsStream( |
| + const base::FilePath& plugin_path, |
| net::URLRequest* request, |
| ResourceResponse* response, |
| std::string* payload) override { |
| @@ -153,12 +154,17 @@ class TestResourceController : public ResourceController { |
| class BufferedResourceHandlerTest : public testing::Test { |
| public: |
| - BufferedResourceHandlerTest() : stream_has_handler_(false) {} |
| + BufferedResourceHandlerTest() |
| + : stream_has_handler_(false), plugin_available_(false) {} |
| void set_stream_has_handler(bool stream_has_handler) { |
| stream_has_handler_ = stream_has_handler; |
| } |
| + void set_plugin_available(bool plugin_available) { |
| + plugin_available_ = plugin_available; |
| + } |
| + |
| bool TestStreamIsIntercepted(bool allow_download, |
| bool must_download, |
| ResourceType request_resource_type); |
| @@ -166,6 +172,7 @@ class BufferedResourceHandlerTest : public testing::Test { |
| private: |
| // Whether the URL request should be intercepted as a stream. |
| bool stream_has_handler_; |
| + bool plugin_available_; |
| TestBrowserThreadBundle thread_bundle_; |
| }; |
| @@ -194,7 +201,7 @@ bool BufferedResourceHandlerTest::TestStreamIsIntercepted( |
| TestResourceDispatcherHostDelegate host_delegate(must_download); |
| host.SetDelegate(&host_delegate); |
| - FakePluginService plugin_service; |
| + FakePluginService plugin_service(plugin_available_); |
| scoped_ptr<ResourceHandler> buffered_handler( |
| new BufferedResourceHandler( |
| scoped_ptr<ResourceHandler>(new TestResourceHandler()).Pass(), |
| @@ -223,6 +230,7 @@ TEST_F(BufferedResourceHandlerTest, StreamHandling) { |
| bool must_download; |
| ResourceType resource_type; |
| + set_plugin_available(false); |
|
raymes
2015/03/19 00:45:51
Let's set the plugin as available for most of the
Deepak
2015/03/19 10:22:23
Done.
|
| // Ensure the stream is handled by MaybeInterceptAsStream in the |
| // ResourceDispatcherHost. |
| set_stream_has_handler(true); |
| @@ -281,6 +289,50 @@ TEST_F(BufferedResourceHandlerTest, StreamHandling) { |
| TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
| } |
| +// Test that stream requests are correctly intercepted under the right |
| +// circumstances with plugin path. |
| +TEST_F(BufferedResourceHandlerTest, StreamHandlingWithPluginPath) { |
|
raymes
2015/03/19 00:39:22
I think it would be sufficient to add a single add
Deepak
2015/03/19 10:22:23
Done.
|
| + bool allow_download; |
| + bool must_download; |
| + ResourceType resource_type; |
| + |
| + // Ensure the stream is handled by MaybeInterceptAsStream in the |
| + // ResourceDispatcherHost. |
| + set_stream_has_handler(true); |
| + |
| + allow_download = false; |
| + must_download = false; |
| + resource_type = RESOURCE_TYPE_OBJECT; |
| + set_plugin_available(true); |
| + EXPECT_TRUE( |
| + TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
| + |
| + allow_download = false; |
| + must_download = false; |
| + resource_type = RESOURCE_TYPE_OBJECT; |
| + set_plugin_available(false); |
| + EXPECT_TRUE( |
| + TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
| + |
| + // Test the cases where the stream isn't handled by MaybeInterceptAsStream |
| + // in the ResourceDispatcherHost. |
| + set_stream_has_handler(false); |
| + |
| + allow_download = false; |
| + must_download = false; |
| + resource_type = RESOURCE_TYPE_OBJECT; |
| + set_plugin_available(true); |
| + EXPECT_FALSE( |
| + TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
| + |
| + allow_download = false; |
| + must_download = false; |
| + resource_type = RESOURCE_TYPE_OBJECT; |
| + set_plugin_available(false); |
| + EXPECT_FALSE( |
| + TestStreamIsIntercepted(allow_download, must_download, resource_type)); |
| +} |
| + |
| } // namespace |
| } // namespace content |