Bug 1472338: part 2) Change `clipboard.readText()` to read from the clipboard asynchr...
[gecko.git] / dom / midi / TestMIDIPlatformService.h
blobaa241d9d49b5025d0b44dab1d80e19e1652a0093
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 Open(MIDIPortParent* aPort) override;
30 virtual void Stop() override;
31 virtual void ScheduleSend(const nsAString& aPort) override;
32 virtual void ScheduleClose(MIDIPortParent* aPort) override;
33 // MIDI Service simulation function. Can take specially formed sysex messages
34 // in order to trigger device connection events and state changes,
35 // interrupting messages for high priority sysex sends, etc...
36 void ProcessMessages(const nsAString& aPort);
38 private:
39 virtual ~TestMIDIPlatformService();
40 // Convenience object for sending runnables to the background thread. All
41 // runnables are pushed to the background thread, and check for existence of a
42 // manager object on the thread before running.
43 nsCOMPtr<nsIThread> mBackgroundThread;
44 // Port that takes test control messages
45 MIDIPortInfo mControlInputPort;
46 // Port that returns test status messages
47 MIDIPortInfo mControlOutputPort;
48 // Used for testing input connection/disconnection
49 MIDIPortInfo mStateTestInputPort;
50 // Used for testing output connection/disconnection
51 MIDIPortInfo mStateTestOutputPort;
52 // Used for testing open() call failures
53 MIDIPortInfo mAlwaysClosedTestOutputPort;
54 // IO Simulation thread. Runs all instances of ProcessMessages().
55 nsCOMPtr<nsIThread> mClientThread;
56 // True if server has been brought up already.
57 bool mIsInitialized;
60 } // namespace mozilla::dom
62 #endif // mozilla_dom_TestMIDIPlatformService_h