visualtest/include/SDL_visualtest_variator_common.h
author David Ludwig <dludwig@pobox.com>
Wed, 25 Dec 2013 21:39:48 -0500
changeset 8563 c0e68f3b6bbb
parent 7924 fcb86d323770
child 11382 2c50e79b19e0
permissions -rw-r--r--
WinRT: compiled the d3d11 renderer's shaders into SDL itself

Previously, the shaders would get compiled separately, the output of which would need to be packaged into the app. This change should make SDL's dll be the only binary needed to include SDL in a WinRT app.
icculus@7924
     1
/* See COPYING.txt for the full license governing this code. */
icculus@7924
     2
/**
icculus@7924
     3
 * \file SDL_visualtest_variator_common.h
icculus@7924
     4
 *
icculus@7924
     5
 * Header for common functionality used by variators.
icculus@7924
     6
 */
icculus@7924
     7
icculus@7924
     8
#include <SDL_types.h>
icculus@7924
     9
#include "SDL_visualtest_sut_configparser.h"
icculus@7924
    10
icculus@7924
    11
#ifndef _SDL_visualtest_variator_common_h
icculus@7924
    12
#define _SDL_visualtest_variator_common_h
icculus@7924
    13
icculus@7924
    14
/** The number of variations one integer option would generate */
icculus@7924
    15
#define SDL_SUT_INTEGER_OPTION_TEST_STEPS 3
icculus@7924
    16
icculus@7924
    17
/* Set up for C function definitions, even when using C++ */
icculus@7924
    18
#ifdef __cplusplus
icculus@7924
    19
extern "C" {
icculus@7924
    20
#endif
icculus@7924
    21
icculus@7924
    22
/** enum for indicating the type of variator being used */
icculus@7924
    23
typedef enum SDLVisualTest_VariatorType
icculus@7924
    24
{
icculus@7924
    25
    SDL_VARIATOR_NONE = 0,
icculus@7924
    26
    SDL_VARIATOR_EXHAUSTIVE,
icculus@7924
    27
    SDL_VARIATOR_RANDOM
icculus@7924
    28
} SDLVisualTest_VariatorType;
icculus@7924
    29
icculus@7924
    30
/**
icculus@7924
    31
 * One possible value for a command line option to the SUT.
icculus@7924
    32
 */
icculus@7924
    33
typedef union SDLVisualTest_SUTOptionValue
icculus@7924
    34
{
icculus@7924
    35
    /*! Value if the option is of type boolean */
icculus@7924
    36
    SDL_bool bool_value;
icculus@7924
    37
    /*! Value if the option is of type integer. If on is true then the option
icculus@7924
    38
        will be passed to the SUT, otherwise it will be ignored. */
icculus@7924
    39
    struct {
icculus@7924
    40
        int value;
icculus@7924
    41
        SDL_bool on;
icculus@7924
    42
    } integer;
icculus@7924
    43
    /*! Index of the string in the enum_values field of the corresponding
icculus@7924
    44
        SDLVisualTest_SUTOption object. If on is true the option will passed
icculus@7924
    45
        to the SUT, otherwise it will be ignored. */
icculus@7924
    46
    struct {
icculus@7924
    47
        int index;
icculus@7924
    48
        SDL_bool on;
icculus@7924
    49
    } enumerated;
icculus@7924
    50
    /*! Value if the option is of type string. If on is true the option will 
icculus@7924
    51
        be passed to the SUT, otherwise it will be ignored. */
icculus@7924
    52
    struct {
icculus@7924
    53
        char* value;
icculus@7924
    54
        SDL_bool on;
icculus@7924
    55
    } string;
icculus@7924
    56
} SDLVisualTest_SUTOptionValue;
icculus@7924
    57
icculus@7924
    58
/**
icculus@7924
    59
 * Represents a valid combination of parameters that can be passed to the SUT.
icculus@7924
    60
 * The ordering of the values here is the same as the ordering of the options in
icculus@7924
    61
 * the SDLVisualTest_SUTConfig object for this variation.
icculus@7924
    62
 */
icculus@7924
    63
typedef struct SDLVisualTest_Variation
icculus@7924
    64
{
icculus@7924
    65
    /*! Pointer to array of option values */
icculus@7924
    66
    SDLVisualTest_SUTOptionValue* vars;
icculus@7924
    67
    /*! Number of option values in \c vars */
icculus@7924
    68
    int num_vars;
icculus@7924
    69
} SDLVisualTest_Variation;
icculus@7924
    70
icculus@7924
    71
/**
icculus@7924
    72
 * "Increments" the value of the option by one and returns the carry. We wrap
icculus@7924
    73
 * around to the initial value on overflow which makes the carry one.
icculus@7924
    74
 * For example: "incrementing" an SDL_FALSE option makes it SDL_TRUE with no
icculus@7924
    75
 * carry, and "incrementing" an SDL_TRUE option makes it SDL_FALSE with carry
icculus@7924
    76
 * one. For integers, a random value in the valid range for the option is used.
icculus@7924
    77
 *
icculus@7924
    78
 * \param var Value of the option
icculus@7924
    79
 * \param opt Object with metadata about the option
icculus@7924
    80
 *
icculus@7924
    81
 * \return 1 if there is a carry for enum and bool type options, 0 otherwise.
icculus@7924
    82
 *         1 is always returned for integer and string type options. -1 is
icculus@7924
    83
 *         returned on error.
icculus@7924
    84
 */
icculus@7924
    85
int SDLVisualTest_NextValue(SDLVisualTest_SUTOptionValue* var,
icculus@7924
    86
                            SDLVisualTest_SUTOption* opt);
icculus@7924
    87
icculus@7924
    88
/**
icculus@7924
    89
 * Converts a variation object into a string of command line arguments.
icculus@7924
    90
 *
icculus@7924
    91
 * \param variation Variation object to be converted.
icculus@7924
    92
 * \param config Config object for the SUT.
icculus@7924
    93
 * \param buffer Pointer to the buffer the arguments string will be copied into.
icculus@7924
    94
 * \param size Size of the buffer.
icculus@7924
    95
 *
icculus@7924
    96
 * \return 1 on success, 0 on failure
icculus@7924
    97
 */
icculus@7924
    98
int SDLVisualTest_MakeStrFromVariation(SDLVisualTest_Variation* variation,
icculus@7924
    99
                                       SDLVisualTest_SUTConfig* config,
icculus@7924
   100
                                       char* buffer, int size);
icculus@7924
   101
icculus@7924
   102
/**
icculus@7924
   103
 * Initializes the variation using the following rules:
icculus@7924
   104
 * - Boolean options are initialized to SDL_FALSE.
icculus@7924
   105
 * - Integer options are initialized to the minimum valid value they can hold.
icculus@7924
   106
 * - Enum options are initialized to the first element in the list of values they
icculus@7924
   107
 *   can take.
icculus@7924
   108
 * - String options are initialized to the name of the option.
icculus@7924
   109
 *
icculus@7924
   110
 * \return 1 on success, 0 on failure.
icculus@7924
   111
 */
icculus@7924
   112
int SDLVisualTest_InitVariation(SDLVisualTest_Variation* variation,
icculus@7924
   113
                                SDLVisualTest_SUTConfig* config);
icculus@7924
   114
icculus@7924
   115
/* Ends C function definitions when using C++ */
icculus@7924
   116
#ifdef __cplusplus
icculus@7924
   117
}
icculus@7924
   118
#endif
icculus@7924
   119
icculus@7924
   120
#endif /* _SDL_visualtest_variator_common_h */