[PATCH 3/6] amstream/tests: Add a test AVI file.

Anton Baskanov baskanov at gmail.com
Mon Jul 20 10:40:09 CDT 2020


Signed-off-by: Anton Baskanov <baskanov at gmail.com>
---
 dlls/amstream/tests/Makefile.in |   3 ++
 dlls/amstream/tests/amstream.c  |  66 +++++++++++++++++++++++++-------
 dlls/amstream/tests/rsrc.rc     |  25 ++++++++++++
 dlls/amstream/tests/test.avi    | Bin 0 -> 12088 bytes
 4 files changed, 81 insertions(+), 13 deletions(-)
 create mode 100644 dlls/amstream/tests/rsrc.rc
 create mode 100644 dlls/amstream/tests/test.avi

diff --git a/dlls/amstream/tests/Makefile.in b/dlls/amstream/tests/Makefile.in
index 81eaed3c15..eb756ddf39 100644
--- a/dlls/amstream/tests/Makefile.in
+++ b/dlls/amstream/tests/Makefile.in
@@ -3,3 +3,6 @@ IMPORTS   = strmbase strmiids uuid ddraw ole32 user32
 
 C_SRCS = \
 	amstream.c
+
+RC_SRCS = \
+	rsrc.rc
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c
index 001cae5611..c1b71afb33 100644
--- a/dlls/amstream/tests/amstream.c
+++ b/dlls/amstream/tests/amstream.c
@@ -53,6 +53,48 @@ static const AM_MEDIA_TYPE audio_mt =
 static const WCHAR primary_video_sink_id[] = L"I{A35FF56A-9FDA-11D0-8FDF-00C04FD9189D}";
 static const WCHAR primary_audio_sink_id[] = L"I{A35FF56B-9FDA-11D0-8FDF-00C04FD9189D}";
 
+static const WCHAR *load_resource(const WCHAR *name)
+{
+    HMODULE module = GetModuleHandleA(NULL);
+    HRSRC resource;
+    DWORD written;
+    HGLOBAL data;
+    HANDLE file;
+    WCHAR *path;
+    DWORD size;
+    void *ptr;
+
+    path = calloc(MAX_PATH + 1, sizeof(WCHAR));
+    ok(!!path, "Failed to allocate temp path string.\n");
+    GetTempPathW(MAX_PATH + 1, path);
+    wcscat(path, name);
+
+    file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+    ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %u.\n", wine_dbgstr_w(path), GetLastError());
+
+    resource = FindResourceW(module, name, (const WCHAR *)RT_RCDATA);
+    ok(!!resource, "Failed to find resource %s, error %u.\n", wine_dbgstr_w(name), GetLastError());
+
+    data = LoadResource(module, resource);
+    size = SizeofResource(module, resource);
+
+    ptr = LockResource(data);
+
+    WriteFile(file, ptr, size, &written, NULL);
+    ok(written == size, "Failed to write file %s.\n", wine_dbgstr_w(path));
+
+    CloseHandle(file);
+
+    return path;
+}
+
+static void unload_resource(const WCHAR *path)
+{
+    BOOL ret = DeleteFileW(path);
+    ok(ret, "Failed to delete file %s.\n", wine_dbgstr_w(path));
+    free((void *)path);
+}
+
 #define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
 static void _expect_ref(IUnknown* obj, ULONG ref, int line)
 {
@@ -229,7 +271,7 @@ static void test_interfaces(void)
     ok(!ref, "Got outstanding refcount %u.\n", ref);
 }
 
-static void test_openfile(void)
+static void test_openfile(const WCHAR *test_avi_path)
 {
     IMediaStreamFilter *filter;
     IAMMultiMediaStream *pams;
@@ -247,7 +289,7 @@ static void test_openfile(void)
     if (pgraph)
         IGraphBuilder_Release(pgraph);
 
-    hr = IAMMultiMediaStream_OpenFile(pams, L"test.avi", AMMSF_NORENDER);
+    hr = IAMMultiMediaStream_OpenFile(pams, test_avi_path, AMMSF_NORENDER);
     ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
 
     hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
@@ -267,7 +309,7 @@ static void test_openfile(void)
 
     check_interface(filter, &IID_IMediaSeeking, FALSE);
 
-    hr = IAMMultiMediaStream_OpenFile(pams, L"test.avi", 0);
+    hr = IAMMultiMediaStream_OpenFile(pams, test_avi_path, 0);
     ok(hr == S_OK, "Got hr %#x.\n", hr);
 
     check_interface(filter, &IID_IMediaSeeking, TRUE);
@@ -278,7 +320,7 @@ static void test_openfile(void)
     ok(!ref, "Got outstanding refcount %d.\n", ref);
 }
 
