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

Unified Diff: chrome/browser/chromeos/drive/job_queue_unittest.cc

Issue 17101020: Support cancellation of non-yet-running jobs in drive::JobScheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix failures in tests. Created 7 years, 6 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 | « chrome/browser/chromeos/drive/job_queue.cc ('k') | chrome/browser/chromeos/drive/job_scheduler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/job_queue_unittest.cc
diff --git a/chrome/browser/chromeos/drive/job_queue_unittest.cc b/chrome/browser/chromeos/drive/job_queue_unittest.cc
index d02a31d28b6aff8014ce447b218c4220874e5388..08d2ced1322b4d0ecc8b3e255316f0a1e591e56d 100644
--- a/chrome/browser/chromeos/drive/job_queue_unittest.cc
+++ b/chrome/browser/chromeos/drive/job_queue_unittest.cc
@@ -66,4 +66,39 @@ TEST(JobQueueTest, BasicJobQueueOperations) {
EXPECT_EQ(105, id);
}
+TEST(JobQueueTest, JobQueueRemove) {
+ const int kNumMaxConcurrentJobs = 3;
+ const int kNumPriorityLevels = 2;
+ enum {HIGH_PRIORITY, LOW_PRIORITY};
+
+ // Create a queue. Number of jobs are initially zero.
+ JobQueue queue(kNumMaxConcurrentJobs, kNumPriorityLevels);
+ EXPECT_EQ(0U, queue.GetNumberOfJobs());
+
+ // Push 4 jobs.
+ queue.Push(101, LOW_PRIORITY);
+ queue.Push(102, HIGH_PRIORITY);
+ queue.Push(103, LOW_PRIORITY);
+ queue.Push(104, HIGH_PRIORITY);
+ EXPECT_EQ(4U, queue.GetNumberOfJobs());
+
+ // Remove 2.
+ queue.Remove(101);
+ queue.Remove(104);
+ EXPECT_EQ(2U, queue.GetNumberOfJobs());
+
+ // Pop the 2 jobs.
+ JobID id;
+ EXPECT_TRUE(queue.PopForRun(LOW_PRIORITY, &id));
+ EXPECT_EQ(102, id);
+ EXPECT_TRUE(queue.PopForRun(LOW_PRIORITY, &id));
+ EXPECT_EQ(103, id);
+ queue.MarkFinished(102);
+ queue.MarkFinished(103);
+
+ // 0 job left.
+ EXPECT_EQ(0U, queue.GetNumberOfJobs());
+ EXPECT_FALSE(queue.PopForRun(LOW_PRIORITY, &id));
+}
+
} // namespace drive
« no previous file with comments | « chrome/browser/chromeos/drive/job_queue.cc ('k') | chrome/browser/chromeos/drive/job_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698