| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "media/base/media_log.h" | 6 #include "media/base/media_log.h" |
| 7 #include "media/base/mock_callback.h" | 7 #include "media/base/mock_callback.h" |
| 8 #include "media/base/mock_data_source_host.h" | 8 #include "media/base/mock_data_source_host.h" |
| 9 #include "media/base/mock_filters.h" | 9 #include "media/base/mock_filters.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // Whether the resource load has starting loading but yet to been cancelled. | 67 // Whether the resource load has starting loading but yet to been cancelled. |
| 68 bool loading_; | 68 bool loading_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource); | 70 DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 static const int64 kFileSize = 5000000; | 73 static const int64 kFileSize = 5000000; |
| 74 static const int64 kFarReadPosition = 4000000; | 74 static const int64 kFarReadPosition = 4000000; |
| 75 static const size_t kDataSize = 1024; | 75 static const int kDataSize = 1024; |
| 76 | 76 |
| 77 class BufferedDataSourceTest : public testing::Test { | 77 class BufferedDataSourceTest : public testing::Test { |
| 78 public: | 78 public: |
| 79 BufferedDataSourceTest() | 79 BufferedDataSourceTest() |
| 80 : response_generator_(GURL("http://localhost/foo.webm"), kFileSize), | 80 : response_generator_(GURL("http://localhost/foo.webm"), kFileSize), |
| 81 view_(WebView::create(NULL)), | 81 view_(WebView::create(NULL)), |
| 82 message_loop_(MessageLoop::current()) { | 82 message_loop_(MessageLoop::current()) { |
| 83 view_->initializeMainFrame(&client_); | 83 view_->initializeMainFrame(&client_); |
| 84 | 84 |
| 85 data_source_ = new MockBufferedDataSource(message_loop_, | 85 data_source_ = new MockBufferedDataSource(message_loop_, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 loader()->didReceiveData(url_loader(), data_, kDataSize, kDataSize); | 137 loader()->didReceiveData(url_loader(), data_, kDataSize, kDataSize); |
| 138 message_loop_->RunAllPending(); | 138 message_loop_->RunAllPending(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void FinishLoading() { | 141 void FinishLoading() { |
| 142 data_source_->set_loading(false); | 142 data_source_->set_loading(false); |
| 143 loader()->didFinishLoading(url_loader(), 0); | 143 loader()->didFinishLoading(url_loader(), 0); |
| 144 message_loop_->RunAllPending(); | 144 message_loop_->RunAllPending(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 MOCK_METHOD1(ReadCallback, void(size_t size)); | 147 MOCK_METHOD1(ReadCallback, void(int size)); |
| 148 | 148 |
| 149 void ReadAt(int64 position) { | 149 void ReadAt(int64 position) { |
| 150 data_source_->Read(position, kDataSize, buffer_, | 150 data_source_->Read(position, kDataSize, buffer_, |
| 151 base::Bind(&BufferedDataSourceTest::ReadCallback, | 151 base::Bind(&BufferedDataSourceTest::ReadCallback, |
| 152 base::Unretained(this))); | 152 base::Unretained(this))); |
| 153 message_loop_->RunAllPending(); | 153 message_loop_->RunAllPending(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Accessors for private variables on |data_source_|. | 156 // Accessors for private variables on |data_source_|. |
| 157 BufferedResourceLoader* loader() { | 157 BufferedResourceLoader* loader() { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 // During teardown we'll also report our final network status. | 447 // During teardown we'll also report our final network status. |
| 448 EXPECT_CALL(host_, SetNetworkActivity(false)); | 448 EXPECT_CALL(host_, SetNetworkActivity(false)); |
| 449 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); | 449 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); |
| 450 | 450 |
| 451 EXPECT_TRUE(data_source_->loading()); | 451 EXPECT_TRUE(data_source_->loading()); |
| 452 Stop(); | 452 Stop(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace webkit_media | 455 } // namespace webkit_media |
| OLD | NEW |