Add amstream, atl and avifil32 winetests.
authorDaniel Reimer <reimer.daniel@freenet.de>
Tue, 6 Jul 2010 09:44:43 +0000 (09:44 +0000)
committerDaniel Reimer <reimer.daniel@freenet.de>
Tue, 6 Jul 2010 09:44:43 +0000 (09:44 +0000)
Sync opengl32, powrprof and fix quartz's testlist

svn path=/trunk/; revision=47956

14 files changed:
rostests/winetests/amstream/amstream.c [new file with mode: 0644]
rostests/winetests/amstream/amstream.rbuild [new file with mode: 0644]
rostests/winetests/amstream/testlist.c [new file with mode: 0644]
rostests/winetests/atl/atl.rbuild [new file with mode: 0644]
rostests/winetests/atl/atl_ax.c [new file with mode: 0644]
rostests/winetests/atl/module.c [new file with mode: 0644]
rostests/winetests/atl/testlist.c [new file with mode: 0644]
rostests/winetests/avifil32/api.c [new file with mode: 0644]
rostests/winetests/avifil32/avifil32.rbuild [new file with mode: 0644]
rostests/winetests/avifil32/testlist.c [new file with mode: 0644]
rostests/winetests/directory.rbuild
rostests/winetests/opengl32/opengl.c
rostests/winetests/powrprof/pwrprof.c
rostests/winetests/quartz/testlist.c

