visualtest/include/SDL_visualtest_action_configparser.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_action_configparser.h
icculus@7924
     4
 *
icculus@7924
     5
 * Header file for the parser for action config files.
icculus@7924
     6
 */
icculus@7924
     7
icculus@7924
     8
#ifndef _SDL_visualtest_action_configparser_h
icculus@7924
     9
#define _SDL_visualtest_action_configparser_h
icculus@7924
    10
icculus@7924
    11
/** The maximum length of one line in the actions file */
icculus@7924
    12
#define MAX_ACTION_LINE_LENGTH 300
icculus@7924
    13
icculus@7924
    14
/* Set up for C function definitions, even when using C++ */
icculus@7924
    15
#ifdef __cplusplus
icculus@7924
    16
extern "C" {
icculus@7924
    17
#endif
icculus@7924
    18
icculus@7924
    19
/**
icculus@7924
    20
 * Type of the action.
icculus@7924
    21
 */
icculus@7924
    22
typedef enum
icculus@7924
    23
{
icculus@7924
    24
    /*! Launch an application with some given arguments */
icculus@7924
    25
    SDL_ACTION_LAUNCH = 0,
icculus@7924
    26
    /*! Kill the SUT process */
icculus@7924
    27
    SDL_ACTION_KILL,
icculus@7924
    28
    /*! Quit (Gracefully exit) the SUT process */
icculus@7924
    29
    SDL_ACTION_QUIT,
icculus@7924
    30
    /*! Take a screenshot of the SUT window */
icculus@7924
    31
    SDL_ACTION_SCREENSHOT,
icculus@7924
    32
    /*! Verify a previously taken screenshot */
icculus@7924
    33
    SDL_ACTION_VERIFY
icculus@7924
    34
} SDLVisualTest_ActionType;
icculus@7924
    35
icculus@7924
    36
/**
icculus@7924
    37
 * Struct that defines an action that will be performed on the SUT process at
icculus@7924
    38
 * a specific time.
icculus@7924
    39
 */
icculus@7924
    40
typedef struct SDLVisualTest_Action
icculus@7924
    41
{
icculus@7924
    42
    /*! The type of action to be performed */
icculus@7924
    43
    SDLVisualTest_ActionType type;
icculus@7924
    44
    /*! The time, in milliseconds from the launch of the SUT, when the action
icculus@7924
    45
        will be performed */
icculus@7924
    46
    int time;
icculus@7924
    47
    /*! Any additional information needed to perform the action. */
icculus@7924
    48
    union
icculus@7924
    49
    {
icculus@7924
    50
        /*! The path and arguments to the process to be launched */
icculus@7924
    51
        struct
icculus@7924
    52
        {
icculus@7924
    53
            char* path;
icculus@7924
    54
            char* args;
icculus@7924
    55
        } process;
icculus@7924
    56
    } extra;
icculus@7924
    57
} SDLVisualTest_Action;
icculus@7924
    58
icculus@7924
    59
/**
icculus@7924
    60
 * Struct for a node in the action queue. 
icculus@7924
    61
 */
icculus@7924
    62
typedef struct SDLVisualTest_ActionNode
icculus@7924
    63
{
icculus@7924
    64
    /*! The action in this node */
icculus@7924
    65
    SDLVisualTest_Action action;
icculus@7924
    66
    /*! Pointer to the next element in the queue */
icculus@7924
    67
    struct SDLVisualTest_ActionNode* next;
icculus@7924
    68
} SDLVisualTest_ActionNode;
icculus@7924
    69
icculus@7924
    70
/**
icculus@7924
    71
 * Queue structure for actions loaded from the actions config file. 
icculus@7924
    72
 */
icculus@7924
    73
typedef struct SDLVisualTest_ActionQueue
icculus@7924
    74
{
icculus@7924
    75
    /*! Pointer to the front of the queue */
icculus@7924
    76
    SDLVisualTest_ActionNode* front;
icculus@7924
    77
    /*! Pointer to the rear of the queue */
icculus@7924
    78
    SDLVisualTest_ActionNode* rear;
icculus@7924
    79
    /*! Number of nodes in the queue */
icculus@7924
    80
    int size;
icculus@7924
    81
} SDLVisualTest_ActionQueue;
icculus@7924
    82
icculus@7924
    83
/**
icculus@7924
    84
 * Add an action pointed to by \c action to the rear of the action queue pointed
icculus@7924
    85
 * to by \c queue.
icculus@7924
    86
 *
icculus@7924
    87
 * \return 1 on success, 0 on failure.
icculus@7924
    88
 */
icculus@7924
    89
int SDLVisualTest_EnqueueAction(SDLVisualTest_ActionQueue* queue,
icculus@7924
    90
                                SDLVisualTest_Action action);
icculus@7924
    91
icculus@7924
    92
/**
icculus@7924
    93
 * Remove an action from the front of the action queue pointed to by \c queue.
icculus@7924
    94
 *
icculus@7924
    95
 * \return 1 on success, 0 on failure.
icculus@7924
    96
 */
icculus@7924
    97
int SDLVisualTest_DequeueAction(SDLVisualTest_ActionQueue* queue);
icculus@7924
    98
icculus@7924
    99
/**
icculus@7924
   100
 * Initialize the action queue pointed to by \c queue.
icculus@7924
   101
 */
icculus@7924
   102
void SDLVisualTest_InitActionQueue(SDLVisualTest_ActionQueue* queue);
icculus@7924
   103
icculus@7924
   104
/**
icculus@7924
   105
 * Get the action at the front of the action queue pointed to by \c queue.
icculus@7924
   106
 * The returned action pointer may become invalid after subsequent dequeues.
icculus@7924
   107
 *
icculus@7924
   108
 * \return pointer to the action on success, NULL on failure.
icculus@7924
   109
 */
icculus@7924
   110
SDLVisualTest_Action* SDLVisualTest_GetQueueFront(SDLVisualTest_ActionQueue* queue);
icculus@7924
   111
icculus@7924
   112
/**
icculus@7924
   113
 * Check if the queue pointed to by \c queue is empty or not.
icculus@7924
   114
 *
icculus@7924
   115
 * \return 1 if the queue is empty, 0 otherwise.
icculus@7924
   116
 */
icculus@7924
   117
int SDLVisualTest_IsActionQueueEmpty(SDLVisualTest_ActionQueue* queue);
icculus@7924
   118
icculus@7924
   119
/**
icculus@7924
   120
 * Dequeues all the elements in the queque pointed to by \c queue.
icculus@7924
   121
 */
icculus@7924
   122
void SDLVisualTest_EmptyActionQueue(SDLVisualTest_ActionQueue* queue);
icculus@7924
   123
icculus@7924
   124
/**
icculus@7924
   125
 * Inserts an action \c action into the queue pointed to by \c queue such that
icculus@7924
   126
 * the times of actions in the queue increase as we move from the front to the
icculus@7924
   127
 * rear.
icculus@7924
   128
 *
icculus@7924
   129
 * \return 1 on success, 0 on failure.
icculus@7924
   130
 */
icculus@7924
   131
int SDLVisualTest_InsertIntoActionQueue(SDLVisualTest_ActionQueue* queue,
icculus@7924
   132
                                        SDLVisualTest_Action action);
icculus@7924
   133
icculus@7924
   134
/**
icculus@7924
   135
 * Parses an action config file with path \c file and populates an action queue
icculus@7924
   136
 * pointed to by \c queue with actions.
icculus@7924
   137
 *
icculus@7924
   138
 * \return 1 on success, 0 on failure.
icculus@7924
   139
 */
icculus@7924
   140
int SDLVisualTest_ParseActionConfig(char* file, SDLVisualTest_ActionQueue* queue);
icculus@7924
   141
icculus@7924
   142
/* Ends C function definitions when using C++ */
icculus@7924
   143
#ifdef __cplusplus
icculus@7924
   144
}
icculus@7924
   145
#endif
icculus@7924
   146
icculus@7924
   147
#endif /* _SDL_visualtest_action_configparser_h */