From 433e0fc026d2fddf02ef5c14611bdc9c96bd0fae Mon Sep 17 00:00:00 2001 From: Anton Baskanov Date: Sun, 19 Nov 2023 23:45:30 +0700 Subject: [PATCH] dmime/tests: Test output tool note requeueing. --- dlls/dmime/tests/dmime.c | 118 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 112 insertions(+), 6 deletions(-) diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 16a9a46df81..94f781d2796 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -19,6 +19,7 @@ #define COBJMACROS #include +#include #include #include #include @@ -64,13 +65,13 @@ static double scale_music_time(MUSIC_TIME time, double tempo) return (600000000.0 * time) / (tempo * 768.0); } -#define check_dmus_note_pmsg(a, b, c, d, e, f) check_dmus_note_pmsg_(__LINE__, a, b, c, d, e, f) +#define check_dmus_note_pmsg(a, b, c, d, e, f, g, h, i) check_dmus_note_pmsg_(__LINE__, a, b, c, d, e, f, g, h, i) static void check_dmus_note_pmsg_(int line, DMUS_NOTE_PMSG *msg, MUSIC_TIME time, UINT chan, - UINT duration, UINT key, UINT vel) + UINT duration, UINT key, UINT vel, UINT flags, BOOL time_todo, BOOL flags_todo) { ok_(__FILE__, line)(msg->dwSize == sizeof(*msg), "got dwSize %lu\n", msg->dwSize); ok_(__FILE__, line)(!!msg->rtTime, "got rtTime %I64u\n", msg->rtTime); - ok_(__FILE__, line)(abs(msg->mtTime - time) < 10, "got mtTime %lu\n", msg->mtTime); + todo_wine_if(time_todo) ok_(__FILE__, line)(abs(msg->mtTime - time) < 10, "got mtTime %lu\n", msg->mtTime); ok_(__FILE__, line)(msg->dwPChannel == chan, "got dwPChannel %lu\n", msg->dwPChannel); ok_(__FILE__, line)(!!msg->dwVirtualTrackID, "got dwVirtualTrackID %lu\n", msg->dwVirtualTrackID); ok_(__FILE__, line)(msg->dwType == DMUS_PMSGT_NOTE, "got %#lx\n", msg->dwType); @@ -84,7 +85,7 @@ static void check_dmus_note_pmsg_(int line, DMUS_NOTE_PMSG *msg, MUSIC_TIME time /* FIXME: ok_(__FILE__, line)(!msg->bBeat, "got bBeat %u\n", msg->bBeat); */ /* FIXME: ok_(__FILE__, line)(!msg->bGrid, "got bGrid %u\n", msg->bGrid); */ ok_(__FILE__, line)(msg->bVelocity == vel, "got bVelocity %u\n", msg->bVelocity); - ok_(__FILE__, line)(msg->bFlags == 1, "got bFlags %#x\n", msg->bFlags); + todo_wine_if(flags_todo) ok_(__FILE__, line)(msg->bFlags == flags, "got bFlags %#x\n", msg->bFlags); ok_(__FILE__, line)(!msg->bTimeRange, "got bTimeRange %u\n", msg->bTimeRange); ok_(__FILE__, line)(!msg->bDurRange, "got bDurRange %u\n", msg->bDurRange); ok_(__FILE__, line)(!msg->bVelRange, "got bVelRange %u\n", msg->bVelRange); @@ -2546,10 +2547,25 @@ static void test_performance_pchannel(void) static void test_performance_tool(void) { + DMUS_NOTE_PMSG note60 = + { + .dwSize = sizeof(DMUS_NOTE_PMSG), + .dwFlags = DMUS_PMSGF_REFTIME | DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_QUEUE, + .dwVirtualTrackID = 1, + .dwType = DMUS_PMSGT_NOTE, + .dwGroupID = 1, + .mtDuration = 1000, + .wMusicValue = 60, + .bVelocity = 127, + .bFlags = DMUS_NOTEF_NOTEON, + .bPlayModeFlags = DMUS_PLAYMODE_FIXED, + .bMidiValue = 60, + }; IDirectMusicPerformance *performance; IDirectMusicGraph *graph; IDirectMusicTool *tool; DWORD value, types[1]; + DMUS_NOTE_PMSG *note; DMUS_PMSG msg = {0}; HRESULT hr; @@ -2581,6 +2597,96 @@ static void test_performance_tool(void) hr = IDirectMusicTool_Flush(tool, performance, &msg, 0); todo_wine ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_Init(performance, NULL, NULL, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_AddPort(performance, NULL); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_AllocPMsg(performance, sizeof(DMUS_NOTE_PMSG), (DMUS_PMSG **)¬e); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_MusicToReferenceTime(performance, note60.mtTime, ¬e60.rtTime); + ok(hr == S_OK, "got %#lx\n", hr); + + *note = note60; + note->bFlags = 0; + hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); + ok(hr == DMUS_S_FREE, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_MusicToReferenceTime(performance, note60.mtTime, ¬e60.rtTime); + ok(hr == S_OK, "got %#lx\n", hr); + + *note = note60; + note->mtDuration = 0; + hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); + ok(hr == DMUS_S_FREE, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_MusicToReferenceTime(performance, note60.mtTime, ¬e60.rtTime); + ok(hr == S_OK, "got %#lx\n", hr); + + *note = note60; + hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); + todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(999, 120.0)) < 10.0, + "got %I64d\n", note->rtTime - note60.rtTime); + todo_wine ok(note->mtTime - note60.mtTime == 999, "got %ld\n", note->mtTime - note60.mtTime); + check_dmus_note_pmsg(note, note60.mtTime + 999, 0, 1000, 60, 127, 0, FALSE, TRUE); + + hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_MusicToReferenceTime(performance, note60.mtTime, ¬e60.rtTime); + ok(hr == S_OK, "got %#lx\n", hr); + + *note = note60; + note->nOffset = 1000; + hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); + todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(999, 120.0)) < 10.0, + "got %I64d\n", note->rtTime - note60.rtTime); + todo_wine ok(note->mtTime - note60.mtTime == 999, "got %ld\n", note->mtTime - note60.mtTime); + check_dmus_note_pmsg(note, note60.mtTime + 999, 0, 1000, 60, 127, 0, TRUE, TRUE); + + hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_MusicToReferenceTime(performance, note60.mtTime, ¬e60.rtTime); + ok(hr == S_OK, "got %#lx\n", hr); + + *note = note60; + note->mtDuration = 2; + hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); + todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(1, 120.0)) < 10.0, + "got %I64d\n", note->rtTime - note60.rtTime); + todo_wine ok(note->mtTime - note60.mtTime == 1, "got %ld\n", note->mtTime - note60.mtTime); + check_dmus_note_pmsg(note, note60.mtTime + 1, 0, 2, 60, 127, 0, FALSE, TRUE); + + hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); + ok(hr == S_OK, "got %#lx\n", hr); + hr = IDirectMusicPerformance_MusicToReferenceTime(performance, note60.mtTime, ¬e60.rtTime); + ok(hr == S_OK, "got %#lx\n", hr); + + *note = note60; + note->mtDuration = 1; + hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); + todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(1, 120.0)) < 10.0, + "got %I64d\n", note->rtTime - note60.rtTime); + ok(note->mtTime - note60.mtTime == 1, "got %ld\n", note->mtTime - note60.mtTime); + check_dmus_note_pmsg(note, note60.mtTime + 1, 0, 1, 60, 127, 0, FALSE, TRUE); + + hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)note); + ok(hr == S_OK, "got %#lx\n", hr); + + hr = IDirectMusicPerformance_CloseDown(performance); + ok(hr == S_OK, "got %#lx\n", hr); + IDirectMusicGraph_Release(graph); IDirectMusicTool_Release(tool); @@ -3657,13 +3763,13 @@ static void test_sequence_track(void) ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)¬e); ok(!ret, "got %#lx\n", ret); - check_dmus_note_pmsg(note, 0, 0, 500, 60, 120); + check_dmus_note_pmsg(note, 0, 0, 500, 60, 120, DMUS_NOTEF_NOTEON, FALSE, FALSE); hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)note); ok(hr == S_OK, "got %#lx\n", hr); ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)¬e); ok(!ret, "got %#lx\n", ret); - check_dmus_note_pmsg(note, 1000, 1, 200, 50, 100); + check_dmus_note_pmsg(note, 1000, 1, 200, 50, 100, DMUS_NOTEF_NOTEON, FALSE, FALSE); hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)note); ok(hr == S_OK, "got %#lx\n", hr); -- 2.11.4.GIT