From b5daf2ee87b8856daaeafce9833b8291f1305f29 Mon Sep 17 00:00:00 2001 From: Julius Schwartzenberg Date: Wed, 30 Dec 2009 02:29:14 +0100 Subject: Test which proves the previous patch does the right thing --- dlls/avifil32/tests/api.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/dlls/avifil32/tests/api.c b/dlls/avifil32/tests/api.c index 3ae3197..d33be91 100644 --- a/dlls/avifil32/tests/api.c +++ b/dlls/avifil32/tests/api.c @@ -340,6 +340,68 @@ static void test_default_data(void) ok(DeleteFile("small.avi") !=0, "Deleting file small.avi failed"); } +static void test_ash1_corruption(void) { + COMMON_AVI_HEADERS cah; + PAVIFILE pFile; + int res; + PAVISTREAM pStream1; + AVISTREAMINFO asi1; + + init_test_struct(&cah); + + /* Corrupt the sample size in the audio stream header */ + cah.ash1.dwSampleSize = 0xdeadbeef; + + create_avi_file(&cah); + + res = AVIFileOpen(&pFile, "small.avi", OF_SHARE_DENY_WRITE, 0L); + ok(res == 0, "Unable to open file: error=%u\n", res); + + res = AVIFileGetStream(pFile, &pStream1, 0, 1); + ok(res == 0, "Unable to open audio stream: error=%u\n", res); + + res = AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO)); + ok(res == 0, "Unable to read stream info: error=%u\n", res); + + /* The result will still be 2, because the value is dynamically replaced with the nBlockAlign + value from the stream format header. The next test will prove this */ + todo_wine{ ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize); } + + AVIStreamRelease(pStream1); + AVIFileRelease(pFile); + ok(DeleteFile("small.avi") !=0, "Deleting file small.avi failed"); +} + +static void test_ash1_corruption2(void) { + COMMON_AVI_HEADERS cah; + PAVIFILE pFile; + int res; + PAVISTREAM pStream1; + AVISTREAMINFO asi1; + + init_test_struct(&cah); + + /* Corrupt the block alignment in the audio format header */ + cah.pcmwf.wf.nBlockAlign = 0xdead; + + create_avi_file(&cah); + + res = AVIFileOpen(&pFile, "small.avi", OF_SHARE_DENY_WRITE, 0L); + ok(res == 0, "Unable to open file: error=%u\n", res); + + res = AVIFileGetStream(pFile, &pStream1, 0, 1); + ok(res == 0, "Unable to open audio stream: error=%u\n", res); + + ok(AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO)) == 0, "Unable to read stream info\n"); + + /* The result will also be the corrupt value, as explained above. */ + todo_wine{ ok(asi1.dwSampleSize == 0xdead, "got %u (expected 0xdead)\n", asi1.dwSampleSize); } + + AVIStreamRelease(pStream1); + AVIFileRelease(pFile); + ok(DeleteFile("small.avi") !=0, "Deleting file small.avi failed"); +} + /* ########################### */ START_TEST(api) @@ -348,6 +410,8 @@ START_TEST(api) AVIFileInit(); test_AVISaveOptions(); test_default_data(); + test_ash1_corruption(); + test_ash1_corruption2(); AVIFileExit(); } -- 1.6.3.3