• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TASK_SEQUENCE_MANAGER_TEST_MOCK_TIME_DOMAIN_H_
6 #define BASE_TASK_SEQUENCE_MANAGER_TEST_MOCK_TIME_DOMAIN_H_
7 
8 #include "base/task/sequence_manager/time_domain.h"
9 
10 namespace base {
11 namespace sequence_manager {
12 
13 // TimeDomain with a mock clock and not invoking SequenceManager.
14 // NOTE: All methods are main thread only.
15 class MockTimeDomain : public TimeDomain {
16  public:
17   explicit MockTimeDomain(TimeTicks initial_now_ticks);
18   ~MockTimeDomain() override;
19 
20   void SetNowTicks(TimeTicks now_ticks);
21 
22   // TimeDomain implementation:
23   LazyNow CreateLazyNow() const override;
24   TimeTicks Now() const override;
25   Optional<TimeDelta> DelayTillNextTask(LazyNow* lazy_now) override;
26   void SetNextDelayedDoWork(LazyNow* lazy_now, TimeTicks run_time) override;
27   const char* GetName() const override;
28 
29  private:
30   TimeTicks now_ticks_;
31 
32   DISALLOW_COPY_AND_ASSIGN(MockTimeDomain);
33 };
34 
35 }  // namespace sequence_manager
36 }  // namespace base
37 
38 #endif  // BASE_TASK_SEQUENCE_MANAGER_TEST_MOCK_TIME_DOMAIN_H_
39