From: Yuxuan Shui yshui@codeweavers.com
--- dlls/dmime/tests/dmime.c | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index b8494917234..b0c99804e53 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -1556,11 +1556,23 @@ static void test_segment(void)
static void test_midi(void) { + static const DWORD message_types[] = + { + DMUS_PMSGT_MIDI, + DMUS_PMSGT_NOTE, + DMUS_PMSGT_DIRTY, + }; IDirectMusicSegment8 *segment = NULL; IDirectMusicTrack *track = NULL; IDirectMusicLoader8 *loader; + IDirectMusicTool *tool; + IDirectMusicPerformance *performance; + IDirectMusicGraph *graph; WCHAR test_mid[MAX_PATH], bogus_mid[MAX_PATH]; HRESULT hr; + DMUS_PMSG *pmsg; + DMUS_MIDI_PMSG *midi; + ULONG ret;
load_resource(L"test.mid", test_mid); /* This is a MIDI file with wrong track length. */ @@ -1586,6 +1598,51 @@ static void test_midi(void) todo_wine ok(hr == S_OK, "got %#lx\n", hr); if (track) IDirectMusicTrack_Release(track); track = NULL; + + hr = test_tool_create(message_types, ARRAY_SIZE(message_types), &tool); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = CoCreateInstance(&CLSID_DirectMusicPerformance, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicPerformance, (void **)&performance); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = CoCreateInstance(&CLSID_DirectMusicGraph, NULL, CLSCTX_INPROC_SERVER, + &IID_IDirectMusicGraph, (void **)&graph); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicGraph_InsertTool(graph, (IDirectMusicTool *)tool, NULL, 0, -1); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_SetGraph(performance, graph); + ok(hr == S_OK, "got %#lx\n", hr); + IDirectMusicGraph_Release(graph); + + hr = IDirectMusicPerformance_Init(performance, NULL, 0, 0); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_PlaySegment(performance, (IDirectMusicSegment *)segment, 0x800, 0, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + + ret = test_tool_wait_message(tool, 500, &pmsg); + ok(!ret, "got %lu\n", ret); + ok(pmsg->dwType == DMUS_PMSGT_DIRTY, "got %#lx\n", pmsg->dwType); + hr = IDirectMusicPerformance_FreePMsg(performance, pmsg); + ok(hr == S_OK, "got %#lx\n", hr); + ret = test_tool_wait_message(tool, 500, &pmsg); + ok(!ret, "got %lu\n", ret); + ok(pmsg->dwType == DMUS_PMSGT_MIDI, "got %#lx\n", pmsg->dwType); + midi = (DMUS_MIDI_PMSG *)pmsg; + ok(midi->bStatus == 0xb0, "got %#x\n", midi->bStatus); + hr = IDirectMusicPerformance_FreePMsg(performance, pmsg); + ok(hr == S_OK, "got %#lx\n", hr); + while (!(ret = test_tool_wait_message(tool, -1, &pmsg))) { + trace("ret %lu, pmsg %lx\n", ret, pmsg ? pmsg->dwType : -1); + if (pmsg->dwType == DMUS_PMSGT_MIDI) + { + midi = (DMUS_MIDI_PMSG *)pmsg; + trace("midi message: %x %x %x\n", midi->bStatus, midi->bByte1, midi->bByte2); + } + hr = IDirectMusicPerformance_FreePMsg(performance, pmsg); + }; + IDirectMusicTool_Release(tool); + IDirectMusicPerformance_Release(performance); if (segment) IDirectMusicSegment8_Release(segment); segment = NULL;