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

Unified Diff: content/browser/loader/resource_loader_unittest.cc

Issue 1301103002: moved upload progress logic from ResourceLoader to AsyncResourceHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: single quotes, nits, and return success on success Created 5 years, 4 months 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 | « content/browser/loader/resource_loader.cc ('k') | content/browser/loader/stream_resource_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/resource_loader_unittest.cc
diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc
index fad86d5b8a3871a6e648c5d9239eed40bdecf815..5267113c6583c46b9df0a8ace55d5d8ff01d0c43 100644
--- a/content/browser/loader/resource_loader_unittest.cc
+++ b/content/browser/loader/resource_loader_unittest.cc
@@ -256,8 +256,7 @@ class ResourceHandlerStub : public ResourceHandler {
received_eof_(false),
received_response_completed_(false),
received_request_redirected_(false),
- total_bytes_downloaded_(0),
- upload_position_(0) {}
+ total_bytes_downloaded_(0) {}
// If true, defers the resource load in OnWillStart.
void set_defer_request_on_will_start(bool defer_request_on_will_start) {
@@ -294,24 +293,6 @@ class ResourceHandlerStub : public ResourceHandler {
controller()->Resume();
}
- // Waits until OnUploadProgress is called and returns the upload position.
- uint64 WaitForUploadProgress() {
- wait_for_progress_loop_.reset(new base::RunLoop());
- wait_for_progress_loop_->Run();
- wait_for_progress_loop_.reset();
- return upload_position_;
- }
-
- // ResourceHandler implementation:
- bool OnUploadProgress(uint64 position, uint64 size) override {
- EXPECT_LE(position, size);
- EXPECT_GT(position, upload_position_);
- upload_position_ = position;
- if (wait_for_progress_loop_)
- wait_for_progress_loop_->Quit();
- return true;
- }
-
bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
ResourceResponse* response,
bool* defer) override {
@@ -404,7 +385,6 @@ class ResourceHandlerStub : public ResourceHandler {
net::URLRequestStatus status_;
int total_bytes_downloaded_;
scoped_ptr<base::RunLoop> wait_for_progress_loop_;
- uint64 upload_position_;
};
// Test browser client that captures calls to SelectClientCertificates and
@@ -517,17 +497,6 @@ class ResourceLoaderTest : public testing::Test,
return net::URLRequestTestJob::test_data_1();
}
- // Waits until upload progress reaches |target_position|
- void WaitForUploadProgress(uint64 target_position) {
- while (true) {
- uint64 position = raw_ptr_resource_handler_->WaitForUploadProgress();
- EXPECT_LE(position, target_position);
- loader_->OnUploadProgressACK();
- if (position == target_position)
- break;
- }
- }
-
virtual scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
CreateProtocolHandler() {
return net::URLRequestTestJob::CreateProtocolHandler();
@@ -832,39 +801,6 @@ TEST_F(ResourceLoaderTest, DeferEOF) {
raw_ptr_resource_handler_->status().status());
}
-// Tests that progress is reported correctly while uploading.
-// TODO(andresantoso): Add test for the redirect case.
-TEST_F(ResourceLoaderTest, UploadProgress) {
- // Set up a test server.
- net::test_server::EmbeddedTestServer server;
- ASSERT_TRUE(server.InitializeAndWaitUntilReady());
- base::FilePath path;
- PathService::Get(content::DIR_TEST_DATA, &path);
- server.ServeFilesFromDirectory(path);
-
- scoped_ptr<net::URLRequest> request(
- resource_context_.GetRequestContext()->CreateRequest(
- server.GetURL("/title1.html"),
- net::DEFAULT_PRIORITY,
- nullptr /* delegate */));
-
- // Start an upload.
- auto stream = new NonChunkedUploadDataStream(10);
- request->set_upload(make_scoped_ptr(stream));
-
- SetUpResourceLoader(request.Pass());
- loader_->StartRequest();
-
- stream->AppendData("xx");
- WaitForUploadProgress(2);
-
- stream->AppendData("yyy");
- WaitForUploadProgress(5);
-
- stream->AppendData("zzzzz");
- WaitForUploadProgress(10);
-}
-
class ResourceLoaderRedirectToFileTest : public ResourceLoaderTest {
public:
ResourceLoaderRedirectToFileTest()
« no previous file with comments | « content/browser/loader/resource_loader.cc ('k') | content/browser/loader/stream_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698