Started writing tests for uiWindow.

This commit is contained in:
Pietro Gagliardi 2020-05-24 18:08:48 -04:00
parent 0be1273dab
commit 2f9aaeeb62
3 changed files with 40 additions and 0 deletions

View File

@ -446,6 +446,7 @@ const char *uiWindowTitle(uiWindow *w)
struct windowImplData *wi = (struct windowImplData *) uiControlImplData(uiControl(w));
if (wi->title == NULL)
// TODO replace this with a dedicated UTF-8 empty string object
return "";
return wi->title;
}

View File

@ -5,6 +5,7 @@ libui_test_sources = files([
'controls.c',
'initmain.c',
'noinitwrongthread.c',
'window.c',
])
libui_allcalls_headers = files([
'allcalls.h',

38
test/window.c Normal file
View File

@ -0,0 +1,38 @@
// 24 may 2020
#include "test.h"
Test(CannotMakeWindowAChild)
{
uiWindow *a, *b;
void *ctx;
a = uiNewWindow();
b = uiNewWindow();
ctx = beginCheckProgrammerError("cannot set a uiWindow as the child of another uiControl");
uiControlSetParent(a, b);
// TODO this should not be necessary
uiControlSetParent(a, NULL);
endCheckProgrammerError(ctx);
uiControlFree(uiControl(b));
uiControlFree(uiControl(a));
}
Test(InitialWindowTitleIsEmptyString)
{
uiWindow *w;
const char *title;
w = uiNewWindow();
title = uiWindowTitle(w);
// TODO have a utf8cmp()
if (*title != 0)
// TODO have a diffUTF8
TestErrorf("brand new uiWindow has wrong title:" diff("%s"),
title, "(empty string)");
uiControlFree(uiControl(w));
}
// TODO check that SetTitle works, and also that it sanitizes
// TODO for all the above, check that the underlying title was also set appropriately