From eb17ba28c45efd197b32269227b48c18e4e4496b Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 13 Sep 2013 10:19:51 +0000 Subject: [PATCH] [SCRRUN_WINETEST] * Import from Wine 1.7.1. svn path=/trunk/; revision=60075 --- rostests/winetests/CMakeLists.txt | 1 + rostests/winetests/scrrun/CMakeLists.txt | 17 + rostests/winetests/scrrun/dictionary.c | 102 ++++ rostests/winetests/scrrun/filesystem.c | 681 ++++++++++++++++++++++ rostests/winetests/scrrun/scrrun.idl | 692 +++++++++++++++++++++++ rostests/winetests/scrrun/testlist.c | 14 + 6 files changed, 1507 insertions(+) create mode 100644 rostests/winetests/scrrun/CMakeLists.txt create mode 100644 rostests/winetests/scrrun/dictionary.c create mode 100644 rostests/winetests/scrrun/filesystem.c create mode 100644 rostests/winetests/scrrun/scrrun.idl create mode 100644 rostests/winetests/scrrun/testlist.c diff --git a/rostests/winetests/CMakeLists.txt b/rostests/winetests/CMakeLists.txt index 02208ffd481..32509f68124 100644 --- a/rostests/winetests/CMakeLists.txt +++ b/rostests/winetests/CMakeLists.txt @@ -72,6 +72,7 @@ add_subdirectory(rpcrt4) add_subdirectory(rsabase) add_subdirectory(rsaenh) add_subdirectory(schannel) +add_subdirectory(scrrun) add_subdirectory(secur32) add_subdirectory(serialui) add_subdirectory(services) diff --git a/rostests/winetests/scrrun/CMakeLists.txt b/rostests/winetests/scrrun/CMakeLists.txt new file mode 100644 index 00000000000..31f93928094 --- /dev/null +++ b/rostests/winetests/scrrun/CMakeLists.txt @@ -0,0 +1,17 @@ + +add_definitions( + -D__ROS_LONG64__ + -DUSE_WINE_TODOS) + +list(APPEND SOURCE + dictionary.c + filesystem.c + testlist.c) + +add_executable(scrrun_winetest ${SOURCE}) +add_idl_headers(scrrun_idlheader_test scrrun.idl) +add_dependencies(scrrun_winetest scrrun_idlheader_test) +target_link_libraries(scrrun_winetest uuid) +set_module_type(scrrun_winetest win32cui) +add_importlibs(scrrun_winetest ole32 oleaut32 msvcrt kernel32) +add_cd_file(TARGET scrrun_winetest DESTINATION reactos/bin FOR all) diff --git a/rostests/winetests/scrrun/dictionary.c b/rostests/winetests/scrrun/dictionary.c new file mode 100644 index 00000000000..e28bbb18cab --- /dev/null +++ b/rostests/winetests/scrrun/dictionary.c @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2012 Alistair Leslie-Hughes + * + * 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 + */ + +#define COBJMACROS +#include + +#include "windows.h" +#include "ole2.h" +#include "oleauto.h" +#include "dispex.h" + +#include "wine/test.h" + +#include "scrrun.h" + +static void test_interfaces(void) +{ + static const WCHAR key_add[] = {'a', 0}; + static const WCHAR key_add_value[] = {'a', 0}; + static const WCHAR key_non_exist[] = {'b', 0}; + HRESULT hr; + IDispatch *disp; + IDispatchEx *dispex; + IDictionary *dict; + IObjectWithSite *site; + VARIANT key, value; + VARIANT_BOOL exists; + LONG count = 0; + + hr = CoCreateInstance(&CLSID_Dictionary, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, + &IID_IDispatch, (void**)&disp); + if(FAILED(hr)) { + win_skip("Could not create FileSystem object: %08x\n", hr); + return; + } + + VariantInit(&key); + VariantInit(&value); + + hr = IDispatch_QueryInterface(disp, &IID_IDictionary, (void**)&dict); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + + hr = IDispatch_QueryInterface(disp, &IID_IObjectWithSite, (void**)&site); + ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE); + + hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE); + + V_VT(&key) = VT_BSTR; + V_BSTR(&key) = SysAllocString(key_add); + V_VT(&value) = VT_BSTR; + V_BSTR(&value) = SysAllocString(key_add_value); + hr = IDictionary_Add(dict, &key, &value); + todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + VariantClear(&value); + + exists = VARIANT_FALSE; + hr = IDictionary_Exists(dict, &key, &exists); + todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + todo_wine ok(exists == VARIANT_TRUE, "Expected TRUE but got FALSE.\n"); + VariantClear(&key); + + exists = VARIANT_TRUE; + V_VT(&key) = VT_BSTR; + V_BSTR(&key) = SysAllocString(key_non_exist); + hr = IDictionary_Exists(dict, &key, &exists); + todo_wine ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + todo_wine ok(exists == VARIANT_FALSE, "Expected FALSE but got TRUE.\n"); + VariantClear(&key); + + hr = IDictionary_get_Count(dict, &count); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + todo_wine ok(count == 1, "got %d, expected 1\n", count); + + IDictionary_Release(dict); + IDispatch_Release(disp); +} + +START_TEST(dictionary) +{ + CoInitialize(NULL); + + test_interfaces(); + + + CoUninitialize(); +} diff --git a/rostests/winetests/scrrun/filesystem.c b/rostests/winetests/scrrun/filesystem.c new file mode 100644 index 00000000000..e231f9a0d04 --- /dev/null +++ b/rostests/winetests/scrrun/filesystem.c @@ -0,0 +1,681 @@ +/* + * + * Copyright 2012 Alistair Leslie-Hughes + * + * 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 + */ + +#define COBJMACROS +#include + +#include "windows.h" +#include "ole2.h" +#include "olectl.h" +#include "oleauto.h" +#include "dispex.h" + +#include "wine/test.h" + +#include "initguid.h" +#include "scrrun.h" + +static IFileSystem3 *fs3; + +static void test_interfaces(void) +{ + static const WCHAR nonexistent_dirW[] = { + 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', 0}; + static const WCHAR pathW[] = {'p','a','t','h',0}; + static const WCHAR file_kernel32W[] = { + '\\', 'k', 'e', 'r', 'n', 'e', 'l', '3', '2', '.', 'd', 'l', 'l', 0}; + HRESULT hr; + IDispatch *disp; + IDispatchEx *dispex; + IObjectWithSite *site; + VARIANT_BOOL b; + BSTR path; + WCHAR windows_path[MAX_PATH]; + WCHAR file_path[MAX_PATH]; + + IFileSystem3_QueryInterface(fs3, &IID_IDispatch, (void**)&disp); + + GetSystemDirectoryW(windows_path, MAX_PATH); + lstrcpyW(file_path, windows_path); + lstrcatW(file_path, file_kernel32W); + + hr = IDispatch_QueryInterface(disp, &IID_IObjectWithSite, (void**)&site); + ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE); + + hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE); + + b = VARIANT_TRUE; + hr = IFileSystem3_FileExists(fs3, NULL, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_FALSE, "got %x\n", b); + + hr = IFileSystem3_FileExists(fs3, NULL, NULL); + ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER); + + path = SysAllocString(pathW); + b = VARIANT_TRUE; + hr = IFileSystem3_FileExists(fs3, path, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_FALSE, "got %x\n", b); + SysFreeString(path); + + path = SysAllocString(file_path); + b = VARIANT_FALSE; + hr = IFileSystem3_FileExists(fs3, path, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_TRUE, "got %x\n", b); + SysFreeString(path); + + path = SysAllocString(windows_path); + b = VARIANT_TRUE; + hr = IFileSystem3_FileExists(fs3, path, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_FALSE, "got %x\n", b); + SysFreeString(path); + + /* Folder Exists */ + hr = IFileSystem3_FolderExists(fs3, NULL, NULL); + ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER); + + path = SysAllocString(windows_path); + hr = IFileSystem3_FolderExists(fs3, path, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_TRUE, "Folder doesn't exists\n"); + SysFreeString(path); + + path = SysAllocString(nonexistent_dirW); + hr = IFileSystem3_FolderExists(fs3, path, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_FALSE, "Folder exists\n"); + SysFreeString(path); + + path = SysAllocString(file_path); + hr = IFileSystem3_FolderExists(fs3, path, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_FALSE, "Folder exists\n"); + SysFreeString(path); + + IDispatch_Release(disp); +} + +static void test_createfolder(void) +{ + HRESULT hr; + WCHAR pathW[MAX_PATH]; + BSTR path; + IFolder *folder; + + /* create existing directory */ + GetCurrentDirectoryW(sizeof(pathW)/sizeof(WCHAR), pathW); + path = SysAllocString(pathW); + folder = (void*)0xdeabeef; + hr = IFileSystem3_CreateFolder(fs3, path, &folder); + ok(hr == CTL_E_FILEALREADYEXISTS, "got 0x%08x\n", hr); + ok(folder == NULL, "got %p\n", folder); + SysFreeString(path); +} + +static void test_textstream(void) +{ + static WCHAR testfileW[] = {'t','e','s','t','f','i','l','e','.','t','x','t',0}; + ITextStream *stream; + VARIANT_BOOL b; + HANDLE file; + HRESULT hr; + BSTR name, data; + + file = CreateFileW(testfileW, GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + CloseHandle(file); + + name = SysAllocString(testfileW); + b = VARIANT_FALSE; + hr = IFileSystem3_FileExists(fs3, name, &b); + ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK); + ok(b == VARIANT_TRUE, "got %x\n", b); + + hr = IFileSystem3_OpenTextFile(fs3, name, ForReading, VARIANT_FALSE, TristateFalse, &stream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + b = 10; + hr = ITextStream_get_AtEndOfStream(stream, &b); +todo_wine { + ok(hr == S_FALSE || broken(hr == S_OK), "got 0x%08x\n", hr); + ok(b == VARIANT_TRUE, "got 0x%x\n", b); +} + ITextStream_Release(stream); + + hr = IFileSystem3_OpenTextFile(fs3, name, ForWriting, VARIANT_FALSE, TristateFalse, &stream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + b = 10; + hr = ITextStream_get_AtEndOfStream(stream, &b); +todo_wine { + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + ok(b == VARIANT_TRUE || broken(b == 10), "got 0x%x\n", b); +} + b = 10; + hr = ITextStream_get_AtEndOfLine(stream, &b); +todo_wine { + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + ok(b == VARIANT_FALSE || broken(b == 10), "got 0x%x\n", b); +} + hr = ITextStream_Read(stream, 1, &data); + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + + hr = ITextStream_ReadLine(stream, &data); + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + + hr = ITextStream_ReadAll(stream, &data); + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + + ITextStream_Release(stream); + + hr = IFileSystem3_OpenTextFile(fs3, name, ForAppending, VARIANT_FALSE, TristateFalse, &stream); + ok(hr == S_OK, "got 0x%08x\n", hr); + SysFreeString(name); + + b = 10; + hr = ITextStream_get_AtEndOfStream(stream, &b); +todo_wine { + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + ok(b == VARIANT_TRUE || broken(b == 10), "got 0x%x\n", b); +} + b = 10; + hr = ITextStream_get_AtEndOfLine(stream, &b); +todo_wine { + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + ok(b == VARIANT_FALSE || broken(b == 10), "got 0x%x\n", b); +} + hr = ITextStream_Read(stream, 1, &data); + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + + hr = ITextStream_ReadLine(stream, &data); + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + + hr = ITextStream_ReadAll(stream, &data); + ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + + ITextStream_Release(stream); + + DeleteFileW(testfileW); +} + +static void test_GetFileVersion(void) +{ + static const WCHAR k32W[] = {'\\','k','e','r','n','e','l','3','2','.','d','l','l',0}; + static const WCHAR k33W[] = {'\\','k','e','r','n','e','l','3','3','.','d','l','l',0}; + WCHAR pathW[MAX_PATH], filenameW[MAX_PATH]; + BSTR path, version; + HRESULT hr; + + GetSystemDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR)); + + lstrcpyW(filenameW, pathW); + lstrcatW(filenameW, k32W); + + path = SysAllocString(filenameW); + hr = IFileSystem3_GetFileVersion(fs3, path, &version); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(*version != 0, "got %s\n", wine_dbgstr_w(version)); + SysFreeString(version); + SysFreeString(path); + + lstrcpyW(filenameW, pathW); + lstrcatW(filenameW, k33W); + + path = SysAllocString(filenameW); + version = (void*)0xdeadbeef; + hr = IFileSystem3_GetFileVersion(fs3, path, &version); + ok(broken(hr == S_OK) || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr); + if (hr == S_OK) + { + ok(*version == 0, "got %s\n", wine_dbgstr_w(version)); + SysFreeString(version); + } + else + ok(version == (void*)0xdeadbeef, "got %p\n", version); + SysFreeString(path); +} + +static void test_GetParentFolderName(void) +{ + static const WCHAR path1[] = {'a',0}; + static const WCHAR path2[] = {'a','/','a','/','a',0}; + static const WCHAR path3[] = {'a','\\','a','\\','a',0}; + static const WCHAR path4[] = {'a','/','a','/','/','\\','\\',0}; + static const WCHAR path5[] = {'c',':','\\','\\','a',0}; + static const WCHAR path6[] = {'a','c',':','\\','a',0}; + static const WCHAR result2[] = {'a','/','a',0}; + static const WCHAR result3[] = {'a','\\','a',0}; + static const WCHAR result4[] = {'a',0}; + static const WCHAR result5[] = {'c',':','\\',0}; + static const WCHAR result6[] = {'a','c',':',0}; + + static const struct { + const WCHAR *path; + const WCHAR *result; + } tests[] = { + {NULL, NULL}, + {path1, NULL}, + {path2, result2}, + {path3, result3}, + {path4, result4}, + {path5, result5}, + {path6, result6} + }; + + BSTR path, result; + HRESULT hr; + int i; + + hr = IFileSystem3_GetParentFolderName(fs3, NULL, NULL); + ok(hr == E_POINTER, "GetParentFolderName returned %x, expected E_POINTER\n", hr); + + for(i=0; i