Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / buffered_data_source_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h"
7 #include "content/public/common/url_constants.h"
8 #include "content/renderer/media/buffered_data_source.h"
9 #include "content/renderer/media/test_response_generator.h"
10 #include "content/test/mock_webframeclient.h"
11 #include "content/test/mock_weburlloader.h"
12 #include "media/base/media_log.h"
13 #include "media/base/mock_filters.h"
14 #include "media/base/test_helpers.h"
15 #include "third_party/WebKit/public/platform/WebURLResponse.h"
16 #include "third_party/WebKit/public/web/WebLocalFrame.h"
17 #include "third_party/WebKit/public/web/WebView.h"
18
19 using ::testing::_;
20 using ::testing::Assign;
21 using ::testing::Invoke;
22 using ::testing::InSequence;
23 using ::testing::NiceMock;
24 using ::testing::StrictMock;
25
26 using blink::WebLocalFrame;
27 using blink::WebString;
28 using blink::WebURLLoader;
29 using blink::WebURLResponse;
30 using blink::WebView;
31
32 namespace content {
33
34 class MockBufferedDataSourceHost : public BufferedDataSourceHost {
35  public:
36   MockBufferedDataSourceHost() {}
37   virtual ~MockBufferedDataSourceHost() {}
38
39   MOCK_METHOD1(SetTotalBytes, void(int64 total_bytes));
40   MOCK_METHOD2(AddBufferedByteRange, void(int64 start, int64 end));
41
42  private:
43   DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSourceHost);
44 };
45
46 // Overrides CreateResourceLoader() to permit injecting a MockWebURLLoader.
47 // Also keeps track of whether said MockWebURLLoader is actively loading.
48 class MockBufferedDataSource : public BufferedDataSource {
49  public:
50   MockBufferedDataSource(
51       const scoped_refptr<base::MessageLoopProxy>& message_loop,
52       WebLocalFrame* frame,
53       BufferedDataSourceHost* host)
54       : BufferedDataSource(message_loop, frame, new media::MediaLog(), host,
55                            base::Bind(&MockBufferedDataSource::set_downloading,
56                                       base::Unretained(this))),
57         downloading_(false),
58         loading_(false) {
59   }
60   virtual ~MockBufferedDataSource() {}
61
62   MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(int64, int64));
63   BufferedResourceLoader* CreateMockResourceLoader(int64 first_byte_position,
64                                                    int64 last_byte_position) {
65     CHECK(!loading_) << "Previous resource load wasn't cancelled";
66
67     BufferedResourceLoader* loader =
68         BufferedDataSource::CreateResourceLoader(first_byte_position,
69                                                  last_byte_position);
70
71     // Keep track of active loading state via loadAsynchronously() and cancel().
72     NiceMock<MockWebURLLoader>* url_loader = new NiceMock<MockWebURLLoader>();
73     ON_CALL(*url_loader, loadAsynchronously(_, _))
74         .WillByDefault(Assign(&loading_, true));
75     ON_CALL(*url_loader, cancel())
76         .WillByDefault(Assign(&loading_, false));
77
78     // |test_loader_| will be used when Start() is called.
79     loader->test_loader_ = scoped_ptr<WebURLLoader>(url_loader);
80     return loader;
81   }
82
83   bool loading() { return loading_; }
84   void set_loading(bool loading) { loading_ = loading; }
85   bool downloading() { return downloading_; }
86   void set_downloading(bool downloading) { downloading_ = downloading; }
87
88  private:
89   // Whether the resource is downloading or deferred.
90   bool downloading_;
91
92   // Whether the resource load has starting loading but yet to been cancelled.
93   bool loading_;
94
95   DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource);
96 };
97
98 static const int64 kFileSize = 5000000;
99 static const int64 kFarReadPosition = 4000000;
100 static const int kDataSize = 1024;
101
102 static const char kHttpUrl[] = "http://localhost/foo.webm";
103 static const char kFileUrl[] = "file:///tmp/bar.webm";
104
105 class BufferedDataSourceTest : public testing::Test {
106  public:
107   BufferedDataSourceTest()
108       : view_(WebView::create(NULL)), frame_(WebLocalFrame::create(&client_)) {
109     view_->setMainFrame(frame_);
110
111     data_source_.reset(
112         new MockBufferedDataSource(message_loop_.message_loop_proxy(),
113                                    view_->mainFrame()->toWebLocalFrame(),
114                                    &host_));
115   }
116
117   virtual ~BufferedDataSourceTest() {
118     view_->close();
119     frame_->close();
120   }
121
122   MOCK_METHOD1(OnInitialize, void(bool));
123
124   void Initialize(const char* url, bool expected) {
125     GURL gurl(url);
126     response_generator_.reset(new TestResponseGenerator(gurl, kFileSize));
127
128     ExpectCreateResourceLoader();
129     EXPECT_CALL(*this, OnInitialize(expected));
130     data_source_->Initialize(
131         gurl, BufferedResourceLoader::kUnspecified, base::Bind(
132             &BufferedDataSourceTest::OnInitialize, base::Unretained(this)));
133     message_loop_.RunUntilIdle();
134
135     bool is_http =
136         gurl.SchemeIs(url::kHttpScheme) || gurl.SchemeIs(url::kHttpsScheme);
137     EXPECT_EQ(data_source_->downloading(), is_http);
138   }
139
140   // Helper to initialize tests with a valid 206 response.
141   void InitializeWith206Response() {
142     Initialize(kHttpUrl, true);
143
144     EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
145     Respond(response_generator_->Generate206(0));
146   }
147
148   // Helper to initialize tests with a valid file:// response.
149   void InitializeWithFileResponse() {
150     Initialize(kFileUrl, true);
151
152     EXPECT_CALL(host_, SetTotalBytes(kFileSize));
153     EXPECT_CALL(host_, AddBufferedByteRange(0, kFileSize));
154     Respond(response_generator_->GenerateFileResponse(0));
155   }
156
157   // Stops any active loaders and shuts down the data source.
158   //
159   // This typically happens when the page is closed and for our purposes is
160   // appropriate to do when tearing down a test.
161   void Stop() {
162     if (data_source_->loading()) {
163       loader()->didFail(url_loader(), response_generator_->GenerateError());
164       message_loop_.RunUntilIdle();
165     }
166
167     data_source_->Stop(media::NewExpectedClosure());
168     message_loop_.RunUntilIdle();
169   }
170
171   void ExpectCreateResourceLoader() {
172     EXPECT_CALL(*data_source_, CreateResourceLoader(_, _))
173         .WillOnce(Invoke(data_source_.get(),
174                          &MockBufferedDataSource::CreateMockResourceLoader));
175     message_loop_.RunUntilIdle();
176   }
177
178   void Respond(const WebURLResponse& response) {
179     loader()->didReceiveResponse(url_loader(), response);
180     message_loop_.RunUntilIdle();
181   }
182
183   void ReceiveData(int size) {
184     scoped_ptr<char[]> data(new char[size]);
185     memset(data.get(), 0xA5, size);  // Arbitrary non-zero value.
186
187     loader()->didReceiveData(url_loader(), data.get(), size, size);
188     message_loop_.RunUntilIdle();
189   }
190
191   void FinishLoading() {
192     data_source_->set_loading(false);
193     loader()->didFinishLoading(url_loader(), 0, -1);
194     message_loop_.RunUntilIdle();
195   }
196
197   MOCK_METHOD1(ReadCallback, void(int size));
198
199   void ReadAt(int64 position) {
200     data_source_->Read(position, kDataSize, buffer_,
201                        base::Bind(&BufferedDataSourceTest::ReadCallback,
202                                   base::Unretained(this)));
203     message_loop_.RunUntilIdle();
204   }
205
206   // Accessors for private variables on |data_source_|.
207   BufferedResourceLoader* loader() {
208     return data_source_->loader_.get();
209   }
210   WebURLLoader* url_loader() {
211     return loader()->active_loader_->loader_.get();
212   }
213
214   Preload preload() { return data_source_->preload_; }
215   BufferedResourceLoader::DeferStrategy defer_strategy() {
216     return loader()->defer_strategy_;
217   }
218   int data_source_bitrate() { return data_source_->bitrate_; }
219   int data_source_playback_rate() { return data_source_->playback_rate_; }
220   int loader_bitrate() { return loader()->bitrate_; }
221   int loader_playback_rate() { return loader()->playback_rate_; }
222
223   scoped_ptr<MockBufferedDataSource> data_source_;
224
225   scoped_ptr<TestResponseGenerator> response_generator_;
226   MockWebFrameClient client_;
227   WebView* view_;
228   WebLocalFrame* frame_;
229
230   StrictMock<MockBufferedDataSourceHost> host_;
231   base::MessageLoop message_loop_;
232
233  private:
234   // Used for calling BufferedDataSource::Read().
235   uint8 buffer_[kDataSize];
236
237   DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceTest);
238 };
239
240 TEST_F(BufferedDataSourceTest, Range_Supported) {
241   Initialize(kHttpUrl, true);
242
243   EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
244   Respond(response_generator_->Generate206(0));
245
246   EXPECT_TRUE(data_source_->loading());
247   EXPECT_FALSE(data_source_->IsStreaming());
248   Stop();
249 }
250
251 TEST_F(BufferedDataSourceTest, Range_InstanceSizeUnknown) {
252   Initialize(kHttpUrl, true);
253
254   Respond(response_generator_->Generate206(
255       0, TestResponseGenerator::kNoContentRangeInstanceSize));
256
257   EXPECT_TRUE(data_source_->loading());
258   EXPECT_TRUE(data_source_->IsStreaming());
259   Stop();
260 }
261
262 TEST_F(BufferedDataSourceTest, Range_NotFound) {
263   Initialize(kHttpUrl, false);
264   Respond(response_generator_->Generate404());
265
266   EXPECT_FALSE(data_source_->loading());
267   Stop();
268 }
269
270 TEST_F(BufferedDataSourceTest, Range_NotSupported) {
271   Initialize(kHttpUrl, true);
272   EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
273   Respond(response_generator_->Generate200());
274
275   EXPECT_TRUE(data_source_->loading());
276   EXPECT_TRUE(data_source_->IsStreaming());
277   Stop();
278 }
279
280 // Special carve-out for Apache versions that choose to return a 200 for
281 // Range:0- ("because it's more efficient" than a 206)
282 TEST_F(BufferedDataSourceTest, Range_SupportedButReturned200) {
283   Initialize(kHttpUrl, true);
284   EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
285   WebURLResponse response = response_generator_->Generate200();
286   response.setHTTPHeaderField(WebString::fromUTF8("Accept-Ranges"),
287                               WebString::fromUTF8("bytes"));
288   Respond(response);
289
290   EXPECT_TRUE(data_source_->loading());
291   EXPECT_FALSE(data_source_->IsStreaming());
292   Stop();
293 }
294
295 TEST_F(BufferedDataSourceTest, Range_MissingContentRange) {
296   Initialize(kHttpUrl, false);
297   Respond(response_generator_->Generate206(
298       0, TestResponseGenerator::kNoContentRange));
299
300   EXPECT_FALSE(data_source_->loading());
301   Stop();
302 }
303
304 TEST_F(BufferedDataSourceTest, Range_MissingContentLength) {
305   Initialize(kHttpUrl, true);
306
307   // It'll manage without a Content-Length response.
308   EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
309   Respond(response_generator_->Generate206(
310       0, TestResponseGenerator::kNoContentLength));
311
312   EXPECT_TRUE(data_source_->loading());
313   EXPECT_FALSE(data_source_->IsStreaming());
314   Stop();
315 }
316
317 TEST_F(BufferedDataSourceTest, Range_WrongContentRange) {
318   Initialize(kHttpUrl, false);
319
320   // Now it's done and will fail.
321   Respond(response_generator_->Generate206(1337));
322
323   EXPECT_FALSE(data_source_->loading());
324   Stop();
325 }
326
327 // Test the case where the initial response from the server indicates that
328 // Range requests are supported, but a later request prove otherwise.
329 TEST_F(BufferedDataSourceTest, Range_ServerLied) {
330   InitializeWith206Response();
331
332   // Read causing a new request to be made -- we'll expect it to error.
333   ExpectCreateResourceLoader();
334   ReadAt(kFarReadPosition);
335
336   // Return a 200 in response to a range request.
337   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
338   Respond(response_generator_->Generate200());
339
340   EXPECT_FALSE(data_source_->loading());
341   Stop();
342 }
343
344 TEST_F(BufferedDataSourceTest, Http_AbortWhileReading) {
345   InitializeWith206Response();
346
347   // Make sure there's a pending read -- we'll expect it to error.
348   ReadAt(0);
349
350   // Abort!!!
351   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
352   data_source_->Abort();
353   message_loop_.RunUntilIdle();
354
355   EXPECT_FALSE(data_source_->loading());
356   Stop();
357 }
358
359 TEST_F(BufferedDataSourceTest, File_AbortWhileReading) {
360   InitializeWithFileResponse();
361
362   // Make sure there's a pending read -- we'll expect it to error.
363   ReadAt(0);
364
365   // Abort!!!
366   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
367   data_source_->Abort();
368   message_loop_.RunUntilIdle();
369
370   EXPECT_FALSE(data_source_->loading());
371   Stop();
372 }
373
374 TEST_F(BufferedDataSourceTest, Http_Retry) {
375   InitializeWith206Response();
376
377   // Read to advance our position.
378   EXPECT_CALL(*this, ReadCallback(kDataSize));
379   EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1));
380   ReadAt(0);
381   ReceiveData(kDataSize);
382
383   // Issue a pending read but terminate the connection to force a retry.
384   ReadAt(kDataSize);
385   ExpectCreateResourceLoader();
386   FinishLoading();
387   Respond(response_generator_->Generate206(kDataSize));
388
389   // Complete the read.
390   EXPECT_CALL(*this, ReadCallback(kDataSize));
391   EXPECT_CALL(host_, AddBufferedByteRange(kDataSize, (kDataSize * 2) - 1));
392   ReceiveData(kDataSize);
393
394   EXPECT_TRUE(data_source_->loading());
395   Stop();
396 }
397
398 TEST_F(BufferedDataSourceTest, File_Retry) {
399   InitializeWithFileResponse();
400
401   // Read to advance our position.
402   EXPECT_CALL(*this, ReadCallback(kDataSize));
403   ReadAt(0);
404   ReceiveData(kDataSize);
405
406   // Issue a pending read but terminate the connection to force a retry.
407   ReadAt(kDataSize);
408   ExpectCreateResourceLoader();
409   FinishLoading();
410   Respond(response_generator_->GenerateFileResponse(kDataSize));
411
412   // Complete the read.
413   EXPECT_CALL(*this, ReadCallback(kDataSize));
414   ReceiveData(kDataSize);
415
416   EXPECT_TRUE(data_source_->loading());
417   Stop();
418 }
419
420 TEST_F(BufferedDataSourceTest, Http_TooManyRetries) {
421   InitializeWith206Response();
422
423   // Make sure there's a pending read -- we'll expect it to error.
424   ReadAt(0);
425
426   // It'll try three times.
427   ExpectCreateResourceLoader();
428   FinishLoading();
429   Respond(response_generator_->Generate206(0));
430
431   ExpectCreateResourceLoader();
432   FinishLoading();
433   Respond(response_generator_->Generate206(0));
434
435   ExpectCreateResourceLoader();
436   FinishLoading();
437   Respond(response_generator_->Generate206(0));
438
439   // It'll error after this.
440   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
441   FinishLoading();
442
443   EXPECT_FALSE(data_source_->loading());
444   Stop();
445 }
446
447 TEST_F(BufferedDataSourceTest, File_TooManyRetries) {
448   InitializeWithFileResponse();
449
450   // Make sure there's a pending read -- we'll expect it to error.
451   ReadAt(0);
452
453   // It'll try three times.
454   ExpectCreateResourceLoader();
455   FinishLoading();
456   Respond(response_generator_->GenerateFileResponse(0));
457
458   ExpectCreateResourceLoader();
459   FinishLoading();
460   Respond(response_generator_->GenerateFileResponse(0));
461
462   ExpectCreateResourceLoader();
463   FinishLoading();
464   Respond(response_generator_->GenerateFileResponse(0));
465
466   // It'll error after this.
467   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
468   FinishLoading();
469
470   EXPECT_FALSE(data_source_->loading());
471   Stop();
472 }
473
474 TEST_F(BufferedDataSourceTest, File_InstanceSizeUnknown) {
475   Initialize(kFileUrl, false);
476   EXPECT_FALSE(data_source_->downloading());
477
478   Respond(response_generator_->GenerateFileResponse(-1));
479
480   EXPECT_FALSE(data_source_->loading());
481   Stop();
482 }
483
484 TEST_F(BufferedDataSourceTest, File_Successful) {
485   InitializeWithFileResponse();
486
487   EXPECT_TRUE(data_source_->loading());
488   EXPECT_FALSE(data_source_->IsStreaming());
489   Stop();
490 }
491
492 static void SetTrue(bool* value) {
493   *value = true;
494 }
495
496 // This test makes sure that Stop() does not require a task to run on
497 // |message_loop_| before it calls its callback. This prevents accidental
498 // introduction of a pipeline teardown deadlock. The pipeline owner blocks
499 // the render message loop while waiting for Stop() to complete. Since this
500 // object runs on the render message loop, Stop() will not complete if it
501 // requires a task to run on the the message loop that is being blocked.
502 TEST_F(BufferedDataSourceTest, StopDoesNotUseMessageLoopForCallback) {
503   InitializeWith206Response();
504
505   // Stop() the data source, using a callback that lets us verify that it was
506   // called before Stop() returns. This is to make sure that the callback does
507   // not require |message_loop_| to execute tasks before being called.
508   bool stop_done_called = false;
509   EXPECT_TRUE(data_source_->loading());
510   data_source_->Stop(base::Bind(&SetTrue, &stop_done_called));
511
512   // Verify that the callback was called inside the Stop() call.
513   EXPECT_TRUE(stop_done_called);
514   message_loop_.RunUntilIdle();
515 }
516
517 TEST_F(BufferedDataSourceTest, StopDuringRead) {
518   InitializeWith206Response();
519
520   uint8 buffer[256];
521   data_source_->Read(0, arraysize(buffer), buffer, base::Bind(
522       &BufferedDataSourceTest::ReadCallback, base::Unretained(this)));
523
524   // The outstanding read should fail before the stop callback runs.
525   {
526     InSequence s;
527     EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
528     data_source_->Stop(media::NewExpectedClosure());
529   }
530   message_loop_.RunUntilIdle();
531 }
532
533 TEST_F(BufferedDataSourceTest, DefaultValues) {
534   InitializeWith206Response();
535
536   // Ensure we have sane values for default loading scenario.
537   EXPECT_EQ(AUTO, preload());
538   EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
539
540   EXPECT_EQ(0, data_source_bitrate());
541   EXPECT_EQ(0.0f, data_source_playback_rate());
542   EXPECT_EQ(0, loader_bitrate());
543   EXPECT_EQ(0.0f, loader_playback_rate());
544
545   EXPECT_TRUE(data_source_->loading());
546   Stop();
547 }
548
549 TEST_F(BufferedDataSourceTest, SetBitrate) {
550   InitializeWith206Response();
551
552   data_source_->SetBitrate(1234);
553   message_loop_.RunUntilIdle();
554   EXPECT_EQ(1234, data_source_bitrate());
555   EXPECT_EQ(1234, loader_bitrate());
556
557   // Read so far ahead to cause the loader to get recreated.
558   BufferedResourceLoader* old_loader = loader();
559   ExpectCreateResourceLoader();
560   ReadAt(kFarReadPosition);
561   Respond(response_generator_->Generate206(kFarReadPosition));
562
563   // Verify loader changed but still has same bitrate.
564   EXPECT_NE(old_loader, loader());
565   EXPECT_EQ(1234, loader_bitrate());
566
567   EXPECT_TRUE(data_source_->loading());
568   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
569   Stop();
570 }
571
572 TEST_F(BufferedDataSourceTest, MediaPlaybackRateChanged) {
573   InitializeWith206Response();
574
575   data_source_->MediaPlaybackRateChanged(2.0f);
576   message_loop_.RunUntilIdle();
577   EXPECT_EQ(2.0f, data_source_playback_rate());
578   EXPECT_EQ(2.0f, loader_playback_rate());
579
580   // Read so far ahead to cause the loader to get recreated.
581   BufferedResourceLoader* old_loader = loader();
582   ExpectCreateResourceLoader();
583   ReadAt(kFarReadPosition);
584   Respond(response_generator_->Generate206(kFarReadPosition));
585
586   // Verify loader changed but still has same playback rate.
587   EXPECT_NE(old_loader, loader());
588
589   EXPECT_TRUE(data_source_->loading());
590   EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
591   Stop();
592 }
593
594 TEST_F(BufferedDataSourceTest, Http_Read) {
595   InitializeWith206Response();
596
597   ReadAt(0);
598
599   // Receive first half of the read.
600   EXPECT_CALL(host_, AddBufferedByteRange(0, (kDataSize / 2) - 1));
601   ReceiveData(kDataSize / 2);
602
603   // Receive last half of the read.
604   EXPECT_CALL(*this, ReadCallback(kDataSize));
605   EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1));
606   ReceiveData(kDataSize / 2);
607
608   EXPECT_TRUE(data_source_->downloading());
609   Stop();
610 }
611
612 TEST_F(BufferedDataSourceTest, Http_Read_Seek) {
613   InitializeWith206Response();
614
615   // Read a bit from the beginning.
616   ReadAt(0);
617   EXPECT_CALL(*this, ReadCallback(kDataSize));
618   EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1));
619   ReceiveData(kDataSize);
620
621   // Simulate a seek by reading a bit beyond kDataSize.
622   ReadAt(kDataSize * 2);
623
624   // We receive data leading up to but not including our read.
625   EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2 - 1));
626   ReceiveData(kDataSize);
627
628   // We now receive the rest of the data for our read.
629   EXPECT_CALL(*this, ReadCallback(kDataSize));
630   EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3 - 1));
631   ReceiveData(kDataSize);
632
633   EXPECT_TRUE(data_source_->downloading());
634   Stop();
635 }
636
637 TEST_F(BufferedDataSourceTest, File_Read) {
638   InitializeWithFileResponse();
639
640   ReadAt(0);
641
642   // Receive first half of the read but no buffering update.
643   ReceiveData(kDataSize / 2);
644
645   // Receive last half of the read but no buffering update.
646   EXPECT_CALL(*this, ReadCallback(kDataSize));
647   ReceiveData(kDataSize / 2);
648
649   Stop();
650 }
651
652 TEST_F(BufferedDataSourceTest, Http_FinishLoading) {
653   InitializeWith206Response();
654
655   EXPECT_TRUE(data_source_->downloading());
656   FinishLoading();
657   EXPECT_FALSE(data_source_->downloading());
658
659   Stop();
660 }
661
662 TEST_F(BufferedDataSourceTest, File_FinishLoading) {
663   InitializeWithFileResponse();
664
665   EXPECT_FALSE(data_source_->downloading());
666   FinishLoading();
667   EXPECT_FALSE(data_source_->downloading());
668
669   Stop();
670 }
671
672 }  // namespace content