test/testautomation_main.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 10189 4844b48eb17b
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     1
/**
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     2
 * Automated SDL subsystems management test.
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     3
 *
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7663
diff changeset
     4
 * Written by J�rgen Tjern� "jorgenpt"
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     5
 *
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     6
 * Released under Public Domain.
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     7
 */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     8
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
     9
#include "SDL.h"
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    10
#include "SDL_test.h"
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    11
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    12
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7663
diff changeset
    13
/* !
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    14
 * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    15
 * \sa
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    16
 * http://wiki.libsdl.org/moin.cgi/SDL_Init
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    17
 * http://wiki.libsdl.org/moin.cgi/SDL_Quit
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    18
 */
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    19
static int main_testInitQuitJoystickHaptic (void *arg)
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    20
{
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    21
#if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    22
    return TEST_SKIPPED;
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    23
#else
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    24
    int enabled_subsystems;
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    25
    int initialized_subsystems = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    26
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    27
    SDLTest_AssertCheck( SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems." );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    28
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    29
    enabled_subsystems = SDL_WasInit(initialized_subsystems);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    30
    SDLTest_AssertCheck( enabled_subsystems == initialized_subsystems, "SDL_WasInit(SDL_INIT_EVERYTHING) contains all systems (%i)", enabled_subsystems );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    31
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    32
    SDL_Quit();
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    33
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    34
    enabled_subsystems = SDL_WasInit(initialized_subsystems);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    35
    SDLTest_AssertCheck( enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    36
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    37
    return TEST_COMPLETED;
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    38
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    39
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    40
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7663
diff changeset
    41
/* !
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    42
 * \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem()
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    43
 * \sa
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    44
 * http://wiki.libsdl.org/moin.cgi/SDL_Init
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    45
 * http://wiki.libsdl.org/moin.cgi/SDL_Quit
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    46
 */
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    47
static int main_testInitQuitSubSystem (void *arg)
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    48
{
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    49
#if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED || defined SDL_GAMECONTROLLER_DISABLED
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    50
    return TEST_SKIPPED;
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    51
#else
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    52
    int i;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    53
    int subsystems[] = { SDL_INIT_JOYSTICK, SDL_INIT_HAPTIC, SDL_INIT_GAMECONTROLLER };
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    54
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    55
    for (i = 0; i < SDL_arraysize(subsystems); ++i) {
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    56
        int initialized_system;
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    57
        int subsystem = subsystems[i];
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    58
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    59
        SDLTest_AssertCheck( (SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) before init should be false", subsystem );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    60
        SDLTest_AssertCheck( SDL_InitSubSystem(subsystem) == 0, "SDL_InitSubSystem(%x)", subsystem );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    61
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    62
        initialized_system = SDL_WasInit(subsystem);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    63
        SDLTest_AssertCheck( (initialized_system & subsystem) != 0, "SDL_WasInit(%x) should be true (%x)", subsystem, initialized_system );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    64
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    65
        SDL_QuitSubSystem(subsystem);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    66
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    67
        SDLTest_AssertCheck( (SDL_WasInit(subsystem) & subsystem) == 0, "SDL_WasInit(%x) after shutdown should be false", subsystem );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    68
    }
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    69
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    70
    return TEST_COMPLETED;
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    71
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    72
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    73
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    74
const int joy_and_controller = SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER;
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    75
static int main_testImpliedJoystickInit (void *arg)
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    76
{
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    77
#if defined SDL_JOYSTICK_DISABLED || defined SDL_GAMECONTROLLER_DISABLED
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    78
    return TEST_SKIPPED;
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    79
#else
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    80
    int initialized_system;
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    81
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
    82
    /* First initialize the controller */
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    83
    SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    84
    SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    85
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
    86
    /* Then make sure this implicitly initialized the joystick subsystem */
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
    87
    initialized_system = SDL_WasInit(joy_and_controller);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    88
    SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    89
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
    90
    /* Then quit the controller, and make sure that implicitly also quits the */
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
    91
    /* joystick subsystem */
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    92
    SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    93
    initialized_system = SDL_WasInit(joy_and_controller);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    94
    SDLTest_AssertCheck( (initialized_system & joy_and_controller) == 0, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system );
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6869
diff changeset
    95
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    96
    return TEST_COMPLETED;
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
    97
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    98
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
    99
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   100
static int main_testImpliedJoystickQuit (void *arg)
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   101
{
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   102
#if defined SDL_JOYSTICK_DISABLED || defined SDL_GAMECONTROLLER_DISABLED
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   103
    return TEST_SKIPPED;
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   104
#else
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
   105
    int initialized_system;
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
   106
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   107
    /* First initialize the controller and the joystick (explicitly) */
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   108
    SDLTest_AssertCheck( (SDL_WasInit(joy_and_controller) & joy_and_controller) == 0, "SDL_WasInit() before init should be false for joystick & controller" );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   109
    SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0, "SDL_InitSubSystem(SDL_INIT_JOYSTICK)" );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   110
    SDLTest_AssertCheck( SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == 0, "SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)" );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   111
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   112
    /* Then make sure they're both initialized properly */
6869
baac6ec78a95 Fix another non-C90 variable declaration
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents: 6866
diff changeset
   113
    initialized_system = SDL_WasInit(joy_and_controller);
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   114
    SDLTest_AssertCheck( (initialized_system & joy_and_controller) == joy_and_controller, "SDL_WasInit() should be true for joystick & controller (%x)", initialized_system );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   115
7663
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   116
    /* Then quit the controller, and make sure that it does NOT quit the */
53fe1b64eb2d More non C89 compliant comments
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7191
diff changeset
   117
    /* explicitly initialized joystick subsystem. */
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   118
    SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   119
    initialized_system = SDL_WasInit(joy_and_controller);
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   120
    SDLTest_AssertCheck( (initialized_system & joy_and_controller) == SDL_INIT_JOYSTICK, "SDL_WasInit() should be false for joystick & controller (%x)", initialized_system );
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   121
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   122
    SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
6872
2f4c95464651 Fix fuzzer random boundary functions; add tests for fuzzer
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6869
diff changeset
   123
7189
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   124
    return TEST_COMPLETED;
414be1d64060 Update test harness to handle test return codes; fix comment format in harness; update Main test suite to handle globally disabled features
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7144
diff changeset
   125
#endif
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   126
}
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   127
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   128
static const SDLTest_TestCaseReference mainTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   129
        { (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED};
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   130
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   131
static const SDLTest_TestCaseReference mainTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   132
        { (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED};
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   133
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   134
static const SDLTest_TestCaseReference mainTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   135
        { (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED};
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   136
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   137
static const SDLTest_TestCaseReference mainTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   138
        { (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED};
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   139
10189
4844b48eb17b Fixed three source comments in tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7678
diff changeset
   140
/* Sequence of Main test cases */
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   141
static const SDLTest_TestCaseReference *mainTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   142
    &mainTest1,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   143
    &mainTest2,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   144
    &mainTest3,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   145
    &mainTest4,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   146
    NULL
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   147
};
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   148
10189
4844b48eb17b Fixed three source comments in tests.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7678
diff changeset
   149
/* Main test suite (global) */
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   150
SDLTest_TestSuiteReference mainTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   151
    "Main",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   152
    NULL,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   153
    mainTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7189
diff changeset
   154
    NULL
6866
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   155
};
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   156
e74a4b282450 Don't clobber refcounting in SDL_Init.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
diff changeset
   157
/* vi: set ts=4 sw=4 expandtab: */