Jeremy Drake wrote:
This integrates the scenarios that I wasn't testing from Nikolay Sivov's patch to the tests of 12/7. Also works around some issues I was running into trying to write wide strings as L"foo".
dlls/oleaut32/tests/olepicture.c | 311 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 311 insertions(+), 0 deletions(-)
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c index 2b5b8bb..2929bd7 100644 --- a/dlls/oleaut32/tests/olepicture.c +++ b/dlls/oleaut32/tests/olepicture.c @@ -489,6 +489,315 @@ static void test_OleCreatePictureIndirect(void) IPicture_Release(pict); }
+static void test_VerifyPictureType(IDispatch *pdisp, short expectedtype, int caller_line) +{
- IPicture *pict;
- HRESULT hr;
- short type;
- pict = (void*)0xdeadbeef;
- hr = IDispatch_QueryInterface(pdisp, &IID_IPicture, (LPVOID*)&pict);
- ok(hr == S_OK, "hr %08x\n", hr);
- ok(pict != (void*)0xdeadbeef && pict != NULL, "pict ptr, caller line %d\n", caller_line);
- if (SUCCEEDED(hr))
- {
type = 0xdead;
hr = IPicture_get_Type(pict, &type);
ok(hr == S_OK, "hr %08x, caller line %d\n", hr, caller_line);
ok(type == expectedtype, "type %hd, expected %hd, caller line %d\n", type, expectedtype, caller_line);
IPicture_Release(pict);
- }
+}
+static const WCHAR nopath[] = { '\', 'n', 'o', 'p', 'a', 't', 'h', 0 }; +static void test_OleLoadPictureFile(void) +{
- IDispatch *disp;
- HRESULT hr;
- char filename[MAX_PATH];
- VARIANT varFilename;
- HANDLE file;
- DWORD written;
- DWORD widestringlen;
- BSTR tmp = NULL, tmp2 = NULL;
- GetTempFileNameA(".", "gif", 0, filename);
- file = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
- ok(file != INVALID_HANDLE_VALUE, "file creation error %u\n", GetLastError());
- if (file == INVALID_HANDLE_VALUE) return;
- WriteFile(file, gif4pixel, sizeof(gif4pixel), &written, NULL);
- ok(written == sizeof(gif4pixel), "write\n");
- VariantInit(&varFilename);
- V_VT(&varFilename) = VT_ERROR;
- V_ERROR(&varFilename) = DISP_E_PARAMNOTFOUND;
- todo_wine
- {
disp = (void*)0xdeadbeef;
hr = OleLoadPictureFileEx(varFilename, 2, 2, LP_DEFAULT, &disp);
ok(hr == S_OK, "hr %08x\n", hr);
ok(disp != (void*)0xdeadbeef, "dispatch ptr\n");
if (disp != (void*)0xdeadbeef)
{
test_VerifyPictureType(disp, PICTYPE_NONE, __LINE__);
IDispatch_Release(disp);
}
- }
- widestringlen = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
- ok(widestringlen != 0, "determining wide string length error %u\n", GetLastError());
- if (widestringlen == 0) return;
- V_VT(&varFilename) = VT_BSTR;
- V_BSTR(&varFilename) = SysAllocStringLen(NULL, widestringlen - 1);
- ok(MultiByteToWideChar(CP_ACP, 0, filename, -1, V_BSTR(&varFilename), widestringlen),
"filename to wide string conversion error %u\n", GetLastError());
- disp = (void*)0xdeadbeef;
- todo_wine
- {
hr = OleLoadPictureFile(varFilename, &disp);
ok(hr == CTL_E_PERMISSIONDENIED, "hr %08x\n", hr);
- }
- ok(disp == (void*)0xdeadbeef, "dispatch ptr\n");
- CloseHandle(file);
- disp = (void*)0xdeadbeef;
- todo_wine
- {
hr = OleLoadPictureFileEx(varFilename, 2, 2, LP_DEFAULT, &disp);
ok(hr == S_OK, "hr %08x\n", hr);
ok(disp != (void*)0xdeadbeef && disp != NULL, "dispatch ptr\n");
if (SUCCEEDED(hr))
{
test_VerifyPictureType(disp, PICTYPE_BITMAP, __LINE__);
IDispatch_Release(disp);
}
- }
- todo_wine
- {
disp = (void*)0xdeadbeef;
hr = OleLoadPictureFile(varFilename, &disp);
ok(hr == S_OK, "hr %08x\n", hr);
ok(disp != (void*)0xdeadbeef && disp != NULL, "dispatch ptr\n");
if (SUCCEEDED(hr))
{
test_VerifyPictureType(disp, PICTYPE_BITMAP, __LINE__);
IDispatch_Release(disp);
}
- }
- ok(MoveFileA(filename, "33"), "move file\n");
- file = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
- ok(file != INVALID_HANDLE_VALUE, "file creation error %u\n", GetLastError());
- if (file != INVALID_HANDLE_VALUE)
- {
WriteFile(file, "this is not a valid picture", 28, &written, NULL);
ok(written == 28, "write\n");
CloseHandle(file);
disp = (void*)0xdeadbeef;
todo_wine
{
hr = OleLoadPictureFile(varFilename, &disp);
ok(hr == CTL_E_INVALIDPICTURE, "hr %08x\n", hr);
ok(disp == NULL, "dispatch ptr\n"); /* XXX this one is not unmodified!! */
}
DeleteFileA(filename);
- }
- tmp = SysAllocString(nopath);
- ok(tmp != NULL, "SysAllocString\n");
- if (tmp != NULL)
- {
hr = VarBstrCat(V_BSTR(&varFilename), tmp, &tmp2);
if (SUCCEEDED(hr))
{
SysFreeString(V_BSTR(&varFilename));
V_BSTR(&varFilename) = tmp2;
disp = (void*)0xdeadbeef;
todo_wine
{
hr = OleLoadPictureFile(varFilename, &disp);
ok(hr == CTL_E_PATHNOTFOUND, "hr %08x\n", hr);
}
ok(disp == (void*)0xdeadbeef, "dispatch ptr\n");
}
SysFreeString(tmp);
- }
- VariantClear(&varFilename);
- VariantInit(&varFilename);
- V_VT(&varFilename) = VT_I4;
- V_I4(&varFilename) = 33;
- todo_wine
- {
disp = (void*)0xdeadbeef;
hr = OleLoadPictureFile(varFilename, &disp);
ok(hr == S_OK, "hr %08x\n", hr);
ok(disp != (void*)0xdeadbeef && disp != NULL, "dispatch ptr\n");
if (SUCCEEDED(hr))
{
test_VerifyPictureType(disp, PICTYPE_BITMAP, __LINE__);
IDispatch_Release(disp);
}
- }
- ok(V_VT(&varFilename) == VT_I4 && V_I4(&varFilename) == 33, "variant unmodified\n");
- DeleteFileA("33");
- VariantClear(&varFilename);
+}
+static void test_OleLoadPicturePath(void) +{
- static const WCHAR fileproto[] = { 'f','i','l','e',':','/','/',0 };
- IDispatch *disp;
- HRESULT hr;
- char filename[MAX_PATH];
- char absfile[MAX_PATH];
- HANDLE file;
- DWORD written;
- DWORD widestringlen;
- BSTR bstrname = NULL;
- BSTR tmp = NULL, tmp2 = NULL;
- GetTempFileNameA(".", "gif", 0, filename);
- GetFullPathNameA(filename, MAX_PATH, absfile, NULL);
- file = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
- ok(file != INVALID_HANDLE_VALUE, "file creation error %u\n", GetLastError());
- if (file == INVALID_HANDLE_VALUE) return;
- WriteFile(file, gif4pixel, sizeof(gif4pixel), &written, NULL);
- ok(written == sizeof(gif4pixel), "write\n");
- widestringlen = MultiByteToWideChar(CP_ACP, 0, absfile, -1, NULL, 0);
- ok(widestringlen != 0, "determining wide string length error %u\n", GetLastError());
- if (widestringlen == 0) return;
- bstrname = SysAllocStringLen(NULL, widestringlen - 1);
- ok(MultiByteToWideChar(CP_ACP, 0, absfile, -1, bstrname, widestringlen),
"filename to wide string conversion error %u\n", GetLastError());
- disp = (void*)0xdeadbeef;
- hr = OleLoadPicturePath(bstrname, NULL, 0, 0, &IID_IDispatch, (LPVOID*)&disp);
- if (hr == E_UNEXPECTED)
- {
/* E_UNEXPECTED is returned from OleLoadPicturePath on win95 without IE installed */
win_skip("OleLoadPicturePath seems to not work on this platform. No IE?\n");
CloseHandle(file);
DeleteFileA(filename);
return;
- }
- ok(hr == INET_E_DATA_NOT_AVAILABLE /*>=XP*/ ||
hr == E_FAIL /*<=2k*/, "hr %08x\n", hr);
- todo_wine ok(disp == NULL, "dispatch ptr\n");
- CloseHandle(file);
- disp = (void*)0xdeadbeef;
- todo_wine
- {
hr = OleLoadPicturePath(bstrname, NULL, 0, 0, &IID_IDispatch, (LPVOID*)&disp);
ok(hr == S_OK, "hr %08x\n", hr);
ok(disp != NULL && disp != (void*)0xdeadbeef, "dispatch ptr\n");
if (SUCCEEDED(hr))
{
test_VerifyPictureType(disp, PICTYPE_BITMAP, __LINE__);
IDispatch_Release(disp);
}
- }
- disp = (void*)0xdeadbeef;
- todo_wine
- {
tmp = SysAllocString(fileproto);
hr = VarBstrCat(tmp, bstrname, &tmp2);
SysFreeString(tmp);
tmp = NULL;
hr = OleLoadPicturePath(tmp2, NULL, 0, 0, &IID_IDispatch, (LPVOID*)&disp);
ok(hr == S_OK, "hr %08x\n", hr);
ok(disp != NULL && disp != (void*)0xdeadbeef, "dispatch ptr\n");
if (SUCCEEDED(hr))
{
test_VerifyPictureType(disp, PICTYPE_BITMAP, __LINE__);
IDispatch_Release(disp);
}
SysFreeString(tmp2);
tmp2 = NULL;
- }
- widestringlen = MultiByteToWideChar(CP_ACP, 0, filename, -1, NULL, 0);
- ok(widestringlen != 0, "determining wide string length error %u\n", GetLastError());
- if (widestringlen == 0) return;
- tmp = SysAllocStringLen(NULL, widestringlen - 1);
- ok(MultiByteToWideChar(CP_ACP, 0, filename, -1, tmp, widestringlen),
"filename to wide string conversion error %u\n", GetLastError());
- disp = (void*)0xdeadbeef;
- todo_wine
- {
hr = OleLoadPicturePath(tmp, NULL, 0, 0, &IID_IDispatch, (LPVOID*)&disp);
ok(hr == INET_E_UNKNOWN_PROTOCOL /*>= XP*/ ||
hr == E_FAIL /*<= 2k*/, "hr %08x\n", hr);
ok(disp == NULL, "dispatch ptr\n");
SysFreeString(tmp);
tmp = NULL;
- }
- file = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
- ok(file != INVALID_HANDLE_VALUE, "file creation error %u\n", GetLastError());
- if (file != INVALID_HANDLE_VALUE)
- {
WriteFile(file, "this is not a valid picture", 28, &written, NULL);
ok(written == 28, "write\n");
CloseHandle(file);
disp = (void*)0xdeadbeef;
todo_wine
{
hr = OleLoadPicturePath(bstrname, NULL, 0, 0, &IID_IDispatch, (LPVOID*)&disp);
ok(hr == E_FAIL, "hr %08x\n", hr);
ok(disp == NULL, "dispatch ptr\n");
}
- }
- DeleteFileA(filename);
- tmp = SysAllocString(nopath);
- hr = VarBstrCat(bstrname, tmp, &tmp2);
- SysFreeString(bstrname);
- bstrname = tmp2;
- disp = (void*)0xdeadbeef;
- todo_wine
- {
hr = OleLoadPicturePath(bstrname, NULL, 0, 0, &IID_IDispatch, (LPVOID*)&disp);
ok(hr == INET_E_RESOURCE_NOT_FOUND /*>=XP*/ ||
hr == E_FAIL /*<=2k*/, "hr %08x\n", hr);
ok(disp == NULL, "dispatch ptr\n");
- }
- SysFreeString(tmp);
- SysFreeString(bstrname);
+}
static void test_apm() { OLE_HANDLE handle; @@ -671,6 +980,8 @@ START_TEST(olepicture)
test_Invoke(); test_OleCreatePictureIndirect();
- test_OleLoadPictureFile();
- test_OleLoadPicturePath(); test_Render();
}
Hi Jeremy,
Could you please use spaces instead of tabs. I know that this file already has some tabs but please don't add more.