test/testautomation_surface.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 17 Aug 2016 21:04:50 +0200
changeset 10275 ba7dc3ebb81e
parent 9282 e3ee6ba9eae8
permissions -rw-r--r--
Emscripten: Fixed opening previously closed joystick.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Original code: automated SDL surface test written by Edgar Simo "bobbens"
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 * Adapted/rewritten for test lib by Andreas Schiffler
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
6780
111b37940b35 Add define to surface suite to quiet VS compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
     6
/* Supress C4996 VS compiler warnings for unlink() */
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
     7
#define _CRT_SECURE_NO_DEPRECATE
6780
111b37940b35 Add define to surface suite to quiet VS compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
     8
#define _CRT_NONSTDC_NO_DEPRECATE
111b37940b35 Add define to surface suite to quiet VS compiler warnings
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6779
diff changeset
     9
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
#include <stdio.h>
9282
e3ee6ba9eae8 Maybe patched to compile on Windows for real now?
Ryan C. Gordon <icculus@icculus.org>
parents: 9281
diff changeset
    11
#ifndef _MSC_VER
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9218
diff changeset
    12
#include <unistd.h>
9281
85246fbeeac1 Patched to compile on Windows.
Ryan C. Gordon <icculus@icculus.org>
parents: 9278
diff changeset
    13
#endif
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
#include <sys/stat.h>
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
#include "SDL.h"
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
#include "SDL_test.h"
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
8673
50135c28f7cf Fixed warning on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 7720
diff changeset
    19
#ifdef __MACOSX__
50135c28f7cf Fixed warning on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 7720
diff changeset
    20
#include <unistd.h> /* For unlink() */
50135c28f7cf Fixed warning on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 7720
diff changeset
    21
