2019-05-28 20:54:13 -05:00
|
|
|
// 28 may 2019
|
|
|
|
#include "test.h"
|
|
|
|
|
2019-06-09 14:29:03 -05:00
|
|
|
#define allcallsCase(f, ...) \
|
2019-06-09 20:00:33 -05:00
|
|
|
void doCase ## f(void *data) \
|
2019-06-09 14:29:03 -05:00
|
|
|
{ \
|
|
|
|
f(__VA_ARGS__); \
|
2019-05-28 20:54:13 -05:00
|
|
|
}
|
2019-06-09 14:29:03 -05:00
|
|
|
allcallsCase(uiQueueMain, NULL, NULL)
|
|
|
|
#include "allcalls.h"
|
|
|
|
#undef allcallsCase
|
2019-05-28 20:54:13 -05:00
|
|
|
|
2019-06-09 14:29:03 -05:00
|
|
|
static const struct {
|
|
|
|
const char *name;
|
2019-06-09 20:00:33 -05:00
|
|
|
void (*f)(void *data);
|
2019-06-09 18:00:01 -05:00
|
|
|
const char *beforeInitWant;
|
|
|
|
const char *wrongThreadWant;
|
|
|
|
} allCases[] = {
|
|
|
|
#define allcallsCase(f, ...) { #f, doCase ## f, \
|
|
|
|
"attempt to call " #f "() before uiInit()", \
|
2019-06-09 21:33:45 -05:00
|
|
|
allcallsThread(#f), \
|
2019-06-09 18:00:01 -05:00
|
|
|
},
|
2019-06-09 21:33:45 -05:00
|
|
|
#define allcallsThread(f) NULL
|
|
|
|
allcallsCase(uiQueueMain, NULL, NULL)
|
|
|
|
#undef allcallsThread
|
|
|
|
#define allcallsThread(f) "attempt to call " f "() on a thread other than the GUI thread"
|
2019-05-28 20:54:13 -05:00
|
|
|
#include "allcalls.h"
|
2019-06-09 14:29:03 -05:00
|
|
|
#undef allcallsCase
|
2019-06-09 18:00:01 -05:00
|
|
|
{ NULL, NULL, NULL, NULL },
|
2019-06-09 14:29:03 -05:00
|
|
|
};
|
2019-05-28 20:54:13 -05:00
|
|
|
|
|
|
|
testingTestInSet(beforeTests, FunctionsFailBeforeInit)
|
|
|
|
{
|
2019-06-09 14:29:03 -05:00
|
|
|
size_t i;
|
2019-05-28 20:54:13 -05:00
|
|
|
|
2019-06-09 18:00:01 -05:00
|
|
|
for (i = 0; allCases[i].name != NULL; i++) {
|
2019-06-09 21:33:45 -05:00
|
|
|
if (allCases[i].beforeInitWant == NULL)
|
2019-06-09 18:00:01 -05:00
|
|
|
continue;
|
2019-06-09 21:33:45 -05:00
|
|
|
checkProgrammerError(t, allCases[i].name, allCases[i].f, NULL, allCases[i].beforeInitWant);
|
2019-06-09 18:00:01 -05:00
|
|
|
}
|
2019-05-28 20:54:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
testingTest(FunctionsFailOnWrongThread)
|
|
|
|
{
|
2019-06-09 15:14:18 -05:00
|
|
|
size_t i;
|
2019-05-28 20:54:13 -05:00
|
|
|
|
2019-06-09 18:00:01 -05:00
|
|
|
for (i = 0; allCases[i].name != NULL; i++) {
|
2019-06-09 21:33:45 -05:00
|
|
|
if (allCases[i].wrongThreadWant == NULL)
|
2019-06-09 18:00:01 -05:00
|
|
|
continue;
|
2019-06-09 21:33:45 -05:00
|
|
|
checkProgrammerErrorInThread(t, allCases[i].name, allCases[i].f, NULL, allCases[i].wrongThreadWant);
|
2019-06-09 18:00:01 -05:00
|
|
|
}
|
2019-05-28 20:54:13 -05:00
|
|
|
}
|