static void testcase1(const char *desc) { ggi_visual_t vis; ggi_color green, back; int err; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); err = ggiSetGraphMode(vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_8BIT); if(err < 0) { printassert(0, "Palettized mode not available.\n"); printsuccess(); ggiClose(vis); ggiExit(); return; } green.r = 100; green.g = 40000; green.b = 4000; err = ggiSetPalette(vis, GGI_PALETTE_DONTCARE, 1, &green); if (err < 0) { printfailure("Unable to install colormap with one entry.\n"); ggiClose(vis); ggiExit(); return; } printassert(err == (int)ggiMapColor(vis, &green), "ggiMapColor inconsistent with retval of ggiSetPalette.\n"); ggiUnmapPixel(vis, err, &back); if(green.r != back.r || green.g != back.g || green.b != back.b) { printfailure("Unexpected color from ggiUnmapPixel.\n"); ggiClose(vis); ggiExit(); return; } ggiSetGCForeground(vis, err); ggiDrawBox(vis, 0, 0, 3000, 3000); ggiFlush(vis); /* You should see a green square, how to test this? */ ggUSleep(5000000); printsuccess(); ggiClose(vis); ggiExit(); }
static void testcase7(const char *desc) { int err; ggi_visual_t vis; ggi_mode mode; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); /* sync mode enables mansync if used */ /* Get the default mode */ err = ggiCheckGraphMode (vis, 640, 480, GGI_AUTO, GGI_AUTO, GT_AUTO, &mode); if (err != GGI_OK) { printfailure("ggiCheckGraphMode: #1: No 640x480 mode available\n"); ggiClose(vis); ggiExit(); return; } err = ggiSetMode(vis, &mode); if (err != GGI_OK) { printfailure("ggiSetMode() #1: failed although ggiCheckGraphMode() was OK!\n"); ggiClose(vis); ggiExit(); return; } err = ggiCheckGraphMode(vis, 320, 200, GGI_AUTO, GGI_AUTO, GT_AUTO, &mode); if (err != GGI_OK) { printfailure("ggiCheckGraphMode: #2: No 320x200 mode available\n"); ggiClose(vis); ggiExit(); return; } err = ggiSetMode(vis, &mode); if (err != GGI_OK) { printfailure("ggiSetMode() #2: resetting a mode failed although ggiCheckGraphMode() was OK!\n"); ggiClose(vis); ggiExit(); return; } ggiClose(vis); ggiExit(); printsuccess(); return; }
static void testcase2(const char *desc) { int err; ggi_visual_t vis; ggi_mode mode; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); err = ggiCheckSimpleMode(vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_AUTO, &mode); err = ggiSetMode(vis, &mode); if (err != GGI_OK) { printfailure("ggiSetMode: expected return value: GGI_OK\n" "actual return value: %i\n", err); return; } ggiClose(vis); ggiExit(); printsuccess(); return; }
static void testcase3(const char *desc) { char buffer[1024]; const char *str = " \tdisplay-multi:(display-x:-noshm):(display-aa)"; const char *retstr; const char *expected = "display-x:-noshm"; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; /* Testcase: Passing a string with valid arguments * expects to return ":" */ retstr = ggParseTarget(&str[16], buffer, sizeof(buffer)); if (retstr == NULL || strncmp(":", retstr, 1) != 0) { printfailure("expected return value: \"%s\"\n" "actual return value: \"%s\"\n", ":", (retstr) ? retstr : "NULL"); return; } if (strncmp(expected, buffer, 1024) != 0) { printfailure("expected target value: \"%s\"\n" "actual target value: \"%s\"\n", expected, buffer); return; } printsuccess(); return; }
static void testcase2(const char *desc) { char buffer[3]; const char *str = " \tdisplay-multi:(display-x:-noshm):(display-aa)"; const char *retstr; const char *expected = "d"; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; /* Testcase: Passing a string with an too short * target buffer expects to fill out the buffer * as much as possible, but not complete. */ retstr = ggParseTarget(str, buffer, sizeof(buffer)); if (retstr != NULL) { printfailure("expected return value: \"%s\"\n" "actual return value: \"%s\"\n", "NULL", (retstr) ? retstr : "NULL"); return; } if (strncmp(expected, buffer, 3) != 0) { printfailure("expected target value: \"%s\"\n" "actual target value: \"%s\"\n", expected, buffer); return; } printsuccess(); return; }
static void testcase1(const char *desc) { char buffer[1024]; const char *str = " \t"; const char *retstr; const char *expected = ""; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; /* Testcase: Passing a string with whitespaces only * expects to return \0 */ retstr = ggParseTarget(str, buffer, sizeof(buffer)); if (strncmp(expected, retstr, 1) != 0) { printfailure("expected return value: \"%s\"\n" "actual return value: \"%s\"\n", expected, retstr); return; } printsuccess(); return; }
static void testcase2(const char *desc) { int err; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggExit(); if (err != 1) { printfailure("expected return value: 1\n" "actual return value: %i\n", err); return; } err = ggExit(); if (err != GGI_OK) { printfailure("expected return value: 0\n" "actual return value: %i\n", err); return; } printsuccess(); return; }
static void testcase5(const char *desc) { int err; ggi_visual_t vis; ggi_mode sug_mode, final_mode; int visible_w, visible_h; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); ggiSetFlags(vis, GGIFLAG_ASYNC); /* Get the default mode */ err = ggiCheckGraphMode (vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_AUTO, &sug_mode); if (err != GGI_OK) { printfailure("ggiCheckGraphMode: No graphic mode available\n"); ggiClose(vis); ggiExit(); return; } visible_w = sug_mode.visible.x; visible_h = sug_mode.visible.y; err = ggiCheckGraphMode(vis, visible_w, visible_h, visible_w, visible_h*2, GT_AUTO, &final_mode); if (!err) { /* actually print an info output */ printassert(0 == 1, "Info: Applications may assume now," " panning via ggiSetOrigin() is available\n"); /* Note, Applications have no other way to figure out if * ggiSetOrigin() is available or not */ } else { final_mode = sug_mode; } err = ggiSetMode(vis, &final_mode); if (err) { printfailure("ggiSetMode() failed although ggiCheckGraphMode() was OK!\n"); ggiClose(vis); ggiExit(); } ggiClose(vis); ggiExit(); printsuccess(); return; }
static void testcase1(const char *desc) { void *lock; int result; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; lock = ggLockCreate(); if(lock == NULL) { printfailure("Failed to create lock."); return; } ggLock(lock); result = ggTryLock(lock); if(result == 0) { printfailure("Lock should have been locked already."); return; } printassert(result == GGI_EBUSY, "Lock not busy. result: %i\n", result); ggUnlock(lock); result = ggTryLock(lock); printassert(result != GGI_EBUSY, "Lock shouldn't be busy. result: %i\n", result); if (result != 0) { printfailure("Locking failed.\n" "expected result: 0\n" "actual result: %i\n", result); return; } ggUnlock(lock); result = ggLockDestroy(lock); if(result != 0) { printfailure("Failed to destroy lock."); return; } printsuccess(); return; }
static void testcase8(const char *desc) { int err; ggi_visual_t vis; ggi_mode mode; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); mode.virt.x = mode.virt.y = GGI_AUTO; mode.visible.x = mode.visible.y = GGI_AUTO; mode.frames = GGI_AUTO; mode.graphtype = GT_AUTO; mode.dpp.x = mode.dpp.y = 1; mode.size.x = -19493; mode.size.y = 31831; /* Get the default mode */ ggiCheckMode(vis, &mode); err = ggiSetMode(vis, &mode); if (err != GGI_OK) { printfailure("ggiSetMode() failed even though ggiCheckMode() was called!\n"); ggiClose(vis); ggiExit(); return; } ggiClose(vis); ggiExit(); printsuccess(); return; }
static void testcase1(const char *desc) { int ret; ggi_visual_t vis; ggi_mode mode; ggi_pixel pixel_color; ggi_color color_color; #if 0 unsigned int j, size; const ggi_directbuffer *dbuf = NULL; #endif color_color.r = 0x0000; color_color.g = 0xffff; color_color.b = 0xffff; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; vis = ggNewStem(libggi, NULL); if (vis == NULL) { printfailure("Couldn't create stem for %s", DISPLAYSTR); return; } ret = ggiOpen(vis, DISPLAYSTR, NULL); if (ret != 0) { printfailure("Couldn't open %s", DISPLAYSTR); return; } #if 0 /* Here, XGGI would switch to async mode, * if there were a place to hook in ggiFlush() */ ggiSetFlags(vis, GGIFLAG_ASYNC); #endif /* Now check, if mansync is actually running * - note, we are in sync mode here. */ /* stop mansync. If it runs as it should, * we don't fail with an assertion here */ ret = MANSYNC_stop(STEM_API_DATA(vis, libggi, struct ggi_visual*)); if (ret != 0) { printfailure("BUG: mansync not running - forgot to call " "MANSYNC_start(vis) right after MANSYNC_init(vis)?\n"); goto exit_testcase; } /* now restart it */ ret = MANSYNC_start(STEM_API_DATA(vis, libggi, struct ggi_visual*)); if (ret != 0) { printfailure("BUG: mansync couldn't be relaunched\n"); goto exit_testcase; } ggiParseMode("", &mode); ggiCheckMode(vis, &mode); ret = ggiSetMode(vis, &mode); if (ret != GGI_OK) { printfailure("expected return value: \"%i\"\n" "actual return value: \"%i\"\n", GGI_OK, ret); goto exit_testcase; } /* Disable directbuffer as this is not required to * perform the test */ #if 0 ret = -1; size = GT_SIZE(mode.graphtype); for (j = 0; (dbuf = ggiDBGetBuffer(vis, j)) != NULL; j++) { if ((dbuf->type & GGI_DB_SIMPLE_PLB) && ((8*dbuf->buffer.plb.stride) % size) == 0) { /* found */ ret = GGI_OK; break; } } if (ret != GGI_OK) { printfailure("This mode and target has no suitable DirectBuffer\n"); goto exit_testcase; } if (ggiResourceAcquire(dbuf->resource, GGI_ACTYPE_WRITE | GGI_ACTYPE_READ) != 0) { printfailure("Unable to acquire DirectBuffer\n"); goto exit_testcase; } #endif /* ... and now draw something. */ pixel_color = ggiMapColor(vis, &color_color); ggiSetGCForeground(vis, pixel_color); ggiFillscreen(vis); #if 0 ggiResourceRelease(dbuf->resource); #endif exit_testcase: ggDelStem(vis); printsuccess(); return; }
static void testcase9(const char *desc) { int err; ggi_modelist *ml; ggi_mode_padded mp; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; ml = _GGI_modelist_create(2); mp.mode.frames = 1; mp.mode.visible.x = 100; mp.mode.visible.y = 100; mp.mode.virt.x = 100; mp.mode.virt.y = 100; mp.mode.size.x = 100; mp.mode.size.x = 100; mp.mode.graphtype = GT_32BIT; mp.mode.dpp.x = 1; mp.mode.dpp.y = 1; mp.user_data = NULL; _GGI_modelist_append(ml, &mp); mp.mode.frames = 1; mp.mode.visible.x = 200; mp.mode.visible.y = 200; mp.mode.virt.x = 200; mp.mode.virt.y = 200; mp.mode.size.x = 200; mp.mode.size.x = 200; mp.mode.graphtype = GT_16BIT; mp.mode.dpp.x = 1; mp.mode.dpp.y = 1; mp.user_data = NULL; _GGI_modelist_append(ml, &mp); mp.mode.frames = GGI_AUTO; mp.mode.visible.x = GGI_AUTO; mp.mode.visible.y = GGI_AUTO; mp.mode.virt.x = GGI_AUTO; mp.mode.virt.y = GGI_AUTO; mp.mode.size.x = 200; mp.mode.size.x = 200; mp.mode.graphtype = GT_AUTO; mp.mode.dpp.x = GGI_AUTO; mp.mode.dpp.y = GGI_AUTO; mp.user_data = NULL; err = _GGI_modelist_checkmode(ml, &mp); _GGI_modelist_destroy(ml); if (err != GGI_OK) { printfailure("_GGI_modelist_checkmode() failed even though there is a match!\n"); return; } if (mp.mode.size.x != 200 || mp.mode.size.y != 200) { printfailure("_GGI_modelist_checkmode() suggested the wrong mode!\n"); return; } printsuccess(); return; }
static void testcase1(const char *desc) { int err; ggi_visual_t vis; ggi_mode mode; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); err = ggiCheckSimpleMode(vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_AUTO, &mode); if (err == GGI_OK) { if (mode.visible.x == GGI_AUTO) { printfailure("visible.x: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.visible.y == GGI_AUTO) { printfailure("visible.y: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.virt.x == GGI_AUTO) { printfailure("virt.x: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.virt.y == GGI_AUTO) { printfailure("virt.y: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.size.x == GGI_AUTO) { printfailure("size.x: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.size.y == GGI_AUTO) { printfailure("size.y: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.frames == GGI_AUTO) { printfailure("frames: expected return value: != GGI_AUTO\n" "actual return value: GGI_AUTO\n"); return; } if (mode.graphtype == GT_AUTO) { printfailure("graphtype: expected return value: != GT_AUTO\n" "actual return value: GT_AUTO\n"); return; } } ggiClose(vis); ggiExit(); printsuccess(); return; }
static void testcase4(const char *desc) { int err; ggi_visual_t vis; ggi_mode mode; ggi_coord size; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); err = ggiCheckSimpleMode( vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_AUTO, &mode); printassert(err == GGI_OK, "ggiCheckSimpleMode: can't find a mode\n"); if(err != GGI_OK) { ggiClose(vis); ggiExit(); printsuccess(); return; } printassert(mode.size.x != GGI_AUTO && mode.size.y != GGI_AUTO, "physical size is apparently not supported\n"); if(mode.size.x == GGI_AUTO || mode.size.y == GGI_AUTO) { ggiClose(vis); ggiExit(); printsuccess(); return; } /* Clear out all but the physical size */ mode.frames = GGI_AUTO; mode.visible.x = GGI_AUTO; mode.visible.y = GGI_AUTO; mode.virt.x = GGI_AUTO; mode.virt.y = GGI_AUTO; mode.graphtype = GT_AUTO; mode.dpp.x = GGI_AUTO; mode.dpp.y = GGI_AUTO; size = mode.size; /* This mode should be there */ err = ggiCheckMode(vis, &mode); ggiClose(vis); ggiExit(); if (err != GGI_OK) { printfailure("ggiCheckMode: expected return value: GGI_OK\n" "actual return value: %i\n", err); return; } if (mode.size.x != size.x) { printfailure( "ggiCheckMode: size.x: expected return value: %i\n" "actual return value: %i\n", size.x, mode.size.x); return; } if (mode.size.y != size.y) { printfailure( "ggiCheckMode: size.y: expected return value: %i\n" "actual return value: %i\n", size.y, mode.size.y); return; } printsuccess(); }