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 "ash/system/chromeos/session/logout_confirmation_controller.h" | 5 #include "ash/system/chromeos/session/logout_confirmation_controller.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace { | 22 namespace { |
23 | 23 |
24 // A SingleThreadTaskRunner that mocks the current time and allows it to be | 24 // A SingleThreadTaskRunner that mocks the current time and allows it to be |
25 // fast-forwarded. TODO(bartfab): Copies of this class exist in several tests. | 25 // fast-forwarded. TODO(bartfab): Copies of this class exist in several tests. |
26 // Consolidate them (crbug.com/329911). | 26 // Consolidate them (crbug.com/329911). |
27 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { | 27 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { |
28 public: | 28 public: |
29 MockTimeSingleThreadTaskRunner(); | 29 MockTimeSingleThreadTaskRunner(); |
30 | 30 |
31 // base::SingleThreadTaskRunner: | 31 // base::SingleThreadTaskRunner: |
32 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | 32 virtual bool RunsTasksOnCurrentThread() const override; |
33 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 33 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
34 const base::Closure& task, | 34 const base::Closure& task, |
35 base::TimeDelta delay) OVERRIDE; | 35 base::TimeDelta delay) override; |
36 virtual bool PostNonNestableDelayedTask( | 36 virtual bool PostNonNestableDelayedTask( |
37 const tracked_objects::Location& from_here, | 37 const tracked_objects::Location& from_here, |
38 const base::Closure& task, | 38 const base::Closure& task, |
39 base::TimeDelta delay) OVERRIDE; | 39 base::TimeDelta delay) override; |
40 | 40 |
41 const base::TimeTicks& GetCurrentTime() const; | 41 const base::TimeTicks& GetCurrentTime() const; |
42 | 42 |
43 void FastForwardBy(base::TimeDelta delta); | 43 void FastForwardBy(base::TimeDelta delta); |
44 void FastForwardUntilNoTasksRemain(); | 44 void FastForwardUntilNoTasksRemain(); |
45 | 45 |
46 private: | 46 private: |
47 // Strict weak temporal ordering of tasks. | 47 // Strict weak temporal ordering of tasks. |
48 class TemporalOrder { | 48 class TemporalOrder { |
49 public: | 49 public: |
(...skipping 13 matching lines...) Expand all Loading... |
63 }; | 63 }; |
64 | 64 |
65 // A base::TickClock that uses a MockTimeSingleThreadTaskRunner as the source of | 65 // A base::TickClock that uses a MockTimeSingleThreadTaskRunner as the source of |
66 // the current time. | 66 // the current time. |
67 class MockClock : public base::TickClock { | 67 class MockClock : public base::TickClock { |
68 public: | 68 public: |
69 explicit MockClock(scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner); | 69 explicit MockClock(scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner); |
70 virtual ~MockClock(); | 70 virtual ~MockClock(); |
71 | 71 |
72 // base::TickClock: | 72 // base::TickClock: |
73 virtual base::TimeTicks NowTicks() OVERRIDE; | 73 virtual base::TimeTicks NowTicks() override; |
74 | 74 |
75 private: | 75 private: |
76 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_; | 76 scoped_refptr<MockTimeSingleThreadTaskRunner> task_runner_; |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(MockClock); | 78 DISALLOW_COPY_AND_ASSIGN(MockClock); |
79 }; | 79 }; |
80 | 80 |
81 | 81 |
82 MockTimeSingleThreadTaskRunner::MockTimeSingleThreadTaskRunner() { | 82 MockTimeSingleThreadTaskRunner::MockTimeSingleThreadTaskRunner() { |
83 } | 83 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 controller_.ConfirmLogout( | 281 controller_.ConfirmLogout( |
282 runner_->GetCurrentTime() + base::TimeDelta::FromSeconds(10)); | 282 runner_->GetCurrentTime() + base::TimeDelta::FromSeconds(10)); |
283 EXPECT_FALSE(log_out_called_); | 283 EXPECT_FALSE(log_out_called_); |
284 runner_->FastForwardBy(base::TimeDelta::FromSeconds(9)); | 284 runner_->FastForwardBy(base::TimeDelta::FromSeconds(9)); |
285 EXPECT_FALSE(log_out_called_); | 285 EXPECT_FALSE(log_out_called_); |
286 runner_->FastForwardBy(base::TimeDelta::FromSeconds(2)); | 286 runner_->FastForwardBy(base::TimeDelta::FromSeconds(2)); |
287 EXPECT_TRUE(log_out_called_); | 287 EXPECT_TRUE(log_out_called_); |
288 } | 288 } |
289 | 289 |
290 } // namespace ash | 290 } // namespace ash |
OLD | NEW |