Beispiel #1
0
static int test_screen(x11display_t * x11disp, x11display_t * x11disp2)
{
   x11display_t * disp[2] = { x11disp, x11disp2 };

   for (unsigned i = 0; i < lengthof(disp); ++i) {
      const uint32_t N = nrofscreens_x11display(disp[i]);
      const uint32_t D = defaultscreennr_x11display(disp[i]);

      // TEST defaultscreen_x11display
      x11screen_t x11screen = defaultscreen_x11display(disp[i]);
      TEST(x11screen.display  == disp[i]);
      TEST(x11screen.nrscreen == D);

      // TEST defaultscreennr_x11display
      TEST(N >  defaultscreennr_x11display(disp[i]));
      TEST(D == defaultscreennr_x11display(disp[i]));

      // TEST nrofscreens_x11display
      TEST(N == nrofscreens_x11display(disp[i]));
      TEST(1 <= nrofscreens_x11display(disp[i]));
   }

   return 0 ;
ONERR:
   return EINVAL ;
}
Beispiel #2
0
static int childprocess_unittest(void)
{
    x11display_t      x11disp   = x11display_FREE ;
    x11screen_t       x11screen = x11screen_FREE ;
    resourceusage_t   usage     = resourceusage_FREE ;

    // prepare
    TEST(0 == init_x11display(&x11disp, ":0")) ;
    x11screen = defaultscreen_x11display(&x11disp) ;

    if (test_iterator(&x11screen))      goto ONERR;
    if (test_initfree(&x11screen))      goto ONERR;
    if (test_setvideomode(&x11screen))  goto ONERR; // has memory leak

    TEST(0 == init_resourceusage(&usage)) ;

    if (test_iterator(&x11screen))      goto ONERR;
    if (test_initfree(&x11screen))      goto ONERR;

    TEST(0 == same_resourceusage(&usage)) ;
    TEST(0 == free_resourceusage(&usage)) ;

    // unprepare
    TEST(0 == free_x11display(&x11disp)) ;

    return 0 ;
ONERR:
    (void) free_resourceusage(&usage) ;
    (void) free_x11display(&x11disp) ;
    return EINVAL ;
}