https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d315fd93d34009bf6e4d5b5dccca6a5364eb4e5b

commit d315fd93d34009bf6e4d5b5dccca6a5364eb4e5b
Author:     Mark Jansen <[email protected]>
AuthorDate: Sat Aug 3 15:13:21 2019 +0200
Commit:     Mark Jansen <[email protected]>
CommitDate: Sat Oct 19 18:42:14 2019 +0200

    [FONTEXT_APITEST] Add simple api test showing interfaces
    CORE-14690
---
 modules/rostests/apitests/CMakeLists.txt         |   1 +
 modules/rostests/apitests/fontext/CMakeLists.txt |  22 +++
 modules/rostests/apitests/fontext/shellext.cpp   | 194 +++++++++++++++++++++++
 modules/rostests/apitests/fontext/testlist.c     |  12 ++
 4 files changed, 229 insertions(+)

diff --git a/modules/rostests/apitests/CMakeLists.txt 
b/modules/rostests/apitests/CMakeLists.txt
index 1d623104fc7..8910f89b56a 100644
--- a/modules/rostests/apitests/CMakeLists.txt
+++ b/modules/rostests/apitests/CMakeLists.txt
@@ -12,6 +12,7 @@ add_subdirectory(crt)
 add_subdirectory(dbghelp)
 add_subdirectory(dciman32)
 add_subdirectory(dnsapi)
+add_subdirectory(fontext)
 add_subdirectory(gdi32)
 add_subdirectory(gditools)
 add_subdirectory(iphlpapi)
