OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/session_length_limiter.h" | 5 #include "chrome/browser/chromeos/session_length_limiter.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 MOCK_METHOD0(StopSession, void(void)); | 38 MOCK_METHOD0(StopSession, void(void)); |
39 }; | 39 }; |
40 | 40 |
41 // A SingleThreadTaskRunner that mocks the current time and allows it to be | 41 // A SingleThreadTaskRunner that mocks the current time and allows it to be |
42 // fast-forwarded. | 42 // fast-forwarded. |
43 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { | 43 class MockTimeSingleThreadTaskRunner : public base::SingleThreadTaskRunner { |
44 public: | 44 public: |
45 MockTimeSingleThreadTaskRunner(); | 45 MockTimeSingleThreadTaskRunner(); |
46 | 46 |
47 // base::SingleThreadTaskRunner: | 47 // base::SingleThreadTaskRunner: |
48 virtual bool RunsTasksOnCurrentThread() const OVERRIDE; | 48 virtual bool RunsTasksOnCurrentThread() const override; |
49 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, | 49 virtual bool PostDelayedTask(const tracked_objects::Location& from_here, |
50 const base::Closure& task, | 50 const base::Closure& task, |
51 base::TimeDelta delay) OVERRIDE; | 51 base::TimeDelta delay) override; |
52 virtual bool PostNonNestableDelayedTask( | 52 virtual bool PostNonNestableDelayedTask( |
53 const tracked_objects::Location& from_here, | 53 const tracked_objects::Location& from_here, |
54 const base::Closure& task, | 54 const base::Closure& task, |
55 base::TimeDelta delay) OVERRIDE; | 55 base::TimeDelta delay) override; |
56 | 56 |
57 const base::TimeTicks& GetCurrentTime() const; | 57 const base::TimeTicks& GetCurrentTime() const; |
58 | 58 |
59 void FastForwardBy(const base::TimeDelta& time_delta); | 59 void FastForwardBy(const base::TimeDelta& time_delta); |
60 void FastForwardUntilNoTasksRemain(); | 60 void FastForwardUntilNoTasksRemain(); |
61 | 61 |
62 private: | 62 private: |
63 // Strict weak temporal ordering of tasks. | 63 // Strict weak temporal ordering of tasks. |
64 class TemporalOrder { | 64 class TemporalOrder { |
65 public: | 65 public: |
(...skipping 10 matching lines...) Expand all Loading... |
76 TemporalOrder> tasks_; | 76 TemporalOrder> tasks_; |
77 }; | 77 }; |
78 | 78 |
79 } // namespace | 79 } // namespace |
80 | 80 |
81 class SessionLengthLimiterTest : public testing::Test { | 81 class SessionLengthLimiterTest : public testing::Test { |
82 protected: | 82 protected: |
83 SessionLengthLimiterTest(); | 83 SessionLengthLimiterTest(); |
84 | 84 |
85 // testing::Test: | 85 // testing::Test: |
86 virtual void SetUp() OVERRIDE; | 86 virtual void SetUp() override; |
87 virtual void TearDown() OVERRIDE; | 87 virtual void TearDown() override; |
88 | 88 |
89 void SetSessionUserActivitySeenPref(bool user_activity_seen); | 89 void SetSessionUserActivitySeenPref(bool user_activity_seen); |
90 void ClearSessionUserActivitySeenPref(); | 90 void ClearSessionUserActivitySeenPref(); |
91 bool IsSessionUserActivitySeenPrefSet(); | 91 bool IsSessionUserActivitySeenPrefSet(); |
92 bool GetSessionUserActivitySeenPref(); | 92 bool GetSessionUserActivitySeenPref(); |
93 | 93 |
94 void SetSessionStartTimePref(const base::TimeTicks& session_start_time); | 94 void SetSessionStartTimePref(const base::TimeTicks& session_start_time); |
95 void ClearSessionStartTimePref(); | 95 void ClearSessionStartTimePref(); |
96 bool IsSessionStartTimePrefSet(); | 96 bool IsSessionStartTimePrefSet(); |
97 base::TimeTicks GetSessionStartTimePref(); | 97 base::TimeTicks GetSessionStartTimePref(); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 runner_->FastForwardBy(base::TimeDelta::FromSeconds(50)); | 841 runner_->FastForwardBy(base::TimeDelta::FromSeconds(50)); |
842 | 842 |
843 // Remove the session length limit. | 843 // Remove the session length limit. |
844 ClearSessionLengthLimitPref(); | 844 ClearSessionLengthLimitPref(); |
845 | 845 |
846 // Verify that no timer fires to terminate the session. | 846 // Verify that no timer fires to terminate the session. |
847 runner_->FastForwardUntilNoTasksRemain(); | 847 runner_->FastForwardUntilNoTasksRemain(); |
848 } | 848 } |
849 | 849 |
850 } // namespace chromeos | 850 } // namespace chromeos |
OLD | NEW |