libui/test/controls_unix.c

55 lines
1.3 KiB
C
Raw Normal View History

2020-05-11 21:37:02 -05:00
// 10 june 2019
#include "test_unix.h"
2020-05-31 12:37:56 -05:00
static GtkWidget *osVtableNopHandle(uiControl *c, void *implData)
{
return NULL;
}
2020-05-11 21:37:02 -05:00
static const uiControlOSVtable osVtable = {
.Size = sizeof (uiControlOSVtable),
2020-05-31 12:37:56 -05:00
.Handle = osVtableNopHandle,
2020-05-11 21:37:02 -05:00
};
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);
}
2020-05-31 12:37:56 -05:00
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);
}