test/testautomation_audio.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Mon, 24 Dec 2012 14:43:57 -0800
changeset 6772 5229a117ef97
child 6819 afef68703f54
permissions -rw-r--r--
Added audio test suite; minor code cleanups in test lib
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6772
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
 * Original code: automated SDL audio test written by Edgar Simo "bobbens"
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
 * New/updated tests: aschiffler at ferzkopp dot net
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
#include <stdio.h>
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
#include "SDL.h"
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
#include "SDL_test.h"
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
/* ================= Test Case Implementation ================== */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
/* Fixture */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
void
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
_audioSetUp(void *arg)
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
	/* Start SDL audio subsystem */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
	int ret = SDL_InitSubSystem( SDL_INIT_AUDIO );
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
        SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
	SDLTest_AssertCheck(ret==0, "Check result from SDL_InitSubSystem(SDL_INIT_AUDIO)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
	if (ret != 0) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
           SDLTest_LogError("%s", SDL_GetError());
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
        }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
/* Test case functions */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
 * \brief Enumerate and name available audio devices (output and capture).
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
 * 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
int audio_enumerateAndNameAudioDevices()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
   int t, tt;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
   int i, n, nn;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
   const char *name, *nameAgain;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
   /* Iterate over types: t=0 output device, t=1 input/capture device */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
   for (t=0; t<2; t++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    44
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
      /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
      n = SDL_GetNumAudioDevices(t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
      SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(%i)", t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
      SDLTest_Log("Number of %s devices < 0, reported as %i", (t) ? "output" : "capture", n);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
      SDLTest_AssertCheck(n >= 0, "Validate result is >= 0, got: %i", n);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
      /* Variation of non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
      if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
         tt = t + SDLTest_RandomIntegerInRange(1,10);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
         nn = SDL_GetNumAudioDevices(tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
         SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", tt, n, nn);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
         nn = SDL_GetNumAudioDevices(-tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
         SDLTest_AssertCheck(n==nn, "Verify result from SDL_GetNumAudioDevices(%i), expected same number of audio devices %i, got %i", -tt, n, nn);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
      } 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
      /* List devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
      if (n>0) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
         for (i=0; i<n; i++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
            name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
            SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
            SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
            if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
              SDLTest_AssertCheck(SDL_strlen(name)>0, "verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, t, name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
              if (t==1) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
                  /* Also try non-zero type */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
                  tt = t + SDLTest_RandomIntegerInRange(1,10);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
                  nameAgain = SDL_GetAudioDeviceName(i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
                  SDLTest_AssertCheck(nameAgain != NULL, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not NULL", i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
                  if (nameAgain != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
                    SDLTest_AssertCheck(SDL_strlen(nameAgain)>0, "Verify result from SDL_GetAudioDeviceName(%i, %i) is not empty, got: '%s'", i, tt, nameAgain);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
                    SDLTest_AssertCheck(SDL_strcmp(name, nameAgain)==0, 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
                      "Verify SDL_GetAudioDeviceName(%i, %i) and SDL_GetAudioDeviceName(%i %i) return the same string", 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
                      i, t, i, tt);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
                  }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
               }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
            }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
 * \brief Negative tests around enumeration and naming of audio devices.
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
 * 
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetNumAudioDevices
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
 * \sa http://wiki.libsdl.org/moin.cgi/SDL_GetAudioDeviceName
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
int audio_enumerateAndNameAudioDevicesNegativeTests()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
   int t;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
   int i, j, no, nc;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
   /* Get number of devices. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
   no = SDL_GetNumAudioDevices(0);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(0)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
   nc = SDL_GetNumAudioDevices(1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
   SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(1)");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
   /* Invalid device index when getting name */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
   for (t=0; t<2; t++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
      /* Negative device index */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
      i = SDLTest_RandomIntegerInRange(-10,-1);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
      name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
      SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
      SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result NULL, expected NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   113
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   114
      /* Device index past range */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
      for (j=0; j<3; j++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
         i = (t) ? nc+j : no+j;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   118
         SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
         SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   120
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   121
      
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   122
      /* Capture index past capture range but within output range */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   123
      if ((no>0) && (no>nc) && (t==1)) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   124
         i = no-1;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
         name = SDL_GetAudioDeviceName(i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
         SDLTest_AssertPass("Call to SDL_GetAudioDeviceName(%i, %i)", i, t);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   127
         SDLTest_AssertCheck(name == NULL, "Check SDL_GetAudioDeviceName(%i, %i) result, expected: NULL, got: %s", i, t, (name == NULL) ? "NULL" : name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   128
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   129
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   130
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   135
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
 * @brief Checks available audio driver names.
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   137
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
int audio_printAudioDrivers()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   139
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   140
   int i, n;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   141
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   142
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   143
   /* Get number of drivers */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   144
   n = SDL_GetNumAudioDrivers();
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
   SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   146
   SDLTest_AssertCheck(n>=0, "Verify number of audio drivers >= 0, got: %i", n);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   147
   
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
   /* List drivers. */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
   if (n>0)
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   150
   {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   151
      for (i=0; i<n; i++) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   152
         name = SDL_GetAudioDriver(i);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   153
         SDLTest_AssertPass("Call to SDL_GetAudioDriver(%i)", i);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   154
         SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   155
         if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   156
            SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
         }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   158
      }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   159
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   160
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   161
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   162
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   164
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   165
/**
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   166
 * @brief Checks current audio driver name with initialized audio.
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   167
 */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   168
int audio_printCurrentAudioDriver()
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   169
{
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   170
   const char *name;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   171
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   172
   /* Check current audio driver */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   173
   name = SDL_GetCurrentAudioDriver();
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   174
   SDLTest_AssertPass("Call to SDL_GetCurrentAudioDriver()");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   175
   SDLTest_AssertCheck(name != NULL, "Verify returned name is not NULL");
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   176
   if (name != NULL) {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   177
      SDLTest_AssertCheck(SDL_strlen(name)>0, "Verify returned name is not empty, got: '%s'", name);
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   178
   }
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   179
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   180
   return TEST_COMPLETED;
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   181
}
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   182
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   183
/* ================= Test Case References ================== */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   184
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   185
/* Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   186
static const SDLTest_TestCaseReference audioTest1 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   187
		{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevices, "audio_enumerateAndNameAudioDevices", "Enumerate and name available audio devices (output and capture)", TEST_ENABLED };
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   188
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   189
static const SDLTest_TestCaseReference audioTest2 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   190
		{ (SDLTest_TestCaseFp)audio_enumerateAndNameAudioDevicesNegativeTests, "audio_enumerateAndNameAudioDevicesNegativeTests", "Negative tests around enumeration and naming of audio devices.", TEST_ENABLED };
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   191
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   192
static const SDLTest_TestCaseReference audioTest3 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   193
		{ (SDLTest_TestCaseFp)audio_printAudioDrivers, "audio_printAudioDrivers", "Checks available audio driver names.", TEST_ENABLED };
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   194
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   195
static const SDLTest_TestCaseReference audioTest4 =
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   196
		{ (SDLTest_TestCaseFp)audio_printCurrentAudioDriver, "audio_printCurrentAudioDriver", "Checks current audio driver name with initialized audio.", TEST_ENABLED };
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   197
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   198
/* Sequence of Audio test cases */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   199
static const SDLTest_TestCaseReference *audioTests[] =  {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   200
	&audioTest1, &audioTest2, &audioTest3, &audioTest4, NULL
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   201
};
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   203
/* Audio test suite (global) */
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   204
SDLTest_TestSuiteReference audioTestSuite = {
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   205
	"Audio",
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   206
	_audioSetUp,
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   207
	audioTests,
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   208
	NULL
5229a117ef97 Added audio test suite; minor code cleanups in test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   209
};