ReactOS 0.4.15-dev-7924-g5949c20
OpenAs_RunDLL.cpp File Reference
#include "shelltest.h"
#include <stdio.h>
#include <process.h>
Include dependency graph for OpenAs_RunDLL.cpp:

Go to the source code of this file.

Classes

struct  TEST_ENTRY
 

Macros

#define COUNT   5
 
#define INTERVAL   200
 
#define DEATH   999
 
#define OPENED   1
 
#define NOT_OPENED   0
 
#define BAD_INST   ((HINSTANCE)0xDEAD)
 
#define BAD_SZ_A   ((LPCSTR)0xDEAD)
 
#define BAD_SZ_W   ((LPCWSTR)0xDEAD)
 

Typedefs

typedef void(WINAPIOPENAS_RUNDLLA) (HWND, HINSTANCE, LPCSTR, int)
 
typedef void(WINAPIOPENAS_RUNDLLW) (HWND, HINSTANCE, LPCWSTR, int)
 

Functions

static unsigned __stdcall watch_thread_proc (void *arg)
 
static void StartWatchGUI (const TEST_ENTRY *pEntry)
 
static void DoEntry (const TEST_ENTRY *pEntry)
 
 START_TEST (OpenAs_RunDLL)
 

Variables

static OPENAS_RUNDLLA pOpenAs_RunDLLA = NULL
 
static OPENAS_RUNDLLW pOpenAs_RunDLLW = NULL
 
static const TEST_ENTRY s_TestEntries []
 
static HANDLE s_hThread = NULL
 
static INT s_nRet = NOT_OPENED
 

Macro Definition Documentation

◆ BAD_INST

#define BAD_INST   ((HINSTANCE)0xDEAD)

Definition at line 39 of file OpenAs_RunDLL.cpp.

◆ BAD_SZ_A

#define BAD_SZ_A   ((LPCSTR)0xDEAD)

Definition at line 40 of file OpenAs_RunDLL.cpp.

◆ BAD_SZ_W

#define BAD_SZ_W   ((LPCWSTR)0xDEAD)

Definition at line 41 of file OpenAs_RunDLL.cpp.

◆ COUNT

#define COUNT   5

Definition at line 32 of file OpenAs_RunDLL.cpp.

◆ DEATH

#define DEATH   999

Definition at line 35 of file OpenAs_RunDLL.cpp.

◆ INTERVAL

#define INTERVAL   200

Definition at line 33 of file OpenAs_RunDLL.cpp.

◆ NOT_OPENED

#define NOT_OPENED   0

Definition at line 37 of file OpenAs_RunDLL.cpp.

◆ OPENED

#define OPENED   1

Definition at line 36 of file OpenAs_RunDLL.cpp.

Typedef Documentation

◆ OPENAS_RUNDLLA

typedef void(WINAPI * OPENAS_RUNDLLA) (HWND, HINSTANCE, LPCSTR, int)

Definition at line 13 of file OpenAs_RunDLL.cpp.

◆ OPENAS_RUNDLLW

typedef void(WINAPI * OPENAS_RUNDLLW) (HWND, HINSTANCE, LPCWSTR, int)

Definition at line 15 of file OpenAs_RunDLL.cpp.

Function Documentation

◆ DoEntry()

static void DoEntry ( const TEST_ENTRY pEntry)
static

Definition at line 100 of file OpenAs_RunDLL.cpp.

