This commit is contained in:
Pietro Gagliardi 2020-06-07 20:58:11 -04:00
parent 1c7718ec58
commit 6f4610f82a
1 changed files with 80 additions and 0 deletions

80
test/window_windows.c Normal file
View File

@ -0,0 +1,80 @@
// 24 may 2020
#include "test_windows.h"
Test(WindowHasHandleFromStart)
{
uiWindow *a;
a = uiNewWindow();
if (uiWindowsControlHandle(uiControl(a)) == NULL)
TestErrorf("uiWindowsControlHandle(brand new uiWindow) is NULL; should not be");
uiControlFree(uiControl(a));
}
Test(InitialWindowTitleIsEmptyString_OSLevel)
{
uiWindow *w;
HWND hwnd;
uint16_t *title;
w = uiNewWindow();
hwnd = uiWindowsControlHandle(uiControl(w));
title = testGetWindowText(hwnd);
if (!utf16equal(title, testUTF16Empty))
utf16diffError("brand new uiWindow has wrong title", title, testUTF16Empty);
free(title);
uiControlFree(uiControl(w));
}
static void testSetWindowTitleImplFull(const char *file, long line, const char *title, const uint16_t *want)
{
uiWindow *w;
HWND hwnd;
uint16_t *got;
w = uiNewWindow();
uiWindowSetTitle(w, title);
hwnd = uiWindowsControlHandle(uiControl(w));
got = testGetWindowText(hwnd);
if (!utf16equal(got, want))
utf16diffErrorFull(file, line, "GetWindowTextW() reported wrong title after uiWindowSetTitle()", got, want);
free(got);
uiControlFree(uiControl(w));
}
#define testSetWindowTitleImpl(title, want) testSetWindowTitleImplFull(__FILE__, __LINE__, title, want)
Test(SetWindowTitle_OSLevel_Empty)
{
testSetWindowTitleImpl(testUTF8Empty, testUTF16Empty);
}
Test(SetWindowTitle_OSLevel_ASCIIOnly)
{
testSetWindowTitleImpl(testUTF8ASCIIOnly, testUTF16ASCIIOnly);
}
Test(SetWindowTitle_OSLevel_WithTwoByte)
{
testSetWindowTitleImpl(testUTF8WithTwoByte, testUTF16WithTwoByte);
}
Test(SetWindowTitle_OSLevel_WithThreeByte)
{
testSetWindowTitleImpl(testUTF8WithThreeByte, testUTF16WithThreeByte);
}
Test(SetWindowTitle_OSLevel_WithFourByte)
{
testSetWindowTitleImpl(testUTF8WithFourByte, testUTF16WithFourByte);
}
Test(SetWindowTitle_OSLevel_Combined)
{
testSetWindowTitleImpl(testUTF8Combined, testUTF16Combined);
}
Test(SetWindowTitle_OSLevel_Invalid)
{
testSetWindowTitleImpl(testUTF8InvalidInput, testUTF16InvalidOutput);
}