Akihiro Sagawa : winmm/tests: Add EOF and buffer pointer tests for mmio.
Alexandre Julliard
julliard at winehq.org
Tue Nov 20 13:52:23 CST 2012
Module: wine
Branch: master
Commit: 1aa15750edf060b12a50b547ebadb086d9fc9ca2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1aa15750edf060b12a50b547ebadb086d9fc9ca2
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Wed Nov 14 19:20:03 2012 +0900
winmm/tests: Add EOF and buffer pointer tests for mmio.
---
dlls/winmm/tests/mmio.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c
index a4e7a2d..232f84b 100644
--- a/dlls/winmm/tests/mmio.c
+++ b/dlls/winmm/tests/mmio.c
@@ -787,6 +787,110 @@ static void test_mmioSeek(void)
DeleteFileA(test_file);
}
+static void test_mmio_end_of_file(void)
+{
+ char test_file[MAX_PATH], buffer[128], data[16];
+ MMIOINFO mmio;
+ HMMIO hmmio;
+ LONG ret;
+ MMRESULT res;
+
+ if (!create_test_file(test_file)) return;
+
+ memset(&mmio, 0, sizeof(mmio));
+ mmio.fccIOProc = FOURCC_DOS;
+ mmio.pchBuffer = buffer;
+ mmio.cchBuffer = sizeof(buffer);
+ hmmio = mmioOpen(test_file, &mmio, MMIO_READ);
+ ok(hmmio != NULL, "mmioOpen error %u\n", mmio.wErrorRet);
+ if (hmmio == NULL) {
+ DeleteFileA(test_file);
+ return;
+ }
+
+ ret = mmioSeek(hmmio, 0, SEEK_END);
+ ok(sizeof(RIFF_buf) == ret, "got %d\n", ret);
+
+ ret = mmioRead(hmmio, data, sizeof(data));
+ todo_wine ok(ret == 0, "expected %d, got %d\n", 0, ret);
+
+ res = mmioGetInfo(hmmio, &mmio, 0);
+ ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
+
+ res = mmioAdvance(hmmio, &mmio, MMIO_READ);
+ ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
+ todo_wine ok(mmio.pchNext == mmio.pchEndRead, "expected %p, got %p\n", mmio.pchEndRead, mmio.pchNext);
+
+ mmioClose(hmmio, 0);
+ DeleteFileA(test_file);
+}
+
+static void test_mmio_buffer_pointer(void)
+{
+ char test_file[MAX_PATH];
+ char buffer[5], data[16];
+ MMIOINFO mmio;
+ HMMIO hmmio;
+ LONG size, pos;
+ MMRESULT res;
+
+ if (!create_test_file(test_file)) return;
+
+ memset(&mmio, 0, sizeof(mmio));
+ mmio.fccIOProc = FOURCC_DOS;
+ mmio.pchBuffer = buffer;
+ mmio.cchBuffer = sizeof(buffer);
+ hmmio = mmioOpen(test_file, &mmio, MMIO_READ);
+ ok(hmmio != NULL, "mmioOpen error %u\n", mmio.wErrorRet);
+ if (hmmio == NULL) {
+ DeleteFileA(test_file);
+ return;
+ }
+
+ /* the buffer is empty */
+ size = mmioRead(hmmio, data, 0);
+ ok(size == 0, "expected 0, got %d\n", size);
+ res = mmioGetInfo(hmmio, &mmio, 0);
+ ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
+ ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
+
+ /* fill the buffer */
+ size = mmioAdvance(hmmio, &mmio, MMIO_READ);
+ ok(mmio.pchEndRead-mmio.pchBuffer == sizeof(buffer), "got %d\n", (int)(mmio.pchEndRead-mmio.pchBuffer));
+
+ /* seeking to the same buffer chunk, the buffer is kept */
+ size = sizeof(buffer)/2;
+ pos = mmioSeek(hmmio, size, SEEK_SET);
+ ok(pos == size, "failed to seek, expected %d, got %d\n", size, pos);
+ res = mmioGetInfo(hmmio, &mmio, 0);
+ ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
+ ok(mmio.lBufOffset == 0, "expected 0, got %d\n", mmio.lBufOffset);
+ ok(mmio.pchNext-mmio.pchBuffer == size, "expected %d, got %d\n", size, (int)(mmio.pchNext-mmio.pchBuffer));
+ ok(mmio.pchEndRead-mmio.pchBuffer == sizeof(buffer), "got %d\n", (int)(mmio.pchEndRead-mmio.pchBuffer));
+
+ /* seeking to another buffer chunk, the buffer is empty */
+ size = sizeof(buffer) * 3 + sizeof(buffer) / 2;
+ pos = mmioSeek(hmmio, size, SEEK_SET);
+ ok(pos == size, "failed to seek, got %d\n", pos);
+ res = mmioGetInfo(hmmio, &mmio, 0);
+ ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
+ todo_wine ok(mmio.lBufOffset == size, "expected %d, got %d\n", size, mmio.lBufOffset);
+ todo_wine ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
+ todo_wine ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
+
+ /* reading a lot (as sizeof(data) > mmio.cchBuffer), the buffer is empty */
+ size = mmioRead(hmmio, data, sizeof(data));
+ ok(size == sizeof(data), "failed to read, got %d\n", size);
+ res = mmioGetInfo(hmmio, &mmio, 0);
+ ok(res == MMSYSERR_NOERROR, "expected 0, got %d\n", res);
+ todo_wine ok(mmio.lBufOffset == pos+size, "expected %d, got %d\n", pos+size, mmio.lBufOffset);
+ todo_wine ok(mmio.pchNext == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchNext);
+ todo_wine ok(mmio.pchEndRead == mmio.pchBuffer, "expected %p, got %p\n", mmio.pchBuffer, mmio.pchEndRead);
+
+ mmioClose(hmmio, 0);
+ DeleteFileA(test_file);
+}
+
START_TEST(mmio)
{
/* Make it possible to run the tests against a specific AVI file in
@@ -803,4 +907,6 @@ START_TEST(mmio)
test_mmioSetBuffer(fname);
test_mmioOpen_fourcc();
test_mmioSeek();
+ test_mmio_end_of_file();
+ test_mmio_buffer_pointer();
}
More information about the wine-cvs
mailing list