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)); | 100 EXPECT_CALL(host_, SetLocalSourceFromFilter(is_local_source)); |
101 | 101 |
102 InSequence s; | 102 InSequence s; |
103 EXPECT_CALL(host_, SetTotalBytes(kDataSize)); | 103 EXPECT_CALL(host_, SetTotalBytes(kDataSize)); |
104 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); | 104 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); |
105 | 105 |
106 data_source_->didFinishLoading(NULL, 0); | 106 data_source_->didFinishLoading(NULL, 0); |
107 | 107 |
108 // Let the tasks to be executed. | 108 // Let the tasks to be executed. |
109 MessageLoop::current()->RunAllPending(); | 109 MessageLoop::current()->RunAllPending(); |
110 } | 110 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 TEST_F(SimpleDataSourceTest, InitializeData) { | 191 TEST_F(SimpleDataSourceTest, InitializeData) { |
192 url_loader_ = new NiceMock<MockWebURLLoader>(); | 192 url_loader_ = new NiceMock<MockWebURLLoader>(); |
193 | 193 |
194 data_source_ = new SimpleDataSource(MessageLoop::current(), | 194 data_source_ = new SimpleDataSource(MessageLoop::current(), |
195 view_->mainFrame()); | 195 view_->mainFrame()); |
196 // There is no need to provide a message loop to data source. | 196 // There is no need to provide a message loop to data source. |
197 data_source_->set_host(&host_); | 197 data_source_->set_host(&host_); |
198 data_source_->SetURLLoaderForTest(url_loader_); | 198 data_source_->SetURLLoaderForTest(url_loader_); |
199 | 199 |
200 EXPECT_CALL(host_, SetLoaded(true)); | 200 EXPECT_CALL(host_, SetLocalSourceFromFilter(true)); |
201 EXPECT_CALL(host_, SetTotalBytes(sizeof(kDataUrlDecoded))); | 201 EXPECT_CALL(host_, SetTotalBytes(sizeof(kDataUrlDecoded))); |
202 EXPECT_CALL(host_, SetBufferedBytes(sizeof(kDataUrlDecoded))); | 202 EXPECT_CALL(host_, SetBufferedBytes(sizeof(kDataUrlDecoded))); |
203 | 203 |
204 data_source_->Initialize(kDataUrl, | 204 data_source_->Initialize(kDataUrl, |
205 media::NewExpectedStatusCB(media::PIPELINE_OK)); | 205 media::NewExpectedStatusCB(media::PIPELINE_OK)); |
206 MessageLoop::current()->RunAllPending(); | 206 MessageLoop::current()->RunAllPending(); |
207 | 207 |
208 DestroyDataSource(); | 208 DestroyDataSource(); |
209 } | 209 } |
210 | 210 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 InitializeDataSource(kHttpUrl, | 278 InitializeDataSource(kHttpUrl, |
279 media::NewExpectedStatusCB(media::PIPELINE_OK)); | 279 media::NewExpectedStatusCB(media::PIPELINE_OK)); |
280 Redirect(kHttpRedirectToSameDomainUrl1); | 280 Redirect(kHttpRedirectToSameDomainUrl1); |
281 Redirect(kHttpRedirectToDifferentDomainUrl1); | 281 Redirect(kHttpRedirectToDifferentDomainUrl1); |
282 RequestSucceeded(false); | 282 RequestSucceeded(false); |
283 EXPECT_FALSE(data_source_->HasSingleOrigin()); | 283 EXPECT_FALSE(data_source_->HasSingleOrigin()); |
284 DestroyDataSource(); | 284 DestroyDataSource(); |
285 } | 285 } |
286 | 286 |
287 } // namespace webkit_media | 287 } // namespace webkit_media |
OLD | NEW |