| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 EXPECT_LT(b, c); | 52 EXPECT_LT(b, c); |
| 53 EXPECT_LT(a2, c); | 53 EXPECT_LT(a2, c); |
| 54 } | 54 } |
| 55 | 55 |
| 56 class OrderedSimpleTaskRunnerTest : public testing::Test { | 56 class OrderedSimpleTaskRunnerTest : public testing::Test { |
| 57 public: | 57 public: |
| 58 OrderedSimpleTaskRunnerTest() | 58 OrderedSimpleTaskRunnerTest() |
| 59 : now_src_(TestNowSource::Create(base::TimeTicks())) { | 59 : now_src_(TestNowSource::Create(base::TimeTicks())) { |
| 60 task_runner_ = new OrderedSimpleTaskRunner(now_src_, true); | 60 task_runner_ = new OrderedSimpleTaskRunner(now_src_, true); |
| 61 } | 61 } |
| 62 virtual ~OrderedSimpleTaskRunnerTest() {} | 62 ~OrderedSimpleTaskRunnerTest() override {} |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 std::string executed_tasks_; | 65 std::string executed_tasks_; |
| 66 scoped_refptr<TestNowSource> now_src_; | 66 scoped_refptr<TestNowSource> 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, |
| 71 base::Unretained(this), | 71 base::Unretained(this), |
| 72 task_num); | 72 task_num); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 437 |
| 438 task_runner_->SetRunTaskLimit(0); | 438 task_runner_->SetRunTaskLimit(0); |
| 439 RUN_AND_CHECK_RESULT(EXPECT_TRUE, RunUntilTime(run_to), ""); | 439 RUN_AND_CHECK_RESULT(EXPECT_TRUE, RunUntilTime(run_to), ""); |
| 440 | 440 |
| 441 task_runner_->SetRunTaskLimit(100); | 441 task_runner_->SetRunTaskLimit(100); |
| 442 RUN_AND_CHECK_RESULT(EXPECT_FALSE, RunUntilTime(run_to), "4(4ms) 5(5ms)"); | 442 RUN_AND_CHECK_RESULT(EXPECT_FALSE, RunUntilTime(run_to), "4(4ms) 5(5ms)"); |
| 443 EXPECT_EQ(run_to, now_src_->Now()); | 443 EXPECT_EQ(run_to, now_src_->Now()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 } // namespace cc | 446 } // namespace cc |
| OLD | NEW |