diff --git a/rostests/winetests/amstream/amstream.c b/rostests/winetests/amstream/amstream.c
new file mode 100644 (file)
index 0000000..f59bc06
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Unit tests for MultiMedia Stream functions
+ *
+ * Copyright (C) 2009 Christian Costa
+ *
+ * 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 <assert.h>
+
+#define COBJMACROS
+
+#include "wine/test.h"
+#include "initguid.h"
+#include "amstream.h"
+
+#define FILE_LEN 9
+static const char fileA[FILE_LEN] = "test.avi";
+
+IAMMultiMediaStream* pams;
+IDirectDraw7* pdd7 = NULL;
+IDirectDrawSurface7* pdds7 = NULL;
+
+static int create_ammultimediastream(void)
+{
+    return S_OK == CoCreateInstance(
+        &CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMultiMediaStream, (LPVOID*)&pams);
+}
+
+static void release_ammultimediastream(void)
+{
+    IAMMultiMediaStream_Release(pams);
+}
+
+static int create_directdraw(void)
+{
+    HRESULT hr;
+    IDirectDraw* pdd = NULL;
+    DDSURFACEDESC2 ddsd;
+
+    hr = DirectDrawCreate(NULL, &pdd, NULL);
+    ok(hr==DD_OK, "DirectDrawCreate returned: %x\n", hr);
+    if (hr != DD_OK)
+       goto error;
+
+    hr = IDirectDraw_QueryInterface(pdd, &IID_IDirectDraw7, (LPVOID*)&pdd7);
+    ok(hr==DD_OK, "QueryInterface returned: %x\n", hr);
+    if (hr != DD_OK) goto error;
+
+    hr = IDirectDraw7_SetCooperativeLevel(pdd7, GetDesktopWindow(), DDSCL_NORMAL);
+    ok(hr==DD_OK, "SetCooperativeLevel returned: %x\n", hr);
+
+    ZeroMemory(&ddsd, sizeof(ddsd));
+    ddsd.dwSize = sizeof(ddsd);
+    ddsd.dwFlags = DDSD_CAPS;
+    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+    hr = IDirectDraw7_CreateSurface(pdd7, &ddsd, &pdds7, NULL);
+    ok(hr==DD_OK, "CreateSurface returned: %x\n", hr);
+
+    return TRUE;
+
+error:
+    if (pdds7)
+        IDirectDrawSurface7_Release(pdds7);
+    if (pdd7)
+        IDirectDraw7_Release(pdd7);
+    if (pdd)
+        IDirectDraw_Release(pdd);
+
+    return FALSE;
+}
+
+static void release_directdraw(void)
+{
+    IDirectDrawSurface7_Release(pdds7);
+    IDirectDraw7_Release(pdd7);
+}
+
+static void test_openfile(void)
+{
+    HANDLE h;
+    HRESULT hr;
+    WCHAR fileW[FILE_LEN];
+    IGraphBuilder* pgraph;
+
+    if (!create_ammultimediastream())
+        return;
+
+    h = CreateFileA(fileA, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+    if (h == INVALID_HANDLE_VALUE) {
+        release_ammultimediastream();
+        return;
+    }
+
+    MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
+
+    hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
+    ok(hr==S_OK, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr);
+    ok(pgraph==NULL, "Filtergraph should not be created yet\n");
+
+    if (pgraph)
+        IGraphBuilder_Release(pgraph);
+
+    hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0);
+    ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
+
+    hr = IAMMultiMediaStream_GetFilterGraph(pams, &pgraph);
+    ok(hr==S_OK, "IAMMultiMediaStream_GetFilterGraph returned: %x\n", hr);
+    ok(pgraph!=NULL, "Filtergraph should be created\n");
+
+    if (pgraph)
+        IGraphBuilder_Release(pgraph);
+
+    release_ammultimediastream();
+}
+
+static void renderfile(const char * fileA)
+{
+    HRESULT hr;
+    WCHAR fileW[FILE_LEN];
+    IMediaStream *pvidstream = NULL;
+    IDirectDrawMediaStream *pddstream = NULL;
+    IDirectDrawStreamSample *pddsample = NULL;
+
+    if (!create_directdraw())
+        return;
+
+    MultiByteToWideChar(CP_ACP, 0, fileA, -1, fileW, FILE_LEN);
+
+    hr = IAMMultiMediaStream_Initialize(pams, STREAMTYPE_READ, 0, NULL);
+    ok(hr==S_OK, "IAMMultiMediaStream_Initialize returned: %x\n", hr);
+
+    hr = IAMMultiMediaStream_AddMediaStream(pams, (IUnknown*)pdd7, &MSPID_PrimaryVideo, 0, NULL);
+    ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr);
+
+    hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
+    ok(hr==S_OK, "IAMMultiMediaStream_AddMediaStream returned: %x\n", hr);
+
+    hr = IAMMultiMediaStream_OpenFile(pams, fileW, 0);
+    ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
+
+    hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream);
+    ok(hr==S_OK, "IAMMultiMediaStream_GetMediaStream returned: %x\n", hr);
+    if (FAILED(hr)) goto error;
+
+    hr = IMediaStream_QueryInterface(pvidstream, &IID_IDirectDrawMediaStream, (LPVOID*)&pddstream);
+    ok(hr==S_OK, "IMediaStream_QueryInterface returned: %x\n", hr);
+    if (FAILED(hr)) goto error;
+
+    hr = IDirectDrawMediaStream_CreateSample(pddstream, NULL, NULL, 0, &pddsample);
+    todo_wine ok(hr==S_OK, "IDirectDrawMediaStream_CreateSample returned: %x\n", hr);
+
+error:
+    if (pddsample)
+        IDirectDrawMediaSample_Release(pddsample);
+    if (pddstream)
+        IDirectDrawMediaStream_Release(pddstream);
+    if (pvidstream)
+        IMediaStream_Release(pvidstream);
+
+    release_directdraw();
+}
+
+static void test_render(void)
+{
+    HANDLE h;
+
+    if (!create_ammultimediastream())
+        return;
+
+    h = CreateFileA(fileA, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
+    if (h != INVALID_HANDLE_VALUE) {
+        CloseHandle(h);
+        renderfile(fileA);
+    }
+
+    release_ammultimediastream();
+}
+
+START_TEST(amstream)
+{
+    CoInitializeEx(NULL, COINIT_MULTITHREADED);
+    test_openfile();
+    test_render();
+    CoUninitialize();
+}
diff --git a/rostests/winetests/amstream/amstream.rbuild b/rostests/winetests/amstream/amstream.rbuild
new file mode 100644 (file)
index 0000000..27305d6
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+<module name="amstream_winetest" type="win32cui" installbase="bin" installname="amstream_winetest.exe" allowwarnings="true">
+       <include base="amstream_winetest">.</include>
+       <library>wine</library>
+       <library>ole32</library>
+       <library>user32</library>
+       <library>uuid</library>
+       <library>ntdll</library>
+       <library>ddraw</library>
+       <file>amstream.c</file>
+       <file>testlist.c</file>
+</module>
+</group>
diff --git a/rostests/winetests/amstream/testlist.c b/rostests/winetests/amstream/testlist.c
new file mode 100644 (file)
index 0000000..e0d0fd3
--- /dev/null
@@ -0,0 +1,15 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define STANDALONE
+#include "wine/test.h"
+
+extern void func_amstream(void);
+
+const struct test winetest_testlist[] =
+{
+    { "amstream", func_amstream },
+    { 0, 0 }
+};
diff --git a/rostests/winetests/atl/atl.rbuild b/rostests/winetests/atl/atl.rbuild
new file mode 100644 (file)
index 0000000..b158bd5
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+<module name="atl_winetest" type="win32cui" installbase="bin" installname="atl_winetest.exe" allowwarnings="true">
+       <include base="atl_winetest">.</include>
+       <library>wine</library>
+       <library>ole32</library>
+       <library>user32</library>
+       <library>uuid</library>
+       <library>ntdll</library>
+       <library>atl</library>
+       <file>atl_ax.c</file>
+       <file>module.c</file>
+       <file>testlist.c</file>
+</module>
+</group>
diff --git a/rostests/winetests/atl/atl_ax.c b/rostests/winetests/atl/atl_ax.c
new file mode 100644 (file)
index 0000000..8b9966c
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Unit tests for Active Template Library ActiveX functions
+ *
+ * Copyright 2010 Andrew Nguyen
+ *
+ * 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 <stdarg.h>
+#include <stdio.h>
+
+#define COBJMACROS
+
+#include <wine/test.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <wingdi.h>
+#include <winnls.h>
+#include <winerror.h>
+#include <winnt.h>
+#include <wtypes.h>
+#include <olectl.h>
+#include <ocidl.h>
+#include <exdisp.h>
+
+HRESULT WINAPI AtlAxAttachControl(IUnknown *, HWND, IUnknown **);
+
+static ATOM register_class(void)
+{
+    WNDCLASSA wndclassA;
+
+    wndclassA.style = 0;
+    wndclassA.lpfnWndProc = DefWindowProc;
+    wndclassA.cbClsExtra = 0;
+    wndclassA.cbWndExtra = 0;
+    wndclassA.hInstance = GetModuleHandleA(NULL);
+    wndclassA.hIcon = NULL;
+    wndclassA.hCursor = LoadCursorA(NULL, IDC_ARROW);
+    wndclassA.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
+    wndclassA.lpszMenuName = NULL;
+    wndclassA.lpszClassName = "WineAtlTestClass";
+
+    return RegisterClassA(&wndclassA);
+}
+
+static void test_AtlAxAttachControl(void)
+{
+    HWND hwnd = CreateWindowA("WineAtlTestClass", "Wine ATL Test Window", 0,
+                              CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+                              CW_USEDEFAULT, NULL, NULL, NULL, NULL);
+    HRESULT hr;
+    IUnknown *pObj, *pContainer;
+
+    hr = AtlAxAttachControl(NULL, NULL, NULL);
+    ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
+
+    pContainer = (IUnknown *)0xdeadbeef;
+    hr = AtlAxAttachControl(NULL, NULL, &pContainer);
+    ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
+    ok(pContainer == (IUnknown *)0xdeadbeef,
+       "Expected the output container pointer to be untouched, got %p\n", pContainer);
+
+    hr = AtlAxAttachControl(NULL, hwnd, NULL);
+    ok(hr == E_INVALIDARG, "Expected AtlAxAttachControl to return E_INVALIDARG, got 0x%08x\n", hr);
+
+    hr = CoCreateInstance(&CLSID_WebBrowser, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
+                          &IID_IOleObject, (void **)&pObj);
+    ok(hr == S_OK, "Expected CoCreateInstance to return S_OK, got 0x%08x\n", hr);
+
+    if (FAILED(hr))
+    {
+        skip("Couldn't obtain a test IOleObject instance\n");
+        return;
+    }
+
+    hr = AtlAxAttachControl(pObj, NULL, NULL);
+    todo_wine
+    ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
+
+    pContainer = (IUnknown *)0xdeadbeef;
+    hr = AtlAxAttachControl(pObj, NULL, &pContainer);
+    todo_wine
+    ok(hr == S_FALSE, "Expected AtlAxAttachControl to return S_FALSE, got 0x%08x\n", hr);
+    ok(pContainer != (IUnknown *)0xdeadbeef &&
+       pContainer != NULL,
+       "Expected the output container pointer to be initialized to non-NULL, got %p\n", pContainer);
+
+    if (pContainer != (IUnknown *)0xdeadbeef && pContainer != NULL)
+        IUnknown_Release(pContainer);
+
+    hr = AtlAxAttachControl(pObj, hwnd, NULL);
+    ok(hr == S_OK, "Expected AtlAxAttachControl to return S_OK, got 0x%08x\n", hr);
+
+    IUnknown_Release(pObj);
+
+    DestroyWindow(hwnd);
+}
+
+START_TEST(atl_ax)
+{
+    if (!register_class())
+        return;
+
+    CoInitialize(NULL);
+
+    test_AtlAxAttachControl();
+
+    CoUninitialize();
+}
diff --git a/rostests/winetests/atl/module.c b/rostests/winetests/atl/module.c
new file mode 100644 (file)
index 0000000..294d87b
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * ATL test program
+ *
+ * Copyright 2010 Marcus Meissner
+ *
+ *
+ * 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 <stdarg.h>
+#include <stdio.h>
+
+#define COBJMACROS
+
+#include <wine/test.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winuser.h>
+#include <wingdi.h>
+#include <winnls.h>
+#include <winerror.h>
+#include <winnt.h>
+#include <initguid.h>
+#include <wtypes.h>
+#include <olectl.h>
+#include <ocidl.h>
+
+struct _ATL_OBJMAP_ENTRYW;
+struct _AtlCreateWndData;
+struct _ATL_TERMFUNC_ELEM;
+
+struct _ATL_MODULEW
+{
+    UINT cbSize;
+    HINSTANCE m_hInst;
+    HINSTANCE m_hInstResource;
+    HINSTANCE m_hInstTypeLib;
+    struct _ATL_OBJMAP_ENTRYW* m_pObjMap;
+    LONG m_nLockCnt;
+    HANDLE m_hHeap;
+    union
+    {
+        CRITICAL_SECTION m_csTypeInfoHolder;
+        CRITICAL_SECTION m_csStaticDataInit;
+    } u;
+    CRITICAL_SECTION m_csWindowCreate;
+    CRITICAL_SECTION m_csObjMap;
+
+    DWORD dwAtlBuildVer;
+    struct _AtlCreateWndData* m_pCreateWndList;
+    BOOL m_bDestroyHeap;
+    GUID* pguidVer;
+    DWORD m_dwHeaps;
+    HANDLE* m_phHeaps;
+    int m_nHeap;
+    struct _ATL_TERMFUNC_ELEM* m_pTermFuncs;
+};
+
+HRESULT WINAPI AtlModuleInit(struct _ATL_MODULEW* pM, struct _ATL_OBJMAP_ENTRYW* p, HINSTANCE h);
+
+#define MAXSIZE 512
+static void test_StructSize(void)
+{
+        struct _ATL_MODULEW  *tst;
+        HRESULT              hres;
+       int i;
+
+        tst = HeapAlloc (GetProcessHeap(),HEAP_ZERO_MEMORY,MAXSIZE);
+
+       for (i=0;i<MAXSIZE;i++) {
+               tst->cbSize = i;
+               hres = AtlModuleInit(tst, NULL, NULL);
+
+               switch (i)  {
+                case FIELD_OFFSET( struct _ATL_MODULEW, dwAtlBuildVer ):
+               case sizeof(struct _ATL_MODULEW):
+#ifdef _WIN64
+               case sizeof(struct _ATL_MODULEW) + sizeof(void *):
+#endif
+                       ok (hres == S_OK, "AtlModuleInit with %d failed (0x%x).\n", i, (int)hres);
+                       break;
+               default:
+                       ok (FAILED(hres), "AtlModuleInit with %d succeeded? (0x%x).\n", i, (int)hres);
+                       break;
+               }
+       }
+}
+
+START_TEST(module)
+{
+        test_StructSize();
+}
diff --git a/rostests/winetests/atl/testlist.c b/rostests/winetests/atl/testlist.c
new file mode 100644 (file)
index 0000000..aa47da7
--- /dev/null
@@ -0,0 +1,15 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define STANDALONE
+#include "wine/test.h"
+
+extern void func_module(void);
+
+const struct test winetest_testlist[] =
+{
+    { "module", func_module },
+    { 0, 0 }
+};
diff --git a/rostests/winetests/avifil32/api.c b/rostests/winetests/avifil32/api.c
new file mode 100644 (file)
index 0000000..fe295bf
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ * Unit test suite for AVI Functions
+ *
+ * Copyright 2008 Detlef Riekenberg
+ *
+ * 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 <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+#include "wingdi.h"
+#include "vfw.h"
+#include "wine/test.h"
+
+/* ########################### */
+
+static const CHAR winetest0[] = "winetest0";
+static const CHAR winetest1[] = "winetest1";
+static const CHAR testfilename[]  = "wine_avifil32_test.avi";
+
+/* ########################### */
+
+static const DWORD deffh[] = /* file_header */
+{
+    FOURCC_RIFF, 0x34c6 /* length */, formtypeAVI,
+    FOURCC_LIST, 0x1ac /* length */,
+    listtypeAVIHEADER, ckidAVIMAINHDR, sizeof(MainAVIHeader),
+};
+
+static const MainAVIHeader defmah =
+{
+    0x00008256, /* dwMicroSecPerFrame   */
+    0x000080e8, /* dwMaxBytesPerSec     */
+    0x00000000, /* dwPaddingGranularity */
+    0x00000910, /* dwFlags              */
+    1,          /* dwTotalFrames        */
+    0,          /* dwInitialFrames      */
+    2,          /* dwStreams            */
+    0x00100000, /* dwSuggestedBufferSize*/
+    8,          /* dwWidth              */
+    6,          /* dwHeight             */
+    { 0, 0, 0, 0 } /* dwReserved[4] */
+};
+
+static const AVIStreamHeader defash0 =
+{
+    streamtypeVIDEO, /* fccType              */
+    0x30323449,      /* fccHandler           */
+    0x00000000,      /* dwFlags              */
+    0,               /* wPriority            */
+    0,               /* wLanguage            */
+    0,               /* dwInitialFrames      */
+    0x000003e9,      /* dwScale              */
+    0x00007530,      /* dwRate               */
+    0,               /* dwStart              */
+    1,               /* dwLength             */
+    0x00100000,      /* dwSuggestedBufferSize*/
+    0xffffffff,      /* dwQuality            */
+    0,               /* dwSampleSize         */
+    { 0, 0, 0, 0 }   /* short left right top bottom */
+};
+
+static const AVIStreamHeader defash1 =
+{
+    /* AVIStreamHeader */
+    streamtypeAUDIO, /* fccType              */
+    1,               /* fccHandler           */
+    0,               /* dwFlags              */
+    0,               /* wPriority            */
+    0,               /* wLanguage            */
+    0,               /* dwInitialFrames      */
+    1,               /* dwScale              */
+    0x00002b11,      /* dwRate               */
+    0,               /* dwStart              */
+    0x00000665,      /* dwLength             */
+    0x00003000,      /* dwSuggestedBufferSize*/
+    0xffffffff,      /* dwQuality            */
+    2,               /* dwSampleSize         */
+    { 0, 0, 0, 0 }   /* short left right top bottom */
+};
+
+static const PCMWAVEFORMAT defpcmwf =
+{
+    {
+        1,      /* wFormatTag      */
+        2,      /* nChannels       */
+        11025,  /* nSamplesPerSec  */
+        22050,  /* nAvgBytesPerSec */
+        2,      /* nBlockAlign     */
+    },
+    8,      /* wBitsPerSample  */
+};
+
+typedef struct common_avi_headers {
+    DWORD           fh[sizeof(deffh)];
+    MainAVIHeader   mah;
+    AVIStreamHeader ash0;
+    AVIStreamHeader ash1;
+    PCMWAVEFORMAT   pcmwf;
+} COMMON_AVI_HEADERS;
+
+/* Extra data needed to get the VFW API to load the file */
+/* DWORD deffh */
+/* MainAVIHeader mah */
+static const DWORD streamlist[] =
+{
+    FOURCC_LIST, 0xd4 /* length */,
+    listtypeSTREAMHEADER, ckidSTREAMHEADER, 0x38 /* length */,
+};
+/* AVIStreamHeader ash0 */
+static const DWORD videostreamformat[] =
+{
+    ckidSTREAMFORMAT, 0x28 /* length */,
+    0x00000028, 0x00000008, 0x00000006, 0x00180001,
+    0x30323449, 0x00000090, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000,
+};
+static const DWORD padding1[] =
+{
+    ckidAVIPADDING, 0xc /* length */,
+    0x00000004, 0x00000000, 0x63643030
+};
+static const DWORD videopropheader[] =
+{
+    0x70727076, 0x44 /* length */,
+    0x00000000, 0x00000000,
+    0x0000001e, 0x00000008, 0x00000006, 0x00100009,
+    0x00000008, 0x00000006, 0x00000001, 0x00000006,
+    0x00000008, 0x00000006, 0x00000008, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000,
+    FOURCC_LIST, 0x70 /* length */,
+    listtypeSTREAMHEADER, ckidSTREAMHEADER, 0x38 /* length */,
+};
+/* AVIStreamHeader ash1 */
+static const DWORD audiostreamformat_pre[] =
+{
+    ckidSTREAMFORMAT, sizeof(PCMWAVEFORMAT) /* length */,
+};
+/* PCMWAVEFORMAT pcmwf */
+static DWORD data[] =
+{
+    ckidAVIPADDING, 0xc /* length */,
+    0x00000004, 0x00000000, 0x62773130,
+    ckidAVIPADDING, 0xc /* length */,
+    0x6c6d646f, 0x686c6d64, 0x000000f8,
+    FOURCC_LIST, 0x18 /* length */,
+    0x4f464e49,
+    0x54465349, 0xc /* length */,
+    0x6676614c, 0x332e3235, 0x00302e37,
+    ckidAVIPADDING, 0x4 /* length */,
+    0,
+    FOURCC_LIST, 0xd1b /* length */, listtypeAVIMOVIE,
+    0, 0
+};
+
+/* ########################### */
+
+static void test_AVISaveOptions(void)
+{
+    AVICOMPRESSOPTIONS options[2];
+    LPAVICOMPRESSOPTIONS poptions[2];
+    PAVISTREAM streams[2] = {NULL, NULL};
+    HRESULT hres;
+    DWORD   res;
+    LONG    lres;
+
+    poptions[0] = &options[0];
+    poptions[1] = &options[1];
+    ZeroMemory(options, sizeof(options));
+
+    SetLastError(0xdeadbeef);
+    hres = CreateEditableStream(&streams[0], NULL);
+    ok(hres == AVIERR_OK, "0: got 0x%x and %p (expected AVIERR_OK)\n", hres, streams[0]);
+
+    SetLastError(0xdeadbeef);
+    hres = CreateEditableStream(&streams[1], NULL);
+    ok(hres == AVIERR_OK, "1: got 0x%x and %p (expected AVIERR_OK)\n", hres, streams[1]);
+
+    SetLastError(0xdeadbeef);
+    hres = EditStreamSetNameA(streams[0], winetest0);
+    todo_wine ok(hres == AVIERR_OK, "0: got 0x%x (expected AVIERR_OK)\n", hres);
+
+    SetLastError(0xdeadbeef);
+    hres = EditStreamSetNameA(streams[1], winetest1);
+    todo_wine ok(hres == AVIERR_OK, "1: got 0x%x (expected AVIERR_OK)\n", hres);
+
+    if (winetest_interactive) {
+        SetLastError(0xdeadbeef);
+        res = AVISaveOptions(0, ICMF_CHOOSE_DATARATE |ICMF_CHOOSE_KEYFRAME | ICMF_CHOOSE_ALLCOMPRESSORS,
+                             2, streams, poptions);
+        trace("got %u with 0x%x/%u\n", res, GetLastError(), GetLastError());
+    }
+
+    SetLastError(0xdeadbeef);
+    lres = AVISaveOptionsFree(2, poptions);
+    ok(lres == AVIERR_OK, "got 0x%x with 0x%x/%u\n", lres, GetLastError(), GetLastError());
+
+    SetLastError(0xdeadbeef);
+    res = AVIStreamRelease(streams[0]);
+    ok(res == 0, "0: got refcount %u (expected 0)\n", res);
+
+    SetLastError(0xdeadbeef);
+    res = AVIStreamRelease(streams[1]);
+    ok(res == 0, "1: got refcount %u (expected 0)\n", res);
+
+}
+
+/* ########################### */
+
+static void init_test_struct(COMMON_AVI_HEADERS *cah)
+{
+    memcpy(cah->fh, deffh, sizeof(deffh));
+    cah->mah = defmah;
+    cah->ash0 = defash0;
+    cah->ash1 = defash1;
+    cah->pcmwf = defpcmwf;
+}
+
+static void create_avi_file(const COMMON_AVI_HEADERS *cah, char *filename)
+{
+    HANDLE hFile;
+    DWORD written;
+
+    hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+    ok(hFile != INVALID_HANDLE_VALUE, "Couldn't create file\n");
+
+    WriteFile(hFile, &cah->fh, sizeof(deffh), &written, NULL);
+    WriteFile(hFile, &cah->mah, sizeof(MainAVIHeader), &written, NULL);
+    WriteFile(hFile, streamlist, sizeof(streamlist), &written, NULL);
+    WriteFile(hFile, &cah->ash0, 0x38, &written, NULL);
+    WriteFile(hFile, videostreamformat, sizeof(videostreamformat), &written, NULL);
+    WriteFile(hFile, padding1, sizeof(padding1), &written, NULL);
+    WriteFile(hFile, videopropheader, sizeof(videopropheader), &written, NULL);
+    WriteFile(hFile, &cah->ash1, 0x38, &written, NULL);
+    WriteFile(hFile, audiostreamformat_pre, sizeof(audiostreamformat_pre), &written, NULL);
+    WriteFile(hFile, &cah->pcmwf, sizeof(PCMWAVEFORMAT), &written, NULL);
+    WriteFile(hFile, data, sizeof(data), &written, NULL);
+
+    CloseHandle(hFile);
+}
+
+static void test_default_data(void)
+{
+    COMMON_AVI_HEADERS cah;
+    char filename[MAX_PATH];
+    PAVIFILE pFile;
+    int res;
+    LONG lSize;
+    PAVISTREAM pStream0;
+    PAVISTREAM pStream1;
+    AVISTREAMINFO asi0;
+    AVISTREAMINFO asi1;
+    WAVEFORMATEX wfx;
+
+    GetTempPath(MAX_PATH, filename);
+    strcpy(filename+strlen(filename), testfilename);
+
+    init_test_struct(&cah);
+    create_avi_file(&cah, filename);
+
+    res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);
+    ok(res != AVIERR_BADFORMAT, "Unable to open file: error1=%u\n", AVIERR_BADFORMAT);
+    ok(res != AVIERR_MEMORY, "Unable to open file: error2=%u\n", AVIERR_MEMORY);
+    ok(res != AVIERR_FILEREAD, "Unable to open file: error3=%u\n", AVIERR_FILEREAD);
+    ok(res != AVIERR_FILEOPEN, "Unable to open file: error4=%u\n", AVIERR_FILEOPEN);
+    ok(res != REGDB_E_CLASSNOTREG, "Unable to open file: error5=%u\n", REGDB_E_CLASSNOTREG);
+    ok(res == 0, "Unable to open file: error=%u\n", res);
+
+    res = AVIFileGetStream(pFile, &pStream0, 0, 0);
+    ok(res == 0, "Unable to open video stream: error=%u\n", res);
+
+    res = AVIFileGetStream(pFile, &pStream1, 0, 1);
+    ok(res == 0, "Unable to open audio stream: error=%u\n", res);
+
+    res = AVIStreamInfo(pStream0, &asi0, sizeof(AVISTREAMINFO));
+    ok(res == 0, "Unable to read stream info: error=%u\n", res);
+
+    res = AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO));
+    ok(res == 0, "Unable to read stream info: error=%u\n", res);
+
+    res = AVIStreamReadFormat(pStream0, AVIStreamStart(pStream1), NULL, &lSize);
+    ok(res == 0, "Unable to read format size: error=%u\n", res);
+
+    res = AVIStreamReadFormat(pStream1, AVIStreamStart(pStream1), &wfx, &lSize);
+    ok(res == 0, "Unable to read format: error=%u\n", res);
+
+    ok(asi0.fccType == streamtypeVIDEO, "got 0x%x (expected streamtypeVIDEO)\n", asi0.fccType);
+    ok(asi0.fccHandler == 0x30323449, "got 0x%x (expected 0x30323449)\n", asi0.fccHandler);
+    ok(asi0.dwFlags == 0, "got %u (expected 0)\n", asi0.dwFlags);
+    ok(asi0.wPriority == 0, "got %u (expected 0)\n", asi0.wPriority);
+    ok(asi0.wLanguage == 0, "got %u (expected 0)\n", asi0.wLanguage);
+    ok(asi0.dwScale == 1001, "got %u (expected 1001)\n", asi0.dwScale);
+    ok(asi0.dwRate == 30000, "got %u (expected 30000)\n", asi0.dwRate);
+    ok(asi0.dwStart == 0, "got %u (expected 0)\n", asi0.dwStart);
+    ok(asi0.dwLength == 1, "got %u (expected 1)\n", asi0.dwLength);
+    ok(asi0.dwInitialFrames == 0, "got %u (expected 0)\n", asi0.dwInitialFrames);
+    ok(asi0.dwSuggestedBufferSize == 0, "got %u (expected 0)\n", asi0.dwSuggestedBufferSize);
+    ok(asi0.dwQuality == 0xffffffff, "got 0x%x (expected 0xffffffff)\n", asi0.dwQuality);
+    ok(asi0.dwSampleSize == 0, "got %u (expected 0)\n", asi0.dwSampleSize);
+    ok(asi0.rcFrame.left == 0, "got %u (expected 0)\n", asi0.rcFrame.left);
+    ok(asi0.rcFrame.top == 0, "got %u (expected 0)\n", asi0.rcFrame.top);
+    ok(asi0.rcFrame.right == 8, "got %u (expected 8)\n", asi0.rcFrame.right);  /* these are based on the values in the mah and not */
+    ok(asi0.rcFrame.bottom == 6, "got %u (expected 6)\n", asi0.rcFrame.bottom);/* on the ones in the ash which are 0 here */
+    ok(asi0.dwEditCount == 0, "got %u (expected 0)\n", asi0.dwEditCount);
+    ok(asi0.dwFormatChangeCount == 0, "got %u (expected 0)\n", asi0.dwFormatChangeCount);
+
+    ok(asi1.fccType == streamtypeAUDIO, "got 0x%x (expected streamtypeVIDEO)\n", asi1.fccType);
+    ok(asi1.fccHandler == 0x1, "got 0x%x (expected 0x1)\n", asi1.fccHandler);
+    ok(asi1.dwFlags == 0, "got %u (expected 0)\n", asi1.dwFlags);
+    ok(asi1.wPriority == 0, "got %u (expected 0)\n", asi1.wPriority);
+    ok(asi1.wLanguage == 0, "got %u (expected 0)\n", asi1.wLanguage);
+    ok(asi1.dwScale == 1, "got %u (expected 1)\n", asi1.dwScale);
+    ok(asi1.dwRate == 11025, "got %u (expected 11025)\n", asi1.dwRate);
+    ok(asi1.dwStart == 0, "got %u (expected 0)\n", asi1.dwStart);
+    ok(asi1.dwLength == 1637, "got %u (expected 1637)\n", asi1.dwLength);
+    ok(asi1.dwInitialFrames == 0, "got %u (expected 0)\n", asi1.dwInitialFrames);
+    ok(asi1.dwSuggestedBufferSize == 0, "got %u (expected 0)\n", asi1.dwSuggestedBufferSize);
+    ok(asi1.dwQuality == 0xffffffff, "got 0x%x (expected 0xffffffff)\n", asi1.dwQuality);
+    ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize);
+    ok(asi1.rcFrame.left == 0, "got %u (expected 0)\n", asi1.rcFrame.left);
+    ok(asi1.rcFrame.top == 0, "got %u (expected 0)\n", asi1.rcFrame.top);
+    ok(asi1.rcFrame.right == 0, "got %u (expected 0)\n", asi1.rcFrame.right);
+    ok(asi1.rcFrame.bottom == 0, "got %u (expected 0)\n", asi1.rcFrame.bottom);
+    ok(asi1.dwEditCount == 0, "got %u (expected 0)\n", asi1.dwEditCount);
+    ok(asi1.dwFormatChangeCount == 0, "got %u (expected 0)\n", asi1.dwFormatChangeCount);
+
+    ok(wfx.wFormatTag == 1, "got %u (expected 1)\n",wfx.wFormatTag);
+    ok(wfx.nChannels == 2, "got %u (expected 2)\n",wfx.nChannels);
+    ok(wfx.wFormatTag == 1, "got %u (expected 1)\n",wfx.wFormatTag);
+    ok(wfx.nSamplesPerSec == 11025, "got %u (expected 11025)\n",wfx.nSamplesPerSec);
+    ok(wfx.nAvgBytesPerSec == 22050, "got %u (expected 22050)\n",wfx.nAvgBytesPerSec);
+    ok(wfx.nBlockAlign == 2, "got %u (expected 2)\n",wfx.nBlockAlign);
+
+    AVIStreamRelease(pStream0);
+    AVIStreamRelease(pStream1);
+    AVIFileRelease(pFile);
+    ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
+}
+
+static void test_amh_corruption(void)
+{
+    COMMON_AVI_HEADERS cah;
+    char filename[MAX_PATH];
+    PAVIFILE pFile;
+    int res;
+
+    GetTempPath(MAX_PATH, filename);
+    strcpy(filename+strlen(filename), testfilename);
+
+    /* Make sure only AVI files with the proper headers will be loaded */
+    init_test_struct(&cah);
+    cah.fh[3] = mmioFOURCC('A', 'V', 'i', ' ');
+
+    create_avi_file(&cah, filename);
+    res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);
+    ok(res != 0, "Able to open file: error=%u\n", res);
+
+    ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
+}
+
+static void test_ash1_corruption(void)
+{
+    COMMON_AVI_HEADERS cah;
+    char filename[MAX_PATH];
+    PAVIFILE pFile;
+    int res;
+    PAVISTREAM pStream1;
+    AVISTREAMINFO asi1;
+
+    GetTempPath(MAX_PATH, filename);
+    strcpy(filename+strlen(filename), testfilename);
+
+    /* Corrupt the sample size in the audio stream header */
+    init_test_struct(&cah);
+    cah.ash1.dwSampleSize = 0xdeadbeef;
+
+    create_avi_file(&cah, filename);
+
+    res = AVIFileOpen(&pFile, filename, 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 */
+    ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize);
+
+    AVIStreamRelease(pStream1);
+    AVIFileRelease(pFile);
+    ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
+}
+
+static void test_ash1_corruption2(void)
+{
+    COMMON_AVI_HEADERS cah;
+    char filename[MAX_PATH];
+    PAVIFILE pFile;
+    int res;
+    PAVISTREAM pStream1;
+    AVISTREAMINFO asi1;
+
+    GetTempPath(MAX_PATH, filename);
+    strcpy(filename+strlen(filename), testfilename);
+
+    /* Corrupt the block alignment in the audio format header */
+    init_test_struct(&cah);
+    cah.pcmwf.wf.nBlockAlign = 0xdead;
+
+    create_avi_file(&cah, filename);
+
+    res = AVIFileOpen(&pFile, filename, 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. */
+    ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)\n", asi1.dwSampleSize);
+
+    AVIStreamRelease(pStream1);
+    AVIFileRelease(pFile);
+    ok(DeleteFile(filename) !=0, "Deleting file %s failed\n", filename);
+}
+
+/* ########################### */
+
+START_TEST(api)
+{
+
+    AVIFileInit();
+    test_AVISaveOptions();
+    test_default_data();
+    test_amh_corruption();
+    test_ash1_corruption();
+    test_ash1_corruption2();
+    AVIFileExit();
+
+}
diff --git a/rostests/winetests/avifil32/avifil32.rbuild b/rostests/winetests/avifil32/avifil32.rbuild
new file mode 100644 (file)
index 0000000..5c7e070
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<group>
+<module name="avifil32_winetest" type="win32cui" installbase="bin" installname="avifil32_winetest.exe" allowwarnings="true">
+       <include base="avifil32_winetest">.</include>
+       <library>avifil32</library>
+       <library>wine</library>
+       <file>api.c</file>
+       <file>testlist.c</file>
+</module>
+</group>
diff --git a/rostests/winetests/avifil32/testlist.c b/rostests/winetests/avifil32/testlist.c
new file mode 100644 (file)
index 0000000..4215c4a
--- /dev/null
@@ -0,0 +1,15 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define STANDALONE
+#include "wine/test.h"
+
+extern void func_api(void);
+
+const struct test winetest_testlist[] =
+{
+    { "api", func_api },
+    { 0, 0 }
+};
index a35ec8e..3a345e3 100644 (file)
        <directory name="advpack">
                <xi:include href="advpack/advpack.rbuild" />
        </directory>
