Akihiro Sagawa : winmm/tests: Add tests for visibility of video window.
Alexandre Julliard
julliard at winehq.org
Wed Aug 10 14:54:33 CDT 2022
Module: wine
Branch: master
Commit: 524a92fb330c9bc6c587a76e65d7807e5dcad9fa
URL: https://gitlab.winehq.org/wine/wine/-/commit/524a92fb330c9bc6c587a76e65d7807e5dcad9fa
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Sun Jul 31 20:49:25 2022 +0900
winmm/tests: Add tests for visibility of video window.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
---
dlls/winmm/tests/Makefile.in | 3 ++
dlls/winmm/tests/mci.c | 92 +++++++++++++++++++++++++++++++++++++++++++
dlls/winmm/tests/rsrc.rc | 25 ++++++++++++
dlls/winmm/tests/test.mpg | Bin 0 -> 12288 bytes
4 files changed, 120 insertions(+)
diff --git a/dlls/winmm/tests/Makefile.in b/dlls/winmm/tests/Makefile.in
index 1b191cb5747..2b475dd89c3 100644
--- a/dlls/winmm/tests/Makefile.in
+++ b/dlls/winmm/tests/Makefile.in
@@ -12,3 +12,6 @@ C_SRCS = \
mmio.c \
timer.c \
wave.c
+
+RC_SRCS = \
+ rsrc.rc
diff --git a/dlls/winmm/tests/mci.c b/dlls/winmm/tests/mci.c
index 2e31cf51708..cc73e083b1f 100644
--- a/dlls/winmm/tests/mci.c
+++ b/dlls/winmm/tests/mci.c
@@ -23,6 +23,7 @@
#include "windows.h"
#include "mmsystem.h"
#include "mmreg.h"
+#include "digitalv.h"
#include "wine/test.h"
/* The tests use the MCI's own save capability to create the tempfile.wav to play.
@@ -37,6 +38,7 @@ typedef union {
MCI_GETDEVCAPS_PARMS caps;
MCI_SYSINFO_PARMSA sys;
MCI_SEEK_PARMS seek;
+ MCI_DGV_OPEN_PARMSW dgv_open;
MCI_GENERIC_PARMS gen;
} MCI_PARMS_UNION;
@@ -139,6 +141,31 @@ static BOOL spurious_message(LPMSG msg)
return FALSE;
}
+static WCHAR *load_resource(const WCHAR *name)
+{
+ static WCHAR pathW[MAX_PATH];
+ DWORD written;
+ HANDLE file;
+ HRSRC res;
+ void *ptr;
+
+ GetTempPathW(ARRAY_SIZE(pathW), pathW);
+ wcscat(pathW, name);
+
+ file = CreateFileW(pathW, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+ ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %lu.\n",
+ wine_dbgstr_w(pathW), GetLastError());
+
+ res = FindResourceW(NULL, name, (LPCWSTR)RT_RCDATA);
+ ok(!!res, "Failed to load resource, error %lu.\n", GetLastError());
+ ptr = LockResource(LoadResource(GetModuleHandleA(NULL), res));
+ WriteFile(file, ptr, SizeofResource( GetModuleHandleA(NULL), res), &written, NULL);
+ ok(written == SizeofResource(GetModuleHandleA(NULL), res), "Failed to write resource.\n");
+ CloseHandle(file);
+
+ return pathW;
+}
+
/* A single ok() in each code path allows us to prefix this with todo_wine */
#define test_notification(hwnd, command, type) test_notification_dbg(hwnd, command, type, __LINE__)
static void test_notification_dbg(HWND hwnd, const char* command, WPARAM type, int line)
@@ -1439,6 +1466,68 @@ static void test_threads(void)
ok(mr == 0, "close gave: 0x%lx\n", mr);
}
+static BOOL CALLBACK my_visible_window_proc(HWND hwnd, LPARAM param)
+{
+ HWND *ret = (HWND *)param;
+ DWORD pid;
+
+ GetWindowThreadProcessId(hwnd, &pid);
+ if (pid != GetCurrentProcessId())
+ return TRUE;
+
+ if (GetWindowLongW(hwnd, GWL_STYLE) & WS_VISIBLE)
+ {
+ *ret = hwnd;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void test_video_window(void)
+{
+ const WCHAR *filename = load_resource(L"test.mpg");
+ MCI_PARMS_UNION parm;
+ HWND video_window;
+ MCIDEVICEID id;
+ MCIERROR err;
+ BOOL ret;
+
+ parm.dgv_open.lpstrDeviceType = (WCHAR *)L"MPEGVideo";
+ parm.dgv_open.lpstrElementName = (WCHAR *)filename;
+ err = mciSendCommandW(0, MCI_OPEN, MCI_OPEN_ELEMENT | MCI_OPEN_TYPE, (DWORD_PTR)&parm);
+ ok(!err, "Got %s.\n", dbg_mcierr(err));
+ id = parm.dgv_open.wDeviceID;
+
+ err = mciSendCommandW(id, MCI_PLAY, 0, (DWORD_PTR)&parm);
+ ok(!err, "Got %s.\n", dbg_mcierr(err));
+
+ video_window = NULL;
+ EnumWindows(my_visible_window_proc, (LPARAM)&video_window);
+ ok(video_window != NULL, "Video window should be shown.\n");
+
+ err = mciSendCommandW(id, MCI_STOP, 0, (DWORD_PTR)&parm);
+ ok(!err, "Got %s.\n", dbg_mcierr(err));
+
+ todo_wine ok(IsWindowVisible(video_window), "Video window should be visible.\n");
+
+ err = mciSendCommandW(id, MCI_PLAY, 0, (DWORD_PTR)&parm);
+ ok(!err, "Got %s.\n", dbg_mcierr(err));
+
+ ok(IsWindowVisible(video_window), "Video window should be visible.\n");
+
+ err = mciSendCommandW(id, MCI_SEEK, MCI_SEEK_TO_START, (DWORD_PTR)&parm);
+ ok(!err, "Got %s.\n", dbg_mcierr(err));
+
+ todo_wine ok(IsWindowVisible(video_window), "Video window should be visible.\n");
+
+ err = mciSendCommandW(id, MCI_CLOSE, 0, 0);
+ ok(!err, "Got %s.\n", dbg_mcierr(err));
+
+ ret = DeleteFileW(filename);
+ ok(ret, "Failed to delete %s, error %lu.\n", debugstr_w(filename), GetLastError());
+}
+
START_TEST(mci)
{
char curdir[MAX_PATH], tmpdir[MAX_PATH];
@@ -1463,6 +1552,9 @@ START_TEST(mci)
test_asyncWaveTypeMpegvideo(hwnd);
}else
skip("No output devices available, skipping all output tests\n");
+
+ test_video_window();
+
/* Win9X hangs when exiting with something still open. */
err = mciSendStringA("close all", NULL, 0, hwnd);
ok(!err,"final close all returned %s\n", dbg_mcierr(err));
diff --git a/dlls/winmm/tests/rsrc.rc b/dlls/winmm/tests/rsrc.rc
new file mode 100644
index 00000000000..b5fde1c39ba
--- /dev/null
+++ b/dlls/winmm/tests/rsrc.rc
@@ -0,0 +1,25 @@
+/*
+ * Resource file for mci tests.
+ *
+ * Copyright 2022 Akihiro Sagawa
+ *
+ * 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.16 -r 25 -f mpeg -vcodec mpeg1video -vf scale=32x24 -acodec mp2 test.mpg */
+/* @makedep: test.mpg */
+test.mpg RCDATA "test.mpg"
diff --git a/dlls/winmm/tests/test.mpg b/dlls/winmm/tests/test.mpg
new file mode 100644
index 00000000000..97bb1abae1d
Binary files /dev/null and b/dlls/winmm/tests/test.mpg differ
More information about the wine-cvs
mailing list