test/testautomation_video.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Sun, 06 Jan 2013 15:17:59 -0800
changeset 6800 26c6795ec1a4
child 6891 177f29ae5279
permissions -rw-r--r--
Add new test suites (events, keyboard, syswm, video) with a few new tests each
     1 /**
     2  * Video test suite
     3  */
     4 
     5 #include <stdio.h>
     6 
     7 #include "SDL.h"
     8 #include "SDL_test.h"
     9 
    10 /* Test case functions */
    11 
    12 /**
    13  * @brief Enable and disable screensaver while checking state
    14  */
    15 int
    16 video_enableDisableScreensaver(void *arg)
    17 {
    18 	SDL_bool initialResult;
    19 	SDL_bool result;
    20 
    21 	/* Get current state and proceed according to current state */
    22 	initialResult = SDL_IsScreenSaverEnabled();
    23 	SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");	
    24 	if (initialResult == SDL_TRUE) {
    25 	
    26 	  /* Currently enabled: disable first, then enable again */
    27 	  
    28 	  /* Disable screensaver and check */	
    29 	  SDL_DisableScreenSaver();
    30 	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
    31 	  result = SDL_IsScreenSaverEnabled();
    32 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    33 	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);
    34 	
    35 	  /* Enable screensaver and check */	
    36 	  SDL_EnableScreenSaver();
    37 	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
    38 	  result = SDL_IsScreenSaverEnabled();
    39 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    40 	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
    41 
    42 	} else {
    43 
    44 	  /* Currently disabled: enable first, then disable again */
    45 	  
    46 	  /* Enable screensaver and check */	
    47 	  SDL_EnableScreenSaver();
    48 	  SDLTest_AssertPass("Call to SDL_EnableScreenSaver()");
    49 	  result = SDL_IsScreenSaverEnabled();
    50 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    51 	  SDLTest_AssertCheck(result == SDL_TRUE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_TRUE, result);
    52 
    53 	  /* Disable screensaver and check */	
    54 	  SDL_DisableScreenSaver();
    55 	  SDLTest_AssertPass("Call to SDL_DisableScreenSaver()");	
    56 	  result = SDL_IsScreenSaverEnabled();
    57 	  SDLTest_AssertPass("Call to SDL_IsScreenSaverEnabled()");
    58 	  SDLTest_AssertCheck(result == SDL_FALSE, "Verify result from SDL_IsScreenSaverEnabled, expected: %i, got: %i", SDL_FALSE, result);	
    59 	}	
    60 	
    61 	return TEST_COMPLETED;
    62 }
    63 
    64 /* ================= Test References ================== */
    65 
    66 /* Video test cases */
    67 static const SDLTest_TestCaseReference videoTest1 =
    68 		{ (SDLTest_TestCaseFp)video_enableDisableScreensaver, "video_enableDisableScreensaver",  "Enable and disable screenaver while checking state", TEST_ENABLED };
    69 
    70 /* Sequence of Video test cases */
    71 static const SDLTest_TestCaseReference *videoTests[] =  {
    72 	&videoTest1, NULL
    73 };
    74 
    75 /* Video test suite (global) */
    76 SDLTest_TestSuiteReference videoTestSuite = {
    77 	"Video",
    78 	NULL,
    79 	videoTests,
    80 	NULL
    81 };