OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |