Added test cases for SDL_GetNumRenderDrivers and SDL_CreateRenderer and removed stub test case
authorAndreas Schiffler <aschiffler@ferzkopp.net>
Sat, 06 Aug 2011 13:52:48 -0700
changeset 5815 216d12fb365d
parent 5814 3c920707a142
child 5816 594229a23ec5
Added test cases for SDL_GetNumRenderDrivers and SDL_CreateRenderer and removed stub test case
test/test-automation/tests/testrender/testrender.c
--- a/test/test-automation/tests/testrender/testrender.c	Sat Aug 06 12:56:43 2011 -0700
+++ b/test/test-automation/tests/testrender/testrender.c	Sat Aug 06 13:52:48 2011 -0700
@@ -18,22 +18,76 @@
 
 /* Test cases */
 static const TestCaseReference test1 =
-		(TestCaseReference){ "render_test", "rendery", TEST_ENABLED, 0, 0 };
+		(TestCaseReference){ "render_testGetNumRenderDrivers", "Tests call to SDL_GetNumRenderDrivers", TEST_ENABLED, 0, 0 };
+
+static const TestCaseReference test2 =
+		(TestCaseReference){ "render_testCreateRenderer", "Tests SDL_CreateRenderer", TEST_ENABLED, 0, 0 };
 
 /* Test suite */
 extern const TestCaseReference *testSuite[] =  {
-	&test1, NULL
+	&test1, &test2, NULL
 };
 
 TestCaseReference **QueryTestSuite() {
 	return (TestCaseReference **)testSuite;
 }
 
+// Fixture
+
+void
+SetUp(void *arg)
+{
+  /* Start SDL. */
+  int ret = SDL_Init( SDL_INIT_VIDEO );
+  AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO): %s", SDL_GetError());
+}
+                        
+void
+TearDown(void *arg)
+{
+  /* Quit SDL. */
+  SDL_Quit();
+}
+
 /**
- * @brief Document test case here
+ * @brief Tests call to SDL_GetNumRenderDrivers
+ * \sa 
+ * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers
  */
 int
-render_test(void *arg)
+render_testGetNumRenderDrivers(void *arg)
+{
+  int n;
+  n = SDL_GetNumRenderDrivers();
+  AssertTrue(n>=1, "Number of renderers >= 1, reported as %i", n);
+  if (n<0) {
+    AssertFail("SDL_GetNumRenderDrivers() failed: %s", SDL_GetError());
+  }
+}
+
+/**
+ * @brief Tests call to SDL_CreateRenderer
+ * \sa
+ * http://wiki.libsdl.org/moin.cgi/SDL_CreateRenderer
+ */
+int
+render_testCreateRenderer(void *arg)
 {
-	AssertPass("");
+  SDL_Window *window = NULL;
+  SDL_Renderer *renderer = NULL;
+  int posX = 100, posY = 100, width = 320, height = 240;
+  window = SDL_CreateWindow("Hello World", posX, posY, width, height, 0);
+  if (window != NULL) {
+    AssertPass("Window created");
+    renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
+    if (renderer) {    
+      AssertPass("Renderer created");
+      SDL_DestroyRenderer(renderer);
+    } else {
+      AssertFail("Could not create renderer: %s", SDL_GetError());
+    }
+    SDL_DestroyWindow(window);
+  } else {
+    AssertFail("Could not create window: %s", SDL_GetError());
+  }  
 }