Added uiControlOnFree() checking to test/control.c. Now we can add the tests for uiControlFree() calling Free on children, and then we can finally start implementing these on the other platforms :D
This commit is contained in:
parent
a1b0979506
commit
644afdedaf
|
@ -4,6 +4,8 @@
|
||||||
struct counts {
|
struct counts {
|
||||||
unsigned long countInit;
|
unsigned long countInit;
|
||||||
unsigned long countFree;
|
unsigned long countFree;
|
||||||
|
|
||||||
|
unsigned long countEventOnFree;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void checkCountsFull(testingT *t, const char *file, long line, const struct counts *got, const struct counts *want)
|
static void checkCountsFull(testingT *t, const char *file, long line, const struct counts *got, const struct counts *want)
|
||||||
|
@ -15,6 +17,13 @@ static void checkCountsFull(testingT *t, const char *file, long line, const stru
|
||||||
check(Init);
|
check(Init);
|
||||||
check(Free);
|
check(Free);
|
||||||
#undef check
|
#undef check
|
||||||
|
|
||||||
|
#define check(event) \
|
||||||
|
if (got->countEvent ## event != want->countEvent ## event) \
|
||||||
|
testingTErrorfFull(t, file, line, "wrong number of fires of uiControl" #event "():" diff("%lu"), \
|
||||||
|
got->countEvent ## event, want->countEvent ## event)
|
||||||
|
check(OnFree);
|
||||||
|
#undef check
|
||||||
}
|
}
|
||||||
|
|
||||||
#define checkCounts(t, got, want) checkCountsFull(t, __FILE__, __LINE__, got, want)
|
#define checkCounts(t, got, want) checkCountsFull(t, __FILE__, __LINE__, got, want)
|
||||||
|
@ -71,11 +80,19 @@ size_t testImplDataSize(void)
|
||||||
uint32_t testControlType = 0;
|
uint32_t testControlType = 0;
|
||||||
uint32_t testControlType2 = 0;
|
uint32_t testControlType2 = 0;
|
||||||
|
|
||||||
|
static void eventFreeHandler(void *sender, void *args, void *data)
|
||||||
|
{
|
||||||
|
struct counts *counts = (struct counts *) data;
|
||||||
|
|
||||||
|
counts->countEventOnFree++;
|
||||||
|
}
|
||||||
|
|
||||||
testingTest(ControlMethodsCalled)
|
testingTest(ControlMethodsCalled)
|
||||||
{
|
{
|
||||||
uiControl *c;
|
uiControl *c;
|
||||||
struct counts counts;
|
struct counts counts;
|
||||||
struct counts want;
|
struct counts want;
|
||||||
|
int handler;
|
||||||
|
|
||||||
testingTLogf(t, "*** uiNewControl()");
|
testingTLogf(t, "*** uiNewControl()");
|
||||||
memset(&counts, 0, sizeof (struct counts));
|
memset(&counts, 0, sizeof (struct counts));
|
||||||
|
@ -86,10 +103,12 @@ testingTest(ControlMethodsCalled)
|
||||||
|
|
||||||
testingTLogf(t, "*** uiControlFree()");
|
testingTLogf(t, "*** uiControlFree()");
|
||||||
memset(&counts, 0, sizeof (struct counts));
|
memset(&counts, 0, sizeof (struct counts));
|
||||||
// TODO add event handler
|
handler = uiEventAddHandler(uiControlOnFree(), eventFreeHandler, c, &counts);
|
||||||
uiControlFree(c);
|
uiControlFree(c);
|
||||||
|
uiEventDeleteHandler(uiControlOnFree(), handler);
|
||||||
memset(&want, 0, sizeof (struct counts));
|
memset(&want, 0, sizeof (struct counts));
|
||||||
want.countFree = 1;
|
want.countFree = 1;
|
||||||
|
want.countEventOnFree = 1;
|
||||||
checkCounts(t, &counts, &want);
|
checkCounts(t, &counts, &want);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue