| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/deferred_sequenced_task_runner.h" | 5 #include "base/deferred_sequenced_task_runner.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 void DoNothing(ExecuteTaskOnDestructor* object) { | 57 void DoNothing(ExecuteTaskOnDestructor* object) { |
| 58 } | 58 } |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 DeferredSequencedTaskRunnerTest() : | 61 DeferredSequencedTaskRunnerTest() : |
| 62 loop_(), | 62 loop_(), |
| 63 runner_( | 63 runner_( |
| 64 new base::DeferredSequencedTaskRunner(loop_.message_loop_proxy())) { | 64 new base::DeferredSequencedTaskRunner(loop_.message_loop_proxy())) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 MessageLoop loop_; | 67 base::MessageLoop loop_; |
| 68 scoped_refptr<base::DeferredSequencedTaskRunner> runner_; | 68 scoped_refptr<base::DeferredSequencedTaskRunner> runner_; |
| 69 mutable base::Lock lock_; | 69 mutable base::Lock lock_; |
| 70 std::vector<int> executed_task_ids_; | 70 std::vector<int> executed_task_ids_; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 TEST_F(DeferredSequencedTaskRunnerTest, Stopped) { | 73 TEST_F(DeferredSequencedTaskRunnerTest, Stopped) { |
| 74 PostExecuteTask(1); | 74 PostExecuteTask(1); |
| 75 loop_.RunUntilIdle(); | 75 loop_.RunUntilIdle(); |
| 76 EXPECT_THAT(executed_task_ids_, testing::ElementsAre()); | 76 EXPECT_THAT(executed_task_ids_, testing::ElementsAre()); |
| 77 } | 77 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 StartRunner(); | 175 StartRunner(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 // All |short_lived_object| with id |2 * i| are destroyed before the task | 178 // All |short_lived_object| with id |2 * i| are destroyed before the task |
| 179 // |2 * i + 1| is executed. | 179 // |2 * i + 1| is executed. |
| 180 EXPECT_THAT(executed_task_ids_, | 180 EXPECT_THAT(executed_task_ids_, |
| 181 testing::ElementsAre(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); | 181 testing::ElementsAre(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace | 184 } // namespace |
| OLD | NEW |