| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "media/base/filters.h" | 6 #include "media/base/filters.h" |
| 7 #include "media/base/mock_callback.h" | 7 #include "media/base/mock_callback.h" |
| 8 #include "media/base/mock_filter_host.h" | 8 #include "media/base/mock_filter_host.h" |
| 9 #include "media/base/mock_filters.h" | 9 #include "media/base/mock_filters.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 view_->mainFrame()); | 77 view_->mainFrame()); |
| 78 | 78 |
| 79 // There is no need to provide a message loop to data source. | 79 // There is no need to provide a message loop to data source. |
| 80 data_source_->set_host(&host_); | 80 data_source_->set_host(&host_); |
| 81 data_source_->SetURLLoaderForTest(url_loader_); | 81 data_source_->SetURLLoaderForTest(url_loader_); |
| 82 | 82 |
| 83 data_source_->Initialize(url, callback); | 83 data_source_->Initialize(url, callback); |
| 84 MessageLoop::current()->RunAllPending(); | 84 MessageLoop::current()->RunAllPending(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void RequestSucceeded(bool is_loaded) { | 87 void RequestSucceeded(bool is_local_source) { |
| 88 WebURLResponse response(gurl_); | 88 WebURLResponse response(gurl_); |
| 89 response.setExpectedContentLength(kDataSize); | 89 response.setExpectedContentLength(kDataSize); |
| 90 | 90 |
| 91 data_source_->didReceiveResponse(NULL, response); | 91 data_source_->didReceiveResponse(NULL, response); |
| 92 int64 size; | 92 int64 size; |
| 93 EXPECT_TRUE(data_source_->GetSize(&size)); | 93 EXPECT_TRUE(data_source_->GetSize(&size)); |
| 94 EXPECT_EQ(kDataSize, size); | 94 EXPECT_EQ(kDataSize, size); |
| 95 | 95 |
| 96 for (int i = 0; i < kDataSize; ++i) { | 96 for (int i = 0; i < kDataSize; ++i) { |
| 97 data_source_->didReceiveData(NULL, data_ + i, 1, 1); | 97 data_source_->didReceiveData(NULL, data_ + i, 1, 1); |
| 98 } | 98 } |
| 99 | 99 |
| 100 EXPECT_CALL(host_, SetLoaded(is_loaded)); | |
| 101 | |
| 102 InSequence s; | 100 InSequence s; |
| 103 EXPECT_CALL(host_, SetTotalBytes(kDataSize)); | 101 EXPECT_CALL(host_, SetTotalBytes(kDataSize)); |
| 104 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); | 102 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); |
| 105 | 103 |
| 106 data_source_->didFinishLoading(NULL, 0); | 104 data_source_->didFinishLoading(NULL, 0); |
| 107 | 105 |
| 108 // Let the tasks to be executed. | 106 // Let the tasks to be executed. |
| 109 MessageLoop::current()->RunAllPending(); | 107 MessageLoop::current()->RunAllPending(); |
| 110 } | 108 } |
| 111 | 109 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 188 |
| 191 TEST_F(SimpleDataSourceTest, InitializeData) { | 189 TEST_F(SimpleDataSourceTest, InitializeData) { |
| 192 url_loader_ = new NiceMock<MockWebURLLoader>(); | 190 url_loader_ = new NiceMock<MockWebURLLoader>(); |
| 193 | 191 |
| 194 data_source_ = new SimpleDataSource(MessageLoop::current(), | 192 data_source_ = new SimpleDataSource(MessageLoop::current(), |
| 195 view_->mainFrame()); | 193 view_->mainFrame()); |
| 196 // There is no need to provide a message loop to data source. | 194 // There is no need to provide a message loop to data source. |
| 197 data_source_->set_host(&host_); | 195 data_source_->set_host(&host_); |
| 198 data_source_->SetURLLoaderForTest(url_loader_); | 196 data_source_->SetURLLoaderForTest(url_loader_); |
| 199 | 197 |
| 200 EXPECT_CALL(host_, SetLoaded(true)); | |
| 201 EXPECT_CALL(host_, SetTotalBytes(sizeof(kDataUrlDecoded))); | 198 EXPECT_CALL(host_, SetTotalBytes(sizeof(kDataUrlDecoded))); |
| 202 EXPECT_CALL(host_, SetBufferedBytes(sizeof(kDataUrlDecoded))); | 199 EXPECT_CALL(host_, SetBufferedBytes(sizeof(kDataUrlDecoded))); |
| 203 | 200 |
| 204 data_source_->Initialize(kDataUrl, | 201 data_source_->Initialize(kDataUrl, |
| 205 media::NewExpectedStatusCB(media::PIPELINE_OK)); | 202 media::NewExpectedStatusCB(media::PIPELINE_OK)); |
| 206 MessageLoop::current()->RunAllPending(); | 203 MessageLoop::current()->RunAllPending(); |
| 207 | 204 |
| 208 DestroyDataSource(); | 205 DestroyDataSource(); |
| 209 } | 206 } |
| 210 | 207 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 InitializeDataSource(kHttpUrl, | 275 InitializeDataSource(kHttpUrl, |
| 279 media::NewExpectedStatusCB(media::PIPELINE_OK)); | 276 media::NewExpectedStatusCB(media::PIPELINE_OK)); |
| 280 Redirect(kHttpRedirectToSameDomainUrl1); | 277 Redirect(kHttpRedirectToSameDomainUrl1); |
| 281 Redirect(kHttpRedirectToDifferentDomainUrl1); | 278 Redirect(kHttpRedirectToDifferentDomainUrl1); |
| 282 RequestSucceeded(false); | 279 RequestSucceeded(false); |
| 283 EXPECT_FALSE(data_source_->HasSingleOrigin()); | 280 EXPECT_FALSE(data_source_->HasSingleOrigin()); |
| 284 DestroyDataSource(); | 281 DestroyDataSource(); |
| 285 } | 282 } |
| 286 | 283 |
| 287 } // namespace webkit_media | 284 } // namespace webkit_media |
| OLD | NEW |