| 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/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
| 8 #include "media/base/mock_callback.h" | 8 #include "media/base/mock_callback.h" |
| 9 #include "media/base/mock_filter_host.h" | 9 #include "media/base/mock_filter_host.h" |
| 10 #include "media/base/mock_filters.h" | 10 #include "media/base/mock_filters.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // "callback" parameter. | 161 // "callback" parameter. |
| 162 ON_CALL(*loader_, Read(_, _, _ , _)) | 162 ON_CALL(*loader_, Read(_, _, _ , _)) |
| 163 .WillByDefault(DeleteArg<3>()); | 163 .WillByDefault(DeleteArg<3>()); |
| 164 | 164 |
| 165 ON_CALL(*loader_, instance_size()) | 165 ON_CALL(*loader_, instance_size()) |
| 166 .WillByDefault(Return(instance_size)); | 166 .WillByDefault(Return(instance_size)); |
| 167 ON_CALL(*loader_, partial_response()) | 167 ON_CALL(*loader_, partial_response()) |
| 168 .WillByDefault(Return(partial_response)); | 168 .WillByDefault(Return(partial_response)); |
| 169 ON_CALL(*loader_, url()) | 169 ON_CALL(*loader_, url()) |
| 170 .WillByDefault(ReturnRef(gurl_)); | 170 .WillByDefault(ReturnRef(gurl_)); |
| 171 media::PipelineError expected_init_error = media::PIPELINE_OK; | 171 media::PipelineStatus expected_init_status = media::PIPELINE_OK; |
| 172 if (initialized_ok) { | 172 if (initialized_ok) { |
| 173 // Expected loaded or not. | 173 // Expected loaded or not. |
| 174 EXPECT_CALL(host_, SetLoaded(loaded)); | 174 EXPECT_CALL(host_, SetLoaded(loaded)); |
| 175 | 175 |
| 176 // TODO(hclam): The condition for streaming needs to be adjusted. | 176 // TODO(hclam): The condition for streaming needs to be adjusted. |
| 177 if (instance_size != -1 && (loaded || partial_response)) { | 177 if (instance_size != -1 && (loaded || partial_response)) { |
| 178 EXPECT_CALL(host_, SetTotalBytes(instance_size)); | 178 EXPECT_CALL(host_, SetTotalBytes(instance_size)); |
| 179 if (loaded) | 179 if (loaded) |
| 180 EXPECT_CALL(host_, SetBufferedBytes(instance_size)); | 180 EXPECT_CALL(host_, SetBufferedBytes(instance_size)); |
| 181 else | 181 else |
| 182 EXPECT_CALL(host_, SetBufferedBytes(0)); | 182 EXPECT_CALL(host_, SetBufferedBytes(0)); |
| 183 } else { | 183 } else { |
| 184 EXPECT_CALL(host_, SetStreaming(true)); | 184 EXPECT_CALL(host_, SetStreaming(true)); |
| 185 } | 185 } |
| 186 } else { | 186 } else { |
| 187 expected_init_error = media::PIPELINE_ERROR_NETWORK; | 187 expected_init_status = media::PIPELINE_ERROR_NETWORK; |
| 188 EXPECT_CALL(*loader_, Stop()); | 188 EXPECT_CALL(*loader_, Stop()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 // Actual initialization of the data source. | 191 // Actual initialization of the data source. |
| 192 data_source_->Initialize(url, | 192 data_source_->Initialize(url, |
| 193 media::NewExpectedStatusCallback(expected_init_error)); | 193 media::NewExpectedStatusCallback(expected_init_status)); |
| 194 message_loop_->RunAllPending(); | 194 message_loop_->RunAllPending(); |
| 195 | 195 |
| 196 if (initialized_ok) { | 196 if (initialized_ok) { |
| 197 // Verify the size of the data source. | 197 // Verify the size of the data source. |
| 198 int64 size; | 198 int64 size; |
| 199 if (instance_size != -1 && (loaded || partial_response)) { | 199 if (instance_size != -1 && (loaded || partial_response)) { |
| 200 EXPECT_TRUE(data_source_->GetSize(&size)); | 200 EXPECT_TRUE(data_source_->GetSize(&size)); |
| 201 EXPECT_EQ(instance_size, size); | 201 EXPECT_EQ(instance_size, size); |
| 202 } else { | 202 } else { |
| 203 EXPECT_TRUE(data_source_->IsStreaming()); | 203 EXPECT_TRUE(data_source_->IsStreaming()); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 data_source_->Stop(media::NewExpectedCallback()); | 549 data_source_->Stop(media::NewExpectedCallback()); |
| 550 | 550 |
| 551 // Allow cleanup task to run. | 551 // Allow cleanup task to run. |
| 552 message_loop_->RunAllPending(); | 552 message_loop_->RunAllPending(); |
| 553 | 553 |
| 554 // Verify that Read() was not called on the loader. | 554 // Verify that Read() was not called on the loader. |
| 555 EXPECT_FALSE(read_called); | 555 EXPECT_FALSE(read_called); |
| 556 } | 556 } |
| 557 | 557 |
| 558 } // namespace webkit_glue | 558 } // namespace webkit_glue |
| OLD | NEW |