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"
15 namespace mozilla::dom
{
17 class MIDIPortInterface
;
20 * Platform service implementation used for mochitests. Emulates what a real
21 * platform service should look like, including using an internal IO thread for
25 class TestMIDIPlatformService
: public MIDIPlatformService
{
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
);
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.
60 } // namespace mozilla::dom
62 #endif // mozilla_dom_TestMIDIPlatformService_h