Commit b2441ad6 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dmime/tests: Add some tests for loops on wave tracks.

parent 7aef55a9
......@@ -3542,7 +3542,7 @@ static void test_notification_pmsg(void)
IDirectMusicTool_Release(tool);
}
static void test_wave_pmsg(void)
static void test_wave_pmsg(unsigned num_repeats)
{
static const DWORD message_types[] =
{
......@@ -3550,17 +3550,25 @@ static void test_wave_pmsg(void)
DMUS_PMSGT_WAVE,
};
IDirectMusicPerformance *performance;
IDirectMusicSegmentState *state;
IDirectMusicSegment *segment;
IDirectMusicLoader8 *loader;
IDirectMusicGraph *graph;
WCHAR test_wav[MAX_PATH];
IDirectMusicTool *tool;
DMUS_WAVE_PMSG *wave;
DWORD mt_start_ref;
MUSIC_TIME length;
DMUS_PMSG *msg;
DWORD value;
HRESULT hr;
unsigned i;
DWORD ret;
if (num_repeats)
winetest_push_context("with %u repeats", num_repeats);
else
winetest_push_context("without any repeats");
hr = test_tool_create(message_types, ARRAY_SIZE(message_types), &tool);
ok(hr == S_OK, "got %#lx\n", hr);
......@@ -3599,6 +3607,12 @@ static void test_wave_pmsg(void)
ok(length == 1, "got %lu\n", length);
if (num_repeats)
{
hr = IDirectMusicSegment_SetRepeats(segment, num_repeats);
ok(hr == S_OK, "got %#lx\n", hr);
}
/* without Download, no DMUS_PMSGT_WAVE is sent */
hr = IDirectMusicPerformance_PlaySegment(performance, segment, 0, 0, NULL);
......@@ -3611,10 +3625,14 @@ static void test_wave_pmsg(void)
ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, &msg);
todo_wine_if(num_repeats)
ok(!ret, "got %#lx\n", ret);
if (!ret)
{
ok(msg->dwType == DMUS_PMSGT_DIRTY, "got %p\n", msg);
hr = IDirectMusicPerformance_FreePMsg(performance, msg);
ok(hr == S_OK, "got %#lx\n", hr);
}
ret = test_tool_wait_message(tool, 100, &msg);
ok(ret == WAIT_TIMEOUT, "got %#lx\n", ret);
......@@ -3626,7 +3644,7 @@ static void test_wave_pmsg(void)
hr = IDirectMusicSegment8_Download((IDirectMusicSegment8 *)segment, (IUnknown *)performance);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_PlaySegment(performance, segment, 0, 0, NULL);
hr = IDirectMusicPerformance_PlaySegment(performance, segment, 0, 0, &state);
ok(hr == S_OK, "got %#lx\n", hr);
ret = test_tool_wait_message(tool, 500, &msg);
......@@ -3635,10 +3653,27 @@ static void test_wave_pmsg(void)
hr = IDirectMusicPerformance_FreePMsg(performance, msg);
ok(hr == S_OK, "got %#lx\n", hr);
hr = IDirectMusicPerformance_ReferenceToMusicTime(performance, 1000000, &length);
ok(hr == S_OK, "got %#lx\n", hr);
/* assuming not modified tempo */
length = round((1000000 * 120.0 * DMUS_PPQ) / 600000000.0);
for (i = 0; i <= num_repeats; i++)
{
ret = test_tool_wait_message(tool, 500, (DMUS_PMSG **)&wave);
todo_wine_if(num_repeats && ret)
ok(!ret, "got %#lx\n", ret);
if (ret) continue;
ok(wave->dwType == DMUS_PMSGT_WAVE, "got %p\n", wave);
ok(wave->dwSize == sizeof(*wave), "got %lu\n", wave->dwSize);
ok(!!wave->punkUser, "got %p\n", wave->punkUser);
ok((wave->dwFlags & DMUS_PMSGF_REFTIME) && (wave->dwFlags & DMUS_PMSGF_MUSICTIME),
"got %lx\n", wave->dwFlags);
if (i == 0)
mt_start_ref = wave->mtTime;
else
todo_wine
ok(wave->mtTime == mt_start_ref + length * i, "got %lu (%lu,%lu)\n", wave->mtTime, mt_start_ref, i * length);
ok(wave->rtStartOffset == 0, "got %I64d\n", wave->rtStartOffset);
ok(wave->rtDuration == 1000000, "got %I64d\n", wave->rtDuration);
ok(wave->lOffset == 0, "got %lu\n", wave->lOffset);
......@@ -3647,12 +3682,25 @@ static void test_wave_pmsg(void)
ok(wave->bFlags == 0, "got %#x\n", wave->bFlags);
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)wave);
ok(hr == S_OK, "got %#lx\n", hr);
}
ret = test_tool_wait_message(tool, 500, &msg);
todo_wine_if(num_repeats)
ok(!ret, "got %#lx\n", ret);
if (!ret)
{
ok(msg->dwType == DMUS_PMSGT_DIRTY, "got %p\n", msg);
hr = IDirectMusicPerformance_FreePMsg(performance, msg);
ok(hr == S_OK, "got %#lx\n", hr);
}
hr = IDirectMusicSegment_GetRepeats(segment, &value);
ok(hr == S_OK, "got %#lx\n", hr);
ok(value == num_repeats, "got %lu\n", value);
hr = IDirectMusicSegmentState_GetRepeats(state, &value);
ok(hr == S_OK, "got %#lx\n", hr);
ok(value == num_repeats, "got %lu\n", value);
hr = IDirectMusicSegment8_Unload((IDirectMusicSegment8 *)segment, (IUnknown *)performance);
ok(hr == S_OK, "got %#lx\n", hr);
......@@ -3670,6 +3718,8 @@ static void test_wave_pmsg(void)
IDirectMusicPerformance_Release(performance);
IDirectMusicTool_Release(tool);
winetest_pop_context();
}
static void test_sequence_track(void)
......@@ -4664,7 +4714,8 @@ START_TEST(dmime)
test_performance_time();
test_performance_pmsg();
test_notification_pmsg();
test_wave_pmsg();
test_wave_pmsg(0);
test_wave_pmsg(10);
test_sequence_track();
test_band_track_play();
test_tempo_track_play();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment