test/testautomation_timer.c
changeset 7191 75360622e65f
parent 7156 0758e28b08f3
child 9254 6c469ea796e4
     1.1 --- a/test/testautomation_timer.c	Sat May 18 12:48:50 2013 -0700
     1.2 +++ b/test/testautomation_timer.c	Sat May 18 14:17:52 2013 -0700
     1.3 @@ -21,11 +21,11 @@
     1.4  void
     1.5  _timerSetUp(void *arg)
     1.6  {
     1.7 -	/* Start SDL timer subsystem */
     1.8 -	int ret = SDL_InitSubSystem( SDL_INIT_TIMER );
     1.9 +    /* Start SDL timer subsystem */
    1.10 +    int ret = SDL_InitSubSystem( SDL_INIT_TIMER );
    1.11          SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_TIMER)");
    1.12 -	SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
    1.13 -	if (ret != 0) {
    1.14 +    SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_TIMER)");
    1.15 +    if (ret != 0) {
    1.16             SDLTest_LogError("%s", SDL_GetError());
    1.17          }
    1.18  }
    1.19 @@ -39,11 +39,11 @@
    1.20  timer_getPerformanceCounter(void *arg)
    1.21  {
    1.22    Uint64 result;
    1.23 -                                                                                                        		
    1.24 +
    1.25    result = SDL_GetPerformanceCounter();
    1.26    SDLTest_AssertPass("Call to SDL_GetPerformanceCounter()");
    1.27    SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %lu", result);
    1.28 -  
    1.29 +
    1.30    return TEST_COMPLETED;
    1.31  }
    1.32  
    1.33 @@ -54,11 +54,11 @@
    1.34  timer_getPerformanceFrequency(void *arg)
    1.35  {
    1.36    Uint64 result;
    1.37 -                                                                                                        		
    1.38 +
    1.39    result = SDL_GetPerformanceFrequency();
    1.40    SDLTest_AssertPass("Call to SDL_GetPerformanceFrequency()");
    1.41    SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %lu", result);
    1.42 -  
    1.43 +
    1.44    return TEST_COMPLETED;
    1.45  }
    1.46  
    1.47 @@ -74,18 +74,18 @@
    1.48    Uint32 result2;
    1.49    Uint32 difference;
    1.50  
    1.51 -  /* Zero delay */  
    1.52 +  /* Zero delay */
    1.53    SDL_Delay(0);
    1.54    SDLTest_AssertPass("Call to SDL_Delay(0)");
    1.55 -  
    1.56 +
    1.57    /* Non-zero delay */
    1.58    SDL_Delay(1);
    1.59    SDLTest_AssertPass("Call to SDL_Delay(1)");
    1.60  
    1.61    SDL_Delay(SDLTest_RandomIntegerInRange(5, 15));
    1.62    SDLTest_AssertPass("Call to SDL_Delay()");
    1.63 -  
    1.64 -  /* Get ticks count - should be non-zero by now */                                                                                                      		
    1.65 +
    1.66 +  /* Get ticks count - should be non-zero by now */
    1.67    result = SDL_GetTicks();
    1.68    SDLTest_AssertPass("Call to SDL_GetTicks()");
    1.69    SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %d", result);
    1.70 @@ -99,7 +99,7 @@
    1.71    difference = result2 - result;
    1.72    SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%d, got: %d", testDelay - marginOfError, difference);
    1.73    SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %d", testDelay + marginOfError, difference);
    1.74 -  
    1.75 +
    1.76    return TEST_COMPLETED;
    1.77  }
    1.78  
    1.79 @@ -107,14 +107,14 @@
    1.80  Uint32 _timerTestCallback(Uint32 interval, void *param)
    1.81  {
    1.82     _timerCallbackCalled = 1;
    1.83 -   
    1.84 +
    1.85     if (_paramCheck != 0) {
    1.86         SDLTest_AssertCheck(param != NULL, "Check param pointer, expected: non-NULL, got: %s", (param != NULL) ? "non-NULL" : "NULL");
    1.87         if (param != NULL) {
    1.88            SDLTest_AssertCheck(*(int *)param == _paramValue, "Check param value, expected: %i, got: %i", _paramValue, *(int *)param);
    1.89         }
    1.90     }
    1.91 -   
    1.92 +
    1.93     return 0;
    1.94  }
    1.95  
    1.96 @@ -131,12 +131,12 @@
    1.97    /* Reset state */
    1.98    _paramCheck = 0;
    1.99    _timerCallbackCalled = 0;
   1.100 -  
   1.101 -  /* Set timer with a long delay */  
   1.102 +
   1.103 +  /* Set timer with a long delay */
   1.104    id = SDL_AddTimer(10000, _timerTestCallback, NULL);
   1.105    SDLTest_AssertPass("Call to SDL_AddTimer(10000,...)");
   1.106    SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id);
   1.107 -  
   1.108 +
   1.109    /* Remove timer again and check that callback was not called */
   1.110    result = SDL_RemoveTimer(id);
   1.111    SDLTest_AssertPass("Call to SDL_RemoveTimer()");
   1.112 @@ -154,21 +154,21 @@
   1.113    _paramValue = param;
   1.114    _timerCallbackCalled = 0;
   1.115  
   1.116 -  /* Set timer with a short delay */  
   1.117 +  /* Set timer with a short delay */
   1.118    id = SDL_AddTimer(10, _timerTestCallback, (void *)&param);
   1.119    SDLTest_AssertPass("Call to SDL_AddTimer(10, param)");
   1.120    SDLTest_AssertCheck(id > 0, "Check result value, expected: >0, got: %d", id);
   1.121 -  
   1.122 +
   1.123    /* Wait to let timer trigger callback */
   1.124    SDL_Delay(100);
   1.125    SDLTest_AssertPass("Call to SDL_Delay(100)");
   1.126 -  
   1.127 +
   1.128    /* Remove timer again and check that callback was called */
   1.129    result = SDL_RemoveTimer(id);
   1.130    SDLTest_AssertPass("Call to SDL_RemoveTimer()");
   1.131    SDLTest_AssertCheck(result == SDL_FALSE, "Check result value, expected: %i, got: %i", SDL_FALSE, result);
   1.132    SDLTest_AssertCheck(_timerCallbackCalled == 1, "Check callback WAS called, expected: 1, got: %i", _timerCallbackCalled);
   1.133 -    
   1.134 +
   1.135    return TEST_COMPLETED;
   1.136  }
   1.137  
   1.138 @@ -176,26 +176,26 @@
   1.139  
   1.140  /* Timer test cases */
   1.141  static const SDLTest_TestCaseReference timerTest1 =
   1.142 -		{ (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED };
   1.143 +        { (SDLTest_TestCaseFp)timer_getPerformanceCounter, "timer_getPerformanceCounter", "Call to SDL_GetPerformanceCounter", TEST_ENABLED };
   1.144  
   1.145  static const SDLTest_TestCaseReference timerTest2 =
   1.146 -		{ (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED };
   1.147 +        { (SDLTest_TestCaseFp)timer_getPerformanceFrequency, "timer_getPerformanceFrequency", "Call to SDL_GetPerformanceFrequency", TEST_ENABLED };
   1.148  
   1.149  static const SDLTest_TestCaseReference timerTest3 =
   1.150 -		{ (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED };
   1.151 +        { (SDLTest_TestCaseFp)timer_delayAndGetTicks, "timer_delayAndGetTicks", "Call to SDL_Delay and SDL_GetTicks", TEST_ENABLED };
   1.152  
   1.153  static const SDLTest_TestCaseReference timerTest4 =
   1.154 -		{ (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED };
   1.155 +        { (SDLTest_TestCaseFp)timer_addRemoveTimer, "timer_addRemoveTimer", "Call to SDL_AddTimer and SDL_RemoveTimer", TEST_ENABLED };
   1.156  
   1.157  /* Sequence of Timer test cases */
   1.158  static const SDLTest_TestCaseReference *timerTests[] =  {
   1.159 -	&timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL
   1.160 +    &timerTest1, &timerTest2, &timerTest3, &timerTest4, NULL
   1.161  };
   1.162  
   1.163  /* Timer test suite (global) */
   1.164  SDLTest_TestSuiteReference timerTestSuite = {
   1.165 -	"Timer",
   1.166 -	_timerSetUp,
   1.167 -	timerTests,
   1.168 -	NULL
   1.169 +    "Timer",
   1.170 +    _timerSetUp,
   1.171 +    timerTests,
   1.172 +    NULL
   1.173  };