+       <directory name="amstream">
+               <xi:include href="amstream/amstream.rbuild" />
+       </directory>
+       <directory name="atl">
+               <xi:include href="atl/atl.rbuild" />
+       </directory>
+       <directory name="avifil32">
+               <xi:include href="avifil32/avifil32.rbuild" />
+       </directory>
        <directory name="browseui">
                <xi:include href="browseui/browseui.rbuild" />
        </directory>
        <directory name="oleaut32">
                <xi:include href="oleaut32/oleaut32.rbuild" />
        </directory>
+       <directory name="opengl32">
+               <xi:include href="opengl32/opengl32.rbuild" />
+       </directory>
        <directory name="pdh">
                <xi:include href="pdh/pdh.rbuild" />
        </directory>
index b2d8e18..2b81dda 100644 (file)
 #include <wingdi.h>
 #include "wine/test.h"
 
+void WINAPI glClearColor(float red, float green, float blue, float alpha);
+void WINAPI glClear(unsigned int mask);
+void WINAPI glFinish(void);
+#define GL_COLOR_BUFFER_BIT 0x00004000
 const unsigned char * WINAPI glGetString(unsigned int);
 #define GL_VENDOR 0x1F00
 #define GL_RENDERER 0x1F01
@@ -499,6 +503,148 @@ static void test_acceleration(HDC hdc)
     }
 }
 
