OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "media/base/media_log.h" | 9 #include "media/base/media_log.h" |
10 #include "media/base/mock_callback.h" | 10 #include "media/base/mock_callback.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 ON_CALL(*loader_, range_supported()) | 185 ON_CALL(*loader_, range_supported()) |
186 .WillByDefault(Return(partial_response)); | 186 .WillByDefault(Return(partial_response)); |
187 | 187 |
188 ON_CALL(*loader_, url()) | 188 ON_CALL(*loader_, url()) |
189 .WillByDefault(ReturnRef(gurl_)); | 189 .WillByDefault(ReturnRef(gurl_)); |
190 media::PipelineStatus expected_init_status = media::PIPELINE_OK; | 190 media::PipelineStatus expected_init_status = media::PIPELINE_OK; |
191 if (initialized_ok) { | 191 if (initialized_ok) { |
192 // Expected loaded or not. | 192 // Expected loaded or not. |
193 EXPECT_CALL(host_, SetLoaded(loaded)); | 193 EXPECT_CALL(host_, SetLoaded(loaded)); |
194 | 194 |
195 // TODO(hclam): The condition for streaming needs to be adjusted. | 195 if (instance_size != -1) { |
196 if (instance_size != -1 && (loaded || partial_response)) { | |
197 EXPECT_CALL(host_, SetTotalBytes(instance_size)); | 196 EXPECT_CALL(host_, SetTotalBytes(instance_size)); |
198 if (loaded) | 197 if (loaded) |
199 EXPECT_CALL(host_, SetBufferedBytes(instance_size)); | 198 EXPECT_CALL(host_, SetBufferedBytes(instance_size)); |
200 else | 199 else |
201 EXPECT_CALL(host_, SetBufferedBytes(0)); | 200 EXPECT_CALL(host_, SetBufferedBytes(0)); |
202 } else { | 201 } |
| 202 |
| 203 if (!partial_response || instance_size == -1) |
203 EXPECT_CALL(host_, SetStreaming(true)); | 204 EXPECT_CALL(host_, SetStreaming(true)); |
204 } | 205 |
205 } else { | 206 } else { |
206 expected_init_status = media::PIPELINE_ERROR_NETWORK; | 207 expected_init_status = media::PIPELINE_ERROR_NETWORK; |
207 EXPECT_CALL(*loader_, Stop()); | 208 EXPECT_CALL(*loader_, Stop()); |
208 } | 209 } |
209 | 210 |
210 // Actual initialization of the data source. | 211 // Actual initialization of the data source. |
211 data_source_->Initialize(url, | 212 data_source_->Initialize(url, |
212 media::NewExpectedStatusCB(expected_init_status)); | 213 media::NewExpectedStatusCB(expected_init_status)); |
213 message_loop_->RunAllPending(); | 214 message_loop_->RunAllPending(); |
214 | 215 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 message_loop_->RunAllPending(); | 783 message_loop_->RunAllPending(); |
783 | 784 |
784 // Verify loader changed but still has same bitrate. | 785 // Verify loader changed but still has same bitrate. |
785 EXPECT_NE(old_loader, data_source_->loader().get()); | 786 EXPECT_NE(old_loader, data_source_->loader().get()); |
786 EXPECT_EQ(2.0f, loader_playback_rate()); | 787 EXPECT_EQ(2.0f, loader_playback_rate()); |
787 | 788 |
788 StopDataSource(); | 789 StopDataSource(); |
789 } | 790 } |
790 | 791 |
791 } // namespace webkit_media | 792 } // namespace webkit_media |
OLD | NEW |