tests: Move class definition depending on GTK+ within function evaluation

Move the definition of WindowWithSizeAllocOverride inside of the test
function call to so it is lazily defined. This avoids problems running tests
on systems without GTK+ installed.