visualtest/include/SDL_visualtest_action_configparser.h
changeset 7924 fcb86d323770
child 11382 2c50e79b19e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/visualtest/include/SDL_visualtest_action_configparser.h	Sun Nov 10 00:32:23 2013 -0500
     1.3 @@ -0,0 +1,147 @@
     1.4 +/* See COPYING.txt for the full license governing this code. */
     1.5 +/**
     1.6 + * \file SDL_visualtest_action_configparser.h
     1.7 + *
     1.8 + * Header file for the parser for action config files.
     1.9 + */
    1.10 +
    1.11 +#ifndef _SDL_visualtest_action_configparser_h
    1.12 +#define _SDL_visualtest_action_configparser_h
    1.13 +
    1.14 +/** The maximum length of one line in the actions file */
    1.15 +#define MAX_ACTION_LINE_LENGTH 300
    1.16 +
    1.17 +/* Set up for C function definitions, even when using C++ */
    1.18 +#ifdef __cplusplus
    1.19 +extern "C" {
    1.20 +#endif
    1.21 +
    1.22 +/**
    1.23 + * Type of the action.
    1.24 + */
    1.25 +typedef enum
    1.26 +{
    1.27 +    /*! Launch an application with some given arguments */
    1.28 +    SDL_ACTION_LAUNCH = 0,
    1.29 +    /*! Kill the SUT process */
    1.30 +    SDL_ACTION_KILL,
    1.31 +    /*! Quit (Gracefully exit) the SUT process */
    1.32 +    SDL_ACTION_QUIT,
    1.33 +    /*! Take a screenshot of the SUT window */
    1.34 +    SDL_ACTION_SCREENSHOT,
    1.35 +    /*! Verify a previously taken screenshot */
    1.36 +    SDL_ACTION_VERIFY
    1.37 +} SDLVisualTest_ActionType;
    1.38 +
    1.39 +/**
    1.40 + * Struct that defines an action that will be performed on the SUT process at
    1.41 + * a specific time.
    1.42 + */
    1.43 +typedef struct SDLVisualTest_Action
    1.44 +{
    1.45 +    /*! The type of action to be performed */
    1.46 +    SDLVisualTest_ActionType type;
    1.47 +    /*! The time, in milliseconds from the launch of the SUT, when the action
    1.48 +        will be performed */
    1.49 +    int time;
    1.50 +    /*! Any additional information needed to perform the action. */
    1.51 +    union
    1.52 +    {
    1.53 +        /*! The path and arguments to the process to be launched */
    1.54 +        struct
    1.55 +        {
    1.56 +            char* path;
    1.57 +            char* args;
    1.58 +        } process;
    1.59 +    } extra;
    1.60 +} SDLVisualTest_Action;
    1.61 +
    1.62 +/**
    1.63 + * Struct for a node in the action queue. 
    1.64 + */
    1.65 +typedef struct SDLVisualTest_ActionNode
    1.66 +{
    1.67 +    /*! The action in this node */
    1.68 +    SDLVisualTest_Action action;
    1.69 +    /*! Pointer to the next element in the queue */
    1.70 +    struct SDLVisualTest_ActionNode* next;
    1.71 +} SDLVisualTest_ActionNode;
    1.72 +
    1.73 +/**
    1.74 + * Queue structure for actions loaded from the actions config file. 
    1.75 + */
    1.76 +typedef struct SDLVisualTest_ActionQueue
    1.77 +{
    1.78 +    /*! Pointer to the front of the queue */
    1.79 +    SDLVisualTest_ActionNode* front;
    1.80 +    /*! Pointer to the rear of the queue */
    1.81 +    SDLVisualTest_ActionNode* rear;
    1.82 +    /*! Number of nodes in the queue */
    1.83 +    int size;
    1.84 +} SDLVisualTest_ActionQueue;
    1.85 +
    1.86 +/**
    1.87 + * Add an action pointed to by \c action to the rear of the action queue pointed
    1.88 + * to by \c queue.
    1.89 + *
    1.90 + * \return 1 on success, 0 on failure.
    1.91 + */
    1.92 +int SDLVisualTest_EnqueueAction(SDLVisualTest_ActionQueue* queue,
    1.93 +                                SDLVisualTest_Action action);
    1.94 +
    1.95 +/**
    1.96 + * Remove an action from the front of the action queue pointed to by \c queue.
    1.97 + *
    1.98 + * \return 1 on success, 0 on failure.
    1.99 + */
   1.100 +int SDLVisualTest_DequeueAction(SDLVisualTest_ActionQueue* queue);
   1.101 +
   1.102 +/**
   1.103 + * Initialize the action queue pointed to by \c queue.
   1.104 + */
   1.105 +void SDLVisualTest_InitActionQueue(SDLVisualTest_ActionQueue* queue);
   1.106 +
   1.107 +/**
   1.108 + * Get the action at the front of the action queue pointed to by \c queue.
   1.109 + * The returned action pointer may become invalid after subsequent dequeues.
   1.110 + *
   1.111 + * \return pointer to the action on success, NULL on failure.
   1.112 + */
   1.113 +SDLVisualTest_Action* SDLVisualTest_GetQueueFront(SDLVisualTest_ActionQueue* queue);
   1.114 +
   1.115 +/**
   1.116 + * Check if the queue pointed to by \c queue is empty or not.
   1.117 + *
   1.118 + * \return 1 if the queue is empty, 0 otherwise.
   1.119 + */
   1.120 +int SDLVisualTest_IsActionQueueEmpty(SDLVisualTest_ActionQueue* queue);
   1.121 +
   1.122 +/**
   1.123 + * Dequeues all the elements in the queque pointed to by \c queue.
   1.124 + */
   1.125 +void SDLVisualTest_EmptyActionQueue(SDLVisualTest_ActionQueue* queue);
   1.126 +
   1.127 +/**
   1.128 + * Inserts an action \c action into the queue pointed to by \c queue such that
   1.129 + * the times of actions in the queue increase as we move from the front to the
   1.130 + * rear.
   1.131 + *
   1.132 + * \return 1 on success, 0 on failure.
   1.133 + */
   1.134 +int SDLVisualTest_InsertIntoActionQueue(SDLVisualTest_ActionQueue* queue,
   1.135 +                                        SDLVisualTest_Action action);
   1.136 +
   1.137 +/**
   1.138 + * Parses an action config file with path \c file and populates an action queue
   1.139 + * pointed to by \c queue with actions.
   1.140 + *
   1.141 + * \return 1 on success, 0 on failure.
   1.142 + */
   1.143 +int SDLVisualTest_ParseActionConfig(char* file, SDLVisualTest_ActionQueue* queue);
   1.144 +
   1.145 +/* Ends C function definitions when using C++ */
   1.146 +#ifdef __cplusplus
   1.147 +}
   1.148 +#endif
   1.149 +
   1.150 +#endif /* _SDL_visualtest_action_configparser_h */
   1.151 \ No newline at end of file