From 80dedf5f0d9f13e6b1ab69043d2db76dbbc7350a Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 3 Mar 2016 17:06:46 +0100 Subject: [PATCH 01/20] switch travis to demo dev_nana_in_examples --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 22a458ce..562d2955 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ matrix: - llvm-toolchain-precise before_install: - - git clone --depth=50 --branch=testing https://github.com/qPCR4vir/nana-demo.git nana-demo + - git clone --depth=1 --branch=dev_nana_in_examples https://github.com/qPCR4vir/nana-demo.git nana-demo - export PATH="$HOME/bin:$PATH" - mkdir ~/bin - wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true From 8c479529d7efaa97adab7a587fbaffb8139258c3 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 3 Mar 2016 17:12:01 +0100 Subject: [PATCH 02/20] add to travis Xvfb, an X server to emulate display --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 562d2955..5bce9547 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,6 +66,9 @@ install: - /tmp/tools/cmake --prefix="$HOME" --exclude-subdir before_script : + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" + - sleep 3 # give xvfb some time to start - mkdir bld - cd bld From 8bbfb38a50378bca0fb25d53f3f89e2ba1e91b62 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 3 Mar 2016 17:19:58 +0100 Subject: [PATCH 03/20] add explicit test in travis. we need to set this automatically in cmake. But first we need a general way to exit from an application from the parallel GUI testing function. Now I use fm.close(), and I need to pass a pointer to the main form to that function to do that. A general API::exit() will be much better but don't work. Why? --- .travis.yml | 21 +++++++++++++++++++++ CMakeLists.txt | 24 ++++++------------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5bce9547..d596ff49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,4 +76,25 @@ script: - cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON - make - ls + - ./clicked + - ./HelloWord + - ./background-effects + - ./categ + - ./decore + - ./dock + - ./drag-button + - ./draw + - ./file_explorer + #- ./example_menu + - ./example_listbox + #- ./example_combox + #- ./example.button + #- ./MontiHall + - ./a_group_impl + #- ./animate-bmp + #- ./calculator + #- ./helloworld_demo + #- ./notepad + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b26d32f..5fc96b22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if avail #option(NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find ?" "../") #option(NANA_CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs") #include_directories("${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}") -#list(APPEND NANA_LINKS "${NANA_CMAKE_BOOST_FILESYSTEM_LIB}") +#list(APPEND NANA_LINKS "${NANA_CMAKE_BOOST_FILESYSTEM_LIB}" ) if (NANA_CMAKE_NANA_FILESYSTEM_FORCE) @@ -181,18 +181,6 @@ if (NANA_CMAKE_BUILD_FreeMe) add_definitions(-DBUILD_FreeMe) endif (NANA_CMAKE_BUILD_FreeMe) - -if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) - add_definitions(-DNANA_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) - -endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING) - - - if(NANA_CMAKE_VERBOSE_PREPROCESSOR) add_definitions(-DVERBOSE_PREPROCESSOR) endif(NANA_CMAKE_VERBOSE_PREPROCESSOR) @@ -265,7 +253,7 @@ if (NANA_CMAKE_BUILD_DEMOS) add_definitions(-DNANA_ADD_DEF_AUTOMATIC_GUI_TESTING) endif(NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING) - set (demos helloworld_demo notepad ) + set (demos calculator file_explorer helloworld_demo notepad ) foreach ( demo ${demos}) add_executable(${demo} "../nana-demo/${demo}.cpp") @@ -274,16 +262,16 @@ if (NANA_CMAKE_BUILD_DEMOS) #if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) #add_custom_command( TARGET ${demo} POST_BUILD COMMAND ${demo} ) #add_custom_target(do_always_${demo} ALL COMMAND ${demo}) - add_test(${demo} COMMAND ${demo}) + #add_test(${demo} COMMAND ${demo}) #endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING) install(TARGETS ${demo} RUNTIME DESTINATION "../nana-demo/") message("... to build: ../nana-demo/${demo}.cpp" ) endforeach( demo ${demos}) - set (demos calculator widget_show widget_show2 ) + set (demos widget_show widget_show2 ) if (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS) - list(APPEND demos file_explorer FreeMe) + list(APPEND demos file_explorer FreeMe) # ?? endif (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS) # Pending: FreeMe (added but really completelly compiled if defined BUILD_FreeMe ) @@ -300,7 +288,7 @@ if (NANA_CMAKE_BUILD_DEMOS) decore dock drag-button draw example.button example_combox example_listbox example_menu filebox-txt folder_tree folder_tree_nana folder_tree_std framework_design_1 framework_design_2 framework_design_3 group HelloWord helloword_quit inputbox label_listener lambda_event.Cpp11 listbox_inline_widget listbox_Resolver loader_1 loader_2 - mbox menu_debug menu_popuper modal_form MontiHall place_login png screen stretch_image + main mbox menu_debug menu_popuper modal_form MontiHall place_login png screen stretch_image threading thread-pool various_events window-dragger windows-subclassing ) # Pending: From 39dab0f126dd677257afae79c2755c74034e19f4 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 00:44:48 +0100 Subject: [PATCH 04/20] cleanup and document GUI testing --- .travis.yml | 25 ++++++------ include/nana/gui/wvl.hpp | 30 +++++++++++--- source/gui/wvl.cpp | 85 +++++++++++++++++++++++----------------- 3 files changed, 87 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index d596ff49..b5b40821 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,25 +76,28 @@ script: - cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON - make - ls - - ./clicked - - ./HelloWord + - ./audio_player + - ./a_group_impl + - ./animate-bmp - ./background-effects - ./categ + - ./calculator + - ./clicked - ./decore - ./dock - ./drag-button - ./draw - ./file_explorer - #- ./example_menu + - ./example_menu - ./example_listbox - #- ./example_combox - #- ./example.button - #- ./MontiHall - - ./a_group_impl - #- ./animate-bmp - #- ./calculator - #- ./helloworld_demo - #- ./notepad + - ./example_combox + - ./example.button + - ./HelloWord + - ./MontiHall + - ./helloworld_demo + - ./notepad + + diff --git a/include/nana/gui/wvl.hpp b/include/nana/gui/wvl.hpp index aac2319e..5d6d756c 100644 --- a/include/nana/gui/wvl.hpp +++ b/include/nana/gui/wvl.hpp @@ -1,14 +1,14 @@ -/* +/** * Nana GUI Library Definition * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/wvl.hpp - * @description: + * @file nana/gui/wvl.hpp + * @description * the header file contains the files required for running of Nana.GUI */ @@ -16,7 +16,6 @@ #define NANA_GUI_WVL_HPP - #include "programming_interface.hpp" #include "screen.hpp" #include "widgets/form.hpp" @@ -60,7 +59,26 @@ namespace nana template using form_loader = detail::form_loader; - void exec(unsigned wait = 0, std::function = {}, unsigned wait_end=0, form *fm= nullptr); + /// @brief Take control of the GUI and optionaly automaticaly tests it. + /// + /// @detail It transfers to nana the program flow control, which begin pumping messages + /// 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 + 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 = {} ///< emit events to mimics user actions and may asert results + ); + + /// send a click message to this widget - useffull in GUI testing + void click(widget& w); + + /// in seconds + void Wait(unsigned wait = 0); + }//end namespace nana #endif diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 0e7e4adc..08714df2 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -14,18 +14,9 @@ #include #include #include - #include - -inline unsigned Wait_or_not(unsigned wait = 0) -{ -#ifdef NANA_AUTOMATIC_GUI_TESTING - return wait; -#else - return 0; -#endif -} +#define NANA_AUTOMATIC_GUI_TESTING namespace nana { @@ -37,38 +28,60 @@ namespace nana } } - void exec(unsigned wait, std::function f, unsigned wait_end, form *fm ) + void click(widget& w) { - #ifdef NANA_ADD_DEF_AUTOMATIC_GUI_TESTING - if (!wait) - wait = 10; - if (!f) - f = []() {API::exit(); }; - #endif + arg_click arg; + arg.window_handle = w.handle(); + w.events().click.emit(arg); + } - wait = Wait_or_not(wait); + /// in seconds + void Wait(unsigned wait) + { + if (wait) + std::this_thread::sleep_for(std::chrono::seconds{ wait }); + } - std::cout << "Will wait " << wait << " sec...\n"; - std::thread t([wait, &f, wait_end, fm]() - { if (wait) - { - std::cout << "Waiting " << wait << " sec...\n"; - std::this_thread::sleep_for(std::chrono::seconds{ wait } ); - std::cout << "running... \n" ; - f(); - std::cout << "Done... \n"; - std::cout << "Now waiting anothers " << wait_end << " sec...\n"; - std::this_thread::sleep_for(std::chrono::seconds{ wait_end } ); - std::cout << "Done... \n"; - if (fm) - fm->close(); - API::exit(); // why not works? - } - }); - + void pump() + { detail::bedrock::instance().pump_event(nullptr, false); + } + + void exec(form *main_form, //= nullptr, ///< used to close the program + unsigned wait, // = 1, ///< for the GUI to be constructed, in seconds + unsigned wait_end, // = 1, ///< for the GUI to be destructed, in seconds + std::functionf // = {} ///< 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(); }; + + std::cout << "Will wait " << wait << " sec...\n"; + std::thread t([wait, &f, wait_end, main_form]() + { if (wait) + { + std::cout << "Waiting " << wait << " sec...\n"; + Wait( wait ); + std::cout << "running... \n" ; + if (f) f(); + std::cout << "Done... \n"; + std::cout << "Now waiting anothers " << wait_end << " sec...\n"; + Wait(wait_end); + std::cout << "Done... \n"; + if (main_form) + main_form->close(); + API::exit(); // why not works? + } + }); + pump(); if (t.joinable()) t.join(); + #else + pump(); + #endif } }//end namespace nana From 594fee571bcf51b2451c05e5b7a9adea4a8717bd Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 01:00:28 +0100 Subject: [PATCH 05/20] tested --- .travis.yml | 15 ++++++++------- source/gui/wvl.cpp | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index b5b40821..2034eed2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,24 +78,25 @@ script: - ls - ./audio_player - ./a_group_impl - - ./animate-bmp + #- ./animate-bmp - ./background-effects - ./categ - - ./calculator + #- ./calculator - ./clicked - ./decore - ./dock - ./drag-button - ./draw - ./file_explorer - - ./example_menu + #- ./example_menu - ./example_listbox - - ./example_combox + #- ./example_combox - ./example.button - ./HelloWord - - ./MontiHall - - ./helloworld_demo - - ./notepad + #- ./MontiHall + #- ./helloworld_demo + #- ./notepad + - ./loader_2 diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 08714df2..24ab1241 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -17,7 +17,6 @@ #include #define NANA_AUTOMATIC_GUI_TESTING - namespace nana { namespace detail From 80af0b9a336094d5e63bde31663926e1e8180c4b Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 01:04:48 +0100 Subject: [PATCH 06/20] -#define NANA_AUTOMATIC_GUI_TESTING --- source/gui/wvl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 24ab1241..732a1c69 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -16,7 +16,7 @@ #include #include -#define NANA_AUTOMATIC_GUI_TESTING +//#define NANA_AUTOMATIC_GUI_TESTING namespace nana { namespace detail From 07563a4dabd63ea73fc0857b02dd03b84b55eafa Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 01:08:37 +0100 Subject: [PATCH 07/20] more tests --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2034eed2..4ba9c5a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -91,12 +91,12 @@ script: #- ./example_menu - ./example_listbox #- ./example_combox - - ./example.button + #- ./example.button # ?? - ./HelloWord #- ./MontiHall #- ./helloworld_demo #- ./notepad - - ./loader_2 + #- ./loader_2 From a84e82029bb7092c6d2d431b04d4a86365f5f739 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 01:20:51 +0100 Subject: [PATCH 08/20] no ./widget_show2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4ba9c5a1..ec0373fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,6 +97,7 @@ script: #- ./helloworld_demo #- ./notepad #- ./loader_2 + #- ./widget_show2 From e32cf4045fc1a54f789d9a324e582c90839b6412 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 01:27:23 +0100 Subject: [PATCH 09/20] no ./widget_show --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ec0373fe..e1d943a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -98,7 +98,7 @@ script: #- ./notepad #- ./loader_2 #- ./widget_show2 - + #- ./widget_show From 9c2736abe5c562c528dc8deb7af151acea239d03 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 17:16:32 +0100 Subject: [PATCH 10/20] fixing dir --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fc96b22..95da4a64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,7 +271,7 @@ if (NANA_CMAKE_BUILD_DEMOS) set (demos widget_show widget_show2 ) if (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS) - list(APPEND demos file_explorer FreeMe) # ?? + list(APPEND demos FreeMe) # ?? endif (NANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS) # Pending: FreeMe (added but really completelly compiled if defined BUILD_FreeMe ) From 8043b88b1c08857fb0ddc21f1dec0e395e495195 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 17:17:03 +0100 Subject: [PATCH 11/20] fixing dir --- .gitignore | 1 + .travis.yml | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index ef6de4d4..e46bb0b6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ build/makefile-bkl/* *.ilk *.log [Bb]in +[Bb]in/ [Dd]ebug*/ *.lib *.a diff --git a/.travis.yml b/.travis.yml index e1d943a8..c9831c4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,23 +66,26 @@ install: - /tmp/tools/cmake --prefix="$HOME" --exclude-subdir before_script : + # travis dont have a fisical monitor. We need to instal an emulator: https://docs.travis-ci.com/user/gui-and-headless-browsers/ - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" - sleep 3 # give xvfb some time to start - - mkdir bld - - cd bld + # we have: qPCR4vir/nana/nana-demo and now we are in: qPCR4vir/nana/ our executable tests will assces: ../Examples/*.bmp etc.(need to be in parallel with nana-demo/Examples) + - cd nana-demo + - mkdir bin + - cd bin script: - - cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON + - cmake -G"Unix Makefiles" ../.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON - make - ls - - ./audio_player - ./a_group_impl - #- ./animate-bmp + - ./animate-bmp + - ./audio_player - ./background-effects + #- ./calculator ? - ./categ - #- ./calculator - - ./clicked + - ./clicked - ./decore - ./dock - ./drag-button @@ -91,7 +94,7 @@ script: #- ./example_menu - ./example_listbox #- ./example_combox - #- ./example.button # ?? + - ./example.button - ./HelloWord #- ./MontiHall #- ./helloworld_demo From dae3b4e815df0736cb3ccbafcb63b492e4f51147 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 17:33:20 +0100 Subject: [PATCH 12/20] now with move --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9831c4c..8a0e87e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,13 +71,16 @@ before_script : - "sh -e /etc/init.d/xvfb start" - sleep 3 # give xvfb some time to start # we have: qPCR4vir/nana/nana-demo and now we are in: qPCR4vir/nana/ our executable tests will assces: ../Examples/*.bmp etc.(need to be in parallel with nana-demo/Examples) - - cd nana-demo + #- cd nana-demo - mkdir bin - cd bin script: - - cmake -G"Unix Makefiles" ../.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON + - cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON - make + - cd .. + - mv -v bin/ nana-demo/ + - cd nana-demo/bin - ls - ./a_group_impl - ./animate-bmp From 7125ab8f48e661e61a4fd6ab4f33e872da2bfae5 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 4 Mar 2016 23:54:42 +0100 Subject: [PATCH 13/20] exit_all --- include/nana/gui/programming_interface.hpp | 12 +++++-- include/nana/gui/wvl.hpp | 1 + source/gui/programming_interface.cpp | 38 +++++++++++++++++++++- source/gui/wvl.cpp | 30 +++++++++++------ 4 files changed, 68 insertions(+), 13 deletions(-) diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 8adfd2eb..db8ffc1c 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -143,9 +143,17 @@ namespace API }; }//end namespace detail - void exit(); + void exit(); ///< close all windows in current thread + void exit_all(); ///< close all windows - std::string transform_shortkey_text(std::string text, wchar_t &shortkey, std::string::size_type *skpos); + /// @brief Searchs whether the text contains a '&' and removes the character for transforming. + /// If the text contains more than one '&' charachers, the others are ignored. e.g + /// text = "&&a&bcd&ef", the result should be "&abcdef", shortkey = 'b', and pos = 2. + std::string transform_shortkey_text + ( std::string text, ///< the text is transformed + wchar_t &shortkey, ///< the character which indicates a short key. + std::string::size_type *skpos ///< retrives the shortkey position if it is not a null_ptr; + ); bool register_shortkey(window, unsigned long); void unregister_shortkey(window); diff --git a/include/nana/gui/wvl.hpp b/include/nana/gui/wvl.hpp index 5d6d756c..176af43d 100644 --- a/include/nana/gui/wvl.hpp +++ b/include/nana/gui/wvl.hpp @@ -23,6 +23,7 @@ #include "msgbox.hpp" #include "place.hpp" + namespace nana { namespace detail diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index a5f96e98..12670941 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -326,7 +326,7 @@ namespace API return nullptr; } - //exit + //close all windows in current thread void exit() { @@ -363,6 +363,42 @@ namespace API interface_type::close_window(i); } } + //close all windows + void exit_all() + { + std::vector v; + + internal_scope_guard lock; + restrict::wd_manager().all_handles(v); + if (v.size()) + { + std::vector roots; + native_window_type root = nullptr; + //unsigned tid = nana::system::this_thread_id(); + for (auto wd : v) + { + if (/*(wd->thread_id == tid) &&*/ (wd->root != root)) + { + root = wd->root; + bool exists = false; + for (auto i = roots.cbegin(); i != roots.cend(); ++i) + { + if (*i == root) + { + exists = true; + break; + } + } + + if (!exists) + roots.push_back(root); + } + } + + for (auto i : roots) + interface_type::close_window(i); + } + } //transform_shortkey_text //@brief: This function searchs whether the text contains a '&' and removes the character for transforming. diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 732a1c69..24e58ee0 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -29,6 +29,7 @@ namespace nana void click(widget& w) { + std::cout << "Automatically clicking widget "<close(); - API::exit(); // why not works? + 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"; } }); pump(); From 2c04ba7bf33b2f413e12bf2f27c6e4caec77d5eb Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 03:17:49 +0100 Subject: [PATCH 14/20] all demos added because exec() don't need main form to exit_all --- .travis.yml | 49 +++++++++++++++++++++++++++++--------- CMakeLists.txt | 13 ++++------ include/nana/config.hpp | 8 ++----- include/nana/gui/wvl.hpp | 5 ++-- source/gui/wvl.cpp | 51 +++++++++++++++++----------------------- 5 files changed, 68 insertions(+), 58 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a0e87e7..3b573ebf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 95da4a64..7b622422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 99d73d31..4e1eb6ac 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -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 diff --git a/include/nana/gui/wvl.hpp b/include/nana/gui/wvl.hpp index 176af43d..4da60f25 100644 --- a/include/nana/gui/wvl.hpp +++ b/include/nana/gui/wvl.hpp @@ -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 = {} ///< emit events to mimics user actions and may asert results diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 24e58ee0..1b475c80 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -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::functionf // = {} ///< 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 From cdcf15ee688f0a5684eacf9f5b129305e723156c Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 03:28:20 +0100 Subject: [PATCH 15/20] some demos don't pass --- .travis.yml | 14 +++++++------- include/nana/config.hpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b573ebf..517a34ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,7 +76,7 @@ before_script : - cd bin script: - - cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING=ON + - cmake -G"Unix Makefiles" .. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON - make - cd .. - mv -v bin/ nana-demo/ @@ -86,7 +86,7 @@ script: - ./animate-bmp - ./audio_player - ./background-effects - - ./calculator + #- ./calculator - ./categ - ./clicked - ./decore @@ -94,18 +94,18 @@ script: - ./drag-button - ./draw - ./file_explorer - - ./example_menu + #- ./example_menu - ./example_listbox - - ./example_combox + #- ./example_combox - ./example.button - - ./folder_tree_nana - - ./folder_tree_std + #- ./folder_tree_nana + #- ./folder_tree_std - ./framework_design_1 - ./framework_design_2 - ./framework_design_3 - ./group - ./HelloWord - - ./helloword_quit + #- ./helloword_quit - ./inputbox - ./label_listener - ./lambda_event.cpp11 diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 4e1eb6ac..ae11279d 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -100,7 +100,7 @@ // 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 +//#define NANA_AUTOMATIC_GUI_TESTING From 506ff45e648c3c4e9725f33beec3f9058d59bc9f Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 03:41:46 +0100 Subject: [PATCH 16/20] more demos don't pass --- .travis.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 517a34ac..7710a982 100644 --- a/.travis.yml +++ b/.travis.yml @@ -106,9 +106,9 @@ script: - ./group - ./HelloWord #- ./helloword_quit - - ./inputbox + #- ./inputbox - ./label_listener - - ./lambda_event.cpp11 + #- ./lambda_event.cpp11 - ./listbox_inline_widget - ./listbox_Resolver - ./loader_1 @@ -118,8 +118,6 @@ script: - ./MontiHall - ./helloworld_demo - ./notepad - - ./loader_2 - - ./mbox - ./menu_debug - ./menu_popuper - ./modal_form From 9d038166e55a0efb0fd30c28710c55cf1e8a68b9 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 03:57:13 +0100 Subject: [PATCH 17/20] some dont pass --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7710a982..efe7ea5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -112,22 +112,22 @@ script: - ./listbox_inline_widget - ./listbox_Resolver - ./loader_1 - - ./loader_2 + #- ./loader_2 - ./mbox - ./menu_debug - - ./MontiHall - - ./helloworld_demo - - ./notepad + #- ./MontiHall + #- ./helloworld_demo + #- ./notepad - ./menu_debug - ./menu_popuper - - ./modal_form - - ./widget_show2 - - ./widget_show + #- ./modal_form + #- ./widget_show2 + #- ./widget_show - ./place_login - ./png - - ./screen + #- ./screen - ./stretch_image - - ./threading + #- ./threading # Press a char: - ./thread-pool - ./various_events - ./window-dragger From 7d4387edd41d7940f088c4d13dbe8b23360a54e7 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 04:04:59 +0100 Subject: [PATCH 18/20] 2 more no, but 33 pass --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index efe7ea5a..2c44ccf6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -127,10 +127,10 @@ script: - ./png #- ./screen - ./stretch_image - #- ./threading # Press a char: + - ./threading - ./thread-pool - ./various_events - - ./window-dragger + #- ./window-dragger - ./windows-subclassing From 6ca18613e4857ca7b448660f38bb0b3519aaaee5 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 5 Mar 2016 04:14:10 +0100 Subject: [PATCH 19/20] thread-pool don't pass ? --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c44ccf6..3e64fdb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -128,7 +128,7 @@ script: #- ./screen - ./stretch_image - ./threading - - ./thread-pool + #- ./thread-pool - ./various_events #- ./window-dragger - ./windows-subclassing From 6a8fb2e37c63038cea3b9f9a199258b07f05a45b Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 6 Mar 2016 16:53:52 +0100 Subject: [PATCH 20/20] bedrock's comments --- include/nana/gui/detail/bedrock.hpp | 13 +++++++------ source/gui/detail/bedrock_windows.cpp | 12 ++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/nana/gui/detail/bedrock.hpp b/include/nana/gui/detail/bedrock.hpp index e4872711..128ce532 100644 --- a/include/nana/gui/detail/bedrock.hpp +++ b/include/nana/gui/detail/bedrock.hpp @@ -1,13 +1,15 @@ -/* +/** * A Bedrock Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/detail/bedrock.hpp + * @file nana/gui/detail/bedrock.hpp + * + * @brief A Bedrock Implementation */ #ifndef NANA_GUI_DETAIL_BEDROCK_HPP @@ -26,9 +28,8 @@ namespace detail struct basic_window; class window_manager; - //class bedrock - //@brief: bedrock is a fundamental core component, it provides a abstract to the OS platform - // and some basic functions. + + /// @brief fundamental core component, it provides an abstraction to the OS platform and some basic functions. class bedrock { bedrock(); diff --git a/source/gui/detail/bedrock_windows.cpp b/source/gui/detail/bedrock_windows.cpp index 2915ec1c..112da9c6 100644 --- a/source/gui/detail/bedrock_windows.cpp +++ b/source/gui/detail/bedrock_windows.cpp @@ -1,4 +1,4 @@ -/* +/** * A Bedrock Implementation * Nana C++ Library(http://www.nanapro.org) * Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com) @@ -7,7 +7,8 @@ * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/detail/win32/bedrock.cpp + * @file nana/gui/detail/win32/bedrock.cpp + * @brief A Bedrock Implementation * @contributors: Ariel Vina-Rodriguez */ @@ -18,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -254,6 +256,7 @@ namespace detail { std::stringstream ss; ss<<"Nana.GUI detects a memory leaks in window_manager, "<(wd_manager().number_of_core_window())<<" window(s) are not uninstalled."; + std::cerr << ss.str(); /// \todo add list of cations of open windows and if aut testin GUI do auto Ok after 2 sec. ::MessageBoxA(0, ss.str().c_str(), ("Nana C++ Library"), MB_OK); } @@ -261,8 +264,8 @@ namespace detail delete pi_data_; } - //inc_window - //@brief: increament the number of windows + + /// @brief increament the number of windows in the thread id int bedrock::inc_window(unsigned tid) { //impl refers to the object of private_impl, the object is created when bedrock is creating. @@ -461,6 +464,7 @@ namespace detail { (msgbox(modal_window, "An exception during message pumping!").icon(msgbox::icon_information) <<"An uncaptured non-std exception during message pumping!" + << "\n in form: " << API::window_caption(modal_window) ).show(); internal_scope_guard lock; _m_except_handler();