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

Unified Diff: net/url_request/url_request_file_job_unittest.cc

Issue 2770503002: TEST ONLY: URLRequestFileJob::OnReadComplete doens't fire for 0 byte file. (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_file_job_unittest.cc
diff --git a/net/url_request/url_request_file_job_unittest.cc b/net/url_request/url_request_file_job_unittest.cc
index 2e5aafffbc26a04e1287ab51dd5dfdb17ae85d46..a599da4bcaa2ec682d6e3d189b224cb7c9b874a8 100644
--- a/net/url_request/url_request_file_job_unittest.cc
+++ b/net/url_request/url_request_file_job_unittest.cc
@@ -54,12 +54,14 @@ class TestURLRequestFileJob : public URLRequestFileJob {
protected:
void OnOpenComplete(int result) override {
+ printf("T: OnOpenComplete: %d\n", result);
// Should only be called once.
ASSERT_EQ(ERR_IO_PENDING, *open_result_);
*open_result_ = result;
}
void OnSeekComplete(int64_t result) override {
+ printf("T: OnSeekComplete: %ld\n", result);
// Should only call this if open succeeded.
EXPECT_EQ(OK, *open_result_);
// Should only be called once.
@@ -68,6 +70,7 @@ class TestURLRequestFileJob : public URLRequestFileJob {
}
void OnReadComplete(IOBuffer* buf, int result) override {
+ printf("T: OnReadComplete: %d\n", result);
// Should only call this if seek succeeded.
EXPECT_GE(*seek_position_, 0);
observed_content_->append(std::string(buf->data(), result));
@@ -150,7 +153,7 @@ class TestJobFactory : public URLRequestJobFactory {
// Returns true on success.
bool CreateFileWithContent(const std::string& content,
const base::FilePath& path) {
- return base::WriteFile(path, content.c_str(), content.length());
+ return base::WriteFile(path, content.c_str(), content.length()) != -1;
}
// A simple holder for start/end used in http range requests.
@@ -308,6 +311,10 @@ TEST_F(URLRequestFileJobEventsTest, TinyFile) {
RunSuccessfulRequestWithString(std::string("hello world"), NULL);
}
+TEST_F(URLRequestFileJobEventsTest, ZeroFile) {
+ RunSuccessfulRequestWithString(std::string(""), NULL);
+}
+
TEST_F(URLRequestFileJobEventsTest, SmallFile) {
RunSuccessfulRequestWithString(MakeContentOfSize(17 * 1024), NULL);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698