Sleeping Wombat GUI  0.100
swGUI
Classes
TestFramework

Framework for testing GUI, controls and probably in future applications written swGUI too. More...

Classes

class  sw::gui::TestFramework
 Class used as application entry point in tests. More...
 

Detailed Description

Framework for testing GUI, controls and probably in future applications written swGUI too.

Writing tests

Tests use special sw::gui::TestFramework class which derives from sw::gui::GUISystem and implements all functionalities with minimal context and light dependencies. You can use this class directly or derive your own class normally as you would do in application.

TestFramework gives you posibility to:

Linking libraries

To write test you must link TestFramework.lib which links by itself:

TestFramework doesn't create window nor rendering api - it uses fake subtitutes to minimize testing time.

Moreover you must link other things necessary to make GUI work like:

All these things can change in future versions.

Usage examples

This code uses catch to check test condition but you can use your own testing framework.

TEST_CASE( "KeyUp/KeyDown event" )
{
// Initialize framework.
TestFramework framework( 0, nullptr ); // Provide main function arguments.
framework.Init();
// Create main window (fake window) and get input::EventCapture.
HostWindow* window = framework.CreateNativeHostWindow( 400, 400, "TestWindow" );
input::EventCapture* eventCapturer = framework.GetEventCapturer();
// Set focus to window.
framework.OnFocusChanged( window->GetNativeWindow(), true );
// Add event handlers to tested events.
window->KeyUp() += EventDelegate< KeyEventArgs >( &KeyEventReceived );
window->KeyDown() += EventDelegate< KeyEventArgs >( &KeyEventReceived );
window->PreviewKeyUp() += EventDelegate< KeyEventArgs >( &KeyEventReceived );
window->PreviewKeyDown() += EventDelegate< KeyEventArgs >( &KeyEventReceived );
//....
}
See also
DebugInput