Bug 1880216 - Migrate Fenix docs into Sphinx. r=owlish,geckoview-reviewers,android...
[gecko.git] / dom / midi / TestMIDIPlatformService.h
blob29423a02a40751afdc2a97c7f712469e1a06a78d
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_TestMIDIPlatformService_h
8 #define mozilla_dom_TestMIDIPlatformService_h
10 #include "mozilla/dom/MIDIPlatformService.h"
11 #include "mozilla/dom/MIDITypes.h"
13 class nsIThread;
15 namespace mozilla::dom {
17 class MIDIPortInterface;
19 /**
20 * Platform service implementation used for mochitests. Emulates what a real
21 * platform service should look like, including using an internal IO thread for
22 * message IO.
25 class TestMIDIPlatformService : public MIDIPlatformService {
26 public:
27 TestMIDIPlatformService();
28 virtual void Init() override;
29 virtual void Refresh() override;
30 virtual void Open(MIDIPortParent* aPort) override;
31 virtual void Stop() override;
32 virtual void ScheduleSend(const nsAString& aPort) override;
33 virtual void ScheduleClose(MIDIPortParent* aPort) override;
34 // MIDI Service simulation function. Can take specially formed sysex messages
35 // in order to trigger device connection events and state changes,
36 // interrupting messages for high priority sysex sends, etc...
37 void ProcessMessages(const nsAString& aPort);
39 private:
40 virtual ~TestMIDIPlatformService();
41 // Port that takes test control messages
42 MIDIPortInfo mControlInputPort;
43 // Port that returns test status messages
44 MIDIPortInfo mControlOutputPort;
45 // Used for testing input connection/disconnection
46 MIDIPortInfo mStateTestInputPort;
47 // Used for testing output connection/disconnection
48 MIDIPortInfo mStateTestOutputPort;
49 // Used for testing open() call failures
50 MIDIPortInfo mAlwaysClosedTestOutputPort;
51 // IO Simulation thread. Runs all instances of ProcessMessages().
52 nsCOMPtr<nsIThread> mClientThread;
53 // When true calling Refresh() will add new ports.
54 bool mDoRefresh;
55 // True if server has been brought up already.
56 bool mIsInitialized;
59 } // namespace mozilla::dom
61 #endif // mozilla_dom_TestMIDIPlatformService_h