And updated the tests on Windows. It works!
This commit is contained in:
parent
7cdd6ee38c
commit
1c7718ec58
|
@ -0,0 +1,5 @@
|
|||
// 28 may 2019
|
||||
|
||||
// This file should NOT have include guards as it is intended to be included more than once; see noinitwrongthread_windows.c for details.
|
||||
|
||||
allcallsCase(uiWindowsControlHandle, NULL)
|
|
@ -1,8 +1,14 @@
|
|||
// 10 june 2019
|
||||
#include "test_windows.h"
|
||||
|
||||
static HWND osVtableNopHandle(uiControl *c, void *implData)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const uiControlOSVtable osVtable = {
|
||||
.Size = sizeof (uiControlOSVtable),
|
||||
.Handle = osVtableNopHandle,
|
||||
};
|
||||
|
||||
const uiControlOSVtable *testOSVtable(void)
|
||||
|
@ -23,3 +29,26 @@ Test(WrongControlOSVtableSizeIsProgrammerError)
|
|||
uiRegisterControlType("name", &vtable, &osvt, 0);
|
||||
endCheckProgrammerError(ctx);
|
||||
}
|
||||
|
||||
Test(ControlOSVtableWithMissingHandleMethodIsProgrammerError)
|
||||
{
|
||||
uiControlVtable vtable;
|
||||
uiControlOSVtable osvt;
|
||||
void *ctx;
|
||||
|
||||
testControlLoadNopVtable(&vtable);
|
||||
ctx = beginCheckProgrammerError("uiRegisterControlType(): required uiControlOSVtable method Handle() missing for uiControl type name");
|
||||
osvt = osVtable;
|
||||
osvt.Handle = NULL;
|
||||
uiRegisterControlType("name", &vtable, &osvt, 0);
|
||||
endCheckProgrammerError(ctx);
|
||||
}
|
||||
|
||||
Test(GettingWindowsHandleOfNullControlIsProgrammerError)
|
||||
{
|
||||
void *ctx;
|
||||
|
||||
ctx = beginCheckProgrammerError("uiWindowsControlHandle(): invalid null pointer for uiControl");
|
||||
uiWindowsControlHandle(NULL);
|
||||
endCheckProgrammerError(ctx);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,11 @@ libui_allcalls_headers = files([
|
|||
if libui_OS == 'windows'
|
||||
libui_test_sources += files([
|
||||
'controls_windows.c',
|
||||
'noinitwrongthread_windows.c',
|
||||
'window_windows.c',
|
||||
])
|
||||
libui_allcalls_headers += files([
|
||||
'allcalls_windows.h',
|
||||
])
|
||||
elif libui_OS == 'darwin'
|
||||
libui_test_sources += files([
|
||||
|
@ -51,6 +56,7 @@ libui_test_sources_without_cases = [
|
|||
if libui_OS == 'windows'
|
||||
libui_test_sources_without_cases += [
|
||||
'thread_windows.c',
|
||||
'utf8_windows.c',
|
||||
windows.compile_resources('resources_' + libui_mode + '.rc',
|
||||
args: libui_manifest_args,
|
||||
depend_files: ['test_' + libui_mode + '.manifest']),
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// 28 may 2019
|
||||
#include "test_windows.h"
|
||||
#include "thread.h"
|
||||
|
||||
#define allcallsHeader "allcalls_windows.h"
|
||||
#include "noinitwrongthreadimpl.h"
|
|
@ -3,3 +3,6 @@
|
|||
#include "../windows/winapi.hpp"
|
||||
#define libuiOSHeader "../ui_windows.h"
|
||||
#include "test.h"
|
||||
|
||||
// utf8_windows.c
|
||||
extern uint16_t *testGetWindowText(HWND hwnd);
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// 7 june 2020
|
||||
#include "test_windows.h"
|
||||
|
||||
// Do not put any test cases in this file; they will not be run.
|
||||
|
||||
uint16_t *testGetWindowText(HWND hwnd)
|
||||
{
|
||||
LRESULT n;
|
||||
WCHAR *text;
|
||||
|
||||
n = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
|
||||
// WM_GETTEXTLENGTH does not include the null terminator
|
||||
text = (WCHAR *) malloc((n + 1) * sizeof (WCHAR));
|
||||
if (text == NULL)
|
||||
TestFatalf("memory exhausted allocating space for window text");
|
||||
// note the comparison: the size includes the null terminator, but the return does not
|
||||
if (GetWindowTextW(hwnd, text, n + 1) != n) {
|
||||
DWORD le;
|
||||
|
||||
le = GetLastError();
|
||||
TestFatalf("error getting window text; last error %d", le);
|
||||
}
|
||||
return (uint16_t *) text;
|
||||
}
|
Loading…
Reference in New Issue