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

Side by Side Diff: content/renderer/media/buffered_data_source_unittest.cc

Issue 231793004: Update a few more references to WebFrame to use WebLocalFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor updates Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "media/base/media_log.h" 11 #include "media/base/media_log.h"
12 #include "media/base/mock_data_source_host.h" 12 #include "media/base/mock_data_source_host.h"
13 #include "media/base/mock_filters.h" 13 #include "media/base/mock_filters.h"
14 #include "media/base/test_helpers.h" 14 #include "media/base/test_helpers.h"
15 #include "third_party/WebKit/public/platform/WebURLResponse.h" 15 #include "third_party/WebKit/public/platform/WebURLResponse.h"
16 #include "third_party/WebKit/public/web/WebFrame.h" 16 #include "third_party/WebKit/public/web/WebLocalFrame.h"
17 #include "third_party/WebKit/public/web/WebView.h" 17 #include "third_party/WebKit/public/web/WebView.h"
18 18
19 using ::testing::_; 19 using ::testing::_;
20 using ::testing::Assign; 20 using ::testing::Assign;
21 using ::testing::Invoke; 21 using ::testing::Invoke;
22 using ::testing::InSequence; 22 using ::testing::InSequence;
23 using ::testing::NiceMock; 23 using ::testing::NiceMock;
24 using ::testing::StrictMock; 24 using ::testing::StrictMock;
25 25
26 using blink::WebFrame; 26 using blink::WebLocalFrame;
27 using blink::WebString; 27 using blink::WebString;
28 using blink::WebURLLoader; 28 using blink::WebURLLoader;
29 using blink::WebURLResponse; 29 using blink::WebURLResponse;
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 WebLocalFrame* frame,
41 media::DataSourceHost* host) 41 media::DataSourceHost* host)
42 : BufferedDataSource(message_loop, frame, new media::MediaLog(), host, 42 : BufferedDataSource(message_loop, frame, new media::MediaLog(), host,
43 base::Bind(&MockBufferedDataSource::set_downloading, 43 base::Bind(&MockBufferedDataSource::set_downloading,
44 base::Unretained(this))), 44 base::Unretained(this))),
45 downloading_(false), 45 downloading_(false),
46 loading_(false) { 46 loading_(false) {
47 } 47 }
48 virtual ~MockBufferedDataSource() {} 48 virtual ~MockBufferedDataSource() {}
49 49
50 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64)); 50 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 static const int64 kFileSize = 5000000; 86 static const int64 kFileSize = 5000000;
87 static const int64 kFarReadPosition = 4000000; 87 static const int64 kFarReadPosition = 4000000;
88 static const int kDataSize = 1024; 88 static const int kDataSize = 1024;
89 89
90 static const char kHttpUrl[] = "http://localhost/foo.webm"; 90 static const char kHttpUrl[] = "http://localhost/foo.webm";
91 static const char kFileUrl[] = "file:///tmp/bar.webm"; 91 static const char kFileUrl[] = "file:///tmp/bar.webm";
92 92
93 class BufferedDataSourceTest : public testing::Test { 93 class BufferedDataSourceTest : public testing::Test {
94 public: 94 public:
95 BufferedDataSourceTest() 95 BufferedDataSourceTest()
96 : view_(WebView::create(NULL)), frame_(WebFrame::create(&client_)) { 96 : view_(WebView::create(NULL)), frame_(WebLocalFrame::create(&client_)) {
97 view_->setMainFrame(frame_); 97 view_->setMainFrame(frame_);
98 98
99 data_source_.reset(new MockBufferedDataSource( 99 data_source_.reset(
100 message_loop_.message_loop_proxy(), view_->mainFrame(), &host_)); 100 new MockBufferedDataSource(message_loop_.message_loop_proxy(),
101 view_->mainFrame()->toWebLocalFrame(),
102 &host_));
101 } 103 }
102 104
103 virtual ~BufferedDataSourceTest() { 105 virtual ~BufferedDataSourceTest() {
104 view_->close(); 106 view_->close();
105 frame_->close(); 107 frame_->close();
106 } 108 }
107 109
108 MOCK_METHOD1(OnInitialize, void(bool)); 110 MOCK_METHOD1(OnInitialize, void(bool));
109 111
110 void Initialize(const char* url, bool expected) { 112 void Initialize(const char* url, bool expected) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 int data_source_bitrate() { return data_source_->bitrate_; } 205 int data_source_bitrate() { return data_source_->bitrate_; }
204 int data_source_playback_rate() { return data_source_->playback_rate_; } 206 int data_source_playback_rate() { return data_source_->playback_rate_; }
205 int loader_bitrate() { return loader()->bitrate_; } 207 int loader_bitrate() { return loader()->bitrate_; }
206 int loader_playback_rate() { return loader()->playback_rate_; } 208 int loader_playback_rate() { return loader()->playback_rate_; }
207 209
208 scoped_ptr<MockBufferedDataSource> data_source_; 210 scoped_ptr<MockBufferedDataSource> data_source_;
209 211
210 scoped_ptr<TestResponseGenerator> response_generator_; 212 scoped_ptr<TestResponseGenerator> response_generator_;
211 MockWebFrameClient client_; 213 MockWebFrameClient client_;
212 WebView* view_; 214 WebView* view_;
213 WebFrame* frame_; 215 WebLocalFrame* frame_;
214 216
215 StrictMock<media::MockDataSourceHost> host_; 217 StrictMock<media::MockDataSourceHost> host_;
216 base::MessageLoop message_loop_; 218 base::MessageLoop message_loop_;
217 219
218 private: 220 private:
219 // Used for calling BufferedDataSource::Read(). 221 // Used for calling BufferedDataSource::Read().
220 uint8 buffer_[kDataSize]; 222 uint8 buffer_[kDataSize];
221 223
222 DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceTest); 224 DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceTest);
223 }; 225 };
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 InitializeWithFileResponse(); 650 InitializeWithFileResponse();
649 651
650 EXPECT_FALSE(data_source_->downloading()); 652 EXPECT_FALSE(data_source_->downloading());
651 FinishLoading(); 653 FinishLoading();
652 EXPECT_FALSE(data_source_->downloading()); 654 EXPECT_FALSE(data_source_->downloading());
653 655
654 Stop(); 656 Stop();
655 } 657 }
656 658
657 } // namespace content 659 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698