Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: webkit/glue/media/simple_data_source_unittest.cc

Issue 5619002: Revert 68094 - Refactoring BufferedDataSource to work with WebURLLoader inste... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/media/simple_data_source.cc ('k') | webkit/glue/mock_webframe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/media/simple_data_source_unittest.cc
===================================================================
--- webkit/glue/media/simple_data_source_unittest.cc (revision 68125)
+++ webkit/glue/media/simple_data_source_unittest.cc (working copy)
@@ -6,15 +6,9 @@
#include "media/base/filters.h"
#include "media/base/mock_filter_host.h"
#include "media/base/mock_filters.h"
-#include "net/base/net_errors.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebURLLoader.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
+#include "webkit/glue/media/mock_media_resource_loader_bridge_factory.h"
#include "webkit/glue/media/simple_data_source.h"
-#include "webkit/glue/mock_webframe.h"
-#include "webkit/glue/mock_weburlloader_impl.h"
+#include "webkit/glue/mock_resource_loader_bridge.h"
using ::testing::_;
using ::testing::DoAll;
@@ -27,11 +21,6 @@
using ::testing::StrictMock;
using ::testing::WithArgs;
-using WebKit::WebURLError;
-using WebKit::WebURLLoader;
-using WebKit::WebURLRequest;
-using WebKit::WebURLResponse;
-
namespace {
const int kDataSize = 1024;
@@ -50,56 +39,68 @@
class SimpleDataSourceTest : public testing::Test {
public:
SimpleDataSourceTest() {
+ bridge_factory_.reset(
+ new NiceMock<MockMediaResourceLoaderBridgeFactory>());
+ bridge_.reset(new NiceMock<MockResourceLoaderBridge>());
+
for (int i = 0; i < kDataSize; ++i) {
data_[i] = i;
}
}
virtual ~SimpleDataSourceTest() {
- ignore_result(frame_.release());
+ if (bridge_.get())
+ EXPECT_CALL(*bridge_, OnDestroy());
+ if (bridge_factory_.get())
+ EXPECT_CALL(*bridge_factory_, OnDestroy());
}
void InitializeDataSource(const char* url) {
- gurl_ = GURL(url);
-
- frame_.reset(new NiceMock<MockWebFrame>());
- url_loader_ = new NiceMock<MockWebURLLoader>();
-
data_source_ = new SimpleDataSource(MessageLoop::current(),
- frame_.get());
+ bridge_factory_.get());
+ CHECK(data_source_);
// There is no need to provide a message loop to data source.
data_source_->set_host(&host_);
- data_source_->SetURLLoaderForTest(url_loader_);
+ // First a bridge is created.
InSequence s;
+ EXPECT_CALL(*bridge_factory_, CreateBridge(GURL(url), _, -1, -1))
+ .WillOnce(Return(bridge_.get()));
+ EXPECT_CALL(*bridge_, Start(data_source_.get()))
+ .WillOnce(Return(true));
data_source_->Initialize(url, callback_.NewCallback());
+
MessageLoop::current()->RunAllPending();
}
void RequestSucceeded(bool is_loaded) {
- WebURLResponse response(gurl_);
- response.setExpectedContentLength(kDataSize);
+ ResourceResponseInfo info;
+ info.content_length = kDataSize;
- data_source_->didReceiveResponse(NULL, response);
+ data_source_->OnReceivedResponse(info, false);
int64 size;
EXPECT_TRUE(data_source_->GetSize(&size));
EXPECT_EQ(kDataSize, size);
- for (int i = 0; i < kDataSize; ++i) {
- data_source_->didReceiveData(NULL, data_ + i, 1);
- }
+ for (int i = 0; i < kDataSize; ++i)
+ data_source_->OnReceivedData(data_ + i, 1);
EXPECT_CALL(host_, SetLoaded(is_loaded));
InSequence s;
+ EXPECT_CALL(*bridge_, OnDestroy())
+ .WillOnce(Invoke(this, &SimpleDataSourceTest::ReleaseBridge));
EXPECT_CALL(host_, SetTotalBytes(kDataSize));
EXPECT_CALL(host_, SetBufferedBytes(kDataSize));
EXPECT_CALL(callback_, OnFilterCallback());
EXPECT_CALL(callback_, OnCallbackDestroyed());
- data_source_->didFinishLoading(NULL, 0);
+ URLRequestStatus status;
+ status.set_status(URLRequestStatus::SUCCESS);
+ status.set_os_error(0);
+ data_source_->OnCompletedRequest(status, "", base::Time());
// Let the tasks to be executed.
MessageLoop::current()->RunAllPending();
@@ -107,23 +108,28 @@
void RequestFailed() {
InSequence s;
+ EXPECT_CALL(*bridge_, OnDestroy())
+ .WillOnce(Invoke(this, &SimpleDataSourceTest::ReleaseBridge));
EXPECT_CALL(host_, SetError(media::PIPELINE_ERROR_NETWORK));
EXPECT_CALL(callback_, OnFilterCallback());
EXPECT_CALL(callback_, OnCallbackDestroyed());
- WebURLError error;
- error.reason = net::ERR_FAILED;
- data_source_->didFail(NULL, error);
+ URLRequestStatus status;
+ status.set_status(URLRequestStatus::FAILED);
+ status.set_os_error(100);
+ data_source_->OnCompletedRequest(status, "", base::Time());
// Let the tasks to be executed.
MessageLoop::current()->RunAllPending();
}
void DestroyDataSource() {
+ EXPECT_CALL(*bridge_factory_, OnDestroy())
+ .WillOnce(Invoke(this, &SimpleDataSourceTest::ReleaseBridgeFactory));
+
StrictMock<media::MockFilterCallback> callback;
EXPECT_CALL(callback, OnFilterCallback());
EXPECT_CALL(callback, OnCallbackDestroyed());
-
data_source_->Stop(callback.NewCallback());
MessageLoop::current()->RunAllPending();
@@ -142,17 +148,23 @@
}
}
+ void ReleaseBridge() {
+ ignore_result(bridge_.release());
+ }
+
+ void ReleaseBridgeFactory() {
+ ignore_result(bridge_factory_.release());
+ }
+
MOCK_METHOD1(ReadCallback, void(size_t size));
protected:
- GURL gurl_;
scoped_ptr<MessageLoop> message_loop_;
- NiceMock<MockWebURLLoader>* url_loader_;
+ scoped_ptr<NiceMock<MockMediaResourceLoaderBridgeFactory> > bridge_factory_;
+ scoped_ptr<NiceMock<MockResourceLoaderBridge> > bridge_;
scoped_refptr<SimpleDataSource> data_source_;
StrictMock<media::MockFilterHost> host_;
StrictMock<media::MockFilterCallback> callback_;
- scoped_ptr<NiceMock<MockWebFrame> > frame_;
-
char data_[kDataSize];
DISALLOW_COPY_AND_ASSIGN(SimpleDataSourceTest);
@@ -177,16 +189,13 @@
}
TEST_F(SimpleDataSourceTest, InitializeData) {
- frame_.reset(new NiceMock<MockWebFrame>());
- url_loader_ = new NiceMock<MockWebURLLoader>();
-
data_source_ = new SimpleDataSource(MessageLoop::current(),
- frame_.get());
+ bridge_factory_.get());
EXPECT_TRUE(data_source_->IsUrlSupported(kDataUrl));
+ CHECK(data_source_);
// There is no need to provide a message loop to data source.
data_source_->set_host(&host_);
- data_source_->SetURLLoaderForTest(url_loader_);
EXPECT_CALL(host_, SetLoaded(true));
EXPECT_CALL(host_, SetTotalBytes(sizeof(kDataUrlDecoded)));
@@ -209,7 +218,9 @@
TEST_F(SimpleDataSourceTest, StopWhenDownloading) {
InitializeDataSource(kHttpUrl);
- EXPECT_CALL(*url_loader_, cancel());
+ EXPECT_CALL(*bridge_, Cancel());
+ EXPECT_CALL(*bridge_, OnDestroy())
+ .WillOnce(Invoke(this, &SimpleDataSourceTest::ReleaseBridge));
EXPECT_CALL(callback_, OnCallbackDestroyed());
DestroyDataSource();
}
« no previous file with comments | « webkit/glue/media/simple_data_source.cc ('k') | webkit/glue/mock_webframe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698