all demos added because exec() don't need main form to exit_all

This commit is contained in:
qPCR4vir 2016-03-05 03:17:49 +01:00
parent 7125ab8f48
commit 2c04ba7bf3
5 changed files with 68 additions and 58 deletions

View File

@ -86,7 +86,7 @@ script:
- ./animate-bmp
- ./audio_player
- ./background-effects
#- ./calculator ?
- ./calculator
- ./categ
- ./clicked
- ./decore
@ -94,18 +94,45 @@ script:
- ./drag-button
- ./draw
- ./file_explorer
#- ./example_menu
- ./example_menu
- ./example_listbox
#- ./example_combox
- ./example_combox
- ./example.button
- ./folder_tree_nana
- ./folder_tree_std
- ./framework_design_1
- ./framework_design_2
- ./framework_design_3
- ./group
- ./HelloWord
#- ./MontiHall
#- ./helloworld_demo
#- ./notepad
#- ./loader_2
#- ./widget_show2
#- ./widget_show
- ./helloword_quit
- ./inputbox
- ./label_listener
- ./lambda_event.cpp11
- ./listbox_inline_widget
- ./listbox_Resolver
- ./loader_1
- ./loader_2
- ./mbox
- ./menu_debug
- ./MontiHall
- ./helloworld_demo
- ./notepad
- ./loader_2
- ./mbox
- ./menu_debug
- ./menu_popuper
- ./modal_form
- ./widget_show2
- ./widget_show
- ./place_login
- ./png
- ./screen
- ./stretch_image
- ./threading
- ./thread-pool
- ./various_events
- ./window-dragger
- ./windows-subclassing

View File

@ -30,7 +30,6 @@ option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the
option(NANA_CMAKE_BUILD_DEMOS "Build all the demos form the nana_demo repository." OFF)
option(NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS "" ON)
option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF)
option(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING "Add defoult automatic GUI test?" OFF)
option(NANA_CMAKE_BUILD_FreeMe "Build FreeMe (currently broken)?" OFF)
@ -177,10 +176,6 @@ if(NANA_CMAKE_ENABLE_AUDIO)
endif(UNIX)
endif(NANA_CMAKE_ENABLE_AUDIO)
if (NANA_CMAKE_BUILD_FreeMe)
add_definitions(-DBUILD_FreeMe)
endif (NANA_CMAKE_BUILD_FreeMe)
if(NANA_CMAKE_VERBOSE_PREPROCESSOR)
add_definitions(-DVERBOSE_PREPROCESSOR)
endif(NANA_CMAKE_VERBOSE_PREPROCESSOR)
@ -249,10 +244,6 @@ if (NANA_CMAKE_BUILD_DEMOS)
enable_testing ()
endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
if(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING)
add_definitions(-DNANA_ADD_DEF_AUTOMATIC_GUI_TESTING)
endif(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING)
set (demos calculator file_explorer helloworld_demo notepad )
foreach ( demo ${demos})
@ -270,6 +261,10 @@ if (NANA_CMAKE_BUILD_DEMOS)
set (demos widget_show widget_show2 )
if (NANA_CMAKE_BUILD_FreeMe)
add_definitions(-DBUILD_FreeMe)
endif (NANA_CMAKE_BUILD_FreeMe)
if (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS)
list(APPEND demos FreeMe) # ??
endif (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS)

View File

@ -96,15 +96,11 @@
///////////////////
// Support for NANA_AUTOMATIC_GUI_TESTING
// Will cause the program to self-test the GUI.
// If NANA_ADD_DEF_AUTOMATIC_GUI_TESTING is also defined a default automatic GUI test
// Will cause the program to self-test the GUI. A default automatic GUI test
// will be added to all programs which don't have yet one defined. This default test will simple
// wait 10 sec. (time to construct, show and execute the GUI) and then exit normally.
//
//#define NANA_AUTOMATIC_GUI_TESTING
//#if defined(NANA_AUTOMATIC_GUI_TESTING)
//#define NANA_ADD_DEF_AUTOMATIC_GUI_TESTING
//#endif
#define NANA_AUTOMATIC_GUI_TESTING

View File

@ -66,9 +66,8 @@ namespace nana
/// from the underlying OS, interpreting and sending it with suitable arguments
/// to the nana widgets that registered a response in the corresponding event.
/// It also accept arguments to be used in case of automatic GUI testing.
/// Other Way the arguments are ignored. It seems that only works in simple
/// programs with only one active form ??
void exec(form *main_form = nullptr, ///< used to close the program
/// Other Way the arguments are ignored.
void exec(
unsigned wait = 1, ///< for the GUI to be constructed, in seconds
unsigned wait_end = 1, ///< for the GUI to be destructed, in seconds
std::function<void()> = {} ///< emit events to mimics user actions and may asert results

View File

@ -49,46 +49,39 @@ namespace nana
}
void exec(form *main_form, //= nullptr, ///< used to close the program
void exec(
unsigned wait, // = 1, ///< for the GUI to be constructed, in seconds
unsigned wait_end, // = 1, ///< for the GUI to be destructed, in seconds
std::function<void()>f // = {} ///< emit events to mimics user actions and may asert results
)
{
#ifdef NANA_AUTOMATIC_GUI_TESTING
//if (!wait)
// wait = 1;
//if (!main_form && !f)
// f = []() {API::exit_all(); };
std::cout << "Will wait " << wait << " sec...\n";
std::thread t([wait, &f, wait_end, main_form]()
{ if (wait)
{
Wait( wait );
std::cout << "running... \n" ;
if (f)
{
f();
std::cout << "\nCongratulations, this was not trivial !" << std::endl;
}else
{
std::cout << "\nJust a trivial test." << std::endl;
}
std::cout << "Done... \n";
std::cout << "Now again ";
Wait(wait_end);
std::cout << "Done... Now closing the main form...\n";
/*if (main_form)
main_form->close();*/
std::cout << "Closed... Now API::exit ...\n";
API::exit_all(); // why not works?
std::cout << "Done... Upps - this had not to appear !! \n";
}
});
std::thread t([wait, &f, wait_end]()
{
Wait( wait );
std::cout << "running... \n" ;
if (f)
{
f();
std::cout << "\nCongratulations, this was not trivial !" << std::endl;
}else
{
std::cout << "\nJust a trivial test." << std::endl;
}
std::cout << "Done... \n";
std::cout << "Now again ";
Wait(wait_end);
std::cout << "Done... Now API::exit all ...\n";
API::exit_all();
});
pump();
if (t.joinable())
t.join();
#else
pump();
#endif