apps/graphics/nxwm: nxwm_main.c is no longer a unit test. Need to remove some dangling dependencies on UNITTEST and also some testing that is inappropriate in its new role.

This commit is contained in:
Gregory Nutt 2019-04-04 20:04:12 -06:00
parent c7da99d6a5
commit 755ee18504
12 changed files with 2 additions and 497 deletions

View File

@ -251,13 +251,6 @@ config NXWIDGETS_CURSORCONTROL_SIZE
of cursor controls that can between entered by NX polling cycles
without losing data. Default: 4
config NXWIDGET_MEMMONITOR
bool "Memory Usage Monitor"
default n
---help---
Enable memory usage monitor instrumentation. This feature is only
used by the NxWidget/NxWM unit tests.
endmenu # NxWidgets Configuration
endif # NxWidgets
endmenu # NxWidgets

View File

@ -1,7 +1,7 @@
/********************************************************************************************
* apps/graphics/nxwm/src/capplicationwindow.cxx
*
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -499,77 +499,6 @@ void CApplicationWindow::registerCallbacks(IApplicationCallback *callback)
m_callback = callback;
}
/**
* Simulate a mouse click or release on the minimize icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CApplicationWindow::clickMinimizePosition(bool click)
{
// Get the size and position of the widget
struct nxgl_size_s imageSize;
m_minimizeImage->getSize(imageSize);
struct nxgl_point_s imagePos;
m_minimizeImage->getPos(imagePos);
// And click or release the image at its center
if (click)
{
m_minimizeImage->click(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
else
{
m_minimizeImage->release(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
}
#endif
/**
* Simulate a mouse click or release on the stop icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CApplicationWindow::clickStopIcon(bool click)
{
// The stop icon will not be available for "persistent" applications
if (m_stopImage)
{
// Get the size and position of the widget
struct nxgl_size_s imageSize;
m_stopImage->getSize(imageSize);
struct nxgl_point_s imagePos;
m_stopImage->getPos(imagePos);
// And click or release the image at its center
if (click)
{
m_stopImage->click(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
else
{
m_stopImage->release(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
}
}
#endif
/**
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
*

View File

@ -187,31 +187,3 @@ bool CFullScreenWindow::isFullScreen(void) const
void CFullScreenWindow::registerCallbacks(IApplicationCallback *callback)
{
}
/**
* Simulate a mouse click or release on the minimize icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CFullScreenWindow::clickMinimizePosition(bool click)
{
}
#endif
/**
* Simulate a mouse click or release on the stop icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CFullScreenWindow::clickStopIcon(bool click)
{
}
#endif

View File

@ -389,47 +389,6 @@ bool CStartWindow::addApplication(IApplicationFactory *app)
return true;
}
/**
* Simulate a mouse click or release on the icon at index. This method
* is only available during automated testing of NxWM.
*
* @param index. Selects the icon in the start window
* @param click. True to click and false to release
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CStartWindow::clickIcon(int index, bool click)
{
if (index < m_slots.size())
{
// Get the image widget at this index
NXWidgets::CImage *image = m_slots.at(index).image;
// Get the size and position of the widget
struct nxgl_size_s imageSize;
image->getSize(imageSize);
struct nxgl_point_s imagePos;
image->getPos(imagePos);
// And click or release the image at its center
if (click)
{
image->click(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
else
{
image->release(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
}
}
#endif
/**
* Called when the window minimize button is pressed.
*/

View File

