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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/chromeos/drive/job_queue.h" 5 #include "chrome/browser/chromeos/drive/job_queue.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace drive { 9 namespace drive {
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // The remaining jobs is of low priority, so under HIGH_PRIORITY context, it 60 // The remaining jobs is of low priority, so under HIGH_PRIORITY context, it
61 // cannot be popped for running. 61 // cannot be popped for running.
62 EXPECT_FALSE(queue.PopForRun(HIGH_PRIORITY, &id)); 62 EXPECT_FALSE(queue.PopForRun(HIGH_PRIORITY, &id));
63 63
64 // Under the low priority context, it is fine. 64 // Under the low priority context, it is fine.
65 EXPECT_TRUE(queue.PopForRun(LOW_PRIORITY, &id)); 65 EXPECT_TRUE(queue.PopForRun(LOW_PRIORITY, &id));
66 EXPECT_EQ(105, id); 66 EXPECT_EQ(105, id);
67 } 67 }
68 68
69 TEST(JobQueueTest, JobQueueRemove) {
70 const int kNumMaxConcurrentJobs = 3;
71 const int kNumPriorityLevels = 2;
72 enum {HIGH_PRIORITY, LOW_PRIORITY};
73
74 // Create a queue. Number of jobs are initially zero.
75 JobQueue queue(kNumMaxConcurrentJobs, kNumPriorityLevels);
76 EXPECT_EQ(0U, queue.GetNumberOfJobs());
77
78 // Push 4 jobs.
79 queue.Push(101, LOW_PRIORITY);
80 queue.Push(102, HIGH_PRIORITY);
81 queue.Push(103, LOW_PRIORITY);
82 queue.Push(104, HIGH_PRIORITY);
83 EXPECT_EQ(4U, queue.GetNumberOfJobs());
84
85 // Remove 2.
86 queue.Remove(101);
87 queue.Remove(104);
88 EXPECT_EQ(2U, queue.GetNumberOfJobs());
89
90 // Pop the 2 jobs.
91 JobID id;
92 EXPECT_TRUE(queue.PopForRun(LOW_PRIORITY, &id));
93 EXPECT_EQ(102, id);
94 EXPECT_TRUE(queue.PopForRun(LOW_PRIORITY, &id));
95 EXPECT_EQ(103, id);
96 queue.MarkFinished(102);
97 queue.MarkFinished(103);
98
99 // 0 job left.
100 EXPECT_EQ(0U, queue.GetNumberOfJobs());
101 EXPECT_FALSE(queue.PopForRun(LOW_PRIORITY, &id));
102 }
103
69 } // namespace drive 104 } // namespace drive
OLDNEW
« 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