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