test/test-automation/testplatform/testplatform.c
changeset 5774 4f9f82aa1a33
parent 5766 8cc2ae74cd83
     1.1 --- a/test/test-automation/testplatform/testplatform.c	Tue Jul 19 21:38:15 2011 +0300
     1.2 +++ b/test/test-automation/testplatform/testplatform.c	Wed Jul 20 23:04:55 2011 -0700
     1.3 @@ -40,9 +40,12 @@
     1.4  static const TestCaseReference test10 =
     1.5  		(TestCaseReference){ "platform_testSetErrorInvalidInput", "Tests SDL_SetError with invalid input", TEST_ENABLED, 0, 0 };
     1.6  
     1.7 +static const TestCaseReference test11 =
     1.8 +		(TestCaseReference){ "platform_testGetPowerInfo", "Tests SDL_GetPowerInfo function", TEST_ENABLED, 0, 0 };
     1.9 +
    1.10  /* Test suite */
    1.11  extern const TestCaseReference *testSuite[] =  {
    1.12 -	&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, NULL
    1.13 +	&test1, &test2, &test3, &test4, &test5, &test6, &test7, &test8, &test9, &test10, &test11, NULL
    1.14  };
    1.15  
    1.16  TestCaseReference **QueryTestSuite() {
    1.17 @@ -137,6 +140,10 @@
    1.18   * \brief Tests SDL_GetXYZ() functions
    1.19   * \sa
    1.20   * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform
    1.21 + * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount
    1.22 + * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize
    1.23 + * http://wiki.libsdl.org/moin.cgi/SDL_GetRevision
    1.24 + * http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber
    1.25   */
    1.26  int platform_testGetFunctions (void *arg)
    1.27  {
    1.28 @@ -158,6 +165,15 @@
    1.29      
    1.30     ret = SDL_GetCPUCount();
    1.31     AssertPass("SDL_GetCPUCount()");
    1.32 +   AssertTrue(ret > 0,
    1.33 +             "SDL_GetCPUCount(): expected count > 0, was: %i", 
    1.34 +             ret);    
    1.35 +
    1.36 +   ret = SDL_GetCPUCacheLineSize();
    1.37 +   AssertPass("SDL_GetCPUCacheLineSize()");
    1.38 +   AssertTrue(ret >= 0,
    1.39 +             "SDL_GetCPUCacheLineSize(): expected size >= 0, was: %i", 
    1.40 +             ret);    
    1.41  
    1.42     revision = (char *)SDL_GetRevision();
    1.43     AssertPass("SDL_GetRevision()");
    1.44 @@ -169,6 +185,16 @@
    1.45  
    1.46  /*!
    1.47   * \brief Tests SDL_HasXYZ() functions
    1.48 + * \sa
    1.49 + * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow
    1.50 + * http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec
    1.51 + * http://wiki.libsdl.org/moin.cgi/SDL_HasMMX
    1.52 + * http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC
    1.53 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE
    1.54 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2
    1.55 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3
    1.56 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41
    1.57 + * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42
    1.58   */
    1.59  int platform_testHasFunctions (void *arg)
    1.60  {
    1.61 @@ -206,6 +232,8 @@
    1.62  
    1.63  /*!
    1.64   * \brief Tests SDL_GetVersion
    1.65 + * \sa
    1.66 + * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion
    1.67   */
    1.68  int platform_testGetVersion(void *arg)
    1.69  {
    1.70 @@ -402,3 +430,79 @@
    1.71     // Clean up                
    1.72     SDL_ClearError();
    1.73  }
    1.74 +
    1.75 +/*!
    1.76 + * \brief Tests SDL_GetPowerInfo
    1.77 + * \sa
    1.78 + * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo
    1.79 + */
    1.80 +int platform_testGetPowerInfo(void *arg)
    1.81 +{
    1.82 +   SDL_PowerState state;
    1.83 +   SDL_PowerState stateAgain;
    1.84 +   int secs;
    1.85 +   int secsAgain;
    1.86 +   int pct;
    1.87 +   int pctAgain;
    1.88 +   
    1.89 +   state = SDL_GetPowerInfo(&secs, &pct);
    1.90 +   AssertPass("SDL_GetPowerInfo()");
    1.91 +   AssertTrue(
    1.92 +       state==SDL_POWERSTATE_UNKNOWN ||
    1.93 +       state==SDL_POWERSTATE_ON_BATTERY ||
    1.94 +       state==SDL_POWERSTATE_NO_BATTERY ||
    1.95 +       state==SDL_POWERSTATE_CHARGING ||
    1.96 +       state==SDL_POWERSTATE_CHARGED,
    1.97 +       "SDL_GetPowerInfo(): state %i is one of the expected values",
    1.98 +       (int)state);
    1.99 +       
   1.100 +   if (state==SDL_POWERSTATE_ON_BATTERY)
   1.101 +   {
   1.102 +      AssertTrue(
   1.103 +         secs >= 0,
   1.104 +         "SDL_GetPowerInfo(): on battery, secs >= 0, was: %i",
   1.105 +         secs);
   1.106 +      AssertTrue(
   1.107 +         (pct >= 0) && (pct <= 100),
   1.108 +         "SDL_GetPowerInfo(): on battery, pct=[0,100], was: %i",
   1.109 +         pct);         
   1.110 +   }
   1.111 +
   1.112 +   if (state==SDL_POWERSTATE_UNKNOWN ||
   1.113 +       state==SDL_POWERSTATE_NO_BATTERY)
   1.114 +   {
   1.115 +      AssertTrue(
   1.116 +         secs == -1,
   1.117 +         "SDL_GetPowerInfo(): no battery, secs == -1, was: %i",
   1.118 +         secs);
   1.119 +      AssertTrue(
   1.120 +         pct == -1,
   1.121 +         "SDL_GetPowerInfo(): no battery, pct == -1, was: %i",
   1.122 +         pct);         
   1.123 +   }
   1.124 +
   1.125 +   // Partial return value variations   
   1.126 +   stateAgain = SDL_GetPowerInfo(&secsAgain, NULL);
   1.127 +   AssertTrue(
   1.128 +        state==stateAgain,
   1.129 +        "State %i returned when only 'secs' requested",
   1.130 +        stateAgain);   
   1.131 +   AssertTrue(
   1.132 +        secs==secsAgain,
   1.133 +        "Value %i matches when only 'secs' requested",
   1.134 +        secsAgain);   
   1.135 +   stateAgain = SDL_GetPowerInfo(NULL, &pctAgain);
   1.136 +   AssertTrue(
   1.137 +        state==stateAgain,
   1.138 +        "State %i returned when only 'pct' requested",
   1.139 +        stateAgain);   
   1.140 +   AssertTrue(
   1.141 +        pct==pctAgain,
   1.142 +        "Value %i matches when only 'pct' requested",
   1.143 +        pctAgain);   
   1.144 +   stateAgain = SDL_GetPowerInfo(NULL, NULL);
   1.145 +   AssertTrue(
   1.146 +        state==stateAgain,
   1.147 +        "State %i returned when no value requested",
   1.148 +        stateAgain); 
   1.149 +}