101{
102 if (pEntry->bWide)
103 {
104 if (pEntry->bCreateFile)
105 {
106 FILE *fp = _wfopen(pEntry->pszFileW, L"wb");
107 ok(fp != NULL, "Line %d: Unable to create file '%s'\n", pEntry->nLine, wine_dbgstr_w(pEntry->pszFileW));
108 fclose(fp);
109 }
110
112 SetLastError(0xDEADFACE);
113
115 {
116 (*pOpenAs_RunDLLW)(NULL, pEntry->hInst, pEntry->pszFileW, SW_SHOWDEFAULT);
117 }
119 {
120 s_nRet = DEATH;
121 }
122 _SEH2_END;
123
124 DWORD dwError = GetLastError();
125 ok(pEntry->dwError == dwError, "Line %d: error expected %ld, was %ld\n", pEntry->nLine, pEntry->dwError, dwError);
126
129
130 if (pEntry->bCreateFile)
131 {
132 ok(DeleteFileW(pEntry->pszFileW), "Line %d: DeleteFileA failed\n", pEntry->nLine);
133 }
134 }
135 else
136 {
137 if (pEntry->bCreateFile)
138 {
139 FILE *fp = fopen(pEntry->pszFileA, "wb");
140 ok(fp != NULL, "Line %d: Unable to create file '%s'\n", pEntry->nLine, pEntry->pszFileA);
141 fclose(fp);
142 }
143
145 SetLastError(0xDEADFACE);
146
148 {
149 (*pOpenAs_RunDLLA)(NULL, pEntry->hInst, pEntry->pszFileA, SW_SHOWDEFAULT);
150 }
152 {
153 s_nRet = DEATH;
154 }
155 _SEH2_END;
156
157 DWORD dwError = GetLastError();
158 ok(pEntry->dwError == dwError, "Line %d: error expected %ld, was %ld\n", pEntry->nLine, pEntry->dwError, dwError);
159
162
163 if (pEntry->bCreateFile)
164 {
165 ok(DeleteFileA(pEntry->pszFileA), "Line %d: DeleteFileA failed\n", pEntry->nLine);
166 }
167 }
168
169 // FIXME: This function probably returns void
170 //ok(pEntry->nRet == s_nRet, "Line %d: s_nRet expected %d, was %d\n", pEntry->nLine, pEntry->nRet, s_nRet);
171}
static HANDLE s_hThread
#define DEATH
static void StartWatchGUI(const TEST_ENTRY *pEntry)
static INT s_nRet
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define INFINITE
Definition: serial.h:102
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned long DWORD
Definition: ntddk_ex.h:95
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_Check_return_ _CRTIMP FILE *__cdecl _wfopen(_In_z_ const wchar_t *_Filename, _In_z_ const wchar_t *_Mode)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define wine_dbgstr_w
Definition: kernel32.h:34
#define L(x)
Definition: ntvdm.h:50
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SW_SHOWDEFAULT
Definition: winuser.h:780

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( OpenAs_RunDLL  )

Definition at line 173 of file OpenAs_RunDLL.cpp.

174{
175 HINSTANCE hShell32 = LoadLibraryA("shell32.dll");
176 if (hShell32 == NULL)
177 {
178 skip("Unable to load shell32.dll\n");
179 return;
180 }
181
183 if (pOpenAs_RunDLLA == NULL)
184 {
185 skip("Unable to get OpenAs_RunDLLA\n");
186 return;
187 }
188
190 if (pOpenAs_RunDLLW == NULL)
191 {
192 skip("Unable to get OpenAs_RunDLLW\n");
193 return;
194 }
195
196 TCHAR szCurDir[MAX_PATH], szTempDir[MAX_PATH];
197
198 ok(GetCurrentDirectory(_countof(szCurDir), szCurDir), "GetCurrentDirectory failed\n");
199 ok(GetTempPath(_countof(szTempDir), szTempDir), "GetTempPath failed\n");
200
201 if (!SetCurrentDirectory(szTempDir))
202 {
203 skip("SetCurrentDirectory failed\n");
204 }
205 else
206 {
207 for (size_t i = 0; i < _countof(s_TestEntries); ++i)
208 {
209 const TEST_ENTRY *pEntry = &s_TestEntries[i];
211 }
212
213 ok(SetCurrentDirectory(szCurDir), "SetCurrentDirectory failed\n");
214 }
215
217}
static OPENAS_RUNDLLA pOpenAs_RunDLLA
void(WINAPI * OPENAS_RUNDLLA)(HWND, HINSTANCE, LPCSTR, int)
static OPENAS_RUNDLLW pOpenAs_RunDLLW
void(WINAPI * OPENAS_RUNDLLW)(HWND, HINSTANCE, LPCWSTR, int)
static void DoEntry(const TEST_ENTRY *pEntry)
static const TEST_ENTRY s_TestEntries[]
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HMODULE hShell32
Definition: string.c:34
#define _countof(array)
Definition: sndvol32.h:68
Definition: cmd.c:13
#define GetTempPath
Definition: winbase.h:3850
#define SetCurrentDirectory
Definition: winbase.h:3903
#define GetCurrentDirectory
Definition: winbase.h:3805
char TCHAR
Definition: xmlstorage.h:189

◆ StartWatchGUI()

static void StartWatchGUI ( const TEST_ENTRY pEntry)
static

Definition at line 94 of file OpenAs_RunDLL.cpp.

95{
98}
#define NOT_OPENED
static unsigned __stdcall watch_thread_proc(void *arg)
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
PVOID HANDLE
Definition: typedefs.h:73

