libui/test/controls_unix.c

55 lines
1.3 KiB
C

// 10 june 2019
#include "test_unix.h"
static GtkWidget *osVtableNopHandle(uiControl *c, void *implData)
{
return NULL;
}
static const uiControlOSVtable osVtable = {
.Size = sizeof (uiControlOSVtable),
.Handle = osVtableNopHandle,
};
const uiControlOSVtable *testOSVtable(void)
{
return &osVtable;
}
Test(WrongControlOSVtableSizeIsProgrammerError)
{
uiControlVtable vtable;
uiControlOSVtable osvt;
void *ctx;
testControlLoadNopVtable(&vtable);
ctx = beginCheckProgrammerError("uiRegisterControlType(): wrong size 1 for uiControlOSVtable");
memset(&osvt, 0, sizeof (uiControlOSVtable));
osvt.Size = 1;
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(GettingUnixHandleOfNullControlIsProgrammerError)
{
void *ctx;
ctx = beginCheckProgrammerError("uiUnixControlHandle(): invalid null pointer for uiControl");
uiUnixControlHandle(NULL);
endCheckProgrammerError(ctx);
}