-static void test_renderfile(void)
+static void test_renderfile(const WCHAR *test_avi_path)
 {
     IAMMultiMediaStream *pams;
     HRESULT hr;
@@ -305,7 +347,7 @@ static void test_renderfile(void)
     hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
     ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr);
 
-    hr = IAMMultiMediaStream_OpenFile(pams, L"test.avi", 0);
+    hr = IAMMultiMediaStream_OpenFile(pams, test_avi_path, 0);
     ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
 
     hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream);
@@ -5073,7 +5115,7 @@ static void test_ddrawstream_getsetdirectdraw(void)
 
 START_TEST(amstream)
 {
-    HANDLE file;
+    const WCHAR *test_avi_path;
 
     CoInitializeEx(NULL, COINIT_MULTITHREADED);
 
@@ -5088,14 +5130,12 @@ START_TEST(amstream)
     test_media_types();
     test_IDirectDrawStreamSample();
 
-    file = CreateFileW(L"test.avi", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
-    if (file != INVALID_HANDLE_VALUE)
-    {
-        CloseHandle(file);
+    test_avi_path = load_resource(L"test.avi");
 
-        test_openfile();
-        test_renderfile();
-    }
+    test_openfile(test_avi_path);
+    test_renderfile(test_avi_path);
+
+    unload_resource(test_avi_path);
 
     test_audiodata_query_interface();
     test_audiodata_get_info();
diff --git a/dlls/amstream/tests/rsrc.rc b/dlls/amstream/tests/rsrc.rc
new file mode 100644
index 0000000000..e1fc277503
--- /dev/null
+++ b/dlls/amstream/tests/rsrc.rc
@@ -0,0 +1,25 @@
+/*
+ * Resource file for amstream tests.
+ *
+ * Copyright 2020 Anton Baskanov
+ *
+ * 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
+ */
+
+#include "windef.h"
+
+/* ffmpeg -f lavfi -i smptebars -f lavfi -i "sine=frequency=1000" -t 0.1 -r 10 -ar 8000 -f avi -vcodec rawvideo -vf scale=32x24 -acodec pcm_u8 test.avi */
+/* @makedep: test.avi */
+test.avi RCDATA "test.avi"
diff --git a/dlls/amstream/tests/test.avi b/dlls/amstream/tests/test.avi
new file mode 100644
index 0000000000000000000000000000000000000000..70aead54538fbc89b9c563121bbf217a5a78131d
GIT binary patch
literal 12088
zcmWIYbaOM%XJBv)^HlKh3=Y|&#K4e|Qk0WemYHF}z`(Gejgi5 at 2gm>d0Zs-6MhKIE
z2_nLv0Hh_LV#pN8tOo)N48<iyIY10Ht1L66*we(w09hT#JT9mJh~2=#!0;akU}_YA
zrUUh-X#fR4SOJJZ_AxT>Fo4VgsYeH1p?=;HK)Yd51_mj~=xRp!qaiRF0;3@?8Umvs
zFd71*Aut*OqaiRF0;3@?8UmvsFd72GI|RxKiV9qiya*b9Pyk}kxB at e9)Bwf?jYojQ
zV0;jb4nX4^HE81;iKQvUAic-{#CMQ~h$t{KFzf;{LE{|A>OkWhK%;<T8^AFapjr at S
zWZ+=H7|$>)PlA{<N{)uWXb6mkz-S1JhQMeDjE2By2#kinXb6mkz-S1JhQMeDjFb=n
zjSsK at 2NLpAa&v$v<HtzxI2M0`#$%*_;+}qP{+_{ZA$&l#Phwe`skxqov7VuU0eCd!
z2XF*t6pV(zXb6nF5CD}B*Vq{ta`VeFK`X;RE6BD2!P-TO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