testautomation_events.c File Reference
`#include <stdio.h>`
`#include "SDL.h"`
`#include "SDL_test.h"`
Include dependency graph for testautomation_events.c:

Go to the source code of this file.

## Functions

int | _events_sampleNullEventFilter (void *userdata, SDL_Event *event)
int | events_pushPumpAndPollUserevent (void *arg)
| Test pumping and peeking events. More...
int | events_addDelEventWatch (void *arg)
| Adds and deletes an event watch function with NULL userdata. More...
int | events_addDelEventWatchWithUserdata (void *arg)
| Adds and deletes an event watch function with userdata. More...

## Variables

int | _userdataCheck = 0
int | _userdataValue = 0
int | _eventFilterCalled = 0
int | _userdataValue1 = 1
int | _userdataValue2 = 2
static const SDLTest_TestCaseReference | eventsTest1
static const SDLTest_TestCaseReference | eventsTest2
static const SDLTest_TestCaseReference | eventsTest3
static const SDLTest_TestCaseReference * | eventsTests []
SDLTest_TestSuiteReference | eventsTestSuite

## Function Documentation

## _events_sampleNullEventFilter()

int _events_sampleNullEventFilter | ( | void * | userdata,
|  | SDL_Event * | event
| ) |  |

Definition at line 28 of file testautomation_events.c.

References _eventFilterCalled, _userdataCheck, _userdataValue, NULL, and SDLTest_AssertCheck().

Referenced by events_addDelEventWatch(), and events_addDelEventWatchWithUserdata().

{
_eventFilterCalled = 1;
if (_userdataCheck != 0) {
SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL");
if (userdata != NULL) {
SDLTest_AssertCheck(*(int *)userdata == _userdataValue, "Check userdata value, expected: %i, got: %i", _userdataValue, *(int *)userdata);
}
}
return 0;
}
_eventFilterCalled
int _eventFilterCalled
Definition: testautomation_events.c:21
_userdataCheck
int _userdataCheck
Definition: testautomation_events.c:15
SDLTest_AssertCheck
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Definition: SDL_test_assert.c:65
NULL
#define NULL
Definition: begin_code.h:164
_userdataValue
int _userdataValue
Definition: testautomation_events.c:18

## events_addDelEventWatch()

int events_addDelEventWatch | ( | void * | arg | ) |

Adds and deletes an event watch function with NULL userdata.

See also
  http://wiki.libsdl.org/moin.cgi/SDL_AddEventWatch
  http://wiki.libsdl.org/moin.cgi/SDL_DelEventWatch

Definition at line 84 of file testautomation_events.c.

References _eventFilterCalled, _events_sampleNullEventFilter(), _userdataCheck, _userdataValue1, _userdataValue2, NULL, SDL_AddEventWatch, SDL_DelEventWatch, SDL_PumpEvents, SDL_PushEvent, SDL_USEREVENT, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomSint32(), and TEST_COMPLETED.

{
SDL_Event event;
/* Create user event */
event.type = SDL_USEREVENT;
event.user.code = SDLTest_RandomSint32();
event.user.data1 = (void *)&_userdataValue1;
event.user.data2 = (void *)&_userdataValue2;
/* Disable userdata check */
_userdataCheck = 0;
/* Reset event filter call tracker */
_eventFilterCalled = 0;
/* Add watch */
SDL_AddEventWatch(_events_sampleNullEventFilter, NULL);
SDLTest_AssertPass("Call to SDL_AddEventWatch()");
/* Push a user event onto the queue and force queue update */
SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called");
/* Delete watch */
SDL_DelEventWatch(_events_sampleNullEventFilter, NULL);
SDLTest_AssertPass("Call to SDL_DelEventWatch()");
/* Push a user event onto the queue and force queue update */
_eventFilterCalled = 0;
SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called");
return TEST_COMPLETED;
}
SDL_DelEventWatch
#define SDL_DelEventWatch
Definition: SDL_dynapi_overrides.h:129
SDLTest_RandomSint32
Sint32 SDLTest_RandomSint32(void)
Definition: SDL_test_fuzzer.c:111
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
SDL_USEREVENT
Definition: SDL_events.h:154
_eventFilterCalled
int _eventFilterCalled
Definition: testautomation_events.c:21
SDL_PumpEvents
#define SDL_PumpEvents
Definition: SDL_dynapi_overrides.h:116
_userdataCheck
int _userdataCheck
Definition: testautomation_events.c:15
SDLTest_AssertCheck
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Definition: SDL_test_assert.c:65
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
_events_sampleNullEventFilter
int _events_sampleNullEventFilter(void *userdata, SDL_Event *event)
Definition: testautomation_events.c:28
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
_userdataValue1
int _userdataValue1
Definition: testautomation_events.c:24
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
NULL
#define NULL
Definition: begin_code.h:164
SDL_AddEventWatch
#define SDL_AddEventWatch
Definition: SDL_dynapi_overrides.h:128
SDL_Event
General event structure.
Definition: SDL_events.h:525
_userdataValue2
int _userdataValue2
Definition: testautomation_events.c:25

## events_addDelEventWatchWithUserdata()

int events_addDelEventWatchWithUserdata | ( | void * | arg | ) |

Adds and deletes an event watch function with userdata.

See also
  http://wiki.libsdl.org/moin.cgi/SDL_AddEventWatch
  http://wiki.libsdl.org/moin.cgi/SDL_DelEventWatch

Definition at line 134 of file testautomation_events.c.

References _eventFilterCalled, _events_sampleNullEventFilter(), _userdataCheck, _userdataValue, _userdataValue1, _userdataValue2, SDL_AddEventWatch, SDL_DelEventWatch, SDL_PumpEvents, SDL_PushEvent, SDL_USEREVENT, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomIntegerInRange(), SDLTest_RandomSint32(), and TEST_COMPLETED.

{
SDL_Event event;
/* Create user event */
event.type = SDL_USEREVENT;
event.user.code = SDLTest_RandomSint32();
event.user.data1 = (void *)&_userdataValue1;
event.user.data2 = (void *)&_userdataValue2;
/* Enable userdata check and set a value to check */
_userdataCheck = 1;
_userdataValue = SDLTest_RandomIntegerInRange(-1024, 1024);
/* Reset event filter call tracker */
_eventFilterCalled = 0;
/* Add watch */
SDL_AddEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue);
SDLTest_AssertPass("Call to SDL_AddEventWatch()");
/* Push a user event onto the queue and force queue update */
SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 1, "Check that event filter was called");
/* Delete watch */
SDL_DelEventWatch(_events_sampleNullEventFilter, (void *)&_userdataValue);
SDLTest_AssertPass("Call to SDL_DelEventWatch()");
/* Push a user event onto the queue and force queue update */
_eventFilterCalled = 0;
SDL_PushEvent(&event);
SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
SDLTest_AssertCheck(_eventFilterCalled == 0, "Check that event filter was NOT called");
return TEST_COMPLETED;
}
SDL_DelEventWatch
#define SDL_DelEventWatch
Definition: SDL_dynapi_overrides.h:129
SDLTest_RandomIntegerInRange
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max)
Definition: SDL_test_fuzzer.c:163
SDLTest_RandomSint32
Sint32 SDLTest_RandomSint32(void)
Definition: SDL_test_fuzzer.c:111
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
SDL_USEREVENT
Definition: SDL_events.h:154
_eventFilterCalled
int _eventFilterCalled
Definition: testautomation_events.c:21
SDL_PumpEvents
#define SDL_PumpEvents
Definition: SDL_dynapi_overrides.h:116
_userdataCheck
int _userdataCheck
Definition: testautomation_events.c:15
SDLTest_AssertCheck
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Definition: SDL_test_assert.c:65
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2649
_events_sampleNullEventFilter
int _events_sampleNullEventFilter(void *userdata, SDL_Event *event)
Definition: testautomation_events.c:28
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
_userdataValue1
int _userdataValue1
Definition: testautomation_events.c:24
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
SDL_AddEventWatch
#define SDL_AddEventWatch
Definition: SDL_dynapi_overrides.h:128
_userdataValue
int _userdataValue
Definition: testautomation_events.c:18
SDL_Event
General event structure.
Definition: SDL_events.h:525
_userdataValue2
int _userdataValue2
Definition: testautomation_events.c:25

## events_pushPumpAndPollUserevent()

int events_pushPumpAndPollUserevent | ( | void * | arg | ) |

Test pumping and peeking events.

See also
  http://wiki.libsdl.org/moin.cgi/SDL_PumpEvents
  http://wiki.libsdl.org/moin.cgi/SDL_PollEvent

Definition at line 49 of file testautomation_events.c.

References _userdataValue1, _userdataValue2, SDL_UserEvent::code, SDL_UserEvent::data1, SDL_UserEvent::data2, SDL_PollEvent, SDL_PumpEvents, SDL_PushEvent, SDL_USEREVENT, SDLTest_AssertCheck(), SDLTest_AssertPass(), SDLTest_RandomSint32(), TEST_COMPLETED, SDL_Event::type, and SDL_Event::user.

{
SDL_Event event1;
SDL_Event event2;
int result;
/* Create user event */
event1.type = SDL_USEREVENT;
event1.user.code = SDLTest_RandomSint32();
event1.user.data1 = (void *)&_userdataValue1;
event1.user.data2 = (void *)&_userdataValue2;
/* Push a user event onto the queue and force queue update */
SDL_PushEvent(&event1);
SDLTest_AssertPass("Call to SDL_PushEvent()");
SDL_PumpEvents();
SDLTest_AssertPass("Call to SDL_PumpEvents()");
/* Poll for user event */
result = SDL_PollEvent(&event2);
SDLTest_AssertPass("Call to SDL_PollEvent()");
SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result);
return TEST_COMPLETED;
}
SDL_UserEvent::data1
void * data1
Definition: SDL_events.h:501
SDL_PollEvent
#define SDL_PollEvent
Definition: SDL_dynapi_overrides.h:122
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDL_UserEvent::data2
void * data2
Definition: SDL_events.h:502
SDLTest_RandomSint32
Sint32 SDLTest_RandomSint32(void)
Definition: SDL_test_fuzzer.c:111
SDLTest_AssertPass
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(1)
Explicitly pass without checking an assertion condition. Updates assertion counter.
Definition: SDL_test_assert.c:94
SDL_USEREVENT
Definition: SDL_events.h:154
SDL_PumpEvents
#define SDL_PumpEvents
Definition: SDL_dynapi_overrides.h:116
SDLTest_AssertCheck
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription,...) SDL_PRINTF_VARARG_FUNC(2)
Assert for test cases that logs but does not break execution flow on failures. Updates assertion coun...
Definition: SDL_test_assert.c:65
SDL_PushEvent
#define SDL_PushEvent
Definition: SDL_dynapi_overrides.h:125
_userdataValue1
int _userdataValue1
Definition: testautomation_events.c:24
SDL_UserEvent::code
Sint32 code
Definition: SDL_events.h:500
TEST_COMPLETED
#define TEST_COMPLETED
Definition: SDL_test_harness.h:53
SDL_Event
General event structure.
Definition: SDL_events.h:525
SDL_Event::user
SDL_UserEvent user
Definition: SDL_events.h:546
SDL_Event::type
Uint32 type
Definition: SDL_events.h:527
_userdataValue2
int _userdataValue2
Definition: testautomation_events.c:25

## Variable Documentation

## _eventFilterCalled

int _eventFilterCalled = 0

Definition at line 21 of file testautomation_events.c.

Referenced by _events_sampleNullEventFilter(), events_addDelEventWatch(), and events_addDelEventWatchWithUserdata().

## _userdataCheck

int _userdataCheck = 0

Events test suite

Definition at line 15 of file testautomation_events.c.

Referenced by _events_sampleNullEventFilter(), events_addDelEventWatch(), and events_addDelEventWatchWithUserdata().

## _userdataValue

int _userdataValue = 0

Definition at line 18 of file testautomation_events.c.

Referenced by _events_sampleNullEventFilter(), and events_addDelEventWatchWithUserdata().

## _userdataValue1

int _userdataValue1 = 1

Definition at line 24 of file testautomation_events.c.

Referenced by events_addDelEventWatch(), events_addDelEventWatchWithUserdata(), and events_pushPumpAndPollUserevent().

## _userdataValue2

int _userdataValue2 = 2

Definition at line 25 of file testautomation_events.c.

Referenced by events_addDelEventWatch(), events_addDelEventWatchWithUserdata(), and events_pushPumpAndPollUserevent().

## eventsTest1

const SDLTest_TestCaseReference eventsTest1

static

Initial value:
=
{ (SDLTest_TestCaseFp)events_pushPumpAndPollUserevent, "events_pushPumpAndPollUserevent", "Pushes, pumps and polls a user event", TEST_ENABLED }
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47
events_pushPumpAndPollUserevent
int events_pushPumpAndPollUserevent(void *arg)
Test pumping and peeking events.
Definition: testautomation_events.c:49

Definition at line 181 of file testautomation_events.c.

## eventsTest2

const SDLTest_TestCaseReference eventsTest2

static

Initial value:
=
{ (SDLTest_TestCaseFp)events_addDelEventWatch, "events_addDelEventWatch", "Adds and deletes an event watch function with NULL userdata", TEST_ENABLED }
events_addDelEventWatch
int events_addDelEventWatch(void *arg)
Adds and deletes an event watch function with NULL userdata.
Definition: testautomation_events.c:84
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47

Definition at line 184 of file testautomation_events.c.

## eventsTest3

const SDLTest_TestCaseReference eventsTest3

static

Initial value:
=
{ (SDLTest_TestCaseFp)events_addDelEventWatchWithUserdata, "events_addDelEventWatchWithUserdata", "Adds and deletes an event watch function with userdata", TEST_ENABLED }
SDLTest_TestCaseFp
int(* SDLTest_TestCaseFp)(void *arg)
Definition: SDL_test_harness.h:67
events_addDelEventWatchWithUserdata
int events_addDelEventWatchWithUserdata(void *arg)
Adds and deletes an event watch function with userdata.
Definition: testautomation_events.c:134
TEST_ENABLED
#define TEST_ENABLED
Definition: SDL_test_harness.h:47

Definition at line 187 of file testautomation_events.c.

## eventsTests

const SDLTest_TestCaseReference* eventsTests[]

static

Initial value:
= {
&eventsTest1, &eventsTest2, &eventsTest3, NULL
}
eventsTest3
static const SDLTest_TestCaseReference eventsTest3
Definition: testautomation_events.c:187
eventsTest2
static const SDLTest_TestCaseReference eventsTest2
Definition: testautomation_events.c:184
NULL
#define NULL
Definition: begin_code.h:164
eventsTest1
static const SDLTest_TestCaseReference eventsTest1
Definition: testautomation_events.c:181

Definition at line 191 of file testautomation_events.c.

## eventsTestSuite

SDLTest_TestSuiteReference eventsTestSuite

Initial value:
= {
"Events",
NULL,
eventsTests,
NULL
}
eventsTests
static const SDLTest_TestCaseReference * eventsTests[]
Definition: testautomation_events.c:191
NULL
#define NULL
Definition: begin_code.h:164

Definition at line 196 of file testautomation_events.c.