示例#1
0
文件: contener.c 项目: IGLOU-EU/yirl
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();
}
示例#2
0
文件: menu.c 项目: cosmo-ray/yirl
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();
}