🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.1 KiB

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