void testVerticalContenerSdl(void) { GameConfig cfg; Entity *ret; YWidgetState *wid; int t = ydJsonInit(); void *jsonManager; /* Init libs */ g_assert(!ygInitGameConfig(&cfg, NULL, SDL2)); g_assert(!ygInit(&cfg)); /* Parsing json */ jsonManager = ydNewManager(t); ret = ydFromFile(jsonManager, TESTS_PATH"/widget.json"); ret = yeGet(ret, "ContenerTest"); g_assert(ret); ywinAddCallback(ywinCreateNativeCallback("menuTest", testMenuEnter)); wid = ywidNewWidget(ret, NULL); g_assert(wid); do { g_assert(ywidRend(wid) != -1); } while(ywidDoTurn(wid) != ACTION); YE_DESTROY(ret); ygEnd(); }
void testEntityPatch(void) { yeInitMem(); int t = ydJsonInit(); void *jsonManager; Entity *ret; Entity *mn; Entity *mn2; Entity *entries; Entity *patch; jsonManager = ydNewManager(t); ret = ydFromFile(jsonManager, TESTS_PATH"/widget.json", NULL); mn = yeGet(ret, "MenuTest"); mn2 = yeCreateArray(NULL, NULL); yeCopy(mn, mn2); entries = yeGet(mn2, "entries"); yeRemoveChild(entries, 2); g_assert(yeLen(entries) == 2); patch = yePatchCreate(mn, mn2, NULL, NULL); g_assert(patch); yePatchAply(mn, patch); yeDestroy(patch); g_assert(yeLen(yeGet(mn, "entries")) == 2); /* Manu rentre chez toi c'est a moi qu'tu fait d'la peine... */ yeReCreateString("manu", mn2, "<type>"); yeCreateString("ayoyoyo", mn2, "wololo"); yeRemoveChild(mn2, "background"); yeReCreateInt(1337, mn2, "button_background"); yeSetAt(yeGet(entries, 0), "text", "new text"); yeCreateFloat(3.14, entries, NULL); patch = yePatchCreate(mn, mn2, NULL, NULL); g_assert(patch); yePatchAply(mn, patch); g_assert(!yeStrCmpAt(mn, "ayoyoyo", "wololo")); /* une gonsesse de perdu c'est 10 copains qui reviennes */ g_assert(!yeStrCmpAt(mn, "manu", "<type>")); g_assert(yeGetIntAt(mn, "button_background") == 1337); g_assert(!yeGet(mn, "background")); entries = yeGet(mn, "entries"); g_assert(yeGetFloatAt(entries, 2) == 3.14); g_assert(!yeStrCmpAt(yeGet(entries, 0), "new text", "text")); ydJsonEnd(); ydDestroyManager(jsonManager); yeEnd(); }
void testPanelMenuSdl2(void) { yeInitMem(); int t = ydJsonInit(); void *jsonManager; Entity *oret, *ret; YWidgetState *wid; ysRegistreFunc(ysNativeManager(), "menuTest", testMenuEnter); /* load files */ g_assert(t != -1); g_assert(ydJsonGetType() == t); jsonManager = ydNewManager(t); g_assert(jsonManager != NULL); oret = ydFromFile(jsonManager, TESTS_PATH"/widget.json", NULL); ret = yeGet(oret, "MenuTest"); g_assert(ret); g_assert(!ydJsonEnd()); g_assert(!ydDestroyManager(jsonManager)); t = ywMenuInit(); g_assert(t == 0); g_assert(ysdl2Init() != -1); g_assert(ysdl2Type() == 0); yeCreateString("panel", ret, "mn-type"); g_assert(ysdl2RegistreMenu() == 0); wid = ywidNewWidget(ret, NULL); g_assert(wid); do { g_assert(ywidRend(wid) != -1); } while(ywidDoTurn(wid) != ACTION); g_assert(!ywMenuEnd()); YWidDestroy(wid); ysdl2Destroy(); /* end libs */ YE_DESTROY(oret); yeEnd(); }