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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/queue_unittest.cc

Issue 925873002: Fix a queue for FSP API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « chrome/browser/chromeos/file_system_provider/queue.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/file_system_provider/queue.h" 5 #include "chrome/browser/chromeos/file_system_provider/queue.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 queue.Remove(second_token); 106 queue.Remove(second_token);
107 base::RunLoop().RunUntilIdle(); 107 base::RunLoop().RunUntilIdle();
108 EXPECT_EQ(1, first_counter); 108 EXPECT_EQ(1, first_counter);
109 EXPECT_EQ(0, first_abort_counter); 109 EXPECT_EQ(0, first_abort_counter);
110 EXPECT_EQ(1, second_counter); 110 EXPECT_EQ(1, second_counter);
111 EXPECT_EQ(1, second_abort_counter); 111 EXPECT_EQ(1, second_abort_counter);
112 EXPECT_EQ(1, third_counter); 112 EXPECT_EQ(1, third_counter);
113 EXPECT_EQ(0, third_abort_counter); 113 EXPECT_EQ(0, third_abort_counter);
114 } 114 }
115 115
116 TEST_F(FileSystemProviderQueueTest, Enqueue_WhilePreviousNotRemoved) {
117 Queue queue(1);
118 const size_t first_token = queue.NewToken();
119 int first_counter = 0;
120 int first_abort_counter = 0;
121 queue.Enqueue(first_token,
122 base::Bind(&OnRun, &first_counter, &first_abort_counter));
123
124 base::RunLoop().RunUntilIdle();
125 queue.Complete(first_token);
126
127 // Enqueuing a new task must not start it, once the queue is filled with a
128 // completed task.
129 const size_t second_token = queue.NewToken();
130 int second_counter = 0;
131 int second_abort_counter = 0;
132 queue.Enqueue(second_token,
133 base::Bind(&OnRun, &second_counter, &second_abort_counter));
134
135 base::RunLoop().RunUntilIdle();
136 EXPECT_EQ(0, second_counter);
137 EXPECT_EQ(0, second_abort_counter);
138 }
139
116 TEST_F(FileSystemProviderQueueTest, Enqueue_MultipleAtOnce) { 140 TEST_F(FileSystemProviderQueueTest, Enqueue_MultipleAtOnce) {
117 Queue queue(2); 141 Queue queue(2);
118 const size_t first_token = queue.NewToken(); 142 const size_t first_token = queue.NewToken();
119 int first_counter = 0; 143 int first_counter = 0;
120 int first_abort_counter = 0; 144 int first_abort_counter = 0;
121 queue.Enqueue(first_token, 145 queue.Enqueue(first_token,
122 base::Bind(&OnRun, &first_counter, &first_abort_counter)); 146 base::Bind(&OnRun, &first_counter, &first_abort_counter));
123 147
124 const size_t second_token = queue.NewToken(); 148 const size_t second_token = queue.NewToken();
125 int second_counter = 0; 149 int second_counter = 0;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 373
350 base::RunLoop().RunUntilIdle(); 374 base::RunLoop().RunUntilIdle();
351 EXPECT_EQ(1, first_counter); 375 EXPECT_EQ(1, first_counter);
352 EXPECT_EQ(1, first_abort_counter); 376 EXPECT_EQ(1, first_abort_counter);
353 EXPECT_EQ(0, second_counter); 377 EXPECT_EQ(0, second_counter);
354 EXPECT_EQ(0, second_abort_counter); 378 EXPECT_EQ(0, second_abort_counter);
355 } 379 }
356 380
357 } // namespace file_system_provider 381 } // namespace file_system_provider
358 } // namespace chromeos 382 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_system_provider/queue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698