| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef COMPONENTS_ARC_TEST_FAKE_ARC_SESSION_H_ | 5 #ifndef COMPONENTS_ARC_TEST_FAKE_ARC_SESSION_H_ | 
| 6 #define COMPONENTS_ARC_TEST_FAKE_ARC_SESSION_H_ | 6 #define COMPONENTS_ARC_TEST_FAKE_ARC_SESSION_H_ | 
| 7 | 7 | 
| 8 #include <memory> | 8 #include <memory> | 
| 9 | 9 | 
| 10 #include "base/macros.h" | 10 #include "base/macros.h" | 
| 11 #include "components/arc/arc_session.h" | 11 #include "components/arc/arc_session.h" | 
|  | 12 #include "components/arc/arc_session_observer.h" | 
| 12 | 13 | 
| 13 namespace arc { | 14 namespace arc { | 
| 14 | 15 | 
| 15 // A fake ArcSession that creates a local connection. | 16 // A fake ArcSession that creates a local connection. | 
| 16 class FakeArcSession : public ArcSession { | 17 class FakeArcSession : public ArcSession { | 
| 17  public: | 18  public: | 
| 18   FakeArcSession(); | 19   FakeArcSession(); | 
| 19   ~FakeArcSession() override; | 20   ~FakeArcSession() override; | 
| 20 | 21 | 
| 21   // ArcSession overrides: | 22   // ArcSession overrides: | 
| 22   void Start() override; | 23   void Start() override; | 
| 23   void Stop() override; | 24   void Stop() override; | 
| 24   void OnShutdown() override; | 25   void OnShutdown() override; | 
| 25 | 26 | 
| 26   // To emulate unexpected stop, such as crash. | 27   // To emulate unexpected stop, such as crash. | 
| 27   void StopWithReason(ArcBridgeService::StopReason reason); | 28   void StopWithReason(ArcSessionObserver::StopReason reason); | 
| 28 | 29 | 
| 29   // The following control Start() behavior for testing various situations. | 30   // The following control Start() behavior for testing various situations. | 
| 30 | 31 | 
| 31   // Enables/disables boot failure emulation, in which OnStopped(reason) will | 32   // Enables/disables boot failure emulation, in which OnStopped(reason) will | 
| 32   // be called when Start() is called. | 33   // be called when Start() is called. | 
| 33   void EnableBootFailureEmulation(ArcBridgeService::StopReason reason); | 34   void EnableBootFailureEmulation(ArcSessionObserver::StopReason reason); | 
| 34 | 35 | 
| 35   // Emulate Start() is suspended at some phase, before OnReady() is invoked. | 36   // Emulate Start() is suspended at some phase, before OnReady() is invoked. | 
| 36   void SuspendBoot(); | 37   void SuspendBoot(); | 
| 37 | 38 | 
| 38   // Returns FakeArcSession instance. This can be used for a factory | 39   // Returns FakeArcSession instance. This can be used for a factory | 
| 39   // in ArcBridgeServiceImpl. | 40   // in ArcBridgeServiceImpl. | 
| 40   static std::unique_ptr<ArcSession> Create(); | 41   static std::unique_ptr<ArcSession> Create(); | 
| 41 | 42 | 
| 42  private: | 43  private: | 
| 43   bool boot_failure_emulation_enabled_ = false; | 44   bool boot_failure_emulation_enabled_ = false; | 
| 44   ArcBridgeService::StopReason boot_failure_reason_; | 45   ArcSessionObserver::StopReason boot_failure_reason_; | 
| 45 | 46 | 
| 46   bool boot_suspended_ = false; | 47   bool boot_suspended_ = false; | 
| 47 | 48 | 
| 48   DISALLOW_COPY_AND_ASSIGN(FakeArcSession); | 49   DISALLOW_COPY_AND_ASSIGN(FakeArcSession); | 
| 49 }; | 50 }; | 
| 50 | 51 | 
| 51 }  // namespace arc | 52 }  // namespace arc | 
| 52 | 53 | 
| 53 #endif  // COMPONENTS_ARC_TEST_FAKE_ARC_SESSION_H_ | 54 #endif  // COMPONENTS_ARC_TEST_FAKE_ARC_SESSION_H_ | 
| OLD | NEW | 
|---|