[1/6] qedit: Add test framework and test for IMediaDet_put_Filename.

Dan Hipschman dsh at linux.ucla.edu
Thu Apr 3 19:53:41 CDT 2008


This sets up some real tests for qedit using an actual AVI file to test
with.  The resource is constructed from the AVI file by prepending the
size so we know how big it is in the code.  Hence, to use a different AVI
file you can just drop it into the test directory and run make.  However,
the following tests will check the number of streams, frames, format,
etc., so it really shouldn't change that much.

---
 dlls/qedit/tests/Makefile.in |    9 +++++-
 dlls/qedit/tests/mediadet.c  |   67 ++++++++++++++++++++++++++++++++++++++++++
 dlls/qedit/tests/qedit.rc    |   21 +++++++++++++
 dlls/qedit/tests/test.avi    |  Bin 0 -> 5676 bytes
 4 files changed, 96 insertions(+), 1 deletions(-)
 create mode 100644 dlls/qedit/tests/qedit.rc
 create mode 100644 dlls/qedit/tests/test.avi

diff --git a/dlls/qedit/tests/Makefile.in b/dlls/qedit/tests/Makefile.in
index 5236975..4701730 100644
--- a/dlls/qedit/tests/Makefile.in
+++ b/dlls/qedit/tests/Makefile.in
@@ -3,12 +3,19 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = qedit.dll
-IMPORTS   = ole32 kernel32
+IMPORTS   = oleaut32 ole32 kernel32
 EXTRALIBS = -lstrmiids -luuid
 
 CTESTS = \
 	mediadet.c
 
+RC_SRCS = qedit.rc
+
+qedit.res: test.dat
+
+test.dat: test.avi
+	wc -c test.avi | awk '{printf("%s\0", $$1)}' | cat - test.avi > test.dat
+
 @MAKE_TEST_RULES@
 
 @DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/qedit/tests/mediadet.c b/dlls/qedit/tests/mediadet.c
index 5d5178d..46e17a1 100644
--- a/dlls/qedit/tests/mediadet.c
+++ b/dlls/qedit/tests/mediadet.c
@@ -25,22 +25,89 @@
 #include "wine/test.h"
 #include "qedit.h"
 
+static WCHAR test_avi_filename[MAX_PATH];
+
+static BOOL init_tests(void)
+{
+    static WCHAR temp_path[MAX_PATH];
+    static WCHAR prefix[] = {'D','E','S',0};
+    static WCHAR avi[] = {'a','v','i',0};
+    HRSRC res;
+    HGLOBAL data;
+    char *mem;
+    long size;
+    HANDLE fh;
+    DWORD written;
+
+    res = FindResourceW(NULL, (LPWSTR) 1, (LPWSTR) 256);
+    if (!res)
+        return FALSE;
+
+    data = LoadResource(NULL, res);
+    if (!data)
+        return FALSE;
+
+    mem = LockResource(data);
+    if (!mem)
+        return FALSE;
+
+    size = strtol(mem, &mem, 10);
+    ++mem;
+
+    if (!GetTempPathW(sizeof temp_path, temp_path))
+        return FALSE;
+
+    /* We might end up relying on the extension here, so .TMP is no good.  */
+    if (!GetTempFileNameW(temp_path, prefix, 0, test_avi_filename))
+        return FALSE;
+
+    DeleteFileW(test_avi_filename);
+    lstrcpyW(test_avi_filename + lstrlenW(test_avi_filename) - 3, avi);
+
+    fh = CreateFileW(test_avi_filename, GENERIC_WRITE, 0, NULL,
+                     CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+    if (fh == INVALID_HANDLE_VALUE)
+        return FALSE;
+
+    if (!WriteFile(fh, mem, size, &written, NULL) || written != size)
+        return FALSE;
+
+    CloseHandle(fh);
+
+    return TRUE;
+}
+
 static void test_mediadet(void)
 {
     HRESULT hr;
     IMediaDet *pM = NULL;
+    BSTR filename = NULL;
 
     hr = CoCreateInstance(&CLSID_MediaDet, NULL, CLSCTX_INPROC_SERVER,
             &IID_IMediaDet, (LPVOID*)&pM);
     ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
     ok(pM != NULL, "pM is NULL\n");
 
+    filename = SysAllocString(test_avi_filename);
+    hr = IMediaDet_put_Filename(pM, filename);
+    todo_wine ok(hr == S_OK, "IMediaDet_put_Filename -> %x\n", hr);
+    SysFreeString(filename);
+
     hr = IMediaDet_Release(pM);
     ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);
+
+    DeleteFileW(test_avi_filename);
 }
 
 START_TEST(mediadet)
 {
+    if (!init_tests())
+    {
+        skip("Couldn't initialize tests!\n");
+        return;
+    }
+
     CoInitialize(NULL);
     test_mediadet();
+    CoUninitialize();
 }
diff --git a/dlls/qedit/tests/qedit.rc b/dlls/qedit/tests/qedit.rc
new file mode 100644
index 0000000..0aae3ba
--- /dev/null
+++ b/dlls/qedit/tests/qedit.rc
@@ -0,0 +1,21 @@
+/*
+ * Resource file for qedit tests.
+ *
+ * Copyright 2008 Google (Dan Hipschman)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+1 256 test.dat
diff --git a/dlls/qedit/tests/test.avi b/dlls/qedit/tests/test.avi
new file mode 100644
index 0000000000000000000000000000000000000000..8756c64348e3bfda3eba384280f71aae7b9edf7c
GIT binary patch
literal 5676
zcmWIYbaPV?V_<L$^HlKh3=ZL8WMIfhDauJK%gnG~U|?9#1{8n-0Zs-67!O7(0OcfL
z3Xo`!SqFgp;*z2qAO at RNmYGr<8D?mNqzr5x7gPXjCL6LW1A_w4bfEq;4WKXxD*!Rb
zK4u0U29Q||EI<w#C at Ux`a6u9SnXdrE5Pd9gHX~FFCI_O?0mvT?KtWGGH-FDyw-93>
z+t)QOIX at +}NWsX;K+n=r+fdJ-peWV6q^QzJJGrdb$iTqNz|hcK*Pt}1G_R!8LJ#O;
zuTVel349C;(Y6Y{0Xd14K;2oTdD#jni6x1O3bwJM;-ld(njS{;#b`M&S`Lhs1Eb}@
zXgM%i4vdxqqvgP8IWSrd(6Sr=_xXW+?%e#cOap_IWCkGn|0oy at fzc2cu_4ef3PyAY
WWTsRY3INABLG=NM1`n|U>jeM>>Gwha

literal 0
HcmV?d00001

-- 
1.5.3.7




More information about the wine-patches mailing list