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

Side by Side Diff: content/browser/loader/upload_progress_tracker_unittest.cc

Issue 2574143003: Implement upload progress handling in Mojo loading (Closed)
Patch Set: android build fix Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/browser/loader/upload_progress_tracker.h" 5 #include "content/browser/loader/upload_progress_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 upload_progress_tracker_.OnAckReceived(); 183 upload_progress_tracker_.OnAckReceived();
184 upload_progress_tracker_.set_upload_progress(net::UploadProgress(501, 1000)); 184 upload_progress_tracker_.set_upload_progress(net::UploadProgress(501, 1000));
185 185
186 // The second timer task doesn't call ReportUploadProgress since the progress 186 // The second timer task doesn't call ReportUploadProgress since the progress
187 // is too small to report it. 187 // is too small to report it.
188 EXPECT_EQ(1, report_count_); 188 EXPECT_EQ(1, report_count_);
189 task_runner_->RunPendingTasks(); 189 task_runner_->RunPendingTasks();
190 EXPECT_EQ(1, report_count_); 190 EXPECT_EQ(1, report_count_);
191 191
192 upload_progress_tracker_.set_current_time(base::TimeTicks::Now() + 192 upload_progress_tracker_.set_current_time(base::TimeTicks::Now() +
193 base::TimeDelta::FromSeconds(1)); 193 base::TimeDelta::FromSeconds(5));
tzik 2017/01/19 11:53:09 Note: 1s is not enough to trigger the upload progr
194 194
195 // The third timer task calls ReportUploadProgress since it's been long time 195 // The third timer task calls ReportUploadProgress since it's been long time
196 // from the last report. 196 // from the last report.
197 EXPECT_EQ(1, report_count_); 197 EXPECT_EQ(1, report_count_);
198 task_runner_->RunPendingTasks(); 198 task_runner_->RunPendingTasks();
199 EXPECT_EQ(2, report_count_); 199 EXPECT_EQ(2, report_count_);
200 EXPECT_EQ(501, reported_position_); 200 EXPECT_EQ(501, reported_position_);
201 EXPECT_EQ(1000, reported_total_size_); 201 EXPECT_EQ(1000, reported_total_size_);
202 } 202 }
203 203
(...skipping 10 matching lines...) Expand all
214 upload_progress_tracker_.OnAckReceived(); 214 upload_progress_tracker_.OnAckReceived();
215 upload_progress_tracker_.set_upload_progress(net::UploadProgress(250, 1000)); 215 upload_progress_tracker_.set_upload_progress(net::UploadProgress(250, 1000));
216 216
217 // The second timer task doesn't call ReportUploadProgress since the progress 217 // The second timer task doesn't call ReportUploadProgress since the progress
218 // was rewound. 218 // was rewound.
219 EXPECT_EQ(1, report_count_); 219 EXPECT_EQ(1, report_count_);
220 task_runner_->RunPendingTasks(); 220 task_runner_->RunPendingTasks();
221 EXPECT_EQ(1, report_count_); 221 EXPECT_EQ(1, report_count_);
222 222
223 upload_progress_tracker_.set_current_time(base::TimeTicks::Now() + 223 upload_progress_tracker_.set_current_time(base::TimeTicks::Now() +
224 base::TimeDelta::FromSeconds(1)); 224 base::TimeDelta::FromSeconds(5));
225 225
226 // Even after a good amount of time passed, the rewound progress should not be 226 // Even after a good amount of time passed, the rewound progress should not be
227 // reported. 227 // reported.
228 EXPECT_EQ(1, report_count_); 228 EXPECT_EQ(1, report_count_);
229 task_runner_->RunPendingTasks(); 229 task_runner_->RunPendingTasks();
230 EXPECT_EQ(1, report_count_); 230 EXPECT_EQ(1, report_count_);
231 } 231 }
232 232
233 TEST_F(UploadProgressTrackerTest, Completed) { 233 TEST_F(UploadProgressTrackerTest, Completed) {
234 upload_progress_tracker_.set_upload_progress(net::UploadProgress(500, 1000)); 234 upload_progress_tracker_.set_upload_progress(net::UploadProgress(500, 1000));
(...skipping 12 matching lines...) Expand all
247 EXPECT_EQ(2, report_count_); 247 EXPECT_EQ(2, report_count_);
248 EXPECT_EQ(1000, reported_position_); 248 EXPECT_EQ(1000, reported_position_);
249 EXPECT_EQ(1000, reported_total_size_); 249 EXPECT_EQ(1000, reported_total_size_);
250 250
251 task_runner_->RunPendingTasks(); 251 task_runner_->RunPendingTasks();
252 EXPECT_EQ(2, report_count_); 252 EXPECT_EQ(2, report_count_);
253 EXPECT_FALSE(task_runner_->HasPendingTask()); 253 EXPECT_FALSE(task_runner_->HasPendingTask());
254 } 254 }
255 255
256 } // namespace context 256 } // namespace context
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698