test/testautomation_mouse.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 7191 75360622e65f
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Mouse test suite
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
#include <stdio.h>
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
#include <limits.h>
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
#include "SDL.h"
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
#include "SDL_test.h"
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
/* ================= Test Case Implementation ================== */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
/* Test case functions */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
/* Helper to evaluate state returned from SDL_GetMouseState */
7157
a082c2eeb247 Fixed test suite for mouse using Uint8 instead of Uint32 for buttons.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7144
diff changeset
    16
int _mouseStateCheck(Uint32 state)
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    18
  return (state == 0) ||
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    19
         (state == SDL_BUTTON(SDL_BUTTON_LEFT)) ||
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    20
         (state == SDL_BUTTON(SDL_BUTTON_MIDDLE)) ||
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    21
         (state == SDL_BUTTON(SDL_BUTTON_RIGHT)) ||
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    22
         (state == SDL_BUTTON(SDL_BUTTON_X1)) ||
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
    23
         (state == SDL_BUTTON(SDL_BUTTON_X2));
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
/**
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
 * @brief Check call to SDL_GetMouseState
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    28
 *
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
 */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
int
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
mouse_getMouseState(void *arg)
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
{
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
   int x;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
   int y;
7157
a082c2eeb247 Fixed test suite for mouse using Uint8 instead of Uint32 for buttons.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7144
diff changeset
    35
   Uint32 state;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
   /* Pump some events to update mouse state */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
   SDL_PumpEvents();
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
   SDLTest_AssertPass("Call to SDL_PumpEvents()");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    41
   /* Case where x, y pointer is NULL */
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
   state = SDL_GetMouseState(NULL, NULL);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
   SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, NULL)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    44
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
   /* Case where x pointer is not NULL */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
   x = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
   state = SDL_GetMouseState(&x, NULL);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
   SDLTest_AssertPass("Call to SDL_GetMouseState(&x, NULL)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
   SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
   /* Case where y pointer is not NULL */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
   y = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
   state = SDL_GetMouseState(NULL, &y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
   SDLTest_AssertPass("Call to SDL_GetMouseState(NULL, &y)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
   SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
   /* Case where x and y pointer is not NULL */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
   x = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
   y = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
   state = SDL_GetMouseState(&x, &y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
   SDLTest_AssertPass("Call to SDL_GetMouseState(&x, &y)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
   SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
   SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    68
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
   return TEST_COMPLETED;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
/**
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
 * @brief Check call to SDL_GetRelativeMouseState
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    74
 *
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
 */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
int
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
mouse_getRelativeMouseState(void *arg)
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
{
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
   int x;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
   int y;
7157
a082c2eeb247 Fixed test suite for mouse using Uint8 instead of Uint32 for buttons.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 7144
diff changeset
    81
   Uint32 state;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
   /* Pump some events to update mouse state */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
   SDL_PumpEvents();
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
   SDLTest_AssertPass("Call to SDL_PumpEvents()");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
    87
   /* Case where x, y pointer is NULL */
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
   state = SDL_GetRelativeMouseState(NULL, NULL);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
   SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, NULL)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
   /* Case where x pointer is not NULL */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
   x = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
   state = SDL_GetRelativeMouseState(&x, NULL);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
   SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, NULL)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
   SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
   /* Case where y pointer is not NULL */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
   y = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
   state = SDL_GetRelativeMouseState(NULL, &y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
   SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(NULL, &y)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
   SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
   /* Case where x and y pointer is not NULL */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
   x = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
   y = INT_MIN;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
   state = SDL_GetRelativeMouseState(&x, &y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
   SDLTest_AssertPass("Call to SDL_GetRelativeMouseState(&x, &y)");
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
   SDLTest_AssertCheck(x > INT_MIN, "Validate that value of x is > INT_MIN, got: %i", x);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
   SDLTest_AssertCheck(y > INT_MIN, "Validate that value of y is > INT_MIN, got: %i", y);
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   113
   SDLTest_AssertCheck(_mouseStateCheck(state), "Validate state returned from function, got: %i", state);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   114
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
   return TEST_COMPLETED;
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   118
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   119
/* XPM definition of mouse Cursor */
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   120
static const char *_mouseArrowData[] = {
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   121
  /* pixels */
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   122
  "X                               ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   123
  "XX                              ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   124
  "X.X                             ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   125
  "X..X                            ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   126
  "X...X                           ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   127
  "X....X                          ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   128
  "X.....X                         ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   129
  "X......X                        ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   130
  "X.......X                       ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   131
  "X........X                      ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   132
  "X.....XXXXX                     ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   133
  "X..X..X                         ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   134
  "X.X X..X                        ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   135
  "XX  X..X                        ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   136
  "X    X..X                       ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   137
  "     X..X                       ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   138
  "      X..X                      ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   139
  "      X..X                      ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   140
  "       XX                       ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   141
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   142
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   143
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   144
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   145
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   146
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   147
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   148
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   149
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   150
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   151
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   152
  "                                ",
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   153
  "                                "
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   154
};
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   155
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   156
/* Helper that creates a new mouse cursor from an XPM */
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   157
static SDL_Cursor *_initArrowCursor(const char *image[])
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   158
{
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   159
  SDL_Cursor *cursor;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   160
  int i, row, col;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   161
  Uint8 data[4*32];
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   162
  Uint8 mask[4*32];
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   163
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   164
  i = -1;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   165
  for ( row=0; row<32; ++row ) {
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   166
    for ( col=0; col<32; ++col ) {
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   167
      if ( col % 8 ) {
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   168
        data[i] <<= 1;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   169
        mask[i] <<= 1;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   170
      } else {
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   171
        ++i;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   172
        data[i] = mask[i] = 0;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   173
      }
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   174
      switch (image[row][col]) {
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   175
        case 'X':
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   176
          data[i] |= 0x01;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   177
          mask[i] |= 0x01;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   178
          break;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   179
        case '.':
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   180
          mask[i] |= 0x01;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   181
          break;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   182
        case ' ':
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   183
          break;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   184
      }
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   185
    }
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   186
  }
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   187
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   188
  cursor = SDL_CreateCursor(data, mask, 32, 32, 0, 0);
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   189
  return cursor;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   190
}
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   191
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   192
/**
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   193
 * @brief Check call to SDL_CreateCursor and SDL_FreeCursor
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   194
 *
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   195
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateCursor
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   196
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   197
 */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   198
int
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   199
mouse_createFreeCursor(void *arg)
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   200
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   201
    SDL_Cursor *cursor;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   203
    /* Create a cursor */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   204
    cursor = _initArrowCursor(_mouseArrowData);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   205
        SDLTest_AssertPass("Call to SDL_CreateCursor()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   206
        SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   207
    if (cursor == NULL) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   208
        return TEST_ABORTED;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   209
    }
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   210
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   211
    /* Free cursor again */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   212
    SDL_FreeCursor(cursor);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   213
    SDLTest_AssertPass("Call to SDL_FreeCursor()");
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   214
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   215
    return TEST_COMPLETED;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   216
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   217
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   218
/**
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   219
 * @brief Check call to SDL_CreateColorCursor and SDL_FreeCursor
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   220
 *
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   221
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateColorCursor
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   222
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   223
 */
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   224
int
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   225
mouse_createFreeColorCursor(void *arg)
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   226
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   227
    SDL_Surface *face;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   228
    SDL_Cursor *cursor;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   229
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   230
    /* Get sample surface */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   231
    face = SDLTest_ImageFace();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   232
    SDLTest_AssertCheck(face != NULL, "Validate sample input image is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   233
    if (face == NULL) return TEST_ABORTED;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   234
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   235
    /* Create a color cursor from surface */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   236
    cursor = SDL_CreateColorCursor(face, 0, 0);
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   237
        SDLTest_AssertPass("Call to SDL_CreateColorCursor()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   238
        SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateColorCursor() is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   239
    if (cursor == NULL) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   240
        SDL_FreeSurface(face);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   241
        return TEST_ABORTED;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   242
    }
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   243
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   244
    /* Free cursor again */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   245
    SDL_FreeCursor(cursor);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   246
    SDLTest_AssertPass("Call to SDL_FreeCursor()");
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   247
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   248
    /* Clean up */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   249
    SDL_FreeSurface(face);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   250
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   251
    return TEST_COMPLETED;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   252
}
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   253
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   254
/* Helper that changes cursor visibility */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   255
void _changeCursorVisibility(int state)
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   256
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   257
    int oldState;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   258
    int newState;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   259
    int result;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   260
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   261
        oldState = SDL_ShowCursor(SDL_QUERY);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   262
    SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   263
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   264
        result = SDL_ShowCursor(state);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   265
    SDLTest_AssertPass("Call to SDL_ShowCursor(%s)", (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   266
    SDLTest_AssertCheck(result == oldState, "Validate result from SDL_ShowCursor(%s), expected: %i, got: %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   267
        (state == SDL_ENABLE) ? "SDL_ENABLE" : "SDL_DISABLE", oldState, result);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   268
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   269
    newState = SDL_ShowCursor(SDL_QUERY);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   270
    SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   271
    SDLTest_AssertCheck(state == newState, "Validate new state, expected: %i, got: %i",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   272
        state, newState);
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   273
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   274
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   275
/**
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   276
 * @brief Check call to SDL_ShowCursor
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   277
 *
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   278
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_ShowCursor
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   279
 */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   280
int
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   281
mouse_showCursor(void *arg)
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   282
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   283
    int currentState;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   284
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   285
    /* Get current state */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   286
    currentState = SDL_ShowCursor(SDL_QUERY);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   287
    SDLTest_AssertPass("Call to SDL_ShowCursor(SDL_QUERY)");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   288
    SDLTest_AssertCheck(currentState == SDL_DISABLE || currentState == SDL_ENABLE,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   289
        "Validate result is %i or %i, got: %i", SDL_DISABLE, SDL_ENABLE, currentState);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   290
    if (currentState == SDL_DISABLE) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   291
        /* Show the cursor, then hide it again */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   292
        _changeCursorVisibility(SDL_ENABLE);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   293
        _changeCursorVisibility(SDL_DISABLE);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   294
    } else if (currentState == SDL_ENABLE) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   295
        /* Hide the cursor, then show it again */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   296
        _changeCursorVisibility(SDL_DISABLE);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   297
        _changeCursorVisibility(SDL_ENABLE);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   298
    } else {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   299
        return TEST_ABORTED;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   300
    }
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   301
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   302
    return TEST_COMPLETED;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   303
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   304
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   305
/**
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   306
 * @brief Check call to SDL_SetCursor
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   307
 *
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   308
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetCursor
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   309
 */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   310
int
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   311
mouse_setCursor(void *arg)
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   312
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   313
    SDL_Cursor *cursor;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   314
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   315
    /* Create a cursor */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   316
    cursor = _initArrowCursor(_mouseArrowData);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   317
        SDLTest_AssertPass("Call to SDL_CreateCursor()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   318
        SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_CreateCursor() is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   319
    if (cursor == NULL) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   320
        return TEST_ABORTED;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   321
    }
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   322
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   323
    /* Set the arrow cursor */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   324
    SDL_SetCursor(cursor);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   325
    SDLTest_AssertPass("Call to SDL_SetCursor(cursor)");
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   326
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   327
    /* Force redraw */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   328
    SDL_SetCursor(NULL);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   329
    SDLTest_AssertPass("Call to SDL_SetCursor(NULL)");
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   330
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   331
    /* Free cursor again */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   332
    SDL_FreeCursor(cursor);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   333
    SDLTest_AssertPass("Call to SDL_FreeCursor()");
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   334
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   335
    return TEST_COMPLETED;
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   336
}
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   337
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   338
/**
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   339
 * @brief Check call to SDL_GetCursor
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   340
 *
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   341
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetCursor
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   342
 */
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   343
int
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   344
mouse_getCursor(void *arg)
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   345
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   346
    SDL_Cursor *cursor;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   347
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   348
    /* Get current cursor */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   349
    cursor = SDL_GetCursor();
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   350
        SDLTest_AssertPass("Call to SDL_GetCursor()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   351
        SDLTest_AssertCheck(cursor != NULL, "Validate result from SDL_GetCursor() is not NULL");
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   352
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   353
    return TEST_COMPLETED;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   354
}
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   355
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   356
/**
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   357
 * @brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   358
 *
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   359
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetRelativeMouseMode
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   360
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetRelativeMouseMode
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   361
 */
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   362
int
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   363
mouse_getSetRelativeMouseMode(void *arg)
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   364
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   365
    int result;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   366
        int i;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   367
    SDL_bool initialState;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   368
    SDL_bool currentState;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   369
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   370
    /* Capture original state so we can revert back to it later */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   371
    initialState = SDL_GetRelativeMouseMode();
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   372
        SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   373
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   374
        /* Repeat twice to check D->D transition */
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   375
        for (i=0; i<2; i++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   376
      /* Disable - should always be supported */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   377
          result = SDL_SetRelativeMouseMode(SDL_FALSE);
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   378
          SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   379
          SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   380
      currentState = SDL_GetRelativeMouseMode();
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   381
          SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   382
          SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState);
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   383
        }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   384
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   385
        /* Repeat twice to check D->E->E transition */
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   386
        for (i=0; i<2; i++) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   387
      /* Enable - may not be supported */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   388
          result = SDL_SetRelativeMouseMode(SDL_TRUE);
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   389
          SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(TRUE)");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   390
          if (result != -1) {
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   391
            SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   392
        currentState = SDL_GetRelativeMouseMode();
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   393
            SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   394
            SDLTest_AssertCheck(currentState == SDL_TRUE, "Validate current state is TRUE, got: %i", currentState);
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   395
          }
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   396
        }
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   397
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   398
    /* Disable to check E->D transition */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   399
        result = SDL_SetRelativeMouseMode(SDL_FALSE);
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   400
        SDLTest_AssertPass("Call to SDL_SetRelativeMouseMode(FALSE)");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   401
        SDLTest_AssertCheck(result == 0, "Validate result value from SDL_SetRelativeMouseMode, expected: 0, got: %i", result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   402
    currentState = SDL_GetRelativeMouseMode();
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   403
        SDLTest_AssertPass("Call to SDL_GetRelativeMouseMode()");
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   404
        SDLTest_AssertCheck(currentState == SDL_FALSE, "Validate current state is FALSE, got: %i", currentState);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   405
7144
c700de9c8ed4 Corrected spelling in C source files of test suites.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 6921
diff changeset
   406
        /* Revert to original state - ignore result */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   407
        result = SDL_SetRelativeMouseMode(initialState);
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   408
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   409
    return TEST_COMPLETED;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   410
}
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   411
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   412
#define MOUSE_TESTWINDOW_WIDTH  320
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   413
#define MOUSE_TESTWINDOW_HEIGHT 200
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   414
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   415
/**
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   416
 * Creates a test window
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   417
 */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   418
SDL_Window *_createMouseSuiteTestWindow()
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   419
{
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   420
  int posX = 100, posY = 100, width = MOUSE_TESTWINDOW_WIDTH, height = MOUSE_TESTWINDOW_HEIGHT;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   421
  SDL_Window *window;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   422
  window = SDL_CreateWindow("mouse_createMouseSuiteTestWindow", posX, posY, width, height, 0);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   423
  SDLTest_AssertPass("SDL_CreateWindow()");
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   424
  SDLTest_AssertCheck(window != NULL, "Check SDL_CreateWindow result");
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   425
  return window;
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   426
}
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   427
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   428
/*
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   429
 * Destroy test window
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   430
 */
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   431
void _destroyMouseSuiteTestWindow(SDL_Window *window)
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   432
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   433
  if (window != NULL) {
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   434
     SDL_DestroyWindow(window);
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   435
     window = NULL;
6921
9a29af9de577 Add tests to video suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   436
     SDLTest_AssertPass("SDL_DestroyWindow()");
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   437
  }
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   438
}
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   439
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   440
/**
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   441
 * @brief Check call to SDL_WarpMouseInWindow
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   442
 *
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   443
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_WarpMouseInWindow
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   444
 */
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   445
int
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   446
mouse_warpMouseInWindow(void *arg)
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   447
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   448
    const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   449
    int numPositions = 6;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   450
    int xPositions[] = {-1, 0, 1, w-1, w, w+1 };
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   451
    int yPositions[] = {-1, 0, 1, h-1, h, h+1 };
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   452
    int x, y, i, j;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   453
    SDL_Window *window;
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   454
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   455
    /* Create test window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   456
    window = _createMouseSuiteTestWindow();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   457
    if (window == NULL) return TEST_ABORTED;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   458
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   459
    /* Mouse to random position inside window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   460
    x = SDLTest_RandomIntegerInRange(1, w-1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   461
    y = SDLTest_RandomIntegerInRange(1, h-1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   462
    SDL_WarpMouseInWindow(window, x, y);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   463
    SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   464
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   465
        /* Same position again */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   466
    SDL_WarpMouseInWindow(window, x, y);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   467
    SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   468
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   469
    /* Mouse to various boundary positions */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   470
    for (i=0; i<numPositions; i++) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   471
      for (j=0; j<numPositions; j++) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   472
        x = xPositions[i];
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   473
        y = yPositions[j];
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   474
        SDL_WarpMouseInWindow(window, x, y);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   475
        SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   476
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   477
        /* TODO: add tracking of events and check that each call generates a mouse motion event */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   478
        SDL_PumpEvents();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   479
        SDLTest_AssertPass("SDL_PumpEvents()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   480
      }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   481
    }
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   482
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   483
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   484
        /* Clean up test window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   485
    _destroyMouseSuiteTestWindow(window);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   486
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   487
    return TEST_COMPLETED;
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   488
}
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   489
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   490
/**
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   491
 * @brief Check call to SDL_GetMouseFocus
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   492
 *
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   493
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetMouseFocus
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   494
 */
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   495
int
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   496
mouse_getMouseFocus(void *arg)
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   497
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   498
    const int w = MOUSE_TESTWINDOW_WIDTH, h = MOUSE_TESTWINDOW_HEIGHT;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   499
    int x, y;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   500
    SDL_Window *window;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   501
    SDL_Window *focusWindow;
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   502
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   503
    /* Get focus - focus non-deterministic */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   504
    focusWindow = SDL_GetMouseFocus();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   505
    SDLTest_AssertPass("SDL_GetMouseFocus()");
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   506
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   507
        /* Create test window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   508
    window = _createMouseSuiteTestWindow();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   509
    if (window == NULL) return TEST_ABORTED;
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   510
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   511
    /* Mouse to random position inside window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   512
    x = SDLTest_RandomIntegerInRange(1, w-1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   513
    y = SDLTest_RandomIntegerInRange(1, h-1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   514
    SDL_WarpMouseInWindow(window, x, y);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   515
    SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   516
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   517
    /* Pump events to update focus state */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   518
    SDL_PumpEvents();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   519
    SDLTest_AssertPass("SDL_PumpEvents()");
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   520
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   521
        /* Get focus with explicit window setup - focus deterministic */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   522
    focusWindow = SDL_GetMouseFocus();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   523
    SDLTest_AssertPass("SDL_GetMouseFocus()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   524
    SDLTest_AssertCheck (focusWindow != NULL, "Check returned window value is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   525
    SDLTest_AssertCheck (focusWindow == window, "Check returned window value is test window");
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   526
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   527
    /* Mouse to random position outside window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   528
    x = SDLTest_RandomIntegerInRange(-9, -1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   529
    y = SDLTest_RandomIntegerInRange(-9, -1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   530
    SDL_WarpMouseInWindow(window, x, y);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   531
    SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   532
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   533
        /* Clean up test window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   534
    _destroyMouseSuiteTestWindow(window);
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   535
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   536
    /* Pump events to update focus state */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   537
    SDL_PumpEvents();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   538
    SDLTest_AssertPass("SDL_PumpEvents()");
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   539
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   540
        /* Get focus for non-existing window */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   541
    focusWindow = SDL_GetMouseFocus();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   542
    SDLTest_AssertPass("SDL_GetMouseFocus()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   543
    SDLTest_AssertCheck (focusWindow == NULL, "Check returned window value is NULL");
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   544
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   545
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   546
    return TEST_COMPLETED;
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   547
}
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   548
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   549
/* ================= Test References ================== */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   550
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   551
/* Mouse test cases */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   552
static const SDLTest_TestCaseReference mouseTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   553
        { (SDLTest_TestCaseFp)mouse_getMouseState, "mouse_getMouseState", "Check call to SDL_GetMouseState", TEST_ENABLED };
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   554
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   555
static const SDLTest_TestCaseReference mouseTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   556
        { (SDLTest_TestCaseFp)mouse_getRelativeMouseState, "mouse_getRelativeMouseState", "Check call to SDL_GetRelativeMouseState", TEST_ENABLED };
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   557
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   558
static const SDLTest_TestCaseReference mouseTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   559
        { (SDLTest_TestCaseFp)mouse_createFreeCursor, "mouse_createFreeCursor", "Check call to SDL_CreateCursor and SDL_FreeCursor", TEST_ENABLED };
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   560
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   561
static const SDLTest_TestCaseReference mouseTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   562
        { (SDLTest_TestCaseFp)mouse_showCursor, "mouse_showCursor", "Check call to SDL_ShowCursor", TEST_ENABLED };
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   563
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   564
static const SDLTest_TestCaseReference mouseTest5 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   565
        { (SDLTest_TestCaseFp)mouse_setCursor, "mouse_setCursor", "Check call to SDL_SetCursor", TEST_ENABLED };
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   566
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   567
static const SDLTest_TestCaseReference mouseTest6 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   568
        { (SDLTest_TestCaseFp)mouse_getCursor, "mouse_getCursor", "Check call to SDL_GetCursor", TEST_ENABLED };
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   569
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   570
static const SDLTest_TestCaseReference mouseTest7 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   571
        { (SDLTest_TestCaseFp)mouse_warpMouseInWindow, "mouse_warpMouseInWindow", "Check call to SDL_WarpMouseInWindow", TEST_ENABLED };
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   572
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   573
static const SDLTest_TestCaseReference mouseTest8 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   574
        { (SDLTest_TestCaseFp)mouse_getMouseFocus, "mouse_getMouseFocus", "Check call to SDL_getMouseFocus", TEST_ENABLED };
6821
f36771112651 Add tests to mouse suite; fix VS compiler warnings in tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6801
diff changeset
   575
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   576
static const SDLTest_TestCaseReference mouseTest9 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   577
        { (SDLTest_TestCaseFp)mouse_createFreeColorCursor, "mouse_createFreeColorCursor", "Check call to SDL_CreateColorCursor and SDL_FreeCursor", TEST_ENABLED };
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   578
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   579
static const SDLTest_TestCaseReference mouseTest10 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   580
        { (SDLTest_TestCaseFp)mouse_getSetRelativeMouseMode, "mouse_getSetRelativeMouseMode", "Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode", TEST_ENABLED };
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6821
diff changeset
   581
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   582
/* Sequence of Mouse test cases */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   583
static const SDLTest_TestCaseReference *mouseTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   584
    &mouseTest1, &mouseTest2, &mouseTest3, &mouseTest4, &mouseTest5, &mouseTest6,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   585
    &mouseTest7, &mouseTest8, &mouseTest9, &mouseTest10, NULL
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   586
};
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   587
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   588
/* Mouse test suite (global) */
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   589
SDLTest_TestSuiteReference mouseTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   590
    "Mouse",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   591
    NULL,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   592
    mouseTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7157
diff changeset
   593
    NULL
6801
f92e3d5f71a2 Add new test suite (mouse) with a few new tests
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   594
};