+static void test_bitmap_rendering(void)
+{
+    PIXELFORMATDESCRIPTOR pfd;
+    int i, iPixelFormat=0;
+    unsigned int nFormats;
+    HGLRC hglrc;
+    BITMAPINFO biDst;
+    HBITMAP bmpDst, oldDst;
+    HDC hdcDst, hdcScreen;
+    UINT32 *dstBuffer;
+
+    memset(&biDst, 0, sizeof(BITMAPINFO));
+    biDst.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    biDst.bmiHeader.biWidth = 2;
+    biDst.bmiHeader.biHeight = -2;
+    biDst.bmiHeader.biPlanes = 1;
+    biDst.bmiHeader.biBitCount = 32;
+    biDst.bmiHeader.biCompression = BI_RGB;
+
+    hdcScreen = CreateCompatibleDC(0);
+    if(GetDeviceCaps(hdcScreen, BITSPIXEL) != 32)
+    {
+        DeleteDC(hdcScreen);
+        trace("Skipping bitmap rendering test\n");
+        return;
+    }
+
+    hdcDst = CreateCompatibleDC(hdcScreen);
+    bmpDst = CreateDIBSection(hdcDst, &biDst, DIB_RGB_COLORS, (void**)&dstBuffer, NULL, 0);
+    oldDst = SelectObject(hdcDst, bmpDst);
+
+    /* Pick a pixel format by hand because ChoosePixelFormat is unreliable */
+    nFormats = DescribePixelFormat(hdcDst, 0, 0, NULL);
+    for(i=1; i<=nFormats; i++)
+    {
+        memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
+        DescribePixelFormat(hdcDst, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+
+        if((pfd.dwFlags & PFD_DRAW_TO_BITMAP) &&
+           (pfd.dwFlags & PFD_SUPPORT_OPENGL) &&
+           (pfd.cColorBits == 32) &&
+           (pfd.cAlphaBits == 8) )
+        {
+            iPixelFormat = i;
+            break;
+        }
+    }
+
+    if(!iPixelFormat)
+    {
+        skip("Unable to find a suitable pixel format\n");
+    }
+    else
+    {
+        SetPixelFormat(hdcDst, iPixelFormat, &pfd);
+        hglrc = wglCreateContext(hdcDst);
+        todo_wine ok(hglrc != NULL, "Unable to create a context\n");
+
+        if(hglrc)
+        {
+            wglMakeCurrent(hdcDst, hglrc);
+
+            /* Note this is RGBA but we read ARGB back */
+            glClearColor((float)0x22/0xff, (float)0x33/0xff, (float)0x44/0xff, (float)0x11/0xff);
+            glClear(GL_COLOR_BUFFER_BIT);
+            glFinish();
+
+            /* Note apparently the alpha channel is not supported by the software renderer (bitmap only works using software) */
+            ok(dstBuffer[0] == 0x223344, "Expected color=0x223344, received color=%x\n", dstBuffer[0]);
+
+            wglMakeCurrent(NULL, NULL);
+            wglDeleteContext(hglrc);
+        }
+    }
+
+    SelectObject(hdcDst, oldDst);
+    DeleteObject(bmpDst);
+    DeleteDC(hdcDst);
+
+    DeleteDC(hdcScreen);
+}
+
+struct wgl_thread_param
+{
+    HANDLE test_finished;
+    HGLRC hglrc;
+    BOOL hglrc_deleted;
+};
+
+static DWORD WINAPI wgl_thread(void *param)
+{
+    struct wgl_thread_param *p = param;
+
+    p->hglrc_deleted = wglDeleteContext(p->hglrc);
+    SetEvent(p->test_finished);
+
+    return 0;
+}
+
+static void test_deletecontext(HDC hdc)
+{
+    struct wgl_thread_param thread_params;
+    HGLRC hglrc = wglCreateContext(hdc);
+    HANDLE thread_handle;
+    DWORD res, tid;
+
+    if(!hglrc)
+    {
+        skip("wglCreateContext failed!\n");
+        return;
+    }
+
+    res = wglMakeCurrent(hdc, hglrc);
+    if(!res)
+    {
+        skip("wglMakeCurrent failed!\n");
+        return;
+    }
+
+    /* WGL doesn't allow you to delete a context from a different thread than the one in which it is current.
+     * This differs from GLX which does allow it but it delays actual deletion until the context becomes not current.
+     */
+    thread_params.hglrc = hglrc;
+    thread_params.test_finished = CreateEvent(NULL, FALSE, FALSE, NULL);
+    thread_handle = CreateThread(NULL, 0, wgl_thread, &thread_params, 0, &tid);
+    ok(!!thread_handle, "Failed to create thread, last error %#x.\n", GetLastError());
+    if(thread_handle)
+    {
+        WaitForSingleObject(thread_handle, INFINITE);
+        ok(thread_params.hglrc_deleted == FALSE, "Attempt to delete WGL context from another thread passed but should fail!\n");
+    }
+    CloseHandle(thread_params.test_finished);
+
+    res = wglDeleteContext(hglrc);
+    ok(res == TRUE, "wglDeleteContext failed\n");
+
+    /* WGL makes a context not current when deleting it. This differs from GLX behavior where
+     * deletion takes place when the thread becomes not current. */
+    hglrc = wglGetCurrentContext();
+    ok(hglrc == NULL, "A WGL context is active while none was expected\n");
+}
+
 static void test_make_current_read(HDC hdc)
 {
     int res;
@@ -650,6 +796,75 @@ static void test_opengl3(HDC hdc)
     }
 }
 
