ENH: Add test for FindwxWindows. Thanks to: Mathieu Malaterre
This commit is contained in:
parent
db12c17017
commit
97dd683836
@ -361,6 +361,17 @@ IF(BUILD_TESTING)
|
|||||||
objc++)
|
objc++)
|
||||||
ENDIF (APPLE)
|
ENDIF (APPLE)
|
||||||
|
|
||||||
|
IF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
|
||||||
|
# Will be set if the wxwindows gui is on
|
||||||
|
ADD_TEST(UseWX ${EXECUTABLE_OUTPUT_PATH}/cmaketest
|
||||||
|
${CMake_SOURCE_DIR}/Tests/UseWX
|
||||||
|
${CMake_BINARY_DIR}/Tests/UseWX
|
||||||
|
UseWX
|
||||||
|
${CMake_BINARY_DIR}/Tests/UseWX
|
||||||
|
UsewxWindows
|
||||||
|
CMAKE_ARGS -DCMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE:FILEPATH=${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE})
|
||||||
|
ENDIF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
|
||||||
|
|
||||||
IF(UNIX)
|
IF(UNIX)
|
||||||
IF("x${CMAKE_INSTALL_PREFIX}" MATCHES "^x${CMake_BINARY_DIR}/Tests/TestInstall/Prefix$")
|
IF("x${CMAKE_INSTALL_PREFIX}" MATCHES "^x${CMake_BINARY_DIR}/Tests/TestInstall/Prefix$")
|
||||||
CONFIGURE_FILE(
|
CONFIGURE_FILE(
|
||||||
|
9
Tests/UseWX/CMakeLists.txt
Normal file
9
Tests/UseWX/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
PROJECT (UsewxWindows)
|
||||||
|
|
||||||
|
INCLUDE( ${CMAKE_ROOT}/Modules/Use_wxWindows.cmake)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE (UseWX WX.cxx)
|
||||||
|
|
||||||
|
#TODO:
|
||||||
|
#- dll linking is not working on WIN32, need to '-DWXUSINGDLL' to preprocessor
|
||||||
|
|
78
Tests/UseWX/WX.cxx
Normal file
78
Tests/UseWX/WX.cxx
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
//For wx
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/dir.h>
|
||||||
|
|
||||||
|
static void TestDirEnumHelper(wxDir& dir,
|
||||||
|
int flags = wxDIR_DEFAULT,
|
||||||
|
const wxString& filespec = wxEmptyString)
|
||||||
|
{
|
||||||
|
wxString filename;
|
||||||
|
|
||||||
|
if ( !dir.IsOpened() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool cont = dir.GetFirst(&filename, filespec, flags);
|
||||||
|
while ( cont )
|
||||||
|
{
|
||||||
|
wxPrintf(_T("\t%s\n"), filename.c_str());
|
||||||
|
|
||||||
|
cont = dir.GetNext(&filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPuts(_T(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// MyApp
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class MyApp: public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyApp();
|
||||||
|
|
||||||
|
bool OnInit();
|
||||||
|
int MainLoop();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
MyApp::MyApp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyApp::OnInit()
|
||||||
|
{
|
||||||
|
//test a directory that exist:
|
||||||
|
wxDir dir(wxT(".")); //wxDir dir("/tmp");
|
||||||
|
TestDirEnumHelper(dir, wxDIR_DEFAULT | wxDIR_DOTDOT);
|
||||||
|
|
||||||
|
//Testing if link to wx debug library
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
std::cout << "If you read this you're in debug mode." << std::endl;
|
||||||
|
#endif //__WXDEBUG__
|
||||||
|
|
||||||
|
wxChar ch = wxT('*');
|
||||||
|
wxString s = wxT("Hello, world!");
|
||||||
|
int len = s.Len();
|
||||||
|
printf("Length of string is: %d\n", len);
|
||||||
|
|
||||||
|
//Force testing of Unicode mode
|
||||||
|
#ifdef __UNICODE__
|
||||||
|
wprintf(L"Unicode: %s \n", s.c_str());
|
||||||
|
wprintf(:"Char: %c\n", ch);
|
||||||
|
#else
|
||||||
|
printf("ANSI: %s \n", s.c_str());
|
||||||
|
printf("Char: %c\n", ch);
|
||||||
|
#endif //__UNICODE__
|
||||||
|
|
||||||
|
//return immediately
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MyApp::MainLoop()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user