Sweden-Number/dlls/d3dx9_36/tests/line.c

94 lines
3.0 KiB
C

/*
* Copyright 2010 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 "wine/test.h"
#include "d3dx9.h"
static void test_create_line(IDirect3DDevice9* device)
{
HRESULT hr;
LPD3DXLINE line = NULL;
LPDIRECT3DDEVICE9 return_device;
ULONG ref;
hr = D3DXCreateLine(NULL, &line);
ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateLine(device, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateLine(device, &line);
ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);
if (FAILED(hr))
{
return;
}
hr = ID3DXLine_GetDevice(line, NULL);
ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
hr = ID3DXLine_GetDevice(line, &return_device);
ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
ok(return_device == device, "Expected line device %p, got %p\n", device, return_device);
ref = IDirect3DDevice9_Release(return_device);
ok(ref == 2, "Got %x references to device %p, expected 2\n", ref, return_device);
ref = ID3DXLine_Release(line);
ok(ref == 0, "Got %x references to line %p, expected 0\n", ref, line);
}
START_TEST(line)
{
HWND wnd;
IDirect3D9* d3d;
IDirect3DDevice9* device;
D3DPRESENT_PARAMETERS d3dpp;
HRESULT hr;
wnd = CreateWindow("static", "d3dx9_test", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (!wnd) {
skip("Couldn't create application window\n");
return;
}
if (!d3d) {
skip("Couldn't create IDirect3D9 object\n");
DestroyWindow(wnd);
return;
}
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, wnd, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &device);
if (FAILED(hr)) {
skip("Failed to create IDirect3DDevice9 object %#x\n", hr);
IDirect3D9_Release(d3d);
DestroyWindow(wnd);
return;
}
test_create_line(device);
IDirect3DDevice9_Release(device);
IDirect3D9_Release(d3d);
DestroyWindow(wnd);
}