| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_INSTANCE_H_ | |
| 6 #define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_INSTANCE_H_ | |
| 7 | |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "components/arc/arc_bridge_service.h" | |
| 11 #include "components/arc/common/arc_bridge.mojom.h" | |
| 12 #include "mojo/public/cpp/bindings/binding.h" | |
| 13 | |
| 14 namespace arc { | |
| 15 | |
| 16 class FakeArcBridgeInstance : public mojom::ArcBridgeInstance { | |
| 17 public: | |
| 18 class Delegate { | |
| 19 public: | |
| 20 virtual ~Delegate() = default; | |
| 21 virtual void OnStopped(ArcBridgeService::StopReason reason) = 0; | |
| 22 }; | |
| 23 | |
| 24 FakeArcBridgeInstance(); | |
| 25 ~FakeArcBridgeInstance() override; | |
| 26 | |
| 27 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | |
| 28 | |
| 29 // Finalizes the connection between the host and the instance, and signals | |
| 30 // the host that the boot sequence has finished. | |
| 31 void Bind(mojo::InterfaceRequest<mojom::ArcBridgeInstance> interface_request); | |
| 32 | |
| 33 // Resets the binding. Useful to simulate a restart. | |
| 34 void Unbind(); | |
| 35 | |
| 36 // ArcBridgeInstance: | |
| 37 void Init(mojom::ArcBridgeHostPtr host) override; | |
| 38 | |
| 39 // Ensures the call to Init() has been dispatched. | |
| 40 void WaitForInitCall(); | |
| 41 | |
| 42 // The number of times Init() has been called. | |
| 43 int init_calls() const { return init_calls_; } | |
| 44 | |
| 45 // Stops the instance. | |
| 46 void Stop(ArcBridgeService::StopReason reason); | |
| 47 | |
| 48 private: | |
| 49 Delegate* delegate_ = nullptr; | |
| 50 | |
| 51 // Keeps quit closure to wake the running nested RunLoop. | |
| 52 base::Closure quit_closure_; | |
| 53 | |
| 54 // Mojo endpoints. | |
| 55 mojo::Binding<mojom::ArcBridgeInstance> binding_; | |
| 56 mojom::ArcBridgeHostPtr host_ptr_; | |
| 57 int init_calls_ = 0; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeInstance); | |
| 60 }; | |
| 61 | |
| 62 } // namespace arc | |
| 63 | |
| 64 #endif // COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_INSTANCE_H_ | |
| OLD | NEW |