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

Side by Side Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops Created 4 years, 2 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 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "media/base/media_log.h" 13 #include "media/base/media_log.h"
14 #include "media/base/mock_filters.h" 14 #include "media/base/mock_filters.h"
15 #include "media/base/test_helpers.h" 15 #include "media/base/test_helpers.h"
16 #include "media/blink/buffered_data_source_host_impl.h" 16 #include "media/blink/buffered_data_source_host_impl.h"
17 #include "media/blink/mock_webframeclient.h"
18 #include "media/blink/mock_weburlloader.h" 17 #include "media/blink/mock_weburlloader.h"
19 #include "media/blink/multibuffer_data_source.h" 18 #include "media/blink/multibuffer_data_source.h"
20 #include "media/blink/multibuffer_reader.h" 19 #include "media/blink/multibuffer_reader.h"
21 #include "media/blink/resource_multibuffer_data_provider.h" 20 #include "media/blink/resource_multibuffer_data_provider.h"
22 #include "media/blink/test_response_generator.h" 21 #include "media/blink/test_response_generator.h"
23 #include "third_party/WebKit/public/platform/WebURLResponse.h" 22 #include "third_party/WebKit/public/platform/WebURLResponse.h"
23 #include "third_party/WebKit/public/web/WebFrameClient.h"
24 #include "third_party/WebKit/public/web/WebLocalFrame.h" 24 #include "third_party/WebKit/public/web/WebLocalFrame.h"
25 #include "third_party/WebKit/public/web/WebView.h" 25 #include "third_party/WebKit/public/web/WebView.h"
26 26
27 using ::testing::_; 27 using ::testing::_;
28 using ::testing::Assign; 28 using ::testing::Assign;
29 using ::testing::DoAll; 29 using ::testing::DoAll;
30 using ::testing::Invoke; 30 using ::testing::Invoke;
31 using ::testing::InvokeWithoutArgs; 31 using ::testing::InvokeWithoutArgs;
32 using ::testing::InSequence; 32 using ::testing::InSequence;
33 using ::testing::NiceMock; 33 using ::testing::NiceMock;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 static const char kHttpUrl[] = "http://localhost/foo.webm"; 219 static const char kHttpUrl[] = "http://localhost/foo.webm";
220 static const char kFileUrl[] = "file:///tmp/bar.webm"; 220 static const char kFileUrl[] = "file:///tmp/bar.webm";
221 static const char kHttpDifferentPathUrl[] = "http://localhost/bar.webm"; 221 static const char kHttpDifferentPathUrl[] = "http://localhost/bar.webm";
222 static const char kHttpDifferentOriginUrl[] = "http://127.0.0.1/foo.webm"; 222 static const char kHttpDifferentOriginUrl[] = "http://127.0.0.1/foo.webm";
223 223
224 class MultibufferDataSourceTest : public testing::Test { 224 class MultibufferDataSourceTest : public testing::Test {
225 public: 225 public:
226 MultibufferDataSourceTest() 226 MultibufferDataSourceTest()
227 : view_(WebView::create(nullptr, blink::WebPageVisibilityStateVisible)), 227 : view_(WebView::create(nullptr, blink::WebPageVisibilityStateVisible)),
228 frame_( 228 preload_(MultibufferDataSource::AUTO) {
229 WebLocalFrame::create(blink::WebTreeScopeType::Document, &client_)), 229 WebLocalFrame* frame =
230 preload_(MultibufferDataSource::AUTO), 230 WebLocalFrame::create(blink::WebTreeScopeType::Document, &client_);
231 url_index_(make_linked_ptr(new TestUrlIndex(frame_))) { 231 view_->setMainFrame(frame);
232 view_->setMainFrame(frame_); 232 url_index_ = make_linked_ptr(new TestUrlIndex(frame));
233 } 233 }
234 234
235 virtual ~MultibufferDataSourceTest() { 235 virtual ~MultibufferDataSourceTest() {
236 view_->close(); 236 view_->close();
237 frame_->close();
238 } 237 }
239 238
240 MOCK_METHOD1(OnInitialize, void(bool)); 239 MOCK_METHOD1(OnInitialize, void(bool));
241 240
242 void InitializeWithCORS(const char* url, 241 void InitializeWithCORS(const char* url,
243 bool expected, 242 bool expected,
244 UrlData::CORSMode cors_mode) { 243 UrlData::CORSMode cors_mode) {
245 GURL gurl(url); 244 GURL gurl(url);
246 data_source_.reset(new MockMultibufferDataSource( 245 data_source_.reset(new MockMultibufferDataSource(
247 gurl, cors_mode, message_loop_.task_runner(), url_index_, 246 gurl, cors_mode, message_loop_.task_runner(), url_index_,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 468 }
470 int data_source_bitrate() { return data_source_->bitrate_; } 469 int data_source_bitrate() { return data_source_->bitrate_; }
471 double data_source_playback_rate() { return data_source_->playback_rate_; } 470 double data_source_playback_rate() { return data_source_->playback_rate_; }
472 bool is_local_source() { return data_source_->assume_fully_buffered(); } 471 bool is_local_source() { return data_source_->assume_fully_buffered(); }
473 scoped_refptr<UrlData> url_data() { return data_source_->url_data_; } 472 scoped_refptr<UrlData> url_data() { return data_source_->url_data_; }
474 void set_might_be_reused_from_cache_in_future(bool value) { 473 void set_might_be_reused_from_cache_in_future(bool value) {
475 url_data()->set_cacheable(value); 474 url_data()->set_cacheable(value);
476 } 475 }
477 476
478 protected: 477 protected:
479 MockWebFrameClient client_; 478 blink::WebFrameClient client_;
480 WebView* view_; 479 WebView* view_;
481 WebLocalFrame* frame_;
482 MultibufferDataSource::Preload preload_; 480 MultibufferDataSource::Preload preload_;
483 base::MessageLoop message_loop_; 481 base::MessageLoop message_loop_;
484 linked_ptr<TestUrlIndex> url_index_; 482 linked_ptr<TestUrlIndex> url_index_;
485 483
486 std::unique_ptr<MockMultibufferDataSource> data_source_; 484 std::unique_ptr<MockMultibufferDataSource> data_source_;
487 485
488 std::unique_ptr<TestResponseGenerator> response_generator_; 486 std::unique_ptr<TestResponseGenerator> response_generator_;
489 487
490 StrictMock<MockBufferedDataSourceHost> host_; 488 StrictMock<MockBufferedDataSourceHost> host_;
491 489
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 const std::string etag("\"arglebargle glop-glyf?\""); 1519 const std::string etag("\"arglebargle glop-glyf?\"");
1522 response.setHTTPHeaderField(WebString::fromUTF8("Etag"), 1520 response.setHTTPHeaderField(WebString::fromUTF8("Etag"),
1523 WebString::fromUTF8(etag)); 1521 WebString::fromUTF8(etag));
1524 Respond(response); 1522 Respond(response);
1525 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); 1523 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
1526 ReceiveData(kDataSize); 1524 ReceiveData(kDataSize);
1527 1525
1528 EXPECT_EQ(url_data()->etag(), etag); 1526 EXPECT_EQ(url_data()->etag(), etag);
1529 } 1527 }
1530 } // namespace media 1528 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698