aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-05-06 17:11:11 -0400
committerDavid Robillard <d@drobilla.net>2021-05-06 17:14:11 -0400
commit2245365a5727badc3348d3c0d2620bb5e8f568c5 (patch)
tree7903624d3dae3a73543e462abfe18e336665bb87 /test
parent6c482ae6345cba504622dddf900ebdc939eac0d1 (diff)
downloadpugl-2245365a5727badc3348d3c0d2620bb5e8f568c5.tar.gz
pugl-2245365a5727badc3348d3c0d2620bb5e8f568c5.tar.bz2
pugl-2245365a5727badc3348d3c0d2620bb5e8f568c5.zip
Use consistent name for test structure
Diffstat (limited to 'test')
-rw-r--r--test/test_redisplay.c42
-rw-r--r--test/test_timer.c56
-rw-r--r--test/test_update.c38
3 files changed, 68 insertions, 68 deletions
diff --git a/test/test_redisplay.c b/test/test_redisplay.c
index c5b9887..989aad7 100644
--- a/test/test_redisplay.c
+++ b/test/test_redisplay.c
@@ -100,42 +100,42 @@ onEvent(PuglView* view, const PuglEvent* event)
int
main(int argc, char** argv)
{
- PuglTest app = {puglNewWorld(PUGL_PROGRAM, 0),
- NULL,
- puglParseTestOptions(&argc, &argv),
- START};
+ PuglTest test = {puglNewWorld(PUGL_PROGRAM, 0),
+ NULL,
+ puglParseTestOptions(&argc, &argv),
+ START};
// Set up view
- app.view = puglNewView(app.world);
- puglSetClassName(app.world, "Pugl Test");
- puglSetBackend(app.view, puglStubBackend());
- puglSetHandle(app.view, &app);
- puglSetEventFunc(app.view, onEvent);
- puglSetDefaultSize(app.view, 512, 512);
+ test.view = puglNewView(test.world);
+ puglSetClassName(test.world, "Pugl Test");
+ puglSetBackend(test.view, puglStubBackend());
+ puglSetHandle(test.view, &test);
+ puglSetEventFunc(test.view, onEvent);
+ puglSetDefaultSize(test.view, 512, 512);
// Create and show window
- assert(!puglRealize(app.view));
- assert(!puglShow(app.view));
- while (app.state != EXPOSED) {
- assert(!puglUpdate(app.world, timeout));
+ assert(!puglRealize(test.view));
+ assert(!puglShow(test.view));
+ while (test.state != EXPOSED) {
+ assert(!puglUpdate(test.world, timeout));
}
// Send a custom event to trigger a redisplay in the event loop
PuglEvent client_event = {{PUGL_CLIENT, 0}};
client_event.client.data1 = postRedisplayId;
client_event.client.data2 = 0;
- assert(!puglSendEvent(app.view, &client_event));
+ assert(!puglSendEvent(test.view, &client_event));
// Loop until an expose happens in the same iteration as the redisplay
- app.state = SHOULD_REDISPLAY;
- while (app.state != REDISPLAYED) {
- assert(!puglUpdate(app.world, timeout));
- assert(app.state != POSTED_REDISPLAY);
+ test.state = SHOULD_REDISPLAY;
+ while (test.state != REDISPLAYED) {
+ assert(!puglUpdate(test.world, timeout));
+ assert(test.state != POSTED_REDISPLAY);
}
// Tear down
- puglFreeView(app.view);
- puglFreeWorld(app.world);
+ puglFreeView(test.view);
+ puglFreeWorld(test.world);
return 0;
}
diff --git a/test/test_timer.c b/test/test_timer.c
index 613535f..63f1843 100644
--- a/test/test_timer.c
+++ b/test/test_timer.c
@@ -93,42 +93,42 @@ roundPeriod(const double period)
int
main(int argc, char** argv)
{
- PuglTest app = {puglNewWorld(PUGL_PROGRAM, 0),
- NULL,
- puglParseTestOptions(&argc, &argv),
- 0,
- START};
+ PuglTest test = {puglNewWorld(PUGL_PROGRAM, 0),
+ NULL,
+ puglParseTestOptions(&argc, &argv),
+ 0,
+ START};
// Set up view
- app.view = puglNewView(app.world);
- puglSetClassName(app.world, "Pugl Test");
- puglSetBackend(app.view, puglStubBackend());
- puglSetHandle(app.view, &app);
- puglSetEventFunc(app.view, onEvent);
- puglSetDefaultSize(app.view, 512, 512);
+ test.view = puglNewView(test.world);
+ puglSetClassName(test.world, "Pugl Test");
+ puglSetBackend(test.view, puglStubBackend());
+ puglSetHandle(test.view, &test);
+ puglSetEventFunc(test.view, onEvent);
+ puglSetDefaultSize(test.view, 512, 512);
// Create and show window
- assert(!puglRealize(app.view));
- assert(!puglShow(app.view));
- while (app.state != EXPOSED) {
- assert(!puglUpdate(app.world, timeout));
+ assert(!puglRealize(test.view));
+ assert(!puglShow(test.view));
+ while (test.state != EXPOSED) {
+ assert(!puglUpdate(test.world, timeout));
}
// Register a timer with a longer period first
- assert(!puglStartTimer(app.view, timerId, timerPeriod * 2.0));
+ assert(!puglStartTimer(test.view, timerId, timerPeriod * 2.0));
// Replace it with the one we want (to ensure timers are replaced)
- assert(!puglStartTimer(app.view, timerId, timerPeriod));
+ assert(!puglStartTimer(test.view, timerId, timerPeriod));
- const double startTime = puglGetTime(app.world);
+ const double startTime = puglGetTime(test.world);
- puglUpdate(app.world, 1.0);
+ puglUpdate(test.world, 1.0);
// Calculate the actual period of the timer
- const double endTime = puglGetTime(app.world);
+ const double endTime = puglGetTime(test.world);
const double duration = endTime - startTime;
const double expectedPeriod = roundPeriod(timerPeriod);
- const double actualPeriod = roundPeriod(duration / (double)app.numAlarms);
+ const double actualPeriod = roundPeriod(duration / (double)test.numAlarms);
const double difference = fabs(actualPeriod - expectedPeriod);
if (difference > tolerance) {
@@ -140,16 +140,16 @@ main(int argc, char** argv)
assert(difference <= tolerance);
// Deregister timer and tick once to synchronize
- assert(!puglStopTimer(app.view, timerId));
- puglUpdate(app.world, 0.0);
+ assert(!puglStopTimer(test.view, timerId));
+ puglUpdate(test.world, 0.0);
// Update for a half second and check that we receive no more alarms
- app.numAlarms = 0;
- puglUpdate(app.world, 0.5);
- assert(app.numAlarms == 0);
+ test.numAlarms = 0;
+ puglUpdate(test.world, 0.5);
+ assert(test.numAlarms == 0);
- puglFreeView(app.view);
- puglFreeWorld(app.world);
+ puglFreeView(test.view);
+ puglFreeWorld(test.world);
return 0;
}
diff --git a/test/test_update.c b/test/test_update.c
index 89de0b6..e50205e 100644
--- a/test/test_update.c
+++ b/test/test_update.c
@@ -90,36 +90,36 @@ onEvent(PuglView* view, const PuglEvent* event)
int
main(int argc, char** argv)
{
- PuglTest app = {puglNewWorld(PUGL_PROGRAM, 0),
- NULL,
- puglParseTestOptions(&argc, &argv),
- START};
+ PuglTest test = {puglNewWorld(PUGL_PROGRAM, 0),
+ NULL,
+ puglParseTestOptions(&argc, &argv),
+ START};
// Set up view
- app.view = puglNewView(app.world);
- puglSetClassName(app.world, "Pugl Test");
- puglSetBackend(app.view, puglStubBackend());
- puglSetHandle(app.view, &app);
- puglSetEventFunc(app.view, onEvent);
- puglSetDefaultSize(app.view, 512, 512);
+ test.view = puglNewView(test.world);
+ puglSetClassName(test.world, "Pugl Test");
+ puglSetBackend(test.view, puglStubBackend());
+ puglSetHandle(test.view, &test);
+ puglSetEventFunc(test.view, onEvent);
+ puglSetDefaultSize(test.view, 512, 512);
// Create and show window
- assert(!puglRealize(app.view));
- assert(!puglShow(app.view));
+ assert(!puglRealize(test.view));
+ assert(!puglShow(test.view));
// Tick until an expose happens
- while (app.state < EXPOSED1) {
- assert(!puglUpdate(app.world, timeout));
- assert(app.state != UPDATED);
+ while (test.state < EXPOSED1) {
+ assert(!puglUpdate(test.world, timeout));
+ assert(test.state != UPDATED);
}
// Tick once and ensure the update and the expose it posted both happened
- assert(!puglUpdate(app.world, 0.0));
- assert(app.state == EXPOSED2);
+ assert(!puglUpdate(test.world, 0.0));
+ assert(test.state == EXPOSED2);
// Tear down
- puglFreeView(app.view);
- puglFreeWorld(app.world);
+ puglFreeView(test.view);
+ puglFreeWorld(test.world);
return 0;
}