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

Side by Side Diff: media/blink/resource_multibuffer_data_provider_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "media/blink/resource_multibuffer_data_provider.h" 5 #include "media/blink/resource_multibuffer_data_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "media/base/media_log.h" 18 #include "media/base/media_log.h"
19 #include "media/base/seekable_buffer.h" 19 #include "media/base/seekable_buffer.h"
20 #include "media/blink/mock_webframeclient.h"
21 #include "media/blink/mock_weburlloader.h" 20 #include "media/blink/mock_weburlloader.h"
22 #include "media/blink/url_index.h" 21 #include "media/blink/url_index.h"
23 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
24 #include "net/http/http_request_headers.h" 23 #include "net/http/http_request_headers.h"
25 #include "net/http/http_util.h" 24 #include "net/http/http_util.h"
26 #include "third_party/WebKit/public/platform/WebString.h" 25 #include "third_party/WebKit/public/platform/WebString.h"
27 #include "third_party/WebKit/public/platform/WebURLError.h" 26 #include "third_party/WebKit/public/platform/WebURLError.h"
28 #include "third_party/WebKit/public/platform/WebURLRequest.h" 27 #include "third_party/WebKit/public/platform/WebURLRequest.h"
29 #include "third_party/WebKit/public/platform/WebURLResponse.h" 28 #include "third_party/WebKit/public/platform/WebURLResponse.h"
29 #include "third_party/WebKit/public/web/WebFrameClient.h"
30 #include "third_party/WebKit/public/web/WebLocalFrame.h" 30 #include "third_party/WebKit/public/web/WebLocalFrame.h"
31 #include "third_party/WebKit/public/web/WebView.h" 31 #include "third_party/WebKit/public/web/WebView.h"
32 32
33 using ::testing::_; 33 using ::testing::_;
34 using ::testing::InSequence; 34 using ::testing::InSequence;
35 using ::testing::Return; 35 using ::testing::Return;
36 using ::testing::Truly; 36 using ::testing::Truly;
37 using ::testing::NiceMock; 37 using ::testing::NiceMock;
38 38
39 using blink::WebLocalFrame; 39 using blink::WebLocalFrame;
(...skipping 24 matching lines...) Expand all
64 request.httpHeaderField( 64 request.httpHeaderField(
65 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding)) 65 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding))
66 .utf8(); 66 .utf8();
67 return (value.find("identity;q=1") != std::string::npos) && 67 return (value.find("identity;q=1") != std::string::npos) &&
68 (value.find("*;q=0") != std::string::npos); 68 (value.find("*;q=0") != std::string::npos);
69 } 69 }
70 70
71 class ResourceMultiBufferDataProviderTest : public testing::Test { 71 class ResourceMultiBufferDataProviderTest : public testing::Test {
72 public: 72 public:
73 ResourceMultiBufferDataProviderTest() 73 ResourceMultiBufferDataProviderTest()
74 : view_(WebView::create(nullptr, blink::WebPageVisibilityStateVisible)), 74 : view_(WebView::create(nullptr, blink::WebPageVisibilityStateVisible)) {
75 frame_(WebLocalFrame::create(blink::WebTreeScopeType::Document, 75 WebLocalFrame* frame =
76 &client_)) { 76 WebLocalFrame::create(blink::WebTreeScopeType::Document, &client_);
77 view_->setMainFrame(frame_); 77 view_->setMainFrame(frame);
78 url_index_.reset(new UrlIndex(frame_, 0)); 78 url_index_.reset(new UrlIndex(frame, 0));
79 79
80 for (int i = 0; i < kDataSize; ++i) { 80 for (int i = 0; i < kDataSize; ++i) {
81 data_[i] = i; 81 data_[i] = i;
82 } 82 }
83 } 83 }
84 84
85 virtual ~ResourceMultiBufferDataProviderTest() { 85 virtual ~ResourceMultiBufferDataProviderTest() {
86 view_->close(); 86 view_->close();
87 frame_->close();
88 } 87 }
89 88
90 void Initialize(const char* url, int first_position) { 89 void Initialize(const char* url, int first_position) {
91 gurl_ = GURL(url); 90 gurl_ = GURL(url);
92 url_data_ = url_index_->GetByUrl(gurl_, UrlData::CORS_UNSPECIFIED); 91 url_data_ = url_index_->GetByUrl(gurl_, UrlData::CORS_UNSPECIFIED);
93 url_data_->set_etag(kEtag); 92 url_data_->set_etag(kEtag);
94 DCHECK(url_data_); 93 DCHECK(url_data_);
95 DCHECK(url_data_->frame()); 94 DCHECK(url_data_->frame());
96 url_data_->OnRedirect( 95 url_data_->OnRedirect(
97 base::Bind(&ResourceMultiBufferDataProviderTest::RedirectCallback, 96 base::Bind(&ResourceMultiBufferDataProviderTest::RedirectCallback,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 GURL gurl_; 226 GURL gurl_;
228 int64_t first_position_; 227 int64_t first_position_;
229 228
230 std::unique_ptr<UrlIndex> url_index_; 229 std::unique_ptr<UrlIndex> url_index_;
231 scoped_refptr<UrlData> url_data_; 230 scoped_refptr<UrlData> url_data_;
232 scoped_refptr<UrlData> redirected_to_; 231 scoped_refptr<UrlData> redirected_to_;
233 // The loader is owned by the UrlData above. 232 // The loader is owned by the UrlData above.
234 ResourceMultiBufferDataProvider* loader_; 233 ResourceMultiBufferDataProvider* loader_;
235 NiceMock<MockWebURLLoader>* url_loader_; 234 NiceMock<MockWebURLLoader>* url_loader_;
236 235
237 MockWebFrameClient client_; 236 blink::WebFrameClient client_;
238 WebView* view_; 237 WebView* view_;
239 WebLocalFrame* frame_;
240 238
241 base::MessageLoop message_loop_; 239 base::MessageLoop message_loop_;
242 240
243 uint8_t data_[kDataSize]; 241 uint8_t data_[kDataSize];
244 242
245 private: 243 private:
246 DISALLOW_COPY_AND_ASSIGN(ResourceMultiBufferDataProviderTest); 244 DISALLOW_COPY_AND_ASSIGN(ResourceMultiBufferDataProviderTest);
247 }; 245 };
248 246
249 TEST_F(ResourceMultiBufferDataProviderTest, StartStop) { 247 TEST_F(ResourceMultiBufferDataProviderTest, StartStop) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 TEST_F(ResourceMultiBufferDataProviderTest, TestRedirects) { 329 TEST_F(ResourceMultiBufferDataProviderTest, TestRedirects) {
332 // Test redirect. 330 // Test redirect.
333 Initialize(kHttpUrl, 0); 331 Initialize(kHttpUrl, 0);
334 Start(); 332 Start();
335 Redirect(kHttpRedirect); 333 Redirect(kHttpRedirect);
336 FullResponse(1024); 334 FullResponse(1024);
337 StopWhenLoad(); 335 StopWhenLoad();
338 } 336 }
339 337
340 } // namespace media 338 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698