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