+static void test_minimized(void)
+{
+    PIXELFORMATDESCRIPTOR pf_desc =
+    {
+        sizeof(PIXELFORMATDESCRIPTOR),
+        1,                     /* version */
+        PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
+        PFD_TYPE_RGBA,
+        24,                    /* 24-bit color depth */
+        0, 0, 0, 0, 0, 0,      /* color bits */
+        0,                     /* alpha buffer */
+        0,                     /* shift bit */
+        0,                     /* accumulation buffer */
+        0, 0, 0, 0,            /* accum bits */
+        32,                    /* z-buffer */
+        0,                     /* stencil buffer */
+        0,                     /* auxiliary buffer */
+        PFD_MAIN_PLANE,        /* main layer */
+        0,                     /* reserved */
+        0, 0, 0                /* layer masks */
+    };
+    int pixel_format;
+    HWND window;
+    LONG style;
+    HGLRC ctx;
+    BOOL ret;
+    HDC dc;
+
+    window = CreateWindowA("static", "opengl32_test",
+            WS_POPUP | WS_MINIMIZE, 0, 0, 640, 480, 0, 0, 0, 0);
+    ok(!!window, "Failed to create window, last error %#x.\n", GetLastError());
+
+    dc = GetDC(window);
+    ok(!!dc, "Failed to get DC.\n");
+
+    pixel_format = ChoosePixelFormat(dc, &pf_desc);
+    if (!pixel_format)
+    {
+        win_skip("Failed to find pixel format.\n");
+        ReleaseDC(window, dc);
+        DestroyWindow(window);
+        return;
+    }
+
+    ret = SetPixelFormat(dc, pixel_format, &pf_desc);
+    ok(ret, "Failed to set pixel format, last error %#x.\n", GetLastError());
+
+    style = GetWindowLongA(window, GWL_STYLE);
+    ok(style & WS_MINIMIZE, "Window should be minimized, got style %#x.\n", style);
+
+    ctx = wglCreateContext(dc);
+    ok(!!ctx, "Failed to create GL context, last error %#x.\n", GetLastError());
+
+    ret = wglMakeCurrent(dc, ctx);
+    ok(ret, "Failed to make context current, last error %#x.\n", GetLastError());
+
+    style = GetWindowLongA(window, GWL_STYLE);
+    ok(style & WS_MINIMIZE, "window should be minimized, got style %#x.\n", style);
+
+    ret = wglMakeCurrent(NULL, NULL);
+    ok(ret, "Failed to clear current context, last error %#x.\n", GetLastError());
+
+    ret = wglDeleteContext(ctx);
+    ok(ret, "Failed to delete GL context, last error %#x.\n", GetLastError());
+
+    ReleaseDC(window, dc);
+    DestroyWindow(window);
+}
+
 START_TEST(opengl)
 {
     HWND hwnd;
@@ -704,6 +919,8 @@ START_TEST(opengl)
         res = SetPixelFormat(hdc, iPixelFormat, &pfd);
         ok(res, "SetPixelformat failed: %x\n", GetLastError());
 
+        test_bitmap_rendering();
+        test_minimized();
         test_dc(hwnd, hdc);
 
         hglrc = wglCreateContext(hdc);
@@ -732,6 +949,7 @@ START_TEST(opengl)
             return;
         }
 
