OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/cancelable_callback.h" | 7 #include "base/cancelable_callback.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 TestOrderablePendingTask a2 = a; | 50 TestOrderablePendingTask a2 = a; |
51 EXPECT_EQ(a, a2); | 51 EXPECT_EQ(a, a2); |
52 EXPECT_LT(a2, b); | 52 EXPECT_LT(a2, b); |
53 EXPECT_LT(b, c); | 53 EXPECT_LT(b, c); |
54 EXPECT_LT(a2, c); | 54 EXPECT_LT(a2, c); |
55 } | 55 } |
56 | 56 |
57 class OrderedSimpleTaskRunnerTest : public testing::Test { | 57 class OrderedSimpleTaskRunnerTest : public testing::Test { |
58 public: | 58 public: |
59 OrderedSimpleTaskRunnerTest() | 59 OrderedSimpleTaskRunnerTest() |
60 : now_src_(new base::SimpleTestTickClock()), | 60 : now_src_(new base::SimpleTestTickClock(base::TimeTicks())), |
61 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)) {} | 61 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)) {} |
62 ~OrderedSimpleTaskRunnerTest() override {} | 62 ~OrderedSimpleTaskRunnerTest() override {} |
63 | 63 |
64 protected: | 64 protected: |
65 std::string executed_tasks_; | 65 std::string executed_tasks_; |
66 scoped_ptr<base::SimpleTestTickClock> now_src_; | 66 scoped_ptr<base::SimpleTestTickClock> now_src_; |
67 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 67 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
68 | 68 |
69 void PostTask(int task_num, base::TimeDelta delay) { | 69 void PostTask(int task_num, base::TimeDelta delay) { |
70 base::Closure test_task = base::Bind(&OrderedSimpleTaskRunnerTest::Task, | 70 base::Closure test_task = base::Bind(&OrderedSimpleTaskRunnerTest::Task, |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 435 |
436 task_runner_->SetRunTaskLimit(0); | 436 task_runner_->SetRunTaskLimit(0); |
437 RUN_AND_CHECK_RESULT(EXPECT_TRUE, RunUntilTime(run_to), ""); | 437 RUN_AND_CHECK_RESULT(EXPECT_TRUE, RunUntilTime(run_to), ""); |
438 | 438 |
439 task_runner_->SetRunTaskLimit(100); | 439 task_runner_->SetRunTaskLimit(100); |
440 RUN_AND_CHECK_RESULT(EXPECT_FALSE, RunUntilTime(run_to), "4(4ms) 5(5ms)"); | 440 RUN_AND_CHECK_RESULT(EXPECT_FALSE, RunUntilTime(run_to), "4(4ms) 5(5ms)"); |
441 EXPECT_EQ(run_to, now_src_->NowTicks()); | 441 EXPECT_EQ(run_to, now_src_->NowTicks()); |
442 } | 442 } |
443 | 443 |
444 } // namespace cc | 444 } // namespace cc |
OLD | NEW |