Referenced by DoEntry().

◆ watch_thread_proc()

static unsigned __stdcall watch_thread_proc ( void arg)
static

Definition at line 71 of file OpenAs_RunDLL.cpp.

72{
73 for (int i = 0; i < COUNT; ++i)
74 {
76
77 HWND hwnd = FindWindowA("#32770", "Open With");
78 if (hwnd == NULL)
79 continue;
80
82 {
83 trace("not visible\n");
84 continue;
85 }
86
87 s_nRet = OPENED;
89 break;
90 }
91 return 0;
92}
#define OPENED
#define COUNT
#define INTERVAL
#define trace
Definition: atltest.h:70
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define PostMessage
Definition: winuser.h:5832
#define BN_CLICKED
Definition: winuser.h:1925
HWND WINAPI FindWindowA(_In_opt_ LPCSTR, _In_opt_ LPCSTR)
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by StartWatchGUI().

Variable Documentation

◆ pOpenAs_RunDLLA

OPENAS_RUNDLLA pOpenAs_RunDLLA = NULL
static

Definition at line 17 of file OpenAs_RunDLL.cpp.

Referenced by START_TEST().

◆ pOpenAs_RunDLLW

OPENAS_RUNDLLW pOpenAs_RunDLLW = NULL
static

Definition at line 18 of file OpenAs_RunDLL.cpp.

Referenced by START_TEST().

◆ s_hThread

HANDLE s_hThread = NULL
static

Definition at line 67 of file OpenAs_RunDLL.cpp.

Referenced by DIALOG_Printing_DialogProc(), DoEntry(), and StartWatchGUI().

◆ s_nRet

INT s_nRet = NOT_OPENED
static

Definition at line 68 of file OpenAs_RunDLL.cpp.

Referenced by DoEntry(), StartWatchGUI(), and watch_thread_proc().

◆ s_TestEntries

const TEST_ENTRY s_TestEntries[]
static
Initial value:
=
{
{__LINE__, FALSE, NULL, OPENED, FALSE, NULL, NULL, 0 },
{__LINE__, FALSE, NULL, OPENED, FALSE, "", NULL, 0 },
{__LINE__, FALSE, NULL, OPENED, FALSE, "invalid file name.txt", NULL, 0 },
{__LINE__, FALSE, NULL, DEATH, FALSE, BAD_SZ_A, NULL, 0 },
{__LINE__, FALSE, NULL, OPENED, TRUE, "created file.txt", NULL, 0 },
{__LINE__, FALSE, BAD_INST, OPENED, FALSE, NULL, NULL, 0 },
{__LINE__, FALSE, BAD_INST, OPENED, FALSE, "invalid file name.txt", NULL, 0 },
{__LINE__, FALSE, BAD_INST, DEATH, FALSE, BAD_SZ_A, NULL, 0xDEADFACE },
{__LINE__, FALSE, BAD_INST, OPENED, TRUE, "created file.txt", NULL, 0 },
{__LINE__, TRUE, NULL, OPENED, FALSE, NULL, NULL, 0x80070490 },
{__LINE__, TRUE, NULL, OPENED, FALSE, NULL, L"", ERROR_NO_SCROLLBARS },
{__LINE__, TRUE, NULL, OPENED, FALSE, NULL, L"invalid file name.txt", ERROR_NO_SCROLLBARS },
{__LINE__, TRUE, NULL, OPENED, FALSE, NULL, BAD_SZ_W, 0xDEADFACE },
{__LINE__, TRUE, NULL, OPENED, TRUE, NULL, L"created file.txt", ERROR_NO_SCROLLBARS },
{__LINE__, TRUE, BAD_INST, OPENED, FALSE, NULL, NULL, 0x80070490 },
{__LINE__, TRUE, BAD_INST, OPENED, FALSE, NULL, L"invalid file name.txt", ERROR_NO_SCROLLBARS },
{__LINE__, TRUE, BAD_INST, OPENED, FALSE, NULL, BAD_SZ_W, 0xDEADFACE },
{__LINE__, TRUE, BAD_INST, OPENED, TRUE, NULL, L"created file.txt", ERROR_NO_SCROLLBARS },
}
#define BAD_SZ_A
#define BAD_INST
#define BAD_SZ_W
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_NO_SCROLLBARS
Definition: winerror.h:928

Definition at line 43 of file OpenAs_RunDLL.cpp.

Referenced by START_TEST().