#endif
50135c28f7cf Fixed warning on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 7720
diff changeset
    22
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
/* ================= Test Case Implementation ================== */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
/* Shared test surface */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    27
static SDL_Surface *referenceSurface = NULL;
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    28
static SDL_Surface *testSurface = NULL;
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    29
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    30
/* Helper functions for the test cases */
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    31
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    32
#define TEST_SURFACE_WIDTH testSurface->w
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    33
#define TEST_SURFACE_HEIGHT testSurface->h
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
/* Fixture */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    37
/* Create a 32-bit writable surface for blitting tests */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
void
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
_surfaceSetUp(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
{
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    41
    int result;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    42
    SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    43
    SDL_BlendMode currentBlendMode;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    44
    Uint32 rmask, gmask, bmask, amask;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    45
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    46
    rmask = 0xff000000;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    47
    gmask = 0x00ff0000;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    48
    bmask = 0x0000ff00;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    49
    amask = 0x000000ff;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    50
#else
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    51
    rmask = 0x000000ff;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    52
    gmask = 0x0000ff00;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    53
    bmask = 0x00ff0000;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    54
    amask = 0xff000000;
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    55
#endif
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    56
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    57
    referenceSurface = SDLTest_ImageBlit(); /* For size info */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    58
    testSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, referenceSurface->w, referenceSurface->h, 32, rmask, gmask, bmask, amask);
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
    59
    SDLTest_AssertCheck(testSurface != NULL, "Check that testSurface is not NULL");
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    60
    if (testSurface != NULL) {
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    61
      /* Disable blend mode for target surface */
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    62
      result = SDL_SetSurfaceBlendMode(testSurface, blendMode);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    63
      SDLTest_AssertCheck(result == 0, "Validate result from SDL_SetSurfaceBlendMode, expected: 0, got: %i", result);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    64
      result = SDL_GetSurfaceBlendMode(testSurface, &currentBlendMode);
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    65
      SDLTest_AssertCheck(result == 0, "Validate result from SDL_GetSurfaceBlendMode, expected: 0, got: %i", result);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    66
      SDLTest_AssertCheck(currentBlendMode == blendMode, "Validate blendMode, expected: %i, got: %i", blendMode, currentBlendMode);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    67
    }
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
void
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
_surfaceTearDown(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
{
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
    73
    SDL_FreeSurface(referenceSurface);
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
    74
    referenceSurface = NULL;
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
    75
    SDL_FreeSurface(testSurface);
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
    76
    testSurface = NULL;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
 * Helper that clears the test surface
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
void _clearTestSurface()
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    84
    int ret;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    85
    Uint32 color;
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
    86
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    87
    /* Clear surface. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    88
    color = SDL_MapRGBA( testSurface->format, 0, 0, 0, 0);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    89
    SDLTest_AssertPass("Call to SDL_MapRGBA()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    90
    ret = SDL_FillRect( testSurface, NULL, color);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    91
    SDLTest_AssertPass("Call to SDL_FillRect()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
    92
    SDLTest_AssertCheck(ret == 0, "Verify result from SDL_FillRect, expected: 0, got: %i", ret);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
 * Helper that blits in a specific blend mode, -1 for basic blitting, -2 for color mod, -3 for alpha mod, -4 for mixed blend modes.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
void _testBlitBlendMode(int mode)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   100
    int ret;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   101
    int i, j, ni, nj;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   102
    SDL_Surface *face;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   103
    SDL_Rect rect;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   104
    int nmode;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   105
    SDL_BlendMode bmode;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   106
    int checkFailCount1;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   107
    int checkFailCount2;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   108
    int checkFailCount3;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   109
    int checkFailCount4;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   111
    /* Check test surface */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   112
    SDLTest_AssertCheck(testSurface != NULL, "Verify testSurface is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   113
    if (testSurface == NULL) return;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   114
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   115
    /* Create sample surface */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   116
    face = SDLTest_ImageFace();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   117
    SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   118
    if (face == NULL) return;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   120
        /* Reset alpha modulation */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   121
    ret = SDL_SetSurfaceAlphaMod(face, 255);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   122
    SDLTest_AssertPass("Call to SDL_SetSurfaceAlphaMod()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   123
    SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceAlphaMod(), expected: 0, got: %i", ret);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
   124
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   125
        /* Reset color modulation */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   126
    ret = SDL_SetSurfaceColorMod(face, 255, 255, 255);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   127
    SDLTest_AssertPass("Call to SDL_SetSurfaceColorMod()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   128
    SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceColorMod(), expected: 0, got: %i", ret);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
   129
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   130
        /* Reset color key */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   131
    ret = SDL_SetColorKey(face, SDL_FALSE, 0);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   132
    SDLTest_AssertPass("Call to SDL_SetColorKey()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   133
    SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey(), expected: 0, got: %i", ret);
6811
60d95fcfaf3c Update SDL_InvalidParamError to take param name; add additional fuzzer function; add new tests to keyboard test suite; improve surface test suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6780
diff changeset
   134
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   135
    /* Clear the test surface */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
        _clearTestSurface();
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   137
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   138
    /* Target rect size */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   139
    rect.w = face->w;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   140
    rect.h = face->h;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   141
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   142
    /* Steps to take */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   143
    ni = testSurface->w - face->w;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   144
    nj = testSurface->h - face->h;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   146
    /* Optionally set blend mode. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   147
    if (mode >= 0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   148
        ret = SDL_SetSurfaceBlendMode( face, (SDL_BlendMode)mode );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   149
        SDLTest_AssertPass("Call to SDL_SetSurfaceBlendMode()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   150
        SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetSurfaceBlendMode(..., %i), expected: 0, got: %i", mode, ret);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   151
    }
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   152
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   153
    /* Test blend mode. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   154
    checkFailCount1 = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   155
    checkFailCount2 = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   156
    checkFailCount3 = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   157
    checkFailCount4 = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   158
    for (j=0; j <= nj; j+=4) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   159
      for (i=0; i <= ni; i+=4) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   160
        if (mode == -2) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   161
            /* Set color mod. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   162
            ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   163
            if (ret != 0) checkFailCount2++;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   164
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   165
        else if (mode == -3) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   166
            /* Set alpha mod. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   167
            ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   168
            if (ret != 0) checkFailCount3++;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   169
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   170
        else if (mode == -4) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   171
            /* Crazy blending mode magic. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   172
            nmode = (i/4*j/4) % 4;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   173
            if (nmode==0) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   174
                bmode = SDL_BLENDMODE_NONE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   175
            } else if (nmode==1) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   176
                bmode = SDL_BLENDMODE_BLEND;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   177
            } else if (nmode==2) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   178
                bmode = SDL_BLENDMODE_ADD;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   179
            } else if (nmode==3) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   180
                bmode = SDL_BLENDMODE_MOD;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   181
            }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   182
            ret = SDL_SetSurfaceBlendMode( face, bmode );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   183
            if (ret != 0) checkFailCount4++;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   184
        }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   185
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   186
         /* Blitting. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   187
         rect.x = i;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   188
         rect.y = j;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   189
         ret = SDL_BlitSurface( face, NULL, testSurface, &rect );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   190
         if (ret != 0) checkFailCount1++;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   191
      }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   192
    }
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   193
    SDLTest_AssertCheck(checkFailCount1 == 0, "Validate results from calls to SDL_BlitSurface, expected: 0, got: %i", checkFailCount1);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   194
    SDLTest_AssertCheck(checkFailCount2 == 0, "Validate results from calls to SDL_SetSurfaceColorMod, expected: 0, got: %i", checkFailCount2);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   195
    SDLTest_AssertCheck(checkFailCount3 == 0, "Validate results from calls to SDL_SetSurfaceAlphaMod, expected: 0, got: %i", checkFailCount3);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   196
    SDLTest_AssertCheck(checkFailCount4 == 0, "Validate results from calls to SDL_SetSurfaceBlendMode, expected: 0, got: %i", checkFailCount4);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   197
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   198
    /* Clean up */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   199
    SDL_FreeSurface(face);
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   200
    face = NULL;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   201
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   203
/* Helper to check that a file exists */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   204
void
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   205
_AssertFileExist(const char *filename)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   206
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   207
    struct stat st;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   208
    int ret = stat(filename, &st);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   209
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   210
    SDLTest_AssertCheck(ret == 0, "Verify file '%s' exists", filename);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   211
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   212
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   213
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   214
/* Test case functions */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   215
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   216
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   217
 * @brief Tests sprite saving and loading
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   218
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   219
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   220
surface_testSaveLoadBitmap(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   221
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   222
    int ret;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   223
    const char *sampleFilename = "testSaveLoadBitmap.bmp";
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   224
    SDL_Surface *face;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   225
    SDL_Surface *rface;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   226
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   227
    /* Create sample surface */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   228
    face = SDLTest_ImageFace();
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   229
    SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
6779
c3b579c78059 Add missing VS project dependencies to fix buildbot build; fix surface suite; minor update to rwops suite
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6773
diff changeset
   230
    if (face == NULL) return TEST_ABORTED;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   231
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   232
    /* Delete test file; ignore errors */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   233
    unlink(sampleFilename);
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   234
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   235
    /* Save a surface */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   236
    ret = SDL_SaveBMP(face, sampleFilename);
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   237
    SDLTest_AssertPass("Call to SDL_SaveBMP()");
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   238
    SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SaveBMP, expected: 0, got: %i", ret);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   239
    _AssertFileExist(sampleFilename);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   240
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   241
    /* Load a surface */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   242
    rface = SDL_LoadBMP(sampleFilename);
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   243
    SDLTest_AssertPass("Call to SDL_LoadBMP()");
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   244
    SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_LoadBMP is not NULL");
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   245
    if (rface != NULL) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   246
        SDLTest_AssertCheck(face->w == rface->w, "Verify width of loaded surface, expected: %i, got: %i", face->w, rface->w);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   247
        SDLTest_AssertCheck(face->h == rface->h, "Verify height of loaded surface, expected: %i, got: %i", face->h, rface->h);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   248
    }
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   249
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   250
    /* Delete test file; ignore errors */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   251
    unlink(sampleFilename);
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   252
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   253
    /* Clean up */
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   254
    SDL_FreeSurface(face);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   255
    face = NULL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   256
    SDL_FreeSurface(rface);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   257
    rface = NULL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   258
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   259
    return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   260
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   261
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7639
diff changeset
   262
/* !
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   263
 *  Tests surface conversion.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   264
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   265
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   266
surface_testSurfaceConversion(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   267
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   268
    SDL_Surface *rface = NULL, *face = NULL;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   269
    int ret = 0;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   270
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   271
    /* Create sample surface */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   272
    face = SDLTest_ImageFace();
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   273
    SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   274
    if (face == NULL)
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   275
        return TEST_ABORTED;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   276
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   277
    /* Set transparent pixel as the pixel at (0,0) */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   278
    if (face->format->palette) {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   279
       ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   280
       SDLTest_AssertPass("Call to SDL_SetColorKey()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   281
       SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   282
    }
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   283
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   284
    /* Convert to 32 bit to compare. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   285
    rface = SDL_ConvertSurface( face, testSurface->format, 0 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   286
    SDLTest_AssertPass("Call to SDL_ConvertSurface()");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   287
    SDLTest_AssertCheck(rface != NULL, "Verify result from SDL_ConvertSurface is not NULL");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   288
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   289
    /* Compare surface. */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   290
    ret = SDLTest_CompareSurfaces( rface, face, 0 );
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   291
    SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   292
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   293
    /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   294
    SDL_FreeSurface(face);
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   295
    face = NULL;
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   296
    SDL_FreeSurface(rface);
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   297
    rface = NULL;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   298
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   299
    return TEST_COMPLETED;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   300
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   301
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   302
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7639
diff changeset
   303
/* !
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   304
 *  Tests surface conversion across all pixel formats.
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   305
 */
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   306
int
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   307
surface_testCompleteSurfaceConversion(void *arg)
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   308
{
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   309
    Uint32 pixel_formats[] = {
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   310
        SDL_PIXELFORMAT_INDEX8,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   311
        SDL_PIXELFORMAT_RGB332,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   312
        SDL_PIXELFORMAT_RGB444,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   313
        SDL_PIXELFORMAT_RGB555,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   314
        SDL_PIXELFORMAT_BGR555,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   315
        SDL_PIXELFORMAT_ARGB4444,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   316
        SDL_PIXELFORMAT_RGBA4444,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   317
        SDL_PIXELFORMAT_ABGR4444,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   318
        SDL_PIXELFORMAT_BGRA4444,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   319
        SDL_PIXELFORMAT_ARGB1555,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   320
        SDL_PIXELFORMAT_RGBA5551,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   321
        SDL_PIXELFORMAT_ABGR1555,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   322
        SDL_PIXELFORMAT_BGRA5551,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   323
        SDL_PIXELFORMAT_RGB565,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   324
        SDL_PIXELFORMAT_BGR565,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   325
        SDL_PIXELFORMAT_RGB24,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   326
        SDL_PIXELFORMAT_BGR24,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   327
        SDL_PIXELFORMAT_RGB888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   328
        SDL_PIXELFORMAT_RGBX8888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   329
        SDL_PIXELFORMAT_BGR888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   330
        SDL_PIXELFORMAT_BGRX8888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   331
        SDL_PIXELFORMAT_ARGB8888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   332
        SDL_PIXELFORMAT_RGBA8888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   333
        SDL_PIXELFORMAT_ABGR8888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   334
        SDL_PIXELFORMAT_BGRA8888,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   335
        SDL_PIXELFORMAT_ARGB2101010,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   336
    };
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   337
    SDL_Surface *face = NULL, *cvt1, *cvt2, *final;
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   338
    SDL_PixelFormat *fmt1, *fmt2;
7403
9de6ef8865a2 Removed some unused variables.
Ryan C. Gordon <icculus@icculus.org>
parents: 7374
diff changeset
   339
    int i, j, ret = 0;
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   340
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   341
    /* Create sample surface */
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   342
    face = SDLTest_ImageFace();
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   343
    SDLTest_AssertCheck(face != NULL, "Verify face surface is not NULL");
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   344
    if (face == NULL)
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   345
        return TEST_ABORTED;
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   346
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   347
    /* Set transparent pixel as the pixel at (0,0) */
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   348
    if (face->format->palette) {
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   349
       ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   350
       SDLTest_AssertPass("Call to SDL_SetColorKey()");
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   351
       SDLTest_AssertCheck(ret == 0, "Verify result from SDL_SetColorKey, expected: 0, got: %i", ret);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   352
    }
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   353
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   354
    for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) {
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   355
        for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) {
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   356
            fmt1 = SDL_AllocFormat(pixel_formats[i]);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   357
            SDL_assert(fmt1 != NULL);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   358
            cvt1 = SDL_ConvertSurface(face, fmt1, 0);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   359
            SDL_assert(cvt1 != NULL);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   360
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   361
            fmt2 = SDL_AllocFormat(pixel_formats[j]);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   362
            SDL_assert(fmt1 != NULL);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   363
            cvt2 = SDL_ConvertSurface(cvt1, fmt2, 0);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   364
            SDL_assert(cvt2 != NULL);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   365
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   366
            if ( fmt1->BytesPerPixel == face->format->BytesPerPixel &&
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   367
                 fmt2->BytesPerPixel == face->format->BytesPerPixel &&
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   368
                 (fmt1->Amask != 0) == (face->format->Amask != 0) &&
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   369
                 (fmt2->Amask != 0) == (face->format->Amask != 0) ) {
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   370
                final = SDL_ConvertSurface( cvt2, face->format, 0 );
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   371
                SDL_assert(final != NULL);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   372
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   373
                /* Compare surface. */
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   374
                ret = SDLTest_CompareSurfaces( face, final, 0 );
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   375
                SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   376
                SDL_FreeSurface(final);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   377
            }
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   378
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   379
            SDL_FreeSurface(cvt1);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   380
            SDL_FreeFormat(fmt1);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   381
            SDL_FreeSurface(cvt2);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   382
            SDL_FreeFormat(fmt2);
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   383
        }
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   384
    }
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   385
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   386
    /* Clean up. */
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   387
    SDL_FreeSurface( face );
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   388
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   389
    return TEST_COMPLETED;
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   390
}
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   391
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   392
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   393
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   394
 * @brief Tests sprite loading. A failure case.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   395
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   396
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   397
surface_testLoadFailure(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   398
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   399
    SDL_Surface *face = SDL_LoadBMP("nonexistant.bmp");
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   400
    SDLTest_AssertCheck(face == NULL, "SDL_CreateLoadBmp");
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   401
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   402
    return TEST_COMPLETED;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   403
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   404
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   405
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   406
 * @brief Tests some blitting routines.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   407
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   408
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   409
surface_testBlit(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   410
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   411
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   412
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   413
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   414
   /* Basic blitting */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   415
   _testBlitBlendMode(-1);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   416
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   417
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   418
   compareSurface = SDLTest_ImageBlit();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   419
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   420
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   421
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   422
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   423
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   424
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   425
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   426
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   427
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   428
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   429
 * @brief Tests some blitting routines with color mod
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   430
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   431
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   432
surface_testBlitColorMod(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   433
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   434
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   435
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   436
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   437
   /* Basic blitting with color mod */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   438
   _testBlitBlendMode(-2);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   439
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   440
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   441
   compareSurface = SDLTest_ImageBlitColor();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   442
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   443
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   444
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   445
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   446
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   447
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   448
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   449
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   450
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   451
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   452
 * @brief Tests some blitting routines with alpha mod
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   453
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   454
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   455
surface_testBlitAlphaMod(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   456
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   457
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   458
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   459
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   460
   /* Basic blitting with alpha mod */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   461
   _testBlitBlendMode(-3);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   462
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   463
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   464
   compareSurface = SDLTest_ImageBlitAlpha();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   465
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   466
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   467
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   468
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   469
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   470
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   471
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   472
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   473
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   474
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   475
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   476
 * @brief Tests some more blitting routines.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   477
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   478
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   479
surface_testBlitBlendNone(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   480
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   481
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   482
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   483
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   484
   /* Basic blitting */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   485
   _testBlitBlendMode(SDL_BLENDMODE_NONE);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   486
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   487
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   488
   compareSurface = SDLTest_ImageBlitBlendNone();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   489
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   490
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   491
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   492
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   493
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   494
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   495
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   496
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   497
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   498
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   499
 * @brief Tests some more blitting routines.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   500
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   501
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   502
surface_testBlitBlendBlend(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   503
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   504
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   505
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   506
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   507
   /* Blend blitting */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   508
   _testBlitBlendMode(SDL_BLENDMODE_BLEND);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   509
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   510
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   511
   compareSurface = SDLTest_ImageBlitBlend();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   512
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   513
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   514
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   515
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   516
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   517
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   518
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   519
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   520
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   521
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   522
 * @brief Tests some more blitting routines.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   523
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   524
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   525
surface_testBlitBlendAdd(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   526
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   527
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   528
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   529
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   530
   /* Add blitting */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   531
   _testBlitBlendMode(SDL_BLENDMODE_ADD);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   532
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   533
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   534
   compareSurface = SDLTest_ImageBlitBlendAdd();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   535
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   536
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   537
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   538
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   539
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   540
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   541
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   542
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   543
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   544
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   545
 * @brief Tests some more blitting routines.
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   546
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   547
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   548
surface_testBlitBlendMod(void *arg)
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   549
{
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   550
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   551
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   552
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   553
   /* Mod blitting */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   554
   _testBlitBlendMode(SDL_BLENDMODE_MOD);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   555
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   556
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   557
   compareSurface = SDLTest_ImageBlitBlendMod();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   558
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   559
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   560
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   561
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   562
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   563
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   564
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   565
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   566
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   567
/**
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   568
 * @brief Tests some more blitting routines with loop
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   569
 */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   570
int
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   571
surface_testBlitBlendLoop(void *arg) {
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   572
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   573
   int ret;
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   574
   SDL_Surface *compareSurface;
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   575
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   576
   /* All blitting modes */
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   577
   _testBlitBlendMode(-4);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   578
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   579
   /* Verify result by comparing surfaces */
6822
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   580
   compareSurface = SDLTest_ImageBlitBlendAll();
18f6818ba281 Add mouse tests; update test suites
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6811
diff changeset
   581
   ret = SDLTest_CompareSurfaces( testSurface, compareSurface, 0 );
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   582
   SDLTest_AssertCheck(ret == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", ret);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   583
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   584
   /* Clean up. */
7720
f9a649383362 Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7678
diff changeset
   585
   SDL_FreeSurface(compareSurface);
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   586
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   587
   return TEST_COMPLETED;
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   588
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   589
}
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   590
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   591
/* ================= Test References ================== */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   592
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   593
/* Surface test cases */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   594
static const SDLTest_TestCaseReference surfaceTest1 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   595
        { (SDLTest_TestCaseFp)surface_testSaveLoadBitmap, "surface_testSaveLoadBitmap", "Tests sprite saving and loading.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   596
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   597
static const SDLTest_TestCaseReference surfaceTest2 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   598
        { (SDLTest_TestCaseFp)surface_testBlit, "surface_testBlit", "Tests basic blitting.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   599
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   600
static const SDLTest_TestCaseReference surfaceTest3 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   601
        { (SDLTest_TestCaseFp)surface_testBlitBlendNone, "surface_testBlitBlendNone", "Tests blitting routines with none blending mode.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   602
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   603
static const SDLTest_TestCaseReference surfaceTest4 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   604
        { (SDLTest_TestCaseFp)surface_testLoadFailure, "surface_testLoadFailure", "Tests sprite loading. A failure case.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   605
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   606
static const SDLTest_TestCaseReference surfaceTest5 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   607
        { (SDLTest_TestCaseFp)surface_testSurfaceConversion, "surface_testSurfaceConversion", "Tests surface conversion.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   608
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   609
static const SDLTest_TestCaseReference surfaceTest6 =
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   610
        { (SDLTest_TestCaseFp)surface_testCompleteSurfaceConversion, "surface_testCompleteSurfaceConversion", "Tests surface conversion across all pixel formats", TEST_ENABLED};
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   611
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   612
static const SDLTest_TestCaseReference surfaceTest7 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   613
        { (SDLTest_TestCaseFp)surface_testBlitColorMod, "surface_testBlitColorMod", "Tests some blitting routines with color mod.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   614
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   615
static const SDLTest_TestCaseReference surfaceTest8 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   616
        { (SDLTest_TestCaseFp)surface_testBlitAlphaMod, "surface_testBlitAlphaMod", "Tests some blitting routines with alpha mod.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   617
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   618
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   619
static const SDLTest_TestCaseReference surfaceTest9 =
9218
74b8ddd028c7 Fixed two typos in test source.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 8673
diff changeset
   620
        { (SDLTest_TestCaseFp)surface_testBlitBlendLoop, "surface_testBlitBlendLoop", "Test blitting routines with various blending modes", TEST_DISABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   621
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   622
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   623
static const SDLTest_TestCaseReference surfaceTest10 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   624
        { (SDLTest_TestCaseFp)surface_testBlitBlendBlend, "surface_testBlitBlendBlend", "Tests blitting routines with blend blending mode.", TEST_DISABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   625
7172
b3569dff1c6e Fix fuzzer/fuzzer tests on 64bit Linux; remove invalid negative SDL_Scancode test; disable failing surface/render test cases
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6822
diff changeset
   626
/* TODO: rewrite test case, define new test data and re-enable; current implementation fails */
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   627
static const SDLTest_TestCaseReference surfaceTest11 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   628
        { (SDLTest_TestCaseFp)surface_testBlitBlendAdd, "surface_testBlitBlendAdd", "Tests blitting routines with add blending mode.", TEST_DISABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   629
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   630
static const SDLTest_TestCaseReference surfaceTest12 =
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   631
        { (SDLTest_TestCaseFp)surface_testBlitBlendMod, "surface_testBlitBlendMod", "Tests blitting routines with mod blending mode.", TEST_ENABLED};
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   632
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   633
/* Sequence of Surface test cases */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   634
static const SDLTest_TestCaseReference *surfaceTests[] =  {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   635
    &surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
7374
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   636
    &surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10,
29ace61fca99 Added automated test to validate conversion between all supported formats.
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   637
    &surfaceTest11, &surfaceTest12, NULL
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   638
};
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   639
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   640
/* Surface test suite (global) */
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   641
SDLTest_TestSuiteReference surfaceTestSuite = {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   642
    "Surface",
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   643
    _surfaceSetUp,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   644
    surfaceTests,
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7176
diff changeset
   645
    _surfaceTearDown
6773
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   646
5ebc5a9e35b4 Add surface test suite; minor improvements to render suite; refactor image saving into test lib compare function; fix for Haiku build
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   647
};