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

Side by Side Diff: chromecast/media/cma/base/balanced_media_task_runner_unittest.cc

Issue 2311363002: Remove calls to deprecated MessageLoop methods in chromecast. (Closed)
Patch Set: self-review Created 4 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <list> 7 #include <list>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h" 20 #include "chromecast/media/cma/base/balanced_media_task_runner_factory.h"
20 #include "chromecast/media/cma/base/media_task_runner.h" 21 #include "chromecast/media/cma/base/media_task_runner.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 namespace chromecast { 24 namespace chromecast {
24 namespace media { 25 namespace media {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 int expected_timestamps[] = {0, 10, 20, 30, 40, 50, 60, 70}; 225 int expected_timestamps[] = {0, 10, 20, 30, 40, 50, 60, 70};
225 std::vector<int> expected_timestamps_ms(std::vector<int>( 226 std::vector<int> expected_timestamps_ms(std::vector<int>(
226 expected_timestamps, 227 expected_timestamps,
227 expected_timestamps + arraysize(expected_timestamps))); 228 expected_timestamps + arraysize(expected_timestamps)));
228 229
229 SetupTest(base::TimeDelta::FromMilliseconds(30), 230 SetupTest(base::TimeDelta::FromMilliseconds(30),
230 timestamps_ms, 231 timestamps_ms,
231 scheduling_pattern, 232 scheduling_pattern,
232 expected_timestamps_ms); 233 expected_timestamps_ms);
233 ProcessAllTasks(); 234 ProcessAllTasks();
234 message_loop->Run(); 235 base::RunLoop().Run();
235 EXPECT_TRUE(expected_task_timestamps_.empty()); 236 EXPECT_TRUE(expected_task_timestamps_.empty());
236 } 237 }
237 238
238 TEST_F(BalancedMediaTaskRunnerTest, TwoTaskRunnerUnbalanced) { 239 TEST_F(BalancedMediaTaskRunnerTest, TwoTaskRunnerUnbalanced) {
239 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 240 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
240 241
241 // Timestamps of tasks for the 2 task runners. 242 // Timestamps of tasks for the 2 task runners.
242 int timestamps0_ms[] = {0, 10, 20, 30, 40, 30, 50, 60, 20, 30, 70}; 243 int timestamps0_ms[] = {0, 10, 20, 30, 40, 30, 50, 60, 20, 30, 70};
243 int timestamps1_ms[] = {5, 15, 25, 35, 45, 35, 55, 65, 25, 35, 75}; 244 int timestamps1_ms[] = {5, 15, 25, 35, 45, 35, 55, 65, 25, 35, 75};
244 std::vector<std::vector<int> > timestamps_ms(2); 245 std::vector<std::vector<int> > timestamps_ms(2);
(...skipping 12 matching lines...) Expand all
257 5, 0, 10, 20, 30, 15, 40, 25, 50, 35, 60, 45, 70, 55, 65, 75 }; 258 5, 0, 10, 20, 30, 15, 40, 25, 50, 35, 60, 45, 70, 55, 65, 75 };
258 std::vector<int> expected_timestamps_ms(std::vector<int>( 259 std::vector<int> expected_timestamps_ms(std::vector<int>(
259 expected_timestamps, 260 expected_timestamps,
260 expected_timestamps + arraysize(expected_timestamps))); 261 expected_timestamps + arraysize(expected_timestamps)));
261 262
262 SetupTest(base::TimeDelta::FromMilliseconds(30), 263 SetupTest(base::TimeDelta::FromMilliseconds(30),
263 timestamps_ms, 264 timestamps_ms,
264 scheduling_pattern, 265 scheduling_pattern,
265 expected_timestamps_ms); 266 expected_timestamps_ms);
266 ProcessAllTasks(); 267 ProcessAllTasks();
267 message_loop->Run(); 268 base::RunLoop().Run();
268 EXPECT_TRUE(expected_task_timestamps_.empty()); 269 EXPECT_TRUE(expected_task_timestamps_.empty());
269 } 270 }
270 271
271 TEST_F(BalancedMediaTaskRunnerTest, TwoStreamsOfDifferentLength) { 272 TEST_F(BalancedMediaTaskRunnerTest, TwoStreamsOfDifferentLength) {
272 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 273 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
273 274
274 std::vector<std::vector<int>> timestamps = { 275 std::vector<std::vector<int>> timestamps = {
275 // One longer stream and one shorter stream. 276 // One longer stream and one shorter stream.
276 // The longer stream runs first, then the shorter stream begins. 277 // The longer stream runs first, then the shorter stream begins.
277 // After shorter stream ends, it shouldn't block the longer one. 278 // After shorter stream ends, it shouldn't block the longer one.
278 {0, 20, 40, 60, 80, 100, 120, 140, 160}, 279 {0, 20, 40, 60, 80, 100, 120, 140, 160},
279 {51, 61, 71, 81}, 280 {51, 61, 71, 81},
280 }; 281 };
281 282
282 std::vector<int> expected_timestamps = { 283 std::vector<int> expected_timestamps = {
283 0, 20, 40, 60, 51, 80, 61, 71, 81, 100, 120, 140, 160}; 284 0, 20, 40, 60, 51, 80, 61, 71, 81, 100, 120, 140, 160};
284 285
285 std::vector<size_t> scheduling_pattern = { 286 std::vector<size_t> scheduling_pattern = {
286 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0}; 287 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0};
287 288
288 SetupTest(base::TimeDelta::FromMilliseconds(30), timestamps, 289 SetupTest(base::TimeDelta::FromMilliseconds(30), timestamps,
289 scheduling_pattern, expected_timestamps); 290 scheduling_pattern, expected_timestamps);
290 ProcessAllTasks(); 291 ProcessAllTasks();
291 message_loop->Run(); 292 base::RunLoop().Run();
292 EXPECT_TRUE(expected_task_timestamps_.empty()); 293 EXPECT_TRUE(expected_task_timestamps_.empty());
293 } 294 }
294 295
295 } // namespace media 296 } // namespace media
296 } // namespace chromecast 297 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698