@ -746,47 +746,6 @@ void CTaskbar::getDisplaySize(FAR struct nxgl_size_s &size)
rect.getSize(size);
}
/**
* Simulate a mouse click or release on the icon at index. This method
* is only available during automated testing of NxWM.
*
* @param index. Selects the icon in the start window
* @param click. True to click and false to release
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void CTaskbar::clickIcon(int index, bool click)
{
if (index < m_slots.size())
{
// Get the image widget at this index
NXWidgets::CImage *image = m_slots.at(index).image;
// Get the size and position of the widget
struct nxgl_size_s imageSize;
image->getSize(imageSize);
struct nxgl_point_s imagePos;
image->getPos(imagePos);
// And click or release the image at its center
if (click)
{
image->click(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
else
{
image->release(imagePos.x + (imageSize.w >> 1),
imagePos.y + (imageSize.h >> 1));
}
}
}
#endif
/**
* Create a raw window.
*

View File

@ -75,28 +75,6 @@
# include "graphics/nxwm/ckeyboard.hxx"
#endif
/////////////////////////////////////////////////////////////////////////////
// Pre-processor Definitions
/////////////////////////////////////////////////////////////////////////////
#ifdef CONFIG_HAVE_FILENAME
# define showTestStepMemory(msg) \
_showTestStepMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
#endif
#ifdef CONFIG_NXWIDGET_MEMMONITOR
# ifdef CONFIG_HAVE_FILENAME
# define showTestCaseMemory(msg) \
_showTestCaseMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
# define showTestMemory(msg) \
_showTestMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
# endif
#else
# define initMemoryUsage()
# define showTestCaseMemory(msg)
# define showTestMemory(msg)
#endif
/////////////////////////////////////////////////////////////////////////////
// Private Types
/////////////////////////////////////////////////////////////////////////////
@ -110,11 +88,6 @@ struct SNxWmTest
struct NxWM::SCalibrationData calibData; // Calibration data
bool calibrated; // True: Touchscreen has been calibrated
#endif
#ifdef CONFIG_NXWIDGET_MEMMONITOR
unsigned int mmInitial; // Initial memory usage
unsigned int mmStep; // Memory Usage at beginning of test step
unsigned int mmSubStep; // Memory Usage at beginning of test sub-step
#endif
};
/////////////////////////////////////////////////////////////////////////////
@ -135,105 +108,6 @@ extern "C" int nxwm_main(int argc, char *argv[]);
// Public Functions
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Name: updateMemoryUsage
/////////////////////////////////////////////////////////////////////////////
#ifdef CONFIG_NXWIDGET_MEMMONITOR
#ifdef CONFIG_HAVE_FILENAME
static void updateMemoryUsage(unsigned int *previous,
FAR const char *file, int line,
FAR const char *msg)
#else
static void updateMemoryUsage(unsigned int *previous,
FAR const char *msg)
#endif
{
struct mallinfo mmcurrent;
/* Get the current memory usage */
#ifdef CONFIG_CAN_PASS_STRUCTS
mmcurrent = mallinfo();
#else
(void)mallinfo(&mmcurrent);
#endif
/* Show the change from the previous time */
#ifdef CONFIG_HAVE_FILENAME
printf("File: %s Line: %d : %s\n", file, line, msg);
#else
printf("\n%s:\n", msg);
#endif
printf(" Before: %8u After: %8u Change: %8d\n",
*previous, mmcurrent.uordblks, (int)mmcurrent.uordblks - (int)*previous);
/* Set up for the next test */
*previous = mmcurrent.uordblks;
}
#endif
/////////////////////////////////////////////////////////////////////////////
// Name: showTestCaseMemory
/////////////////////////////////////////////////////////////////////////////
#ifdef CONFIG_NXWIDGET_MEMMONITOR
#ifdef CONFIG_HAVE_FILENAME
static void _showTestCaseMemory(FAR const char *file, int line, FAR const char *msg)
{
updateMemoryUsage(&g_nxwmtest.mmStep, file, line, msg);
g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
}
#else
static void showTestCaseMemory(FAR const char *msg)
{
updateMemoryUsage(&g_nxwmtest.mmStep, msg);
g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
}
#endif
#endif
/////////////////////////////////////////////////////////////////////////////
// Name: showTestMemory
/////////////////////////////////////////////////////////////////////////////
#ifdef CONFIG_NXWIDGET_MEMMONITOR
#ifdef CONFIG_HAVE_FILENAME
static void _showTestMemory(FAR const char *file, int line, FAR const char *msg)
{
updateMemoryUsage(&g_nxwmtest.mmInitial, file, line, msg);
}
#else
static void showTestMemory(FAR const char *msg)
{
updateMemoryUsage(&g_nxwmtest.mmInitial, msg);
}
#endif
#endif
/////////////////////////////////////////////////////////////////////////////
// Name: initMemoryUsage
/////////////////////////////////////////////////////////////////////////////
#ifdef CONFIG_NXWIDGET_MEMMONITOR
static void initMemoryUsage(void)
{
struct mallinfo mmcurrent;
#ifdef CONFIG_CAN_PASS_STRUCTS
mmcurrent = mallinfo();
#else
(void)mallinfo(&mmcurrent);
#endif
g_nxwmtest.mmInitial = mmcurrent.uordblks;
g_nxwmtest.mmStep = mmcurrent.uordblks;
g_nxwmtest.mmSubStep = mmcurrent.uordblks;
}
#endif
/////////////////////////////////////////////////////////////////////////////
// Name: cleanup
/////////////////////////////////////////////////////////////////////////////
@ -291,7 +165,6 @@ static bool createTaskbar(void)
printf("createTaskbar: ERROR: Failed to instantiate CTaskbar\n");
return false;
}
showTestCaseMemory("createTaskbar: After create taskbar");
// Connect to the NX server
@ -301,7 +174,6 @@ static bool createTaskbar(void)
printf("createTaskbar: ERROR: Failed to connect CTaskbar instance to the NX server\n");
return false;
}
showTestCaseMemory("createTaskbar: After connecting to the server");
// Initialize the task bar
//
@ -316,7 +188,6 @@ static bool createTaskbar(void)
return false;
}
showTestCaseMemory("createTaskbar: After initializing window manager");
return true;
}
@ -345,7 +216,6 @@ static bool createStartWindow(void)
printf("createStartWindow: ERROR: Failed to create CApplicationWindow\n");
return false;
}
showTestCaseMemory("createStartWindow: After creating CApplicationWindow");
// Open the window (it is hot in here)
@ -355,7 +225,6 @@ static bool createStartWindow(void)
delete window;
return false;
}
showTestCaseMemory("createStartWindow: After opening CApplicationWindow");
// Instantiate the application, providing the window to the application's
// constructor
@ -367,7 +236,6 @@ static bool createStartWindow(void)
delete window;
return false;
}
showTestCaseMemory("createStartWindow: After creating CStartWindow");
// Add the CStartWindow application to the task bar (minimized)
@ -377,7 +245,7 @@ static bool createStartWindow(void)
printf("createStartWindow: ERROR: Failed to start the start window application\n");
return false;
}
showTestCaseMemory("createStartWindow: After starting the start window application");
return true;
}
@ -396,7 +264,6 @@ static bool startWindowManager(void)
return false;
}
showTestCaseMemory("startWindowManager: After starting the window manager");
return true;
}
@ -421,7 +288,6 @@ static bool createTouchScreen(void)
printf("createTouchScreen: ERROR: Failed to create CTouchscreen\n");
return false;
}
showTestCaseMemory("createTouchScreen: After creating CTouchscreen");
printf("createTouchScreen: Start touchscreen listener\n");
if (!g_nxwmtest.touchscreen->start())
@ -431,7 +297,6 @@ static bool createTouchScreen(void)
return false;
}
showTestCaseMemory("createTouchScreen: After starting the touchscreen listener");
return true;
}
#endif
@ -450,7 +315,6 @@ static bool createKeyboard(void)
printf("createKeyboard: ERROR: Failed to create CKeyboard\n");
return false;
}
showTestCaseMemory("createKeyboard After creating CKeyboard");
printf("createKeyboard: Start keyboard listener\n");
if (!keyboard->start())
@ -460,7 +324,6 @@ static bool createKeyboard(void)
return false;
}
showTestCaseMemory("createKeyboard: After starting the keyboard listener");
return true;
}
#endif
@ -481,7 +344,6 @@ static bool createCalibration(void)
printf("createCalibration: ERROR: Failed to create CCalibrationFactory\n");
return false;
}
showTestCaseMemory("createCalibration: After creating CCalibrationFactory");
// Add the calibration application to the start window.
@ -492,7 +354,6 @@ static bool createCalibration(void)
delete factory;
return false;
}
showTestCaseMemory("createCalibration: After adding CCalibration");
// Call StartWindowFactory::create to to create the start window application
@ -503,7 +364,6 @@ static bool createCalibration(void)
printf("createCalibration: ERROR: Failed to create CCalibration\n");
return false;
}
showTestCaseMemory("createCalibration: After creating CCalibration");
#ifdef CONFIG_NXWM_TOUCHSCREEN_CONFIGDATA
// Check if we have previously stored calibration data
@ -541,8 +401,6 @@ static bool createCalibration(void)
delete calibration;
return false;
}
showTestCaseMemory("createCalibration: After starting the start window application");
}
return true;
@ -565,7 +423,6 @@ static bool createNxTerm(void)
printf("createNxTerm: ERROR: Failed to instantiate CNxTermFactory\n");
return false;
}
showTestCaseMemory("createNxTerm: After creating the NxTerm application");
printf("createNxTerm: Adding the NxTerm application to the start window\n");
if (!g_nxwmtest.startwindow->addApplication(console))
@ -575,7 +432,6 @@ static bool createNxTerm(void)
return false;
}
showTestCaseMemory("createNxTerm: After adding the NxTerm application");
return true;
}
#endif
@ -595,7 +451,6 @@ static bool createHexCalculator(void)
printf("createHexCalculator: ERROR: Failed to instantiate CHexCalculatorFactory\n");
return false;
}
showTestCaseMemory("createHexCalculator: After creating the hex calculator application");
printf("createHexCalculator: Adding the hex calculator application to the start window\n");
if (!g_nxwmtest.startwindow->addApplication(calculator))
@ -605,7 +460,6 @@ static bool createHexCalculator(void)
return false;
}
showTestCaseMemory("createHexCalculator: After adding the hex calculator application");
return true;
}
@ -625,7 +479,6 @@ static bool createMediaPlayer(void)
printf("createMediaPlayer: ERROR: Failed to instantiate CMediaPlayerFactory\n");
return false;
}
showTestCaseMemory("createMediaPlayer: After creating the media player application");
printf("createMediaPlayer: Adding the hex calculator application to the start window\n");
if (!g_nxwmtest.startwindow->addApplication(mediaplayer))
@ -635,7 +488,6 @@ static bool createMediaPlayer(void)
return false;
}
showTestCaseMemory("createMediaPlayer: After adding the media player application");
return true;
}
#endif
@ -644,27 +496,6 @@ static bool createMediaPlayer(void)
// Public Functions
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Name: showTestStepMemory
/////////////////////////////////////////////////////////////////////////////
// Called by ad hoc instrumentation in the NxWM/NxWidgets code
#ifdef CONFIG_HAVE_FILENAME
void _showTestStepMemory(FAR const char *file, int line, FAR const char *msg)
{
#ifdef CONFIG_NXWIDGET_MEMMONITOR
updateMemoryUsage(&g_nxwmtest.mmSubStep, file, line, msg);
#endif
}
#else
void showTestStepMemory(FAR const char *msg)
{
#ifdef CONFIG_NXWIDGET_MEMMONITOR
updateMemoryUsage(&g_nxwmtest.mmSubStep, msg);
#endif
}
#endif
/////////////////////////////////////////////////////////////////////////////
// nxwm_main
/////////////////////////////////////////////////////////////////////////////
@ -687,10 +518,6 @@ int nxwm_main(int argc, char *argv[])
(void)boardctl(BOARDIOC_INIT, 0);
#endif
// Initialize memory monitor logic
initMemoryUsage();
#ifdef CONFIG_NXWM_NXTERM
// Initialize the NSH library
@ -700,8 +527,6 @@ int nxwm_main(int argc, char *argv[])
printf("nxwm_main: ERROR: Failed to initialize the NSH library\n");
return EXIT_FAILURE;
}
showTestCaseMemory("nxwm_main: After initializing the NSH library");
#endif
// Create the task bar.
@ -836,31 +661,4 @@ int nxwm_main(int argc, char *argv[])
}
}
#endif
// Wait a little bit for the display to stabilize. Then simulate pressing of
// the 'start window' icon in the task bar
#ifndef CONFIG_NXWM_TOUCHSCREEN
sleep(2);
g_nxwmtest.taskbar->clickIcon(0, true);
usleep(500*1000);
g_nxwmtest.taskbar->clickIcon(0, false);
showTestCaseMemory("nxwm_main: After clicking the start window icon");
// Wait bit to see the result of the button press. Then press the first icon
// in the start menu. That should be the NxTerm icon (if the NxTerm
// is not disabled).
sleep(2);
g_nxwmtest.startwindow->clickIcon(0, true);
usleep(500*1000);
g_nxwmtest.startwindow->clickIcon(0, false);
showTestCaseMemory("nxwm_main: After clicking the NxTerm icon");
#endif
// Wait bit to see the result of the button press.
sleep(2);
showTestMemory("nxwm_main: Final memory usage");
return EXIT_SUCCESS;
}

