From 20958add7b2acc205e71569a3f318196baf7b7cf Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 May 2012 22:43:40 +0000 Subject: NxWM: Add IApplicationFactory so that we can create multiple instances of applications; And, as a result of that, re-vamp entire threading model. this is now buggier than it was before git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4742 42af7a65-404d-4744-a932-0658087f49c3 --- NxWidgets/UnitTests/CButton/cbutton-pushed.png | Bin NxWidgets/UnitTests/CButton/cbutton-released.png | Bin NxWidgets/UnitTests/CButtonArray/cbuttonarray.png | Bin NxWidgets/UnitTests/CCheckBox/ccheckbox.png | Bin NxWidgets/UnitTests/CLabel/clabel.png | Bin NxWidgets/UnitTests/CProgressBar/cprogressbar.png | Bin NxWidgets/UnitTests/CRadioButton/cradiobutton.png | Bin .../CScrollbarHorizontal/cscrollbarhorizontal.png | Bin .../CScrollbarVertical/cscrollbarvertical.png | Bin .../CSliderHorizonal/csliderhorizontal.png | Bin .../UnitTests/CSliderVertical/cslidervertical.png | Bin NxWidgets/UnitTests/CTextBox/ctextbox.png | Bin NxWidgets/UnitTests/README.txt | 10 +- NxWidgets/UnitTests/TestStatus.txt | 0 NxWidgets/UnitTests/nxwm/main.cxx | 173 +++++++++------------ 15 files changed, 80 insertions(+), 103 deletions(-) mode change 100755 => 100644 NxWidgets/UnitTests/CButton/cbutton-pushed.png mode change 100755 => 100644 NxWidgets/UnitTests/CButton/cbutton-released.png mode change 100755 => 100644 NxWidgets/UnitTests/CButtonArray/cbuttonarray.png mode change 100755 => 100644 NxWidgets/UnitTests/CCheckBox/ccheckbox.png mode change 100755 => 100644 NxWidgets/UnitTests/CLabel/clabel.png mode change 100755 => 100644 NxWidgets/UnitTests/CProgressBar/cprogressbar.png mode change 100755 => 100644 NxWidgets/UnitTests/CRadioButton/cradiobutton.png mode change 100755 => 100644 NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.png mode change 100755 => 100644 NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.png mode change 100755 => 100644 NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.png mode change 100755 => 100644 NxWidgets/UnitTests/CSliderVertical/cslidervertical.png mode change 100755 => 100644 NxWidgets/UnitTests/CTextBox/ctextbox.png mode change 100755 => 100644 NxWidgets/UnitTests/TestStatus.txt (limited to 'NxWidgets/UnitTests') diff --git a/NxWidgets/UnitTests/CButton/cbutton-pushed.png b/NxWidgets/UnitTests/CButton/cbutton-pushed.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CButton/cbutton-released.png b/NxWidgets/UnitTests/CButton/cbutton-released.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CButtonArray/cbuttonarray.png b/NxWidgets/UnitTests/CButtonArray/cbuttonarray.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CCheckBox/ccheckbox.png b/NxWidgets/UnitTests/CCheckBox/ccheckbox.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CLabel/clabel.png b/NxWidgets/UnitTests/CLabel/clabel.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CProgressBar/cprogressbar.png b/NxWidgets/UnitTests/CProgressBar/cprogressbar.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CRadioButton/cradiobutton.png b/NxWidgets/UnitTests/CRadioButton/cradiobutton.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.png b/NxWidgets/UnitTests/CScrollbarHorizontal/cscrollbarhorizontal.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.png b/NxWidgets/UnitTests/CScrollbarVertical/cscrollbarvertical.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.png b/NxWidgets/UnitTests/CSliderHorizonal/csliderhorizontal.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CSliderVertical/cslidervertical.png b/NxWidgets/UnitTests/CSliderVertical/cslidervertical.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/CTextBox/ctextbox.png b/NxWidgets/UnitTests/CTextBox/ctextbox.png old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/README.txt b/NxWidgets/UnitTests/README.txt index f501f30f6..cc01c3855 100644 --- a/NxWidgets/UnitTests/README.txt +++ b/NxWidgets/UnitTests/README.txt @@ -35,8 +35,12 @@ Installing and Building the Unit Tests for the STM3210E-EVAL available. However, the unit test can be run on other configurations (see steps d and e below). - NOTE: Another special configuration, sim/nxwm, is recommended for unit-leveling - testing of NxWM because the configuration is more complex in that case. + NOTE: There are some other special configurationsrecommended for unit-leveling + testing of NxWM because the configuration is more complex in that case. These + are: + + 1) sim/nxwmm, or the simulated platform (no touchscreen), and + 2) stm3240g-evel, for the STM3240G-EVAL board (with the STMPE11 touchscreen) We will assume the sim/nsh2 configuration in this discussion. The sim/nsh2 configuration is installed as follows: @@ -286,7 +290,7 @@ CTextBox nxwm Exercises the NxWM window manager. - Use the special configuration nuttx/configs/sim/nxwm + Use the special configurations nuttx/configs/sim/nxwm or nuttx/configs/stm3240g-eval/nxwm. Example ======= diff --git a/NxWidgets/UnitTests/TestStatus.txt b/NxWidgets/UnitTests/TestStatus.txt old mode 100755 new mode 100644 diff --git a/NxWidgets/UnitTests/nxwm/main.cxx b/NxWidgets/UnitTests/nxwm/main.cxx index d4b7caa6b..6a2e952d8 100644 --- a/NxWidgets/UnitTests/nxwm/main.cxx +++ b/NxWidgets/UnitTests/nxwm/main.cxx @@ -83,7 +83,6 @@ struct SNxWmTest NxWM::CStartWindow *startwindow; // The start window #ifdef CONFIG_NXWM_TOUCHSCREEN NxWM::CTouchscreen *touchscreen; // The touchscreen - NxWM::CCalibration *calibration; // The touchscreen calibration application struct NxWM::SCalibrationData calibData; // Calibration data #endif unsigned int mmInitial; // Initial memory usage @@ -250,24 +249,24 @@ static bool createTaskbar(void) // 3. Call CTaskBar::startApplication repeatedly to add applications to the task bar // 4. Call CTaskBar::startWindowManager to start the display with applications in place - printf(MAIN_STRING "Create CTaskbar instance\n"); + printf("createTaskbar: Create CTaskbar instance\n"); g_nxwmtest.taskbar = new NxWM::CTaskbar(); if (!g_nxwmtest.taskbar) { - printf(MAIN_STRING "ERROR: Failed to instantiate CTaskbar\n"); + printf("createTaskbar: ERROR: Failed to instantiate CTaskbar\n"); return false; } - showTestCaseMemory("After create taskbar"); + showTestCaseMemory("createTaskbar: After create taskbar"); // Connect to the NX server - printf(MAIN_STRING "Connect CTaskbar instance to the NX server\n"); + printf("createTaskbar: Connect CTaskbar instance to the NX server\n"); if (!g_nxwmtest.taskbar->connect()) { - printf(MAIN_STRING "ERROR: Failed to connect CTaskbar instance to the NX server\n"); + printf("createTaskbar: ERROR: Failed to connect CTaskbar instance to the NX server\n"); return false; } - showTestCaseMemory("After connecting to the server"); + showTestCaseMemory("createTaskbar: After connecting to the server"); // Initialize the task bar // @@ -275,14 +274,14 @@ static bool createTaskbar(void) // CTaskBar::startWindowManager() brings the window manager up with those applications // in place. - printf(MAIN_STRING "Initialize CTaskbar instance\n"); + printf("createTaskbar: Initialize CTaskbar instance\n"); if (!g_nxwmtest.taskbar->initWindowManager()) { - printf(MAIN_STRING "ERROR: Failed to intialize CTaskbar instance\n"); + printf("createTaskbar: ERROR: Failed to intialize CTaskbar instance\n"); return false; } - showTestCaseMemory("After initializing window manager"); + showTestCaseMemory("createTaskbar: After initializing window manager"); return true; } @@ -292,55 +291,58 @@ static bool createTaskbar(void) static bool createStartWindow(void) { - // Create the start window. The general sequence for setting up the start window is: + // Create the start window. The start window is unique among applications + // because it has no factory. The general sequence for setting up the + // start window is: // - // 1. Call CTaskBar::openApplicationWindow to create a window for the start window, - // 2. Use the window to instantiate Cstartwindow - // 3. Call Cstartwindow::addApplication numerous times to install applications + // 1. Create and open a CApplicationWindow + // 2. Use the window to create the CStartWindow the start window application + // 2. Call Cstartwindow::addApplication numerous times to install applications // in the start window. - // 4. Call CTaskBar::startApplication (initially minimized) to start the start + // 3. Call CTaskBar::startApplication (initially minimized) to start the start // window application. // // NOTE: that the start window should not have a stop button. - printf(MAIN_STRING "Opening the start window application window\n"); NxWM::CApplicationWindow *window = g_nxwmtest.taskbar->openApplicationWindow(NxWM::CApplicationWindow::WINDOW_PERSISTENT); if (!window) { - printf(MAIN_STRING "ERROR: Failed to create CApplicationWindow for the start window\n"); + printf("createStartWindow: ERROR: Failed to create CApplicationWindow\n"); return false; } - showTestCaseMemory("After creating start window application window"); + showTestCaseMemory("createStartWindow: After creating CApplicationWindow"); + + // Open the window (it is hot in here) - printf(MAIN_STRING "Initialize CApplicationWindow\n"); if (!window->open()) { - printf(MAIN_STRING "ERROR: Failed to open CApplicationWindow \n"); + printf("createStartWindow: ERROR: Failed to open CApplicationWindow \n"); delete window; return false; } - showTestCaseMemory("After initializing the start window application window"); + showTestCaseMemory("createStartWindow: After opening CApplicationWindow"); + + // Instantiate the application, providing the window to the application's + // constructor - printf(MAIN_STRING "Creating the start window application\n"); g_nxwmtest.startwindow = new NxWM::CStartWindow(g_nxwmtest.taskbar, window); if (!g_nxwmtest.startwindow) { - printf(MAIN_STRING "ERROR: Failed to instantiate CStartWindow\n"); + gdbg("ERROR: Failed to instantiate CStartWindow\n"); delete window; return false; } + showTestCaseMemory("createStartWindow: After creating CStartWindow"); - // Call CTaskBar::startApplication to start the Calibration application (minimized) + // Add the CStartWindow application to the task bar (minimized) - printf(MAIN_STRING "Start the start window application\n"); + printf("createStartWindow: Start the start window application\n"); if (!g_nxwmtest.taskbar->startApplication(g_nxwmtest.startwindow, true)) { - printf(MAIN_STRING "ERROR: Failed to start the start window application\n"); + printf("createStartWindow: ERROR: Failed to start the start window application\n"); return false; } - showTestCaseMemory("After starting the start window application"); - - showTestCaseMemory("After create the start window application"); + showTestCaseMemory("createStartWindow: After starting the start window application"); return true; } @@ -352,14 +354,14 @@ static bool startWindowManager(void) { // Start the window manager - printf(MAIN_STRING "Start the window manager\n"); + printf("startWindowManager: Start the window manager\n"); if (!g_nxwmtest.taskbar->startWindowManager()) { - printf(MAIN_STRING "ERROR: Failed to start the window manager\n"); + printf("startWindowManager: ERROR: Failed to start the window manager\n"); return false; } - showTestCaseMemory("After starting the window manager"); + showTestCaseMemory("AstartWindowManager: fter starting the window manager"); return true; } @@ -377,23 +379,24 @@ static bool createTouchScreen(void) // Create the touchscreen device - printf(MAIN_STRING "Creating CTouchscreen\n"); + printf("createTouchScreen: Creating CTouchscreen\n"); g_nxwmtest.touchscreen = new NxWM::CTouchscreen(g_nxwmtest.taskbar, &displaySize); if (!g_nxwmtest.touchscreen) { - printf(MAIN_STRING "ERROR: Failed to create CTouchscreen\n"); + printf("createTouchScreen: ERROR: Failed to create CTouchscreen\n"); return false; } + showTestCaseMemory("createTouchScreen: createTouchScreen: After creating CTouchscreen"); - printf(MAIN_STRING "Start touchscreen listener\n"); + printf("createTouchScreen: Start touchscreen listener\n"); if (!g_nxwmtest.touchscreen->start()) { - printf(MAIN_STRING "ERROR: Failed start the touchscreen listener\n"); + printf("createTouchScreen: ERROR: Failed start the touchscreen listener\n"); delete g_nxwmtest.touchscreen; return false; } - showTestCaseMemory("After starting the touchscreen listener"); + showTestCaseMemory("createTouchScreen: After starting the touchscreen listener"); return true; } #endif @@ -405,61 +408,50 @@ static bool createTouchScreen(void) #ifdef CONFIG_NXWM_TOUCHSCREEN static bool createCalibration(void) { - // 1. Call CTaskBar::openFullScreenWindow to create a window for the application, - // 2. Instantiate the application, providing the window to the application's - // constructor, + // 1Create the CCalibrationFactory application factory - printf(MAIN_STRING "Opening the calibration application window\n"); - NxWM::CFullScreenWindow *window = g_nxwmtest.taskbar->openFullScreenWindow(); - if (!window) + printf("createCalibration: Creating CCalibrationFactory\n"); + NxWM::CCalibrationFactory *factory = new NxWM::CCalibrationFactory(g_nxwmtest.taskbar, g_nxwmtest.touchscreen); + if (!factory) { - printf(MAIN_STRING "ERROR: Failed to create CFullScreenWindow for the calibration window\n"); + printf("createCalibration: ERROR: Failed to create CCalibrationFactory\n"); return false; } - showTestCaseMemory("After creating calibration full screen window"); + showTestCaseMemory("createCalibration: After creating CCalibrationFactory"); - printf(MAIN_STRING "Initialize CFullScreenWindow\n"); - if (!window->open()) - { - printf(MAIN_STRING "ERROR: Failed to open CFullScreenWindow \n"); - delete window; - return false; - } - showTestCaseMemory("After initializing the calibration full screen window"); + // Add the calibration application to the start window. - printf(MAIN_STRING "Creating CCalibration application\n"); - g_nxwmtest.calibration = new NxWM::CCalibration(g_nxwmtest.taskbar, window, g_nxwmtest.touchscreen); - if (!g_nxwmtest.calibration) + printf("createCalibration: Adding CCalibration to the start window\n"); + if (!g_nxwmtest.startwindow->addApplication(factory)) { - printf(MAIN_STRING "ERROR: Failed to instantiate CCalibration\n"); - delete window; + printf("createCalibration: ERROR: Failed to add CCalibrationto the start window\n"); + delete factory; return false; } - showTestCaseMemory("After creating CCalibration application"); + showTestCaseMemory("createCalibration: After adding CCalibration"); - // Add the calibration application to the start window. It can't really - // be used to re-calibrate (because there is nothing to get the calibration - // data). But is a good case to test a full screen appliation + // Call StartWindowFactory::create to to create the start window application - printf(MAIN_STRING "Adding CCalibration application to the start window\n"); - if (!g_nxwmtest.startwindow->addApplication(g_nxwmtest.calibration)) + printf("createCalibration: Creating CCalibration\n"); + NxWM::IApplication *calibration = factory->create(); + if (!calibration) { - printf(MAIN_STRING "ERROR: Failed to add CCalibration to the start window\n"); - delete g_nxwmtest.calibration; + printf("createCalibration: ERROR: Failed to create CCalibration\n"); return false; } - showTestCaseMemory("After adding CCalibration application"); + showTestCaseMemory("createCalibration: After creating CCalibration"); // Call CTaskBar::startApplication to start the Calibration application. Nothing // will be displayed because the window manager has not yet been started. - printf(MAIN_STRING "Start the calibration application\n"); - if (!g_nxwmtest.taskbar->startApplication(g_nxwmtest.calibration, false)) + printf("createCalibration: Start the calibration application\n"); + if (!g_nxwmtest.taskbar->startApplication(calibration, false)) { printf(MAIN_STRING "ERROR: Failed to start the calibration application\n"); + delete calibration; return false; } - showTestCaseMemory("After starting the start window application"); + showTestCaseMemory("createCalibration: After starting the start window application"); return true; } #endif @@ -472,43 +464,24 @@ static bool createNxConsole(void) { // Add the NxConsole application to the start window - printf(MAIN_STRING "Opening the NxConsole application window\n"); - NxWM::CApplicationWindow *window = g_nxwmtest.taskbar->openApplicationWindow(); - if (!window) - { - printf(MAIN_STRING "ERROR: Failed to create CApplicationWindow for the NxConsole\n"); - return false; - } - showTestCaseMemory("After creating the NxConsole application window"); - - printf(MAIN_STRING "Initialize CApplicationWindow\n"); - if (!window->open()) - { - printf(MAIN_STRING "ERROR: Failed to open CApplicationWindow \n"); - delete window; - return false; - } - showTestCaseMemory("After initializing the NxConsole application window"); - - printf(MAIN_STRING "Creating the NxConsole application\n"); - NxWM::CNxConsole *console = new NxWM::CNxConsole(g_nxwmtest.taskbar, window); + printf("createNxConsole: Creating the NxConsole application\n"); + NxWM::CNxConsoleFactory *console = new NxWM::CNxConsoleFactory(g_nxwmtest.taskbar); if (!console) { - printf(MAIN_STRING "ERROR: Failed to instantiate CNxConsole\n"); - delete window; + printf("createNxConsole: ERROR: Failed to instantiate CNxConsoleFactory\n"); return false; } - showTestCaseMemory("After creating the NxConsole application"); + showTestCaseMemory("createNxConsole: After creating the NxConsole application"); - printf(MAIN_STRING "Adding the NxConsole application to the start window\n"); + printf("createNxConsole: Adding the NxConsole application to the start window\n"); if (!g_nxwmtest.startwindow->addApplication(console)) { - printf(MAIN_STRING "ERROR: Failed to add CNxConsole to the start window\n"); + printf("createNxConsole: ERROR: Failed to add CNxConsoleFactory to the start window\n"); delete console; return false; } - showTestCaseMemory("After adding the NxConsole application"); + showTestCaseMemory("createNxConsole: After adding the NxConsole application"); return true; } @@ -557,7 +530,7 @@ int MAIN_NAME(int argc, char *argv[]) printf(MAIN_STRING "ERROR: Failed to initialize the NSH library\n"); return EXIT_FAILURE; } - showTestCaseMemory("After initializing the NSH library"); + showTestCaseMemory(MAIN_STRING "After initializing the NSH library"); // Create the task bar. @@ -641,20 +614,20 @@ int MAIN_NAME(int argc, char *argv[]) #ifndef CONFIG_NXWM_TOUCHSCREEN sleep(2); g_nxwmtest.taskbar->clickIcon(0); - showTestCaseMemory("After clicking the start window icon"); + showTestCaseMemory(MAIN_STRING "After clicking the start window icon"); // Wait bit to see the result of the button press. The press the first icon // in the start menu. That should be the NxConsole icon. sleep(2); g_nxwmtest.startwindow->clickIcon(0); - showTestCaseMemory("After clicking the NxConsole icon"); + showTestCaseMemory(MAIN_STRING "After clicking the NxConsole icon"); #endif // Wait bit to see the result of the button press. sleep(2); - showTestMemory("Final memory usage"); + showTestMemory(MAIN_STRING "Final memory usage"); return EXIT_SUCCESS; } -- cgit v1.2.3