OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "content/renderer/media/buffered_data_source.h" | 7 #include "content/renderer/media/buffered_data_source.h" |
8 #include "content/renderer/media/test_response_generator.h" | 8 #include "content/renderer/media/test_response_generator.h" |
9 #include "content/test/mock_webframeclient.h" | 9 #include "content/test/mock_webframeclient.h" |
10 #include "content/test/mock_weburlloader.h" | 10 #include "content/test/mock_weburlloader.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 using blink::WebView; | 30 using blink::WebView; |
31 | 31 |
32 namespace content { | 32 namespace content { |
33 | 33 |
34 // Overrides CreateResourceLoader() to permit injecting a MockWebURLLoader. | 34 // Overrides CreateResourceLoader() to permit injecting a MockWebURLLoader. |
35 // Also keeps track of whether said MockWebURLLoader is actively loading. | 35 // Also keeps track of whether said MockWebURLLoader is actively loading. |
36 class MockBufferedDataSource : public BufferedDataSource { | 36 class MockBufferedDataSource : public BufferedDataSource { |
37 public: | 37 public: |
38 MockBufferedDataSource( | 38 MockBufferedDataSource( |
39 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 39 const scoped_refptr<base::MessageLoopProxy>& message_loop, |
40 WebFrame* frame) | 40 WebFrame* frame, |
41 : BufferedDataSource(message_loop, frame, new media::MediaLog(), | 41 media::DataSourceHost* host) |
| 42 : BufferedDataSource(message_loop, frame, new media::MediaLog(), host, |
42 base::Bind(&MockBufferedDataSource::set_downloading, | 43 base::Bind(&MockBufferedDataSource::set_downloading, |
43 base::Unretained(this))), | 44 base::Unretained(this))), |
44 downloading_(false), | 45 downloading_(false), |
45 loading_(false) { | 46 loading_(false) { |
46 } | 47 } |
47 virtual ~MockBufferedDataSource() {} | 48 virtual ~MockBufferedDataSource() {} |
48 | 49 |
49 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64)); | 50 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64)); |
50 BufferedResourceLoader* CreateMockResourceLoader(int64 first_byte_position, | 51 BufferedResourceLoader* CreateMockResourceLoader(int64 first_byte_position, |
51 int64 last_byte_position) { | 52 int64 last_byte_position) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 static const char kHttpUrl[] = "http://localhost/foo.webm"; | 90 static const char kHttpUrl[] = "http://localhost/foo.webm"; |
90 static const char kFileUrl[] = "file:///tmp/bar.webm"; | 91 static const char kFileUrl[] = "file:///tmp/bar.webm"; |
91 | 92 |
92 class BufferedDataSourceTest : public testing::Test { | 93 class BufferedDataSourceTest : public testing::Test { |
93 public: | 94 public: |
94 BufferedDataSourceTest() | 95 BufferedDataSourceTest() |
95 : view_(WebView::create(NULL)), frame_(WebFrame::create(&client_)) { | 96 : view_(WebView::create(NULL)), frame_(WebFrame::create(&client_)) { |
96 view_->setMainFrame(frame_); | 97 view_->setMainFrame(frame_); |
97 | 98 |
98 data_source_.reset(new MockBufferedDataSource( | 99 data_source_.reset(new MockBufferedDataSource( |
99 message_loop_.message_loop_proxy(), view_->mainFrame())); | 100 message_loop_.message_loop_proxy(), view_->mainFrame(), &host_)); |
100 data_source_->set_host(&host_); | |
101 } | 101 } |
102 | 102 |
103 virtual ~BufferedDataSourceTest() { | 103 virtual ~BufferedDataSourceTest() { |
104 view_->close(); | 104 view_->close(); |
105 frame_->close(); | 105 frame_->close(); |
106 } | 106 } |
107 | 107 |
108 MOCK_METHOD1(OnInitialize, void(bool)); | 108 MOCK_METHOD1(OnInitialize, void(bool)); |
109 | 109 |
110 void Initialize(const char* url, bool expected) { | 110 void Initialize(const char* url, bool expected) { |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 InitializeWithFileResponse(); | 648 InitializeWithFileResponse(); |
649 | 649 |
650 EXPECT_FALSE(data_source_->downloading()); | 650 EXPECT_FALSE(data_source_->downloading()); |
651 FinishLoading(); | 651 FinishLoading(); |
652 EXPECT_FALSE(data_source_->downloading()); | 652 EXPECT_FALSE(data_source_->downloading()); |
653 | 653 |
654 Stop(); | 654 Stop(); |
655 } | 655 } |
656 | 656 |
657 } // namespace content | 657 } // namespace content |
OLD | NEW |