diff --git a/modules/rostests/apitests/fontext/CMakeLists.txt 
b/modules/rostests/apitests/fontext/CMakeLists.txt
new file mode 100644
index 00000000000..80654e4d7d5
--- /dev/null
+++ b/modules/rostests/apitests/fontext/CMakeLists.txt
@@ -0,0 +1,22 @@
+
+add_definitions(
+    -D__ROS_LONG64__
+    -DWINETEST_USE_DBGSTR_LONGLONG
+    -DUNICODE
+    -D_UNICODE
+    -D_ATL_NO_EXCEPTIONS)
+
+set_cpp(WITH_RUNTIME)
+
+include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl
+                    ${CMAKE_CURRENT_BINARY_DIR})
+
+list(APPEND SOURCE
+    shellext.cpp
+    testlist.c)
+
+add_executable(fontext_apitest ${SOURCE})
+set_module_type(fontext_apitest win32cui)
+target_link_libraries(fontext_apitest uuid ${PSEH_LIB})
+add_importlibs(fontext_apitest oleaut32 ole32 shell32 user32 msvcrt kernel32 
ntdll)
+add_rostests_file(TARGET fontext_apitest)
diff --git a/modules/rostests/apitests/fontext/shellext.cpp 
b/modules/rostests/apitests/fontext/shellext.cpp
new file mode 100644
index 00000000000..00480a7497c
--- /dev/null
+++ b/modules/rostests/apitests/fontext/shellext.cpp
@@ -0,0 +1,194 @@
+/*
+ * PROJECT:     fontext_apitest
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     Tests for fontext shell extension behavior
+ * COPYRIGHT:   Copyright 2019 Mark Jansen ([email protected])
+ */
+
+#include <ntstatus.h>
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <ntndk.h>
+#include <atlbase.h>
+#include <atlcom.h>
+#include <shellapi.h>
+#include <shlobj.h>
+#include <shobjidl.h>
+#include <shellutils.h>
+#include "wine/test.h"
+
+const CLSID CLSID_FontExt = { 0xBD84B380, 0x8CA2, 0x1069, { 0xAB, 0x1D, 0x08, 
0x00, 0x09, 0x48, 0xF5, 0x34 } };
+static DWORD g_WinVersion;
+
+
+static HRESULT Initialize(CComPtr<IPersistFolder>& spFolder, LPCWSTR Path)
+{
+    CComHeapPtr<ITEMIDLIST> pidl;
+    CComPtr<IShellFolder> spDesktop;
+
+    HRESULT hr = SHGetDesktopFolder(&spDesktop);
+    ok_hex(hr, S_OK);
+    if (FAILED(hr))
+        return hr;
+
+    DWORD Attributes = 0, chEaten = 0;
+    hr = spDesktop->ParseDisplayName(NULL, NULL, (LPOLESTR)Path, &chEaten, 
&pidl, &Attributes);
+    ok_hex(hr, S_OK);
+    if (FAILED(hr))
+        return hr;
+
+    return spFolder->Initialize(pidl);
+}
+
+
+static void CreateObjectsFromPersistFolder()
+{
+    WCHAR Path[MAX_PATH] = { 0 };
+
+    CComPtr<IPersistFolder> spFolder;
+    HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, 
IID_PPV_ARG(IPersistFolder, &spFolder));
+    ok_hex(hr, S_OK);
+    if (!SUCCEEDED(hr))
+        return;
+
+    hr = SHGetFolderPathW(NULL, CSIDL_WINDOWS, NULL, 0, Path);
+    ok_hex(hr, S_OK);
+    if (FAILED(hr))
+        return;
+
+    // Initializing this in another folder fails
+    hr = Initialize(spFolder, Path);
+    ok_hex(hr, E_FAIL);
+
+    hr = SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, 0, Path);
+    ok_hex(hr, S_OK);
+    if (FAILED(hr))
+        return;
+
+    // Initializing it in the font folder works
+    hr = Initialize(spFolder, Path);
+    ok_hex(hr, S_OK);
+
+    // For ros we do not implement the ShellView, but go directly to the 
ShellFolder.
+    // So we detect this special case
+    if (g_WinVersion < _WIN32_WINNT_VISTA)
+    {
+        CComPtr<IShellFolder> spShellFolder;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IShellFolder, 
&spShellFolder));
+
+        if (SUCCEEDED(hr))
+        {
+            trace("Got IShellFolder on < Vista, faking 0x601\n");
+            g_WinVersion = _WIN32_WINNT_WIN7;
+        }
+    }
+
+    if (g_WinVersion < _WIN32_WINNT_VISTA)
+    {
+        // A view is present
+        CComPtr<IShellView> spView;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IShellView, &spView));
+        ok_hex(hr, S_OK);
+
+        // No shell folder
+        CComPtr<IShellFolder> spShellFolder;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IShellFolder, 
&spShellFolder));
+        ok_hex(hr, E_NOINTERFACE);
+
+        // Ask the view:
+        if (spView)
+        {
+            CComPtr<IObjectWithSite> spObjectWithSite;
+            hr = spView->QueryInterface(IID_PPV_ARG(IObjectWithSite, 
&spObjectWithSite));
+            ok_hex(hr, E_NOINTERFACE);
+
+            CComPtr<IInternetSecurityManager> spISM;
+            hr = spView->QueryInterface(IID_PPV_ARG(IInternetSecurityManager, 
&spISM));
+            ok_hex(hr, E_NOINTERFACE);
+        }
+
+
+        CComPtr<IDropTarget> spDropTarget;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IDropTarget, &spDropTarget));
+        ok_hex(hr, S_OK);
+
+        CComPtr<IExtractIconW> spExtractIcon;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IExtractIconW, 
&spExtractIcon));
+        ok_hex(hr, E_NOINTERFACE);
+    }
+    else
+    {
+        // Here we have a shell folder
+        CComPtr<IShellFolder> spShellFolder;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IShellFolder, 
&spShellFolder));
+        ok_hex(hr, S_OK);
+
+        // But no view anymore
+        CComPtr<IShellView> spView;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IShellView, &spView));
+        ok_hex(hr, E_NOINTERFACE);
+        spView.Release();
+
+
+        CComPtr<IDropTarget> spDropTarget;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IDropTarget, &spDropTarget));
+        ok_hex(hr, E_NOINTERFACE);
+
+        CComPtr<IExtractIconW> spExtractIcon;
+        hr = spFolder->QueryInterface(IID_PPV_ARG(IExtractIconW, 
&spExtractIcon));
+        ok_hex(hr, E_NOINTERFACE);
+    }
+}
+
+
+static void CreateDropTarget()
+{
+    CComPtr<IDropTarget> spDropTarget;
+    HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, 
IID_PPV_ARG(IDropTarget, &spDropTarget));
+    ok_hex(hr, E_NOINTERFACE);
+}
+
+static void CreateExtractIcon()
+{
+    if (g_WinVersion < _WIN32_WINNT_VISTA)
+    {
+        CComPtr<IExtractIconA> spExtractIconA;
+        HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, 
CLSCTX_INPROC_SERVER, IID_PPV_ARG(IExtractIconA, &spExtractIconA));
+        ok_hex(hr, S_OK);
+
+        CComPtr<IExtractIconW> spExtractIconW;
+        hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, 
IID_PPV_ARG(IExtractIconW, &spExtractIconW));
+        ok_hex(hr, S_OK);
+    }
+    else
+    {
+        CComPtr<IExtractIconA> spExtractIconA;
+        HRESULT hr = CoCreateInstance(CLSID_FontExt, NULL, 
CLSCTX_INPROC_SERVER, IID_PPV_ARG(IExtractIconA, &spExtractIconA));
+        ok_hex(hr, E_NOINTERFACE);
+
+        CComPtr<IExtractIconW> spExtractIconW;
+        hr = CoCreateInstance(CLSID_FontExt, NULL, CLSCTX_INPROC_SERVER, 
IID_PPV_ARG(IExtractIconW, &spExtractIconW));
+        ok_hex(hr, E_NOINTERFACE);
+    }
+}
+
+
+
+START_TEST(shellext)
+{
+    RTL_OSVERSIONINFOEXW rtlinfo = {0};
+
+    rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
+    RtlGetVersion((PRTL_OSVERSIONINFOW)&rtlinfo);
+    g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
+
+    trace("g_WinVersion=0x%x\n", g_WinVersion);
+
+    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+    CreateObjectsFromPersistFolder();
+    CreateDropTarget();
+    CreateExtractIcon();
+
+    CoUninitialize();
+}
diff --git a/modules/rostests/apitests/fontext/testlist.c 
b/modules/rostests/apitests/fontext/testlist.c
new file mode 100644
index 00000000000..08fc9631feb
--- /dev/null
+++ b/modules/rostests/apitests/fontext/testlist.c
@@ -0,0 +1,12 @@
+/* Automatically generated file; DO NOT EDIT!! */
+
+#define STANDALONE
+#include <wine/test.h>
+
+extern void func_shellext(void);
+
+const struct test winetest_testlist[] =
+{
+    { "shellext", func_shellext },
+    { 0, 0 }
+};

Reply via email to