summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media/buffered_data_source_unittest.cc
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-05-11 20:53:37 +0100
committerKristian Monsen <kristianm@google.com>2011-05-16 13:54:48 +0100
commit21d179b334e59e9a3bfcaed4c4430bef1bc5759d (patch)
tree64e2bb6da27af6a5c93ca34f6051584aafbfcb9e /webkit/glue/media/buffered_data_source_unittest.cc
parent0c63f00edd6ed0482fd5cbcea937ca088baf7858 (diff)
downloadexternal_chromium-21d179b334e59e9a3bfcaed4c4430bef1bc5759d.zip
external_chromium-21d179b334e59e9a3bfcaed4c4430bef1bc5759d.tar.gz
external_chromium-21d179b334e59e9a3bfcaed4c4430bef1bc5759d.tar.bz2
Merge Chromium at 10.0.621.0: Initial merge by git.
Change-Id: I070cc91c608dfa4a968a5a54c173260765ac8097
Diffstat (limited to 'webkit/glue/media/buffered_data_source_unittest.cc')
-rw-r--r--webkit/glue/media/buffered_data_source_unittest.cc548
1 files changed, 33 insertions, 515 deletions
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc
index 81103b2..dcb11ec 100644
--- a/webkit/glue/media/buffered_data_source_unittest.cc
+++ b/webkit/glue/media/buffered_data_source_unittest.cc
@@ -4,22 +4,18 @@
#include <algorithm>
-#include "base/callback.h"
-#include "base/format_macros.h"
-#include "base/message_loop.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
-#include "media/base/filters.h"
+#include "base/test/test_timeouts.h"
#include "media/base/mock_filter_host.h"
#include "media/base/mock_filters.h"
#include "net/base/net_errors.h"
-#include "net/http/http_response_headers.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "webkit/glue/media/buffered_data_source.h"
-#include "webkit/glue/media/mock_media_resource_loader_bridge_factory.h"
-#include "webkit/glue/mock_resource_loader_bridge.h"
+#include "webkit/mocks/mock_webframe.h"
using ::testing::_;
using ::testing::Assign;
+using ::testing::AtLeast;
using ::testing::DeleteArg;
using ::testing::DoAll;
using ::testing::InSequence;
@@ -49,476 +45,36 @@ enum NetworkState {
namespace webkit_glue {
-// Submit a request completed event to the resource loader due to request
-// being canceled. Pretending the event is from external.
-ACTION_P(RequestCanceled, loader) {
- URLRequestStatus status;
- status.set_status(URLRequestStatus::CANCELED);
- status.set_os_error(net::ERR_ABORTED);
- loader->OnCompletedRequest(status, "", base::Time());
-}
-
-class BufferedResourceLoaderTest : public testing::Test {
+// A mock BufferedDataSource to inject mock BufferedResourceLoader through
+// CreateResourceLoader() method.
+class MockBufferedDataSource : public BufferedDataSource {
public:
- BufferedResourceLoaderTest() {
- bridge_.reset(new StrictMock<MockResourceLoaderBridge>());
-
- for (int i = 0; i < kDataSize; ++i)
- data_[i] = i;
- }
-
- ~BufferedResourceLoaderTest() {
- if (bridge_.get())
- EXPECT_CALL(*bridge_, OnDestroy());
- EXPECT_CALL(bridge_factory_, OnDestroy());
- }
-
- void Initialize(const char* url, int first_position, int last_position) {
- gurl_ = GURL(url);
- first_position_ = first_position;
- last_position_ = last_position;
-
- loader_ = new BufferedResourceLoader(&bridge_factory_, gurl_,
- first_position_, last_position_);
- }
-
- void SetLoaderBuffer(size_t forward_capacity, size_t backward_capacity) {
- loader_->buffer_.reset(
- new media::SeekableBuffer(backward_capacity, forward_capacity));
- }
-
- void Start() {
- InSequence s;
- EXPECT_CALL(bridge_factory_,
- CreateBridge(gurl_, _, first_position_, last_position_))
- .WillOnce(Return(bridge_.get()));
- EXPECT_CALL(*bridge_, Start(loader_.get()));
- loader_->Start(
- NewCallback(this, &BufferedResourceLoaderTest::StartCallback),
- NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback));
- }
-
- void FullResponse(int64 instance_size) {
- EXPECT_CALL(*this, StartCallback(net::OK));
- ResourceResponseInfo info;
- std::string header = base::StringPrintf("HTTP/1.1 200 OK\n"
- "Content-Length: %" PRId64,
- instance_size);
- replace(header.begin(), header.end(), '\n', '\0');
- info.headers = new net::HttpResponseHeaders(header);
- info.content_length = instance_size;
- loader_->OnReceivedResponse(info, false);
- EXPECT_EQ(instance_size, loader_->content_length());
- EXPECT_EQ(instance_size, loader_->instance_size());
- EXPECT_FALSE(loader_->partial_response());
- }
-
- void PartialResponse(int64 first_position, int64 last_position,
- int64 instance_size) {
- EXPECT_CALL(*this, StartCallback(net::OK));
- int64 content_length = last_position - first_position + 1;
- ResourceResponseInfo info;
- std::string header = base::StringPrintf("HTTP/1.1 206 Partial Content\n"
- "Content-Range: bytes "
- "%" PRId64 "-%" PRId64 "/%" PRId64,
- first_position,
- last_position,
- instance_size);
- replace(header.begin(), header.end(), '\n', '\0');
- info.headers = new net::HttpResponseHeaders(header);
- info.content_length = content_length;
- loader_->OnReceivedResponse(info, false);
- EXPECT_EQ(content_length, loader_->content_length());
- EXPECT_EQ(instance_size, loader_->instance_size());
- EXPECT_TRUE(loader_->partial_response());
- }
-
- void StopWhenLoad() {
- InSequence s;
- EXPECT_CALL(*bridge_, Cancel())
- .WillOnce(RequestCanceled(loader_));
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- loader_->Stop();
- }
-
- void ReleaseBridge() {
- ignore_result(bridge_.release());
- }
-
- // Helper method to write to |loader_| from |data_|.
- void WriteLoader(int position, int size) {
- EXPECT_CALL(*this, NetworkCallback())
- .RetiresOnSaturation();
- loader_->OnReceivedData(reinterpret_cast<char*>(data_ + position), size);
- }
-
- // Helper method to read from |loader_|.
- void ReadLoader(int64 position, int size, uint8* buffer) {
- loader_->Read(position, size, buffer,
- NewCallback(this, &BufferedResourceLoaderTest::ReadCallback));
- }
-
- // Verifis that data in buffer[0...size] is equal to data_[pos...pos+size].
- void VerifyBuffer(uint8* buffer, int pos, int size) {
- EXPECT_EQ(0, memcmp(buffer, data_ + pos, size));
- }
-
- // Helper method to disallow deferring in |loader_|.
- void DisallowLoaderDefer() {
- if (loader_->deferred_) {
- EXPECT_CALL(*bridge_, SetDefersLoading(false));
- EXPECT_CALL(*this, NetworkCallback());
- }
- loader_->SetAllowDefer(false);
+ MockBufferedDataSource(
+ MessageLoop* message_loop, WebFrame* frame)
+ : BufferedDataSource(message_loop, frame) {
}
- // Helper method to allow deferring in |loader_|.
- void AllowLoaderDefer() {
- loader_->SetAllowDefer(true);
+ virtual base::TimeDelta GetTimeoutMilliseconds() {
+ return base::TimeDelta::FromMilliseconds(
+ TestTimeouts::tiny_timeout_ms());
}
- MOCK_METHOD1(StartCallback, void(int error));
- MOCK_METHOD1(ReadCallback, void(int error));
- MOCK_METHOD0(NetworkCallback, void());
-
- protected:
- GURL gurl_;
- int64 first_position_;
- int64 last_position_;
-
- scoped_refptr<BufferedResourceLoader> loader_;
- StrictMock<MockMediaResourceLoaderBridgeFactory> bridge_factory_;
- scoped_ptr<StrictMock<MockResourceLoaderBridge> > bridge_;
-
- uint8 data_[kDataSize];
+ MOCK_METHOD2(CreateResourceLoader,
+ BufferedResourceLoader*(int64 first_position,
+ int64 last_position));
private:
- DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoaderTest);
+ DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource);
};
-TEST_F(BufferedResourceLoaderTest, StartStop) {
- Initialize(kHttpUrl, -1, -1);
- Start();
- StopWhenLoad();
-}
-
-// Tests that HTTP header is missing in the response.
-TEST_F(BufferedResourceLoaderTest, MissingHttpHeader) {
- Initialize(kHttpUrl, -1, -1);
- Start();
-
- EXPECT_CALL(*this, StartCallback(net::ERR_INVALID_RESPONSE));
- EXPECT_CALL(*bridge_, Cancel())
- .WillOnce(RequestCanceled(loader_));
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
-
- ResourceResponseInfo info;
- loader_->OnReceivedResponse(info, false);
-}
-
-// Tests that a bad HTTP response is recived, e.g. file not found.
-TEST_F(BufferedResourceLoaderTest, BadHttpResponse) {
- Initialize(kHttpUrl, -1, -1);
- Start();
-
- EXPECT_CALL(*this, StartCallback(net::ERR_FAILED));
- EXPECT_CALL(*bridge_, Cancel())
- .WillOnce(RequestCanceled(loader_));
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
-
- ResourceResponseInfo info;
- info.headers = new net::HttpResponseHeaders("HTTP/1.1 404 Not Found\n");
- loader_->OnReceivedResponse(info, false);
-}
-
-// Tests that partial content is requested but not fulfilled.
-TEST_F(BufferedResourceLoaderTest, NotPartialResponse) {
- Initialize(kHttpUrl, 100, -1);
- Start();
- FullResponse(1024);
- StopWhenLoad();
-}
-
-// Tests that a 200 response is received.
-TEST_F(BufferedResourceLoaderTest, FullResponse) {
- Initialize(kHttpUrl, -1, -1);
- Start();
- FullResponse(1024);
- StopWhenLoad();
-}
-
-// Tests that a partial content response is received.
-TEST_F(BufferedResourceLoaderTest, PartialResponse) {
- Initialize(kHttpUrl, 100, 200);
- Start();
- PartialResponse(100, 200, 1024);
- StopWhenLoad();
-}
-
-// Tests that an invalid partial response is received.
-TEST_F(BufferedResourceLoaderTest, InvalidPartialResponse) {
- Initialize(kHttpUrl, 0, 10);
- Start();
-
- EXPECT_CALL(*this, StartCallback(net::ERR_INVALID_RESPONSE));
- EXPECT_CALL(*bridge_, Cancel())
- .WillOnce(RequestCanceled(loader_));
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
-
- ResourceResponseInfo info;
- std::string header = base::StringPrintf("HTTP/1.1 206 Partial Content\n"
- "Content-Range: bytes %d-%d/%d",
- 1, 10, 1024);
- replace(header.begin(), header.end(), '\n', '\0');
- info.headers = new net::HttpResponseHeaders(header);
- info.content_length = 10;
- loader_->OnReceivedResponse(info, false);
-}
-
-// Tests the logic of sliding window for data buffering and reading.
-TEST_F(BufferedResourceLoaderTest, BufferAndRead) {
- Initialize(kHttpUrl, 10, 29);
- Start();
- PartialResponse(10, 29, 30);
-
- uint8 buffer[10];
- InSequence s;
-
- // Writes 10 bytes and read them back.
- WriteLoader(10, 10);
- EXPECT_CALL(*this, ReadCallback(10));
- ReadLoader(10, 10, buffer);
- VerifyBuffer(buffer, 10, 10);
-
- // Writes 10 bytes and read 2 times.
- WriteLoader(20, 10);
- EXPECT_CALL(*this, ReadCallback(5));
- ReadLoader(20, 5, buffer);
- VerifyBuffer(buffer, 20, 5);
- EXPECT_CALL(*this, ReadCallback(5));
- ReadLoader(25, 5, buffer);
- VerifyBuffer(buffer, 25, 5);
-
- // Read backward within buffer.
- EXPECT_CALL(*this, ReadCallback(10));
- ReadLoader(10, 10, buffer);
- VerifyBuffer(buffer, 10, 10);
-
- // Read backward outside buffer.
- EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS));
- ReadLoader(9, 10, buffer);
-
- // Response has completed.
- EXPECT_CALL(*this, NetworkCallback());
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- URLRequestStatus status;
- status.set_status(URLRequestStatus::SUCCESS);
- loader_->OnCompletedRequest(status, "", base::Time());
-
- // Try to read 10 from position 25 will just return with 5 bytes.
- EXPECT_CALL(*this, ReadCallback(5));
- ReadLoader(25, 10, buffer);
- VerifyBuffer(buffer, 25, 5);
-
- // Try to read outside buffered range after request has completed.
- EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS));
- ReadLoader(5, 10, buffer);
-
- // Try to read beyond the instance size.
- EXPECT_CALL(*this, ReadCallback(0));
- ReadLoader(30, 10, buffer);
-}
-
-TEST_F(BufferedResourceLoaderTest, ReadOutsideBuffer) {
- Initialize(kHttpUrl, 10, 0x00FFFFFF);
- Start();
- PartialResponse(10, 0x00FFFFFF, 0x01000000);
-
- uint8 buffer[10];
- InSequence s;
-
- // Read very far aheard will get a cache miss.
- EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS));
- ReadLoader(0x00FFFFFF, 1, buffer);
-
- // The following call will not call ReadCallback() because it is waiting for
- // data to arrive.
- ReadLoader(10, 10, buffer);
-
- // Writing to loader will fulfill the read request.
- EXPECT_CALL(*this, ReadCallback(10));
- WriteLoader(10, 20);
- VerifyBuffer(buffer, 10, 10);
-
- // The following call cannot be fulfilled now.
- ReadLoader(25, 10, buffer);
-
- EXPECT_CALL(*this, ReadCallback(5));
- EXPECT_CALL(*this, NetworkCallback());
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- URLRequestStatus status;
- status.set_status(URLRequestStatus::SUCCESS);
- loader_->OnCompletedRequest(status, "", base::Time());
-}
-
-TEST_F(BufferedResourceLoaderTest, RequestFailedWhenRead) {
- Initialize(kHttpUrl, 10, 29);
- Start();
- PartialResponse(10, 29, 30);
-
- uint8 buffer[10];
- InSequence s;
-
- ReadLoader(10, 10, buffer);
- EXPECT_CALL(*this, ReadCallback(net::ERR_FAILED));
- EXPECT_CALL(*this, NetworkCallback());
- EXPECT_CALL(*bridge_, OnDestroy())
- .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
- URLRequestStatus status;
- status.set_status(URLRequestStatus::FAILED);
- loader_->OnCompletedRequest(status, "", base::Time());
-}
-
-// Tests the logic of caching data to disk when media is paused.
-TEST_F(BufferedResourceLoaderTest, AllowDefer_NoDataReceived) {
- Initialize(kHttpUrl, 10, 99);
- SetLoaderBuffer(10, 20);
- Start();
- PartialResponse(10, 99, 100);
-
- // Start in undeferred state, then disallow defer, then allow defer
- // without receiving data in between.
- DisallowLoaderDefer();
- AllowLoaderDefer();
- StopWhenLoad();
-}
-
-TEST_F(BufferedResourceLoaderTest, AllowDefer_ReadSameWindow) {
- Initialize(kHttpUrl, 10, 99);
- SetLoaderBuffer(10, 20);
- Start();
- PartialResponse(10, 99, 100);
-
- uint8 buffer[10];
-
- // Start in undeferred state, disallow defer, receive data but don't shift
- // buffer window, then allow defer and read.
- DisallowLoaderDefer();
- WriteLoader(10, 10);
- AllowLoaderDefer();
-
- EXPECT_CALL(*this, ReadCallback(10));
- ReadLoader(10, 10, buffer);
- VerifyBuffer(buffer, 10, 10);
- StopWhenLoad();
-}
-
-TEST_F(BufferedResourceLoaderTest, AllowDefer_ReadPastWindow) {
- Initialize(kHttpUrl, 10, 99);
- SetLoaderBuffer(10, 20);
- Start();
- PartialResponse(10, 99, 100);
-
- uint8 buffer[10];
-
- // Not deferred, disallow defer, received data and shift buffer window,
- // allow defer, then read in area outside of buffer window.
- DisallowLoaderDefer();
- WriteLoader(10, 10);
- WriteLoader(20, 50);
- AllowLoaderDefer();
-
- EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS));
- ReadLoader(10, 10, buffer);
- StopWhenLoad();
-}
-
-TEST_F(BufferedResourceLoaderTest, AllowDefer_DeferredNoDataReceived) {
- Initialize(kHttpUrl, 10, 99);
- SetLoaderBuffer(10, 20);
- Start();
- PartialResponse(10, 99, 100);
-
- uint8 buffer[10];
-
- // Start in deferred state, then disallow defer, receive no data, and
- // allow defer and read.
- EXPECT_CALL(*bridge_, SetDefersLoading(true));
- EXPECT_CALL(*this, NetworkCallback());
- WriteLoader(10, 40);
-
- DisallowLoaderDefer();
- AllowLoaderDefer();
-
- EXPECT_CALL(*this, ReadCallback(10));
- ReadLoader(20, 10, buffer);
- VerifyBuffer(buffer, 20, 10);
- StopWhenLoad();
-}
-
-TEST_F(BufferedResourceLoaderTest, AllowDefer_DeferredReadSameWindow) {
- Initialize(kHttpUrl, 10, 99);
- SetLoaderBuffer(10, 20);
- Start();
- PartialResponse(10, 99, 100);
-
- uint8 buffer[10];
-
- // Start in deferred state, disallow defer, receive data and shift buffer
- // window, allow defer, and read in a place that's still in the window.
- EXPECT_CALL(*bridge_, SetDefersLoading(true));
- EXPECT_CALL(*this, NetworkCallback());
- WriteLoader(10, 30);
-
- DisallowLoaderDefer();
- WriteLoader(40, 5);
- AllowLoaderDefer();
-
- EXPECT_CALL(*this, ReadCallback(10));
- ReadLoader(20, 10, buffer);
- VerifyBuffer(buffer, 20, 10);
- StopWhenLoad();
-}
-
-TEST_F(BufferedResourceLoaderTest, AllowDefer_DeferredReadPastWindow) {
- Initialize(kHttpUrl, 10, 99);
- SetLoaderBuffer(10, 20);
- Start();
- PartialResponse(10, 99, 100);
-
- uint8 buffer[10];
-
- // Start in deferred state, disallow defer, receive data and shift buffer
- // window, allow defer, and read outside of the buffer window.
- EXPECT_CALL(*bridge_, SetDefersLoading(true));
- EXPECT_CALL(*this, NetworkCallback());
- WriteLoader(10, 40);
-
- DisallowLoaderDefer();
- WriteLoader(50, 20);
- WriteLoader(70, 40);
- AllowLoaderDefer();
-
- EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS));
- ReadLoader(20, 5, buffer);
- StopWhenLoad();
-}
-
-// TODO(hclam): add unit test for defer loading.
-
class MockBufferedResourceLoader : public BufferedResourceLoader {
public:
- MockBufferedResourceLoader() : BufferedResourceLoader(NULL, GURL(), 0, 0) {
+ MockBufferedResourceLoader() : BufferedResourceLoader(GURL(), 0, 0) {
}
- MOCK_METHOD2(Start, void(net::CompletionCallback* read_callback,
- NetworkEventCallback* network_callback));
+ MOCK_METHOD3(Start, void(net::CompletionCallback* read_callback,
+ NetworkEventCallback* network_callback,
+ WebFrame* frame));
MOCK_METHOD0(Stop, void());
MOCK_METHOD4(Read, void(int64 position, int read_size, uint8* buffer,
net::CompletionCallback* callback));
@@ -536,33 +92,10 @@ class MockBufferedResourceLoader : public BufferedResourceLoader {
DISALLOW_COPY_AND_ASSIGN(MockBufferedResourceLoader);
};
-// A mock BufferedDataSource to inject mock BufferedResourceLoader through
-// CreateResourceLoader() method.
-class MockBufferedDataSource : public BufferedDataSource {
- public:
- MockBufferedDataSource(
- MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory)
- : BufferedDataSource(message_loop, factory) {
- }
-
- virtual base::TimeDelta GetTimeoutMilliseconds() {
- // It is 100 ms because we don't want the test to run too long.
- return base::TimeDelta::FromMilliseconds(100);
- }
-
- MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(
- int64 first_position, int64 last_position));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource);
-};
-
class BufferedDataSourceTest : public testing::Test {
public:
BufferedDataSourceTest() {
message_loop_ = MessageLoop::current();
- bridge_factory_.reset(
- new StrictMock<MockMediaResourceLoaderBridgeFactory>());
// Prepare test data.
for (size_t i = 0; i < sizeof(data_); ++i) {
@@ -571,20 +104,14 @@ class BufferedDataSourceTest : public testing::Test {
}
virtual ~BufferedDataSourceTest() {
- if (data_source_) {
- // Release the bridge factory because we don't own it.
- // Expects bridge factory to be destroyed along with data source.
- EXPECT_CALL(*bridge_factory_, OnDestroy())
- .WillOnce(Invoke(this,
- &BufferedDataSourceTest::ReleaseBridgeFactory));
- }
+ ignore_result(frame_.release());
}
void ExpectCreateAndStartResourceLoader(int start_error) {
EXPECT_CALL(*data_source_, CreateResourceLoader(_, _))
.WillOnce(Return(loader_.get()));
- EXPECT_CALL(*loader_, Start(NotNull(), NotNull()))
+ EXPECT_CALL(*loader_, Start(NotNull(), NotNull(), NotNull()))
.WillOnce(
DoAll(Assign(&error_, start_error),
Invoke(this,
@@ -597,15 +124,10 @@ class BufferedDataSourceTest : public testing::Test {
// Saves the url first.
gurl_ = GURL(url);
- media::MediaFormat url_format;
- url_format.SetAsString(media::MediaFormat::kMimeType,
- media::mime_type::kURL);
- url_format.SetAsString(media::MediaFormat::kURL, url);
- data_source_ = new MockBufferedDataSource(MessageLoop::current(),
- bridge_factory_.get());
- CHECK(data_source_);
+ frame_.reset(new NiceMock<MockWebFrame>());
- // There is no need to provide a message loop to data source.
+ data_source_ = new MockBufferedDataSource(MessageLoop::current(),
+ frame_.get());
data_source_->set_host(&host_);
scoped_refptr<NiceMock<MockBufferedResourceLoader> > first_loader(
@@ -631,7 +153,7 @@ class BufferedDataSourceTest : public testing::Test {
// Replace loader_ with a new instance.
loader_ = new NiceMock<MockBufferedResourceLoader>();
- // Create and start Make sure Start() is called the new loader.
+ // Create and start. Make sure Start() is called on the new loader.
ExpectCreateAndStartResourceLoader(net::OK);
// Update initialization variable since we know the second loader will
@@ -705,13 +227,10 @@ class BufferedDataSourceTest : public testing::Test {
message_loop_->RunAllPending();
}
- void ReleaseBridgeFactory() {
- ignore_result(bridge_factory_.release());
- }
-
void InvokeStartCallback(
net::CompletionCallback* callback,
- BufferedResourceLoader::NetworkEventCallback* network_callback) {
+ BufferedResourceLoader::NetworkEventCallback* network_callback,
+ WebFrame* frame) {
callback->RunWithParams(Tuple1<int>(error_));
delete callback;
// TODO(hclam): Save this callback.
@@ -790,7 +309,7 @@ class BufferedDataSourceTest : public testing::Test {
.WillOnce(Return(new_loader));
// 3. Then the new loader will be started.
- EXPECT_CALL(*new_loader, Start(NotNull(), NotNull()))
+ EXPECT_CALL(*new_loader, Start(NotNull(), NotNull(), NotNull()))
.WillOnce(DoAll(Assign(&error_, net::OK),
Invoke(this,
&BufferedDataSourceTest::InvokeStartCallback)));
@@ -856,7 +375,7 @@ class BufferedDataSourceTest : public testing::Test {
// 3. Then the new loader will be started and respond to queries about
// whether this is a partial response using the value of the previous
// loader.
- EXPECT_CALL(*new_loader, Start(NotNull(), NotNull()))
+ EXPECT_CALL(*new_loader, Start(NotNull(), NotNull(), NotNull()))
.WillOnce(DoAll(Assign(&error_, net::OK),
Invoke(this,
&BufferedDataSourceTest::InvokeStartCallback)));
@@ -889,10 +408,9 @@ class BufferedDataSourceTest : public testing::Test {
MOCK_METHOD1(ReadCallback, void(size_t size));
- scoped_ptr<StrictMock<MockMediaResourceLoaderBridgeFactory> >
- bridge_factory_;
scoped_refptr<NiceMock<MockBufferedResourceLoader> > loader_;
scoped_refptr<MockBufferedDataSource> data_source_;
+ scoped_ptr<NiceMock<MockWebFrame> > frame_;
StrictMock<media::MockFilterHost> host_;
GURL gurl_;