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 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) { | 101 void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) { |
102 loader_->buffer_.reset( | 102 loader_->buffer_.reset( |
103 new media::SeekableBuffer(backward_capacity, forward_capacity)); | 103 new media::SeekableBuffer(backward_capacity, forward_capacity)); |
104 } | 104 } |
105 | 105 |
106 void Start() { | 106 void Start() { |
107 InSequence s; | 107 InSequence s; |
108 EXPECT_CALL(*url_loader_, loadAsynchronously(Truly(CorrectAcceptEncoding), | 108 EXPECT_CALL(*url_loader_, loadAsynchronously(Truly(CorrectAcceptEncoding), |
109 loader_.get())); | 109 loader_.get())); |
110 loader_->Start( | 110 loader_->Start( |
111 NewCallback(this, &BufferedResourceLoaderTest::StartCallback), | 111 base::Bind(&BufferedResourceLoaderTest::StartCallback, |
scherkus (not reviewing)
2011/12/01 17:42:18
sanity check: are there .h files we can stop inclu
Ami GONE FROM CHROMIUM
2011/12/01 18:11:26
no.
| |
112 base::Unretained(this)), | |
112 base::Bind(&BufferedResourceLoaderTest::NetworkCallback, | 113 base::Bind(&BufferedResourceLoaderTest::NetworkCallback, |
113 base::Unretained(this)), | 114 base::Unretained(this)), |
114 view_->mainFrame()); | 115 view_->mainFrame()); |
115 } | 116 } |
116 | 117 |
117 void FullResponse(int64 instance_size) { | 118 void FullResponse(int64 instance_size) { |
118 FullResponse(instance_size, net::OK); | 119 FullResponse(instance_size, net::OK); |
119 } | 120 } |
120 | 121 |
121 void FullResponse(int64 instance_size, int status) { | 122 void FullResponse(int64 instance_size, int status) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 CHECK_LT(buffered, capacity); | 232 CHECK_LT(buffered, capacity); |
232 | 233 |
233 EXPECT_CALL(*this, NetworkCallback()); | 234 EXPECT_CALL(*this, NetworkCallback()); |
234 WriteData(capacity - buffered); | 235 WriteData(capacity - buffered); |
235 ConfirmLoaderDeferredState(true); | 236 ConfirmLoaderDeferredState(true); |
236 } | 237 } |
237 | 238 |
238 // Helper method to read from |loader_|. | 239 // Helper method to read from |loader_|. |
239 void ReadLoader(int64 position, int size, uint8* buffer) { | 240 void ReadLoader(int64 position, int size, uint8* buffer) { |
240 loader_->Read(position, size, buffer, | 241 loader_->Read(position, size, buffer, |
241 NewCallback(this, &BufferedResourceLoaderTest::ReadCallback)); | 242 base::Bind(&BufferedResourceLoaderTest::ReadCallback, |
243 base::Unretained(this))); | |
242 } | 244 } |
243 | 245 |
244 // Verifies that data in buffer[0...size] is equal to data_[pos...pos+size]. | 246 // Verifies that data in buffer[0...size] is equal to data_[pos...pos+size]. |
245 void VerifyBuffer(uint8* buffer, int pos, int size) { | 247 void VerifyBuffer(uint8* buffer, int pos, int size) { |
246 EXPECT_EQ(0, memcmp(buffer, data_ + pos, size)); | 248 EXPECT_EQ(0, memcmp(buffer, data_ + pos, size)); |
247 } | 249 } |
248 | 250 |
249 void ConfirmLoaderOffsets(int64 expected_offset, | 251 void ConfirmLoaderOffsets(int64 expected_offset, |
250 int expected_first_offset, | 252 int expected_first_offset, |
251 int expected_last_offset) { | 253 int expected_last_offset) { |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 | 1104 |
1103 TEST_F(BufferedResourceLoaderTest, BufferWindow_PlaybackRate_AboveUpperBound) { | 1105 TEST_F(BufferedResourceLoaderTest, BufferWindow_PlaybackRate_AboveUpperBound) { |
1104 Initialize(kHttpUrl, -1, -1); | 1106 Initialize(kHttpUrl, -1, -1); |
1105 Start(); | 1107 Start(); |
1106 loader_->SetPlaybackRate(100); | 1108 loader_->SetPlaybackRate(100); |
1107 CheckBufferWindowBounds(); | 1109 CheckBufferWindowBounds(); |
1108 StopWhenLoad(); | 1110 StopWhenLoad(); |
1109 } | 1111 } |
1110 | 1112 |
1111 } // namespace webkit_media | 1113 } // namespace webkit_media |
OLD | NEW |