visualtest/include/SDL_visualtest_harness_argparser.h
author Ryan C. Gordon <icculus@icculus.org>
Fri, 10 Apr 2020 00:37:35 -0400
changeset 13724 aca267270368
parent 11382 2c50e79b19e0
permissions -rw-r--r--
metal: Added some support interfaces to Apple's Metal API (thanks, Caleb!).

Caleb Cornett's comments:

"A few weeks ago, Alex added a partial Metal API to SDL2:

https://hg.libsdl.org/SDL/rev/b87ba0fad17e

I noticed it was missing a few features that would help Metal become a
first-class citizen in SDL, so I went ahead and wrote them! Here are the new
APIs:

1. SDL_WINDOW_METAL flag for SDL_CreateWindow(). This allows the programmer
to specify that they intend to create a window for use with SDL_MetalView.
The flag is used to ensure correct usage of the API and to prevent
accidentally defaulting to OpenGL on iOS.

2. SDL_Metal_GetLayer(). This function takes a SDL_MetalView and returns a
pointer to the view's backing CAMetalLayer. This simplifies things
considerably, since in the current version of the SDL_Metal API the
programmer is required to bridge-cast a SDL_MetalView handle to an NSView or
UIView (depending on the platform) and then extract the layer from there.
SDL_Metal_GetLayer automatically handles all of that, making the operation
simple and cross-platform.

3. SDL_Metal_GetDrawableSize(). This function already exists in the current
SDL_Metal API (and is used behind-the-scenes for SDL_Vulkan_GetDrawableSize
on Apple platforms) but was not publicly exposed. My patch exposes this
function for public use. It works just like you'd expect.

Tested on macOS 10.14 and iOS 12.4."

Fixes Bugzilla #4796.
icculus@7924
     1
/**
icculus@7924
     2
 *  \file SDL_visualtest_harness_argparser.h
icculus@7924
     3
 *
icculus@7924
     4
 *  Provides functionality to parse command line arguments to the test harness.
icculus@7924
     5
 */
icculus@7924
     6
icculus@7924
     7
#include <SDL.h>
icculus@7924
     8
#include "SDL_visualtest_sut_configparser.h"
icculus@7924
     9
#include "SDL_visualtest_variator_common.h"
icculus@7924
    10
#include "SDL_visualtest_action_configparser.h"
icculus@7924
    11
slouken@11382
    12
#ifndef SDL_visualtest_harness_argparser_h_
slouken@11382
    13
#define SDL_visualtest_harness_argparser_h_
icculus@7924
    14
icculus@7924
    15
/** Maximum length of a path string */
icculus@7924
    16
#define MAX_PATH_LEN 300
icculus@7924
    17
/** Maximum length of a string of SUT arguments */
icculus@7924
    18
#define MAX_SUT_ARGS_LEN 600
icculus@7924
    19
icculus@7924
    20
/* Set up for C function definitions, even when using C++ */
icculus@7924
    21
#ifdef __cplusplus
icculus@7924
    22
extern "C" {
icculus@7924
    23
#endif
icculus@7924
    24
icculus@7924
    25
/**
icculus@7924
    26
 * Stores the state of the test harness.
icculus@7924
    27
 */
icculus@7924
    28
typedef struct SDLVisualTest_HarnessState
icculus@7924
    29
{
icculus@7924
    30
    /*! Path to the System Under Test (SUT) executable */
icculus@7924
    31
    char sutapp[MAX_PATH_LEN];
icculus@7924
    32
    /*! Command line arguments to be passed to the SUT */
icculus@7924
    33
    char sutargs[MAX_SUT_ARGS_LEN];
icculus@7924
    34
    /*! Time in milliseconds after which to kill the SUT */
icculus@7924
    35
    int timeout;
icculus@7924
    36
    /*! Configuration object for the SUT */
icculus@7924
    37
    SDLVisualTest_SUTConfig sut_config;
icculus@7924
    38
    /*! What type of variator to use to generate argument strings */
icculus@7924
    39
    SDLVisualTest_VariatorType variator_type;
icculus@7924
    40
    /*! The number of variations to generate */
icculus@7924
    41
    int num_variations;
icculus@7924
    42
    /*! If true, the test harness will just print the different variations
icculus@7924
    43
        without launching the SUT for each one */
icculus@7924
    44
    SDL_bool no_launch;
icculus@7924
    45
    /*! A queue with actions to be performed while the SUT is running */
icculus@7924
    46
    SDLVisualTest_ActionQueue action_queue;
icculus@7924
    47
    /*! Output directory to save the screenshots */
icculus@7924
    48
    char output_dir[MAX_PATH_LEN];
icculus@7924
    49
    /*! Path to directory with the verification images */
icculus@7924
    50
    char verify_dir[MAX_PATH_LEN];
icculus@7924
    51
} SDLVisualTest_HarnessState;
icculus@7924
    52
icculus@7924
    53
/**
icculus@7924
    54
 * Parse command line paramters to the test harness and populate a state object.
icculus@7924
    55
 *
icculus@7924
    56
 * \param argv  The array of command line parameters.
icculus@7924
    57
 * \param state Pointer to the state object to be populated.
icculus@7924
    58
 *
icculus@7924
    59
 * \return Non-zero on success, zero on failure.
icculus@7924
    60
 */
icculus@7924
    61
int SDLVisualTest_ParseHarnessArgs(char** argv, SDLVisualTest_HarnessState* state);
icculus@7924
    62
icculus@7924
    63
/**
icculus@7924
    64
 * Frees any resources associated with the state object pointed to by \c state.
icculus@7924
    65
 */
icculus@7924
    66
void SDLVisualTest_FreeHarnessState(SDLVisualTest_HarnessState* state);
icculus@7924
    67
icculus@7924
    68
/* Ends C function definitions when using C++ */
icculus@7924
    69
#ifdef __cplusplus
icculus@7924
    70
}
icculus@7924
    71
#endif
icculus@7924
    72
slouken@11382
    73
#endif /* SDL_visualtest_harness_argparser_h_ */
slouken@11382
    74
slouken@11382
    75
/* vi: set ts=4 sw=4 expandtab: */