2019-06-08 20:38:32 -05:00
|
|
|
// 8 june 2019
|
|
|
|
#include "test.h"
|
|
|
|
|
2019-06-09 07:50:12 -05:00
|
|
|
#if 0
|
|
|
|
|
2019-06-08 20:38:32 -05:00
|
|
|
struct testOSImplData {
|
|
|
|
bool initCalled;
|
|
|
|
bool *freeCalled;
|
|
|
|
bool testMethodCalled;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool testVtableInit(uiControl *c, void *implData, void *initData)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testVtableFree(uiControl *c, void *implData)
|
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testVtableTestMethod(uiControl *c, void *implData)
|
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2019-06-11 11:01:35 -05:00
|
|
|
static void createTestVtable(uiControlVtable *vtable)
|
2019-06-08 20:38:32 -05:00
|
|
|
{
|
|
|
|
memset(&vtable, 0, sizeof (uiControlVtable));
|
|
|
|
vtable.Size = sizeof (uiControlVtable);
|
|
|
|
vtable.Init = testVtableInit;
|
|
|
|
vtable.Free = testVtableFree;
|
|
|
|
}
|
|
|
|
|
2019-06-11 11:01:35 -05:00
|
|
|
// TODO namePlaceholder == "name"
|
|
|
|
struct checkControlErrorsParams {
|
|
|
|
const char *namePlaceholder;
|
|
|
|
uiControlVtable *vtablePlaceholder;
|
|
|
|
uiControlOSVtable *osVtablePlaceholder;
|
|
|
|
size_t implDataSizePlaceholder;
|
|
|
|
uiControlVtable *badSizeVtable;
|
|
|
|
};
|
|
|
|
|
2019-06-08 20:38:32 -05:00
|
|
|
testingTest(ControlErrors)
|
|
|
|
{
|
|
|
|
uiControlVtable vtablePlacheolder, vtableBadSize;
|
|
|
|
struct testOSVtable osVtablePlaceholder;
|
|
|
|
|
|
|
|
// create valid vtables
|
|
|
|
createTestVtables(&vtablePlaceholder, &osVtablePlaceholder);
|
|
|
|
|
|
|
|
testProgrammerError(t, uiRegisterControlType(NULL, &vtablePlaceholder, &osVtablePlaceholder, sizeof (struct testImplData)),
|
|
|
|
"invalid null pointer for name passed into uiRegisterControlType()");
|
|
|
|
testProgrammerError(t, uiRegisterControlType("name", NULL, &osVtablePlaceholder, sizeof (struct testImplData)),
|
|
|
|
"invalid null pointer for uiControlVtable passed into uiRegisterControlType()");
|
|
|
|
memset(&vtableBadSize, 0, sizeof (uiEventOptions));
|
|
|
|
vtableBadSize.Size = 1;
|
|
|
|
testProgrammerError(t, uiRegisterControlType("name", &badVtableSize, &osVtablePlaceholder, sizeof (struct testImplData)),
|
2019-06-09 07:50:12 -05:00
|
|
|
"wrong size 1 for uiControlVtable in uiRegisterControlType()");
|
2019-06-08 20:38:32 -05:00
|
|
|
#define testBadMethod(method) { \
|
|
|
|
uiControlVtable bad ## method ## MethodVtable; \
|
|
|
|
bad ## method ## MethodVtable = vtablePlaceholder; \
|
|
|
|
bad ## method ## MehtodVtable.method = NULL; \
|
|
|
|
testProgrammerError(t, uiRegisterControlType("name", &bad ## method ## MethodVtable, &osVtablePlaceholder, sizeof (struct testImplData)), \
|
|
|
|
"TODO"); \
|
|
|
|
}
|
|
|
|
testProgrammerError(t, uiRegisterControlType("name", &vtablePlaceholder, NULL, sizeof (struct testImplData)),
|
|
|
|
"invalid null pointer for uiControlOSVtable passed into uiRegisterControlType()");
|
|
|
|
// OS vtable sizes are tested per-OS
|
|
|
|
}
|
2019-06-09 07:50:12 -05:00
|
|
|
|
|
|
|
#endif
|