e7cd42bc4a516905cd30fa7de76a88fa86faaa9d
[profile/ivi/clutter.git] / tests / conform / test-conform-common.c
1 #include "config.h"
2
3 #include <clutter/clutter.h>
4 #include <stdlib.h>
5
6 #ifdef CLUTTER_WINDOWING_X11
7 #include <X11/Xlib.h>
8 #include <clutter/x11/clutter-x11.h>
9 #endif
10
11 #include "test-conform-common.h"
12
13 /**
14  * test_conform_simple_fixture_setup:
15  *
16  * Initialise stuff before each test is run
17  */
18 void
19 test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture,
20                                    gconstpointer data)
21 {
22   const TestConformSharedState *shared_state = data;
23   static int counter = 0;
24
25   if (counter != 0)
26     g_critical ("We don't support running more than one test at a time\n"
27                 "in a single test run due to the state leakage that often\n"
28                 "causes subsequent tests to fail.\n"
29                 "\n"
30                 "If you want to run all the tests you should run\n"
31                 "$ make test-report");
32   counter++;
33
34 #ifdef HAVE_CLUTTER_GLX
35   {
36     /* on X11 we need a display connection to run the test suite */
37     const gchar *display = g_getenv ("DISPLAY");
38     if (!display || *display == '\0')
39       {
40         g_print ("No DISPLAY found. Unable to run the conformance "
41                  "test suite without a display.\n");
42
43         exit (EXIT_SUCCESS);
44       }
45   }
46 #endif
47
48   g_assert (clutter_init (shared_state->argc_addr, shared_state->argv_addr)
49             == CLUTTER_INIT_SUCCESS);
50
51 #ifdef CLUTTER_WINDOWING_X11
52   /* A lot of the tests depend on a specific stage / framebuffer size
53    * when they read pixels back to verify the results of the test.
54    *
55    * Normally the asynchronous nature of X means that setting the
56    * clutter stage size may really happen an indefinite amount of time
57    * later but since the tests are so short lived and may only render
58    * a single frame this is not an acceptable semantic.
59    */
60   XSynchronize (clutter_x11_get_default_display(), TRUE);
61 #endif
62 }
63
64
65 /**
66  * test_conform_simple_fixture_teardown:
67  *
68  * Cleanup stuff after each test has finished
69  */
70 void
71 test_conform_simple_fixture_teardown (TestConformSimpleFixture *fixture,
72                                       gconstpointer data)
73 {
74   /* const TestConformSharedState *shared_state = data; */
75 }
76
77 void
78 test_conform_get_gl_functions (TestConformGLFunctions *functions)
79 {
80   functions->glGetString = (void *) cogl_get_proc_address ("glGetString");
81   g_assert (functions->glGetString != NULL);
82   functions->glGetIntegerv = (void *) cogl_get_proc_address ("glGetIntegerv");
83   g_assert (functions->glGetIntegerv != NULL);
84   functions->glPixelStorei = (void *) cogl_get_proc_address ("glPixelStorei");
85   g_assert (functions->glPixelStorei != NULL);
86   functions->glBindTexture = (void *) cogl_get_proc_address ("glBindTexture");
87   g_assert (functions->glBindTexture != NULL);
88   functions->glGenTextures = (void *) cogl_get_proc_address ("glGenTextures");
89   g_assert (functions->glGenTextures != NULL);
90   functions->glGetError = (void *) cogl_get_proc_address ("glGetError");
91   g_assert (functions->glGetError != NULL);
92   functions->glDeleteTextures =
93     (void *) cogl_get_proc_address ("glDeleteTextures");
94   g_assert (functions->glDeleteTextures != NULL);
95   functions->glTexImage2D = (void *) cogl_get_proc_address ("glTexImage2D");
96   g_assert (functions->glTexImage2D != NULL);
97   functions->glTexParameteri =
98     (void *) cogl_get_proc_address ("glTexParameteri");
99   g_assert (functions->glTexParameteri != NULL);
100 }