+        test_deletecontext(hdc);
         test_makecurrent(hdc);
         test_setpixelformat(hdc);
         test_sharelists(hdc);
index 34bf0fe..4820ef9 100644 (file)
@@ -10,7 +10,7 @@
 #include "powrprof.h"
 #include "assert.h"
 #include "winnt.h"
-#include "wine/unicode.h"
+
 /*
    LONG WINAPI RegOpenCurrentUser(REGSAM a,PHKEY b)
    {
@@ -23,18 +23,6 @@ unsigned int g_NumPwrSchemesEnumerated = 0;
 unsigned int g_ActivePwrScheme = 3;
 unsigned int g_TempPwrScheme = 99;
 
-#if 0 // FIXME: needed to build. Please update pwrprof winetest.
-typedef struct _PROCESSOR_POWER_INFORMATION {
-   ULONG Number;
-   ULONG MaxMhz;
-   ULONG CurrentMhz;
-   ULONG MhzLimit;
-   ULONG MaxIdleState;
-   ULONG CurrentIdleState;
-} PROCESSOR_POWER_INFORMATION,
-*PPROCESSOR_POWER_INFORMATION;
-#endif
-
 POWER_POLICY g_PowerPolicy;
 
 static const WCHAR szMachPowerPoliciesSubKey[] = { 'S', 'O', 'F', 'T', 'W', 'A', 'R',
index bc231d1..c5d360b 100644 (file)
@@ -7,21 +7,23 @@
 #include "wine/test.h"
 
 extern void func_avisplitter(void);
-extern void func_videorenderer(void);
-extern void func_referenceclock(void);
-extern void func_misc(void);
-extern void func_memallocator(void);
-extern void func_filtermapper(void);
+extern void func_dsoundrender(void);
 extern void func_filtergraph(void);
+extern void func_filtermapper(void);
+extern void func_memallocator(void);
+extern void func_misc(void);
+extern void func_referenceclock(void);
+extern void func_videorenderer(void);
 
 const struct test winetest_testlist[] =
 {
     { "avisplitter", func_avisplitter },
+       { "dsoundrender", func_dsoundrender },
+       { "filtergraph", func_filtergraph },
+       { "filtermapper", func_filtermapper },
+       { "memallocator", func_memallocator },
+       { "misc", func_misc },
        { "videorenderer", func_videorenderer },
        { "referenceclock", func_referenceclock },
-       { "misc", func_misc },
-       { "memallocator", func_memallocator },
-       { "filtermapper", func_filtermapper },
-       { "filtergraph", func_filtergraph },
     { 0, 0 }
 };