OLD | NEW |
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> |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 void Redirect(const char* url) { | 174 void Redirect(const char* url) { |
175 GURL redirectUrl(url); | 175 GURL redirectUrl(url); |
176 blink::WebURLRequest newRequest(redirectUrl); | 176 blink::WebURLRequest newRequest(redirectUrl); |
177 blink::WebURLResponse redirectResponse(gurl_); | 177 blink::WebURLResponse redirectResponse(gurl_); |
178 | 178 |
179 EXPECT_CALL(*this, RedirectCallback(_)) | 179 EXPECT_CALL(*this, RedirectCallback(_)) |
180 .WillOnce( | 180 .WillOnce( |
181 Invoke(this, &ResourceMultiBufferDataProviderTest::SetUrlData)); | 181 Invoke(this, &ResourceMultiBufferDataProviderTest::SetUrlData)); |
182 | 182 |
183 loader_->willFollowRedirect(url_loader_, newRequest, redirectResponse); | 183 loader_->willFollowRedirect(url_loader_, newRequest, redirectResponse, 0); |
184 | 184 |
185 base::RunLoop().RunUntilIdle(); | 185 base::RunLoop().RunUntilIdle(); |
186 } | 186 } |
187 | 187 |
188 void StopWhenLoad() { | 188 void StopWhenLoad() { |
189 InSequence s; | 189 InSequence s; |
190 EXPECT_CALL(*url_loader_, cancel()); | 190 EXPECT_CALL(*url_loader_, cancel()); |
191 loader_ = nullptr; | 191 loader_ = nullptr; |
192 url_data_ = nullptr; | 192 url_data_ = nullptr; |
193 } | 193 } |
194 | 194 |
195 // Helper method to write to |loader_| from |data_|. | 195 // Helper method to write to |loader_| from |data_|. |
196 void WriteLoader(int position, int size) { | 196 void WriteLoader(int position, int size) { |
197 loader_->didReceiveData( | 197 loader_->didReceiveData(url_loader_, |
198 url_loader_, reinterpret_cast<char*>(data_ + position), size, size); | 198 reinterpret_cast<char*>(data_ + position), size, |
| 199 size, size); |
199 } | 200 } |
200 | 201 |
201 void WriteData(int size) { | 202 void WriteData(int size) { |
202 std::unique_ptr<char[]> data(new char[size]); | 203 std::unique_ptr<char[]> data(new char[size]); |
203 loader_->didReceiveData(url_loader_, data.get(), size, size); | 204 loader_->didReceiveData(url_loader_, data.get(), size, size, size); |
204 } | 205 } |
205 | 206 |
206 // Verifies that data in buffer[0...size] is equal to data_[pos...pos+size]. | 207 // Verifies that data in buffer[0...size] is equal to data_[pos...pos+size]. |
207 void VerifyBuffer(uint8_t* buffer, int pos, int size) { | 208 void VerifyBuffer(uint8_t* buffer, int pos, int size) { |
208 EXPECT_EQ(0, memcmp(buffer, data_ + pos, size)); | 209 EXPECT_EQ(0, memcmp(buffer, data_ + pos, size)); |
209 } | 210 } |
210 | 211 |
211 bool HasActiveLoader() { return loader_->active_loader_ != nullptr; } | 212 bool HasActiveLoader() { return loader_->active_loader_ != nullptr; } |
212 MOCK_METHOD1(RedirectCallback, void(const scoped_refptr<UrlData>&)); | 213 MOCK_METHOD1(RedirectCallback, void(const scoped_refptr<UrlData>&)); |
213 | 214 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 TEST_F(ResourceMultiBufferDataProviderTest, TestRedirects) { | 324 TEST_F(ResourceMultiBufferDataProviderTest, TestRedirects) { |
324 // Test redirect. | 325 // Test redirect. |
325 Initialize(kHttpUrl, 0); | 326 Initialize(kHttpUrl, 0); |
326 Start(); | 327 Start(); |
327 Redirect(kHttpRedirect); | 328 Redirect(kHttpRedirect); |
328 FullResponse(1024); | 329 FullResponse(1024); |
329 StopWhenLoad(); | 330 StopWhenLoad(); |
330 } | 331 } |
331 | 332 |
332 } // namespace media | 333 } // namespace media |
OLD | NEW |