View File

@ -203,28 +203,6 @@ namespace NxWM
{
return (m_flags & WINDOW_PERSISTENT) != 0;
}
/**
* Simulate a mouse click or release on the minimize icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void clickMinimizePosition(bool click);
#endif
/**
* Simulate a mouse click or release on the stop icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void clickStopIcon(bool click);
#endif
};
}

View File

@ -155,28 +155,6 @@ namespace NxWM
*/
void registerCallbacks(IApplicationCallback *callback);
/**
* Simulate a mouse click or release on the minimize icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void clickMinimizePosition(bool click);
#endif
/**
* Simulate a mouse click or release on the stop icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void clickStopIcon(bool click);
#endif
};
}

View File

@ -284,18 +284,6 @@ namespace NxWM
*/
bool addApplication(IApplicationFactory *app);
/**
* Simulate a mouse click or release on the icon at index. This method
* is only available during automated testing of NxWM.
*
* @param index. Selects the icon in the start window
* @param click. True to click and false to release
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void clickIcon(int index, bool click);
#endif
};
}

View File

@ -417,18 +417,6 @@ namespace NxWM
*/
inline void redraw() { redrawTopApplication(); }
/**
* Simulate a mouse click or release on the icon at index. This method
* is only available during automated testing of NxWM.
*
* @param index. Selects the icon in the start window
* @param click. True to click and false to release
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
void clickIcon(int index, bool click);
#endif
};
}

View File

@ -174,28 +174,6 @@ namespace NxWM
*/
virtual void registerCallbacks(IApplicationCallback *callback) = 0;
/**
* Simulate a mouse click or release on the minimize icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
virtual void clickMinimizePosition(bool click) = 0;
#endif
/**
* Simulate a mouse click or release on the stop icon. This method
* is only available for automated testing of NxWM.
*
* @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
virtual void clickStopIcon(bool click) = 0;
#endif
};
}

View File

@ -690,20 +690,5 @@
/****************************************************************************
* Global Function Prototypes
****************************************************************************/
/**
* Hook to support monitoring of memory usage by the NxWM unit test.
*/
#ifdef CONFIG_NXWM_UNITTEST
# ifdef CONFIG_HAVE_FILENAME
void _showTestStepMemory(FAR const char *file, int line, FAR const char *msg);
# define showTestStepMemory(msg) \
_showTestStepMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
# else
void showTestStepMemory(FAR const char *msg);
# endif
#else
# define showTestStepMemory(msg)
#endif
#endif // __APPS_INCLUDE_GRAPHICS_NXWM_NXWMCONFIG_HXX