From 232fdc630c42eb165f7659981043e794be03b3b7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 22 Aug 2010 22:16:05 +0000 Subject: [PATCH] Merge the new GUI tests from SOC2010_GUI_TEST branch. Add a lot of tests for many wx GUI classes. Add tests using the new wxUIActionSimulator class but disable them under OS X as too many of them currently fail there. Refactor the test suite to make organizing the existing tests and adding the new ones easier. Improve documentation using the information gathered while testing the classes. Also update the documentation of the testing system itself. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- autoconf_inc.m4 | 2 +- docs/tech/tn0017.txt | 25 +- interface/wx/animate.h | 2 +- interface/wx/artprov.h | 9 +- interface/wx/combobox.h | 2 +- interface/wx/html/htmlwin.h | 43 +- interface/wx/listctrl.h | 30 +- interface/wx/richtext/richtextctrl.h | 34 +- interface/wx/treectrl.h | 24 +- samples/uiaction/uiaction.dsw | 46 -- samples/uiaction/uiaction_vc7.sln | 37 -- samples/uiaction/uiaction_vc8.sln | 38 -- samples/uiaction/uiaction_vc9.sln | 38 -- tests/Makefile.in | 139 +++- tests/asserthelper.cpp | 66 ++ tests/asserthelper.h | 46 ++ tests/config/config.cpp | 4 +- tests/controls/bitmapcomboboxtest.cpp | 116 ++++ tests/controls/bitmaptogglebuttontest.cpp | 115 ++++ tests/controls/bookctrlbasetest.cpp | 169 +++++ tests/controls/bookctrlbasetest.h | 61 ++ tests/controls/buttontest.cpp | 185 ++++++ tests/controls/checkboxtest.cpp | 138 ++++ tests/controls/checklistboxtest.cpp | 96 +++ tests/controls/choicebooktest.cpp | 81 +++ tests/controls/choicetest.cpp | 96 +++ tests/controls/comboboxtest.cpp | 89 ++- tests/controls/frametest.cpp | 87 +++ tests/controls/gaugetest.cpp | 111 ++++ tests/controls/gridtest.cpp | 738 +++++++++++++++++++++ tests/controls/hyperlinkctrltest.cpp | 114 ++++ tests/controls/itemcontainertest.cpp | 245 +++++++ tests/controls/itemcontainertest.h | 58 ++ tests/controls/label.cpp | 2 + tests/controls/listbasetest.cpp | 465 +++++++++++++ tests/controls/listbasetest.h | 57 ++ tests/controls/listbooktest.cpp | 83 +++ tests/controls/listboxtest.cpp | 264 ++++++++ tests/controls/listctrltest.cpp | 177 ++--- tests/controls/listviewtest.cpp | 118 ++++ tests/controls/notebooktest.cpp | 94 +++ tests/controls/pickerbasetest.cpp | 66 ++ tests/controls/pickerbasetest.h | 43 ++ tests/controls/pickertest.cpp | 202 ++++++ tests/controls/radioboxtest.cpp | 230 +++++++ tests/controls/radiobuttontest.cpp | 159 +++++ tests/controls/rearrangelisttest.cpp | 161 +++++ tests/controls/richtextctrltest.cpp | 755 ++++++++++++++++++++++ tests/controls/slidertest.cpp | 207 ++++++ tests/controls/spinctrldbltest.cpp | 183 ++++++ tests/controls/spinctrltest.cpp | 157 +++++ tests/controls/textctrltest.cpp | 320 ++++++++- tests/controls/textentrytest.cpp | 130 ++-- tests/controls/textentrytest.h | 15 +- tests/controls/togglebuttontest.cpp | 110 ++++ tests/controls/toolbooktest.cpp | 81 +++ tests/controls/treebooktest.cpp | 147 +++++ tests/controls/treectrltest.cpp | 439 ++++++++++++- tests/controls/windowtest.cpp | 389 +++++++++++ tests/events/stopwatch.cpp | 34 +- tests/graphics/colour.cpp | 45 +- tests/html/htmlwindow.cpp | 89 ++- tests/image/image.cpp | 4 + tests/makefile.bcc | 138 +++- tests/makefile.gcc | 138 +++- tests/makefile.vc | 138 +++- tests/makefile.wat | 139 +++- tests/net/socket.cpp | 8 +- tests/sizers/boxsizer.cpp | 5 +- tests/test.bkl | 34 + tests/test.cpp | 17 +- tests/test_test_gui.dsp | 164 ++++- tests/test_vc7_test_gui.vcproj | 115 +++- tests/test_vc8_test_gui.vcproj | 148 ++++- tests/test_vc9_test_gui.vcproj | 148 ++++- tests/testableframe.cpp | 79 +++ tests/testableframe.h | 38 ++ tests/testprec.h | 13 + tests/window/setsize.cpp | 5 +- 79 files changed, 9148 insertions(+), 489 deletions(-) delete mode 100644 samples/uiaction/uiaction.dsw delete mode 100644 samples/uiaction/uiaction_vc7.sln delete mode 100644 samples/uiaction/uiaction_vc8.sln delete mode 100644 samples/uiaction/uiaction_vc9.sln create mode 100644 tests/asserthelper.cpp create mode 100644 tests/asserthelper.h create mode 100644 tests/controls/bitmapcomboboxtest.cpp create mode 100644 tests/controls/bitmaptogglebuttontest.cpp create mode 100644 tests/controls/bookctrlbasetest.cpp create mode 100644 tests/controls/bookctrlbasetest.h create mode 100644 tests/controls/buttontest.cpp create mode 100644 tests/controls/checkboxtest.cpp create mode 100644 tests/controls/checklistboxtest.cpp create mode 100644 tests/controls/choicebooktest.cpp create mode 100644 tests/controls/choicetest.cpp create mode 100644 tests/controls/frametest.cpp create mode 100644 tests/controls/gaugetest.cpp create mode 100644 tests/controls/gridtest.cpp create mode 100644 tests/controls/hyperlinkctrltest.cpp create mode 100644 tests/controls/itemcontainertest.cpp create mode 100644 tests/controls/itemcontainertest.h create mode 100644 tests/controls/listbasetest.cpp create mode 100644 tests/controls/listbasetest.h create mode 100644 tests/controls/listbooktest.cpp create mode 100644 tests/controls/listboxtest.cpp create mode 100644 tests/controls/listviewtest.cpp create mode 100644 tests/controls/notebooktest.cpp create mode 100644 tests/controls/pickerbasetest.cpp create mode 100644 tests/controls/pickerbasetest.h create mode 100644 tests/controls/pickertest.cpp create mode 100644 tests/controls/radioboxtest.cpp create mode 100644 tests/controls/radiobuttontest.cpp create mode 100644 tests/controls/rearrangelisttest.cpp create mode 100644 tests/controls/richtextctrltest.cpp create mode 100644 tests/controls/slidertest.cpp create mode 100644 tests/controls/spinctrldbltest.cpp create mode 100644 tests/controls/spinctrltest.cpp create mode 100644 tests/controls/togglebuttontest.cpp create mode 100644 tests/controls/toolbooktest.cpp create mode 100644 tests/controls/treebooktest.cpp create mode 100644 tests/controls/windowtest.cpp create mode 100644 tests/testableframe.cpp create mode 100644 tests/testableframe.h diff --git a/autoconf_inc.m4 b/autoconf_inc.m4 index 01b78cba05..7334c60e2d 100644 --- a/autoconf_inc.m4 +++ b/autoconf_inc.m4 @@ -236,7 +236,7 @@ dnl ### begin block 20_COND_MONOLITHIC_0_SHARED_0_USE_XRC_1[wx.bkl] ### COND_MONOLITHIC_0_SHARED_0_USE_XRC_1="" fi AC_SUBST(COND_MONOLITHIC_0_SHARED_0_USE_XRC_1) -dnl ### begin block 20_COND_MONOLITHIC_0_SHARED_1[wx.bkl] ### +dnl ### begin block 20_COND_MONOLITHIC_0_SHARED_1[../../tests/test.bkl,wx.bkl] ### COND_MONOLITHIC_0_SHARED_1="#" if test "x$MONOLITHIC" = "x0" -a "x$SHARED" = "x1" ; then COND_MONOLITHIC_0_SHARED_1="" diff --git a/docs/tech/tn0017.txt b/docs/tech/tn0017.txt index b9ae2b7cfd..fcda227346 100644 --- a/docs/tech/tn0017.txt +++ b/docs/tech/tn0017.txt @@ -10,10 +10,10 @@ I. CppUnit Installation ----------------------- 1. Get it from http://www.sourceforge.net/projects/cppunit - (latest version as of the time of this writing is 1.8.0) + (latest version as of the time of this writing is 1.10.2) 2. Build the library: - a) Under Windows using VC++ (both versions 6 and 7 work): + a) Under Windows using VC++ (versions 6, 7, 8 & 9 work): - build everything in CppUnitLibraries.dsw work space - add include and lib subdirectories of the directory where you installed cppunit to the compiler search path @@ -41,7 +41,26 @@ II. Writing tests with CppUnit // also include in it's own registry so that these tests can be run alone CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MBConvTestCase, "MBConvTestCase"); - Read CppUnit documentation for more. + Read CppUnit documentation for more. + d) wxUIActionSimulator can be used when user input is required, for example + clicking buttons or typing text. A simple example of this can be found + in controls/buttontest.cpp. After simulating some user input always + wxYield to allow event processing. When writing a test using + wxUIActionSimulator always add the test using WXUISIM_TEST rather than + CPPUNIT_TEST as then it won't run on unsupported platforms. The test itself + must also be wrapped in a #if wxUSE_UIACTIONSIMULATOR block. + e) There are a number of classes that are available to help with testing GUI + elements. Firstly throughout the test run there is a frame of type + wxTestableFrame that you can access through wxTheApp->GetTopWindow(). This + class adds two new functions, GetEventCount, which takes an optional + wxEventType. It then returns the number of events of that type that it has + received since the last call. Passing nothing returns the total number of + event received since the last call. Also there is OnEvent, which counts the + events based on type that are passed to it. To make it easy to count events + there is also a new class called EventCounter which takes a window and event + type and connects the window to the top level wxTestableFrame with the specific + event type. It disconnects again once it is out of scope. It simply reduces + the amount of typing required to count events. 3. add a '' tag for your source file to tests/test.bkl diff --git a/interface/wx/animate.h b/interface/wx/animate.h index 320f49fd4a..5a5803fcb7 100644 --- a/interface/wx/animate.h +++ b/interface/wx/animate.h @@ -183,7 +183,7 @@ public: Note that on wxGTK wxAnimation is capable of loading the formats supported by the internally-used @c gdk-pixbuf library (typically this means only - or @c wxANIMATION_TYPE_GIF). + @c wxANIMATION_TYPE_GIF). On other platforms wxAnimation is always capable of loading both GIF and ANI formats (i.e. both @c wxANIMATION_TYPE_GIF and @c wxANIMATION_TYPE_ANI). diff --git a/interface/wx/artprov.h b/interface/wx/artprov.h index ea9916532b..a9f7c2b21b 100644 --- a/interface/wx/artprov.h +++ b/interface/wx/artprov.h @@ -130,12 +130,13 @@ typedef class wxString wxArtID; wxBitmap bmp = wxArtProvider::GetBitmap("gtk-cdrom", wxART_MENU); #endif @endcode - For a list of the GTK+ stock items please refer to the GTK+ documentation page - http://library.gnome.org/devel/gtk/stable/gtk-Stock-Items.html. + For a list of the GTK+ stock items please refer to the + GTK+ documentation + page. It is also possible to load icons from the current icon theme by specifying their name (without extension and directory components). - Icon themes recognized by GTK+ follow the freedesktop.org Icon Themes specification - (see http://freedesktop.org/Standards/icon-theme-spec). + Icon themes recognized by GTK+ follow the freedesktop.org + Icon Themes specification. Note that themes are not guaranteed to contain all icons, so wxArtProvider may return ::wxNullBitmap or ::wxNullIcon. The default theme is typically installed in @c /usr/share/icons/hicolor. diff --git a/interface/wx/combobox.h b/interface/wx/combobox.h index 5bcca09acc..6dcefeebc2 100644 --- a/interface/wx/combobox.h +++ b/interface/wx/combobox.h @@ -237,7 +237,7 @@ public: @note For a combobox with @c wxCB_READONLY style the string must be in the combobox choices list, otherwise the call to SetValue() is - ignored. + ignored. This is case insensitive. @param text The text to set. diff --git a/interface/wx/html/htmlwin.h b/interface/wx/html/htmlwin.h index 0d4dc05baf..ef7dde2599 100644 --- a/interface/wx/html/htmlwin.h +++ b/interface/wx/html/htmlwin.h @@ -16,13 +16,13 @@ downloaded via HTTP protocol) in a window. The width of the window is constant - given in the constructor - and virtual height is changed dynamically depending on page size. - Once the window is created you can set its content by calling SetPage(text), - LoadPage(filename) or wxHtmlWindow::LoadFile. + Once the window is created you can set its content by calling SetPage() with raw HTML, + LoadPage() with a wxFileSystem location or LoadFile() with a filename. @note - wxHtmlWindow uses the wxImage class for displaying images. - Don't forget to initialize all image formats you need before loading any page! - (See ::wxInitAllImageHandlers and wxImage::AddHandler.) + wxHtmlWindow uses the wxImage class for displaying images, as such you need to + initialize the handlers for any image formats you use before loading a page. + See ::wxInitAllImageHandlers and wxImage::AddHandler. @beginStyleTable @style{wxHW_SCROLLBAR_NEVER} @@ -108,7 +108,7 @@ public: wxString GetOpenedPage() const; /** - Returns title of the opened page or wxEmptyString if current page does not + Returns title of the opened page or wxEmptyString if the current page does not contain \ tag. */ wxString GetOpenedPageTitle() const; @@ -119,20 +119,20 @@ public: wxFrame* GetRelatedFrame() const; /** - Moves back to the previous page. - (each page displayed using LoadPage() is stored in history list.) + Moves back to the previous page. Only pages displayed using LoadPage() + are stored in history list. */ bool HistoryBack(); /** Returns @true if it is possible to go back in the history - (i.e. HistoryBack() won't fail). + i.e. HistoryBack() won't fail. */ bool HistoryCanBack(); /** Returns @true if it is possible to go forward in the history - (i.e. HistoryBack() won't fail). + i.e. HistoryForward() won't fail. */ bool HistoryCanForward(); @@ -142,12 +142,13 @@ public: void HistoryClear(); /** - Moves to next page in history. + Moves to next page in history. Only pages displayed using LoadPage() + are stored in history list. */ bool HistoryForward(); /** - Loads HTML page from file and displays it. + Loads an HTML page from a file and displays it. @return @false if an error occurred, @true otherwise @@ -156,12 +157,13 @@ public: bool LoadFile(const wxFileName& filename); /** - Unlike SetPage() this function first loads HTML page from @a location - and then displays it. See example: + Unlike SetPage() this function first loads the HTML page from @a location + and then displays it. @param location - The address of document. - See wxFileSystem for details on address format and behaviour of "opener". + The address of the document. + See the @ref overview_fs for details on the address format + and wxFileSystem for a description of how the file is opened. @return @false if an error occurred, @true otherwise @@ -258,8 +260,8 @@ public: void SelectWord(const wxPoint& pos); /** - Returns current selection as plain text. - Returns empty string if no text is currently selected. + Returns the current selection as plain text. + Returns an empty string if no text is currently selected. */ wxString SelectionToText(); @@ -292,8 +294,7 @@ public: const wxString& fixed_face = wxEmptyString); /** - Sets HTML page and display it. This won't @b load the page!! - It will display the @e source. See example: + Sets the source of a page and displays it, for example: @code htmlwin -> SetPage("Hello, world!"); @endcode @@ -301,7 +302,7 @@ public: If you want to load a document from some location use LoadPage() instead. @param source - The HTML document source to be displayed. + The HTML to be displayed. @return @false if an error occurred, @true otherwise. */ diff --git a/interface/wx/listctrl.h b/interface/wx/listctrl.h index fa380eeb01..c6252bca22 100644 --- a/interface/wx/listctrl.h +++ b/interface/wx/listctrl.h @@ -86,44 +86,65 @@ @beginEventEmissionTable{wxListEvent} @event{EVT_LIST_BEGIN_DRAG(id, func)} Begin dragging with the left mouse button. + Processes a @c wxEVT_COMMAND_LIST_BEGIN_DRAG event type. @event{EVT_LIST_BEGIN_RDRAG(id, func)} - Begin dragging with the right mouse button.. - @event{EVT_LIST_BEGIN_LABEL_EDIT(id, func)} + Begin dragging with the right mouse button. + Processes a @c wxEVT_COMMAND_LIST_BEGIN_RDRAG event type. + @event{EVT_BEGIN_LABEL_EDIT(id, func)} Begin editing a label. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT event type. @event{EVT_LIST_END_LABEL_EDIT(id, func)} Finish editing a label. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_LIST_END_LABEL_EDIT event type. @event{EVT_LIST_DELETE_ITEM(id, func)} An item was deleted. + Processes a @c wxEVT_COMMAND_LIST_DELETE_ITEM event type. @event{EVT_LIST_DELETE_ALL_ITEMS(id, func)} All items were deleted. + Processes a @c wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS event type. @event{EVT_LIST_ITEM_SELECTED(id, func)} The item has been selected. + Processes a @c wxEVT_COMMAND_LIST_ITEM_SELECTED event type. @event{EVT_LIST_ITEM_DESELECTED(id, func)} The item has been deselected. + Processes a @c wxEVT_COMMAND_LIST_ITEM_DESELECTED event type. @event{EVT_LIST_ITEM_ACTIVATED(id, func)} The item has been activated (ENTER or double click). + Processes a @c wxEVT_COMMAND_LIST_ITEM_ACTIVATED event type. @event{EVT_LIST_ITEM_FOCUSED(id, func)} The currently focused item has changed. + Processes a @c wxEVT_COMMAND_LIST_ITEM_FOCUSED event type. @event{EVT_LIST_ITEM_MIDDLE_CLICK(id, func)} - The middle mouse button has been clicked on an item. + The middle mouse button has been clicked on an item. This is + only supported by the generic control. + Processes a @c wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK event type. @event{EVT_LIST_ITEM_RIGHT_CLICK(id, func)} The right mouse button has been clicked on an item. + Processes a @c wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event type. @event{EVT_LIST_KEY_DOWN(id, func)} A key has been pressed. + Processes a @c wxEVT_COMMAND_LIST_KEY_DOWN event type. @event{EVT_LIST_INSERT_ITEM(id, func)} An item has been inserted. + Processes a @c wxEVT_COMMAND_LIST_INSERT_ITEM event type. @event{EVT_LIST_COL_CLICK(id, func)} A column (m_col) has been left-clicked. + Processes a @c wxEVT_COMMAND_LIST_COL_CLICK event type. @event{EVT_LIST_COL_RIGHT_CLICK(id, func)} A column (m_col) has been right-clicked. + Processes a @c wxEVT_COMMAND_LIST_COL_RIGHT_CLICK event type. @event{EVT_LIST_COL_BEGIN_DRAG(id, func)} The user started resizing a column - can be vetoed. + Processes a @c wxEVT_COMMAND_LIST_COL_BEGIN_DRAG event type. @event{EVT_LIST_COL_DRAGGING(id, func)} The divider between columns is being dragged. + Processes a @c wxEVT_COMMAND_LIST_COL_DRAGGING event type. @event{EVT_LIST_COL_END_DRAG(id, func)} A column has been resized by the user. + Processes a @c wxEVT_COMMAND_LIST_COL_END_DRAG event type. @event{EVT_LIST_CACHE_HINT(id, func)} Prepare cache for a virtual list control. + Processes a @c wxEVT_COMMAND_LIST_CACHE_HINT event type. @endEventTable @@ -198,6 +219,9 @@ public: /** Deletes all items and all columns. + + @note This sends an event of type @c wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS + under all platforms. */ void ClearAll(); diff --git a/interface/wx/richtext/richtextctrl.h b/interface/wx/richtext/richtextctrl.h index bb54cd7072..86c3f0a144 100644 --- a/interface/wx/richtext/richtextctrl.h +++ b/interface/wx/richtext/richtextctrl.h @@ -13,41 +13,41 @@ @beginEventTable{wxRichTextEvent} @event{EVT_RICHTEXT_CHARACTER(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_CHARACTER event, generated when the user + Process a @c wxEVT_COMMAND_RICHTEXT_CHARACTER event, generated when the user presses a character key. Valid event functions: GetFlags, GetPosition, GetCharacter. @event{EVT_RICHTEXT_DELETE(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_DELETE event, generated when the user + Process a @c wxEVT_COMMAND_RICHTEXT_DELETE event, generated when the user presses the backspace or delete key. Valid event functions: GetFlags, GetPosition. @event{EVT_RICHTEXT_RETURN(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_RETURN event, generated when the user + Process a @c wxEVT_COMMAND_RICHTEXT_RETURN event, generated when the user presses the return key. Valid event functions: GetFlags, GetPosition. @event{EVT_RICHTEXT_STYLE_CHANGED(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED event, generated when + Process a @c wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED event, generated when styling has been applied to the control. Valid event functions: GetPosition, GetRange. @event{EVT_RICHTEXT_STYLESHEET_CHANGED(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING event, generated + Process a @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING event, generated when the control's stylesheet has changed, for example the user added, edited or deleted a style. Valid event functions: GetRange, GetPosition. @event{EVT_RICHTEXT_STYLESHEET_REPLACING(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING event, generated + Process a @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING event, generated when the control's stylesheet is about to be replaced, for example when a file is loaded into the control. Valid event functions: Veto, GetOldStyleSheet, GetNewStyleSheet. @event{EVT_RICHTEXT_STYLESHEET_REPLACED(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED event, generated + Process a @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED event, generated when the control's stylesheet has been replaced, for example when a file is loaded into the control. Valid event functions: GetOldStyleSheet, GetNewStyleSheet. @event{EVT_RICHTEXT_CONTENT_INSERTED(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED event, generated when + Process a @c wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED event, generated when content has been inserted into the control. Valid event functions: GetPosition, GetRange. @event{EVT_RICHTEXT_CONTENT_DELETED(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED event, generated when + Process a @c wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED event, generated when content has been deleted from the control. Valid event functions: GetPosition, GetRange. @event{EVT_RICHTEXT_BUFFER_RESET(id, func)} - Process a wxEVT_COMMAND_RICHTEXT_BUFFER_RESET event, generated when the + Process a @c wxEVT_COMMAND_RICHTEXT_BUFFER_RESET event, generated when the buffer has been reset by deleting all content. You can use this to set a default style for the first new paragraph. @endEventTable @@ -74,30 +74,30 @@ public: wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0); /** - Returns the character pressed, within a wxEVT_COMMAND_RICHTEXT_CHARACTER event. + Returns the character pressed, within a @c wxEVT_COMMAND_RICHTEXT_CHARACTER event. */ wxChar GetCharacter() const; /** Returns flags indicating modifier keys pressed. - Possible values are wxRICHTEXT_CTRL_DOWN, wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN. + Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN. */ int GetFlags() const; /** Returns the new style sheet. - Can be used in a wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or - wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler. + Can be used in a @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or + @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler. */ wxRichTextStyleSheet* GetNewStyleSheet() const; /** Returns the old style sheet. - Can be used in a wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or - wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler. + Can be used in a @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or + @c wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler. */ wxRichTextStyleSheet* GetOldStyleSheet() const; @@ -119,7 +119,7 @@ public: /** Sets flags indicating modifier keys pressed. - Possible values are wxRICHTEXT_CTRL_DOWN, wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN. + Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN. */ void SetFlags(int flags); diff --git a/interface/wx/treectrl.h b/interface/wx/treectrl.h index e152cca208..d41d5d4336 100644 --- a/interface/wx/treectrl.h +++ b/interface/wx/treectrl.h @@ -65,51 +65,73 @@ Begin dragging with the left mouse button. If you want to enable left-dragging you need to intercept this event and explicitely call wxTreeEvent::Allow(), as it's vetoed by default. + Processes a @c wxEVT_COMMAND_TREE_BEGIN_DRAG event type. @event{EVT_TREE_BEGIN_RDRAG(id, func)} Begin dragging with the right mouse button. If you want to enable right-dragging you need to intercept this event and explicitely call wxTreeEvent::Allow(), as it's vetoed by default. + Processes a @c wxEVT_COMMAND_TREE_BEGIN_RDRAG event type. @event{EVT_TREE_END_DRAG(id, func)} End dragging with the left or right mouse button. + Processes a @c wxEVT_COMMAND_TREE_END_DRAG event type. @event{EVT_TREE_BEGIN_LABEL_EDIT(id, func)} Begin editing a label. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT event type. @event{EVT_TREE_END_LABEL_EDIT(id, func)} Finish editing a label. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT event type. @event{EVT_TREE_DELETE_ITEM(id, func)} An item was deleted. + Processes a @c wxEVT_COMMAND_TREE_DELETE_ITEM event type. @event{EVT_TREE_GET_INFO(id, func)} Request information from the application. + Processes a @c wxEVT_COMMAND_TREE_GET_INFO event type. @event{EVT_TREE_SET_INFO(id, func)} Information is being supplied. + Processes a @c wxEVT_COMMAND_TREE_SET_INFO event type. @event{EVT_TREE_ITEM_ACTIVATED(id, func)} The item has been activated, i.e. chosen by double clicking it with mouse or from keyboard. + Processes a @c wxEVT_COMMAND_TREE_ITEM_ACTIVATED event type. @event{EVT_TREE_ITEM_COLLAPSED(id, func)} The item has been collapsed. + Processes a @c wxEVT_COMMAND_TREE_ITEM_COLLAPSED event type. @event{EVT_TREE_ITEM_COLLAPSING(id, func)} The item is being collapsed. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_TREE_ITEM_COLLAPSING event type. @event{EVT_TREE_ITEM_EXPANDED(id, func)} The item has been expanded. + Processes a @c wxEVT_COMMAND_TREE_ITEM_EXPANDED event type. @event{EVT_TREE_ITEM_EXPANDING(id, func)} The item is being expanded. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_TREE_ITEM_EXPANDING event type. @event{EVT_TREE_ITEM_RIGHT_CLICK(id, func)} The user has clicked the item with the right mouse button. + Processes a @c wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK event type. @event{EVT_TREE_ITEM_MIDDLE_CLICK(id, func)} - The user has clicked the item with the middle mouse button. + The user has clicked the item with the middle mouse button. This is + only supported by the generic control. + Processes a @c wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK event type. @event{EVT_TREE_SEL_CHANGED(id, func)} Selection has changed. + Processes a @c wxEVT_COMMAND_TREE_SEL_CHANGED event type. @event{EVT_TREE_SEL_CHANGING(id, func)} Selection is changing. This can be prevented by calling Veto(). + Processes a @c wxEVT_COMMAND_TREE_SEL_CHANGING event type. @event{EVT_TREE_KEY_DOWN(id, func)} A key has been pressed. + Processes a @c wxEVT_COMMAND_TREE_KEY_DOWN event type. @event{EVT_TREE_ITEM_GETTOOLTIP(id, func)} The opportunity to set the item tooltip is being given to the application (call wxTreeEvent::SetToolTip). Windows only. + Processes a @c wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP event type. @event{EVT_TREE_ITEM_MENU(id, func)} The context menu for the selected item has been requested, either by a right click or by using the menu key. + Processes a @c wxEVT_COMMAND_TREE_ITEM_MENU event type. @event{EVT_TREE_STATE_IMAGE_CLICK(id, func)} The state image has been clicked. Windows only. + Processes a @c wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK event type. @endEventTable diff --git a/samples/uiaction/uiaction.dsw b/samples/uiaction/uiaction.dsw deleted file mode 100644 index 01020976ad..0000000000 --- a/samples/uiaction/uiaction.dsw +++ /dev/null @@ -1,46 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### -Project: "uiaction"=uiaction.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -Begin Project Dependency -Project_Dep_Name core -End Project Dependency -Begin Project Dependency -Project_Dep_Name base -End Project Dependency -}}} - -############################################################################### - -Project: "core"=..\..\build\msw\wx_core.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "base"=..\..\build\msw\wx_base.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - diff --git a/samples/uiaction/uiaction_vc7.sln b/samples/uiaction/uiaction_vc7.sln deleted file mode 100644 index 756a042635..0000000000 --- a/samples/uiaction/uiaction_vc7.sln +++ /dev/null @@ -1,37 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uiaction", "uiaction_vc7.vcproj", "{15C7D338-F667-5379-A751-0BB06CCFC077}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Universal Debug|Win32 = Universal Debug|Win32 - Universal Release|Win32 = Universal Release|Win32 - DLL Debug|Win32 = DLL Debug|Win32 - DLL Release|Win32 = DLL Release|Win32 - DLL Universal Debug|Win32 = DLL Universal Debug|Win32 - DLL Universal Release|Win32 = DLL Universal Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {15C7D338-F667-5379-A751-0BB06CCFC077}.Debug|Win32.ActiveCfg = Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Debug|Win32.Build.0 = Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Release|Win32.ActiveCfg = Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Release|Win32.Build.0 = Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Universal Debug|Win32.ActiveCfg = Universal Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Universal Debug|Win32.Build.0 = Universal Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Universal Release|Win32.ActiveCfg = Universal Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.Universal Release|Win32.Build.0 = Universal Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Debug|Win32.Build.0 = DLL Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Release|Win32.ActiveCfg = DLL Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Release|Win32.Build.0 = DLL Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Universal Debug|Win32.ActiveCfg = DLL Universal Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Universal Debug|Win32.Build.0 = DLL Universal Debug|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Universal Release|Win32.ActiveCfg = DLL Universal Release|Win32 - {15C7D338-F667-5379-A751-0BB06CCFC077}.DLL Universal Release|Win32.Build.0 = DLL Universal Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal - diff --git a/samples/uiaction/uiaction_vc8.sln b/samples/uiaction/uiaction_vc8.sln deleted file mode 100644 index e90de5163e..0000000000 --- a/samples/uiaction/uiaction_vc8.sln +++ /dev/null @@ -1,38 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uiaction", "uiaction_vc8.vcproj", "{F4A15A83-3FE9-5957-9AC3-45393E610AF5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Universal Debug|Win32 = Universal Debug|Win32 - Universal Release|Win32 = Universal Release|Win32 - DLL Debug|Win32 = DLL Debug|Win32 - DLL Release|Win32 = DLL Release|Win32 - DLL Universal Debug|Win32 = DLL Universal Debug|Win32 - DLL Universal Release|Win32 = DLL Universal Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Debug|Win32.Build.0 = Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Release|Win32.ActiveCfg = Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Release|Win32.Build.0 = Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Universal Debug|Win32.ActiveCfg = Universal Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Universal Debug|Win32.Build.0 = Universal Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Universal Release|Win32.ActiveCfg = Universal Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.Universal Release|Win32.Build.0 = Universal Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Debug|Win32.Build.0 = DLL Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Release|Win32.ActiveCfg = DLL Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Release|Win32.Build.0 = DLL Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Universal Debug|Win32.ActiveCfg = DLL Universal Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Universal Debug|Win32.Build.0 = DLL Universal Debug|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Universal Release|Win32.ActiveCfg = DLL Universal Release|Win32 - {F4A15A83-3FE9-5957-9AC3-45393E610AF5}.DLL Universal Release|Win32.Build.0 = DLL Universal Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal - diff --git a/samples/uiaction/uiaction_vc9.sln b/samples/uiaction/uiaction_vc9.sln deleted file mode 100644 index fe8613a2e1..0000000000 --- a/samples/uiaction/uiaction_vc9.sln +++ /dev/null @@ -1,38 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uiaction", "uiaction_vc9.vcproj", "{3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Universal Debug|Win32 = Universal Debug|Win32 - Universal Release|Win32 = Universal Release|Win32 - DLL Debug|Win32 = DLL Debug|Win32 - DLL Release|Win32 = DLL Release|Win32 - DLL Universal Debug|Win32 = DLL Universal Debug|Win32 - DLL Universal Release|Win32 = DLL Universal Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Debug|Win32.ActiveCfg = Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Debug|Win32.Build.0 = Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Release|Win32.ActiveCfg = Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Release|Win32.Build.0 = Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Universal Debug|Win32.ActiveCfg = Universal Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Universal Debug|Win32.Build.0 = Universal Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Universal Release|Win32.ActiveCfg = Universal Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.Universal Release|Win32.Build.0 = Universal Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Debug|Win32.Build.0 = DLL Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Release|Win32.ActiveCfg = DLL Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Release|Win32.Build.0 = DLL Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Universal Debug|Win32.ActiveCfg = DLL Universal Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Universal Debug|Win32.Build.0 = DLL Universal Debug|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Universal Release|Win32.ActiveCfg = DLL Universal Release|Win32 - {3D3BB744-B01F-51D9-BA3D-D09A20EC55DF}.DLL Universal Release|Win32.Build.0 = DLL Universal Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal - diff --git a/tests/Makefile.in b/tests/Makefile.in index d26a68fd06..4a10638eba 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -46,7 +46,7 @@ wx_top_builddir = @wx_top_builddir@ DESTDIR = WX_RELEASE = 2.9 -WX_VERSION = $(WX_RELEASE).1 +WX_VERSION = $(WX_RELEASE).2 LIBDIRNAME = $(wx_top_builddir)/lib TEST_CXXFLAGS = $(__test_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ @@ -144,7 +144,9 @@ TEST_GUI_CXXFLAGS = $(__test_gui_PCH_INC) -D__WX$(TOOLKIT)__ \ TEST_GUI_OBJECTS = \ $(__test_gui___win32rc) \ $(__test_gui_os2_lib_res) \ + test_gui_asserthelper.o \ test_gui_test.o \ + test_gui_testableframe.o \ test_gui_rect.o \ test_gui_size.o \ test_gui_point.o \ @@ -153,13 +155,44 @@ TEST_GUI_OBJECTS = \ test_gui_ellipsization.o \ test_gui_measuring.o \ test_gui_config.o \ + test_gui_bitmapcomboboxtest.o \ + test_gui_bitmaptogglebuttontest.o \ + test_gui_bookctrlbasetest.o \ + test_gui_buttontest.o \ + test_gui_checkboxtest.o \ + test_gui_checklistboxtest.o \ + test_gui_choicebooktest.o \ + test_gui_choicetest.o \ test_gui_comboboxtest.o \ + test_gui_frametest.o \ + test_gui_gaugetest.o \ + test_gui_gridtest.o \ test_gui_headerctrltest.o \ + test_gui_hyperlinkctrltest.o \ + test_gui_itemcontainertest.o \ test_gui_label.o \ + test_gui_listbasetest.o \ + test_gui_listbooktest.o \ + test_gui_listboxtest.o \ test_gui_listctrltest.o \ + test_gui_listviewtest.o \ + test_gui_notebooktest.o \ + test_gui_pickerbasetest.o \ + test_gui_pickertest.o \ + test_gui_radioboxtest.o \ + test_gui_radiobuttontest.o \ + test_gui_rearrangelisttest.o \ + test_gui_richtextctrltest.o \ + test_gui_slidertest.o \ + test_gui_spinctrldbltest.o \ + test_gui_spinctrltest.o \ test_gui_textctrltest.o \ test_gui_textentrytest.o \ + test_gui_togglebuttontest.o \ + test_gui_toolbooktest.o \ + test_gui_treebooktest.o \ test_gui_treectrltest.o \ + test_gui_windowtest.o \ test_gui_clone.o \ test_gui_propagation.o \ test_gui_fonttest.o \ @@ -233,6 +266,9 @@ TEST_GUI_ODEP = $(_____pch_testprec_test_gui_testprec_h_gch___depname) @COND_ICC_PCH_1@ ./.pch/testprec_test_gui/testprec.h.gch @COND_USE_PCH_1@_____pch_testprec_test_gui_testprec_h_gch___depname \ @COND_USE_PCH_1@ = ./.pch/testprec_test_gui/testprec.h.gch +COND_MONOLITHIC_0___WXLIB_RICHTEXT_p = \ + -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0@__WXLIB_RICHTEXT_p = $(COND_MONOLITHIC_0___WXLIB_RICHTEXT_p) COND_MONOLITHIC_0_USE_MEDIA_1___WXLIB_MEDIA_p = \ -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media-$(WX_RELEASE)$(HOST_SUFFIX) @COND_MONOLITHIC_0_USE_MEDIA_1@__WXLIB_MEDIA_p = $(COND_MONOLITHIC_0_USE_MEDIA_1___WXLIB_MEDIA_p) @@ -312,7 +348,7 @@ test$(EXEEXT): $(TEST_OBJECTS) @COND_USE_PCH_1@ $(BK_MAKE_PCH) ./.pch/testprec_test/testprec.h.gch testprec.h $(CXX) $(TEST_CXXFLAGS) @COND_USE_GUI_1@test_gui$(EXEEXT): $(TEST_GUI_OBJECTS) $(__test_gui___win32rc) -@COND_USE_GUI_1@ $(CXX) -o $@ $(TEST_GUI_OBJECTS) -L$(LIBDIRNAME) $(SAMPLES_RPATH_FLAG) $(CPPUNIT_LIBS) $(LDFLAGS) $(__WXLIB_MEDIA_p) $(EXTRALIBS_MEDIA) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(EXTRALIBS_XML) $(__WXLIB_ADV_p) $(PLUGIN_ADV_EXTRALIBS) $(__WXLIB_HTML_p) $(EXTRALIBS_HTML) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) +@COND_USE_GUI_1@ $(CXX) -o $@ $(TEST_GUI_OBJECTS) -L$(LIBDIRNAME) $(SAMPLES_RPATH_FLAG) $(CPPUNIT_LIBS) $(LDFLAGS) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(EXTRALIBS_MEDIA) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(EXTRALIBS_XML) $(__WXLIB_ADV_p) $(PLUGIN_ADV_EXTRALIBS) $(__WXLIB_HTML_p) $(EXTRALIBS_HTML) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) @COND_USE_GUI_1@ @COND_USE_GUI_1@ $(__test_gui___mac_setfilecmd) @@ -614,9 +650,15 @@ test_xmltest.o: $(srcdir)/xml/xmltest.cpp $(TEST_ODEP) test_gui_sample_rc.o: $(srcdir)/../samples/sample.rc $(TEST_GUI_ODEP) $(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_5) $(__DEBUG_DEFINE_p_5) $(__EXCEPTIONS_DEFINE_p_5) $(__RTTI_DEFINE_p_5) $(__THREAD_DEFINE_p_5) --include-dir $(srcdir) $(__DLLFLAG_p_5) --include-dir $(srcdir)/../samples $(__RCDEFDIR_p_1) --include-dir $(top_srcdir)/include +test_gui_asserthelper.o: $(srcdir)/asserthelper.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/asserthelper.cpp + test_gui_test.o: $(srcdir)/test.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/test.cpp +test_gui_testableframe.o: $(srcdir)/testableframe.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/testableframe.cpp + test_gui_rect.o: $(srcdir)/geometry/rect.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/geometry/rect.cpp @@ -641,27 +683,120 @@ test_gui_measuring.o: $(srcdir)/graphics/measuring.cpp $(TEST_GUI_ODEP) test_gui_config.o: $(srcdir)/config/config.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/config/config.cpp +test_gui_bitmapcomboboxtest.o: $(srcdir)/controls/bitmapcomboboxtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/bitmapcomboboxtest.cpp + +test_gui_bitmaptogglebuttontest.o: $(srcdir)/controls/bitmaptogglebuttontest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/bitmaptogglebuttontest.cpp + +test_gui_bookctrlbasetest.o: $(srcdir)/controls/bookctrlbasetest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/bookctrlbasetest.cpp + +test_gui_buttontest.o: $(srcdir)/controls/buttontest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/buttontest.cpp + +test_gui_checkboxtest.o: $(srcdir)/controls/checkboxtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/checkboxtest.cpp + +test_gui_checklistboxtest.o: $(srcdir)/controls/checklistboxtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/checklistboxtest.cpp + +test_gui_choicebooktest.o: $(srcdir)/controls/choicebooktest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/choicebooktest.cpp + +test_gui_choicetest.o: $(srcdir)/controls/choicetest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/choicetest.cpp + test_gui_comboboxtest.o: $(srcdir)/controls/comboboxtest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/comboboxtest.cpp +test_gui_frametest.o: $(srcdir)/controls/frametest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/frametest.cpp + +test_gui_gaugetest.o: $(srcdir)/controls/gaugetest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/gaugetest.cpp + +test_gui_gridtest.o: $(srcdir)/controls/gridtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/gridtest.cpp + test_gui_headerctrltest.o: $(srcdir)/controls/headerctrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/headerctrltest.cpp +test_gui_hyperlinkctrltest.o: $(srcdir)/controls/hyperlinkctrltest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/hyperlinkctrltest.cpp + +test_gui_itemcontainertest.o: $(srcdir)/controls/itemcontainertest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/itemcontainertest.cpp + test_gui_label.o: $(srcdir)/controls/label.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/label.cpp +test_gui_listbasetest.o: $(srcdir)/controls/listbasetest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listbasetest.cpp + +test_gui_listbooktest.o: $(srcdir)/controls/listbooktest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listbooktest.cpp + +test_gui_listboxtest.o: $(srcdir)/controls/listboxtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listboxtest.cpp + test_gui_listctrltest.o: $(srcdir)/controls/listctrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listctrltest.cpp +test_gui_listviewtest.o: $(srcdir)/controls/listviewtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/listviewtest.cpp + +test_gui_notebooktest.o: $(srcdir)/controls/notebooktest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/notebooktest.cpp + +test_gui_pickerbasetest.o: $(srcdir)/controls/pickerbasetest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/pickerbasetest.cpp + +test_gui_pickertest.o: $(srcdir)/controls/pickertest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/pickertest.cpp + +test_gui_radioboxtest.o: $(srcdir)/controls/radioboxtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/radioboxtest.cpp + +test_gui_radiobuttontest.o: $(srcdir)/controls/radiobuttontest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/radiobuttontest.cpp + +test_gui_rearrangelisttest.o: $(srcdir)/controls/rearrangelisttest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/rearrangelisttest.cpp + +test_gui_richtextctrltest.o: $(srcdir)/controls/richtextctrltest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/richtextctrltest.cpp + +test_gui_slidertest.o: $(srcdir)/controls/slidertest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/slidertest.cpp + +test_gui_spinctrldbltest.o: $(srcdir)/controls/spinctrldbltest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/spinctrldbltest.cpp + +test_gui_spinctrltest.o: $(srcdir)/controls/spinctrltest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/spinctrltest.cpp + test_gui_textctrltest.o: $(srcdir)/controls/textctrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textctrltest.cpp test_gui_textentrytest.o: $(srcdir)/controls/textentrytest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textentrytest.cpp +test_gui_togglebuttontest.o: $(srcdir)/controls/togglebuttontest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/togglebuttontest.cpp + +test_gui_toolbooktest.o: $(srcdir)/controls/toolbooktest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/toolbooktest.cpp + +test_gui_treebooktest.o: $(srcdir)/controls/treebooktest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/treebooktest.cpp + test_gui_treectrltest.o: $(srcdir)/controls/treectrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/treectrltest.cpp +test_gui_windowtest.o: $(srcdir)/controls/windowtest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/windowtest.cpp + test_gui_clone.o: $(srcdir)/events/clone.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/events/clone.cpp diff --git a/tests/asserthelper.cpp b/tests/asserthelper.cpp new file mode 100644 index 0000000000..9ca5feb1d3 --- /dev/null +++ b/tests/asserthelper.cpp @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/asserthelper.cpp +// Purpose: Helper functions for cppunit +// Author: Steven Lamerton +// Created: 2010-07-23 +// RCS-ID: $Id$ +// Copyright: (c) 2009 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "asserthelper.h" + +namespace +{ + std::ostream& operator<<(std::ostream& os, const ColourChannel& cc) + { + os.width(2); + os.fill('0'); + os << static_cast(cc.m_value); + return os; + } +} // anonymous namespace + +std::ostream& operator<<(std::ostream& os, const wxColour& c) +{ + os << std::hex << std::noshowbase + << "(" + << ColourChannel(c.Red()) << ", " + << ColourChannel(c.Green()) << ", " + << ColourChannel(c.Blue()); + + if ( const unsigned char a = c.Alpha() ) + { + os << ", " << ColourChannel(a); + } + + os << ")"; + + return os; +} + +std::ostream& operator<<(std::ostream& os, const wxSize& s) +{ + os << s.x << "x" << s.y; + + return os; +} + +std::ostream& operator<<(std::ostream& os, const wxFont& f) +{ + os << f.GetNativeFontInfoUserDesc(); + + return os; +} + +std::ostream& operator<<(std::ostream& os, const wxPoint& p) +{ + os << "(" << p.x << ", " << p.y << ")"; + + return os; +} diff --git a/tests/asserthelper.h b/tests/asserthelper.h new file mode 100644 index 0000000000..5743154038 --- /dev/null +++ b/tests/asserthelper.h @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/asserthelper.h +// Purpose: Helper functions for cppunit +// Author: Steven Lamerton +// Created: 2010-07-23 +// RCS-ID: $Id$ +// Copyright: (c) 2009 Vadim Zeitlin +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TESTS_ASSERTHELPER_H_ +#define _WX_TESTS_ASSERTHELPER_H_ + +#include +#include +#include +#include + +namespace +{ + // by default colour components values are output incorrectly because they + // are unsigned chars, define a small helper struct which formats them in + // a more useful way + struct ColourChannel + { + ColourChannel(unsigned char value) : m_value(value) { } + + unsigned char m_value; + }; + + std::ostream& operator<<(std::ostream& os, const ColourChannel& cc); + +} // anonymous namespace + +// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxColour objects +std::ostream& operator<<(std::ostream& os, const wxColour& c); + +// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxSize objects +std::ostream& operator<<(std::ostream& os, const wxSize& s); + +// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxFont objects +std::ostream& operator<<(std::ostream& os, const wxFont& f); + +// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxPoint objects +std::ostream& operator<<(std::ostream& os, const wxPoint& p); + +#endif diff --git a/tests/config/config.cpp b/tests/config/config.cpp index dad0dd2a4b..005ae67d39 100644 --- a/tests/config/config.cpp +++ b/tests/config/config.cpp @@ -18,6 +18,8 @@ #include "testprec.h" +#if wxUSE_CONFIG + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -208,4 +210,4 @@ void ConfigTestCase::RecordingDefaultsTest() delete config; } - +#endif //wxUSE_CONFIG diff --git a/tests/controls/bitmapcomboboxtest.cpp b/tests/controls/bitmapcomboboxtest.cpp new file mode 100644 index 0000000000..dbaa82daf1 --- /dev/null +++ b/tests/controls/bitmapcomboboxtest.cpp @@ -0,0 +1,116 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/bitmapcomboboxtest.cpp +// Purpose: wxBitmapComboBox unit test +// Author: Steven Lamerton +// Created: 2010-07-15 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_BITMAPCOMBOBOX + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/bmpcbox.h" +#include "wx/artprov.h" +#include "textentrytest.h" +#include "itemcontainertest.h" +#include "asserthelper.h" + +//Test only if we are based off of wxComboBox +#ifndef wxGENERIC_BITMAPCOMBOBOX + +class BitmapComboBoxTestCase : public TextEntryTestCase, + public ItemContainerTestCase, + public CppUnit::TestCase +{ +public: + BitmapComboBoxTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxTextEntry *GetTestEntry() const { return m_combo; } + virtual wxWindow *GetTestWindow() const { return m_combo; } + + virtual wxItemContainer *GetContainer() const { return m_combo; } + virtual wxWindow *GetContainerWindow() const { return m_combo; } + + virtual void CheckStringSelection(const char * WXUNUSED(sel)) + { + // do nothing here, as explained in TextEntryTestCase comment, our + // GetStringSelection() is the wxChoice, not wxTextEntry, one and there + // is no way to return the selection contents directly + } + + CPPUNIT_TEST_SUITE( BitmapComboBoxTestCase ); + wxTEXT_ENTRY_TESTS(); + wxITEM_CONTAINER_TESTS(); + CPPUNIT_TEST( Bitmap ); + CPPUNIT_TEST_SUITE_END(); + + void Bitmap(); + + wxBitmapComboBox *m_combo; + + DECLARE_NO_COPY_CLASS(BitmapComboBoxTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( BitmapComboBoxTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapComboBoxTestCase, + "BitmapComboBoxTestCase" ); + +void BitmapComboBoxTestCase::setUp() +{ + m_combo = new wxBitmapComboBox(wxTheApp->GetTopWindow(), wxID_ANY); +} + +void BitmapComboBoxTestCase::tearDown() +{ + wxDELETE(m_combo); +} + +void BitmapComboBoxTestCase::Bitmap() +{ + wxArrayString items; + items.push_back("item 0"); + items.push_back("item 1"); + + //We need this otherwise MSVC complains as it cannot find a suitable append + static_cast(m_combo)->Append(items); + + CPPUNIT_ASSERT(!m_combo->GetItemBitmap(0).IsOk()); + + wxBitmap bitmap = wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, + wxSize(16, 16)); + + m_combo->Append("item with bitmap", bitmap); + + CPPUNIT_ASSERT(m_combo->GetItemBitmap(2).IsOk()); + + m_combo->Insert("item with bitmap", bitmap, 1); + + CPPUNIT_ASSERT(m_combo->GetItemBitmap(1).IsOk()); + + m_combo->SetItemBitmap(0, bitmap); + + CPPUNIT_ASSERT(m_combo->GetItemBitmap(0).IsOk()); + + CPPUNIT_ASSERT_EQUAL(wxSize(16, 16), m_combo->GetBitmapSize()); +} + +#endif //wxGENERIC_BITMAPCOMBOBOX + +#endif //wxUSE_BITMAPCOMBOBOX diff --git a/tests/controls/bitmaptogglebuttontest.cpp b/tests/controls/bitmaptogglebuttontest.cpp new file mode 100644 index 0000000000..a71be54b06 --- /dev/null +++ b/tests/controls/bitmaptogglebuttontest.cpp @@ -0,0 +1,115 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/bitmaptogglebuttontest.cpp +// Purpose: wxBitmapToggleButton unit test +// Author: Steven Lamerton +// Created: 2010-07-17 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "testableframe.h" +#include "wx/uiaction.h" +#include "wx/artprov.h" +#include "wx/tglbtn.h" + +class BitmapToggleButtonTestCase : public CppUnit::TestCase +{ +public: + BitmapToggleButtonTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( BitmapToggleButtonTestCase ); + WXUISIM_TEST( Click ); + CPPUNIT_TEST( Value ); + CPPUNIT_TEST_SUITE_END(); + + void Click(); + void Value(); + + wxBitmapToggleButton* m_button; + + DECLARE_NO_COPY_CLASS(BitmapToggleButtonTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( BitmapToggleButtonTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( BitmapToggleButtonTestCase, + "BitmapToggleButtonTestCase" ); + +void BitmapToggleButtonTestCase::setUp() +{ + m_button = new wxBitmapToggleButton(wxTheApp->GetTopWindow(), wxID_ANY, + wxArtProvider::GetIcon(wxART_INFORMATION, + wxART_OTHER, + wxSize(32, 32))); + m_button->Update(); + m_button->Refresh(); +} + +void BitmapToggleButtonTestCase::tearDown() +{ + wxDELETE(m_button); +} + +void BitmapToggleButtonTestCase::Click() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_button, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED); + + wxUIActionSimulator sim; + + //We move in slightly to account for window decorations + sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10)); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT(m_button->GetValue()); + + wxMilliSleep(1000); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT(!m_button->GetValue()); +#endif // wxUSE_UIACTIONSIMULATOR +} + +void BitmapToggleButtonTestCase::Value() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED); + + m_button->SetValue(true); + + CPPUNIT_ASSERT(m_button->GetValue()); + + m_button->SetValue(false); + + CPPUNIT_ASSERT(!m_button->GetValue()); + + CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() ); +} diff --git a/tests/controls/bookctrlbasetest.cpp b/tests/controls/bookctrlbasetest.cpp new file mode 100644 index 0000000000..41ddeb2828 --- /dev/null +++ b/tests/controls/bookctrlbasetest.cpp @@ -0,0 +1,169 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/bookctrlbasetest.cpp +// Purpose: wxBookCtrlBase unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/panel.h" +#endif // WX_PRECOMP + +#include "wx/artprov.h" +#include "wx/imaglist.h" +#include "wx/bookctrl.h" +#include "wx/toolbook.h" +#include "wx/toolbar.h" +#include "bookctrlbasetest.h" +#include "testableframe.h" + +void BookCtrlBaseTestCase::AddPanels() +{ + wxBookCtrlBase * const base = GetBase(); + + wxSize size(32, 32); + + m_list = new wxImageList(size.x, size.y); + m_list->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size)); + m_list->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size)); + m_list->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size)); + + base->AssignImageList(m_list); + + //We need to realize the toolbar if we ware running the wxToolbook tests + wxToolbook *book = wxDynamicCast(base, wxToolbook); + + if(book) + book->GetToolBar()->Realize(); + + m_panel1 = new wxPanel(base); + m_panel2 = new wxPanel(base); + m_panel3 = new wxPanel(base); + + base->AddPage(m_panel1, "Panel 1", false, 0); + base->AddPage(m_panel2, "Panel 2", false, 1); + base->AddPage(m_panel3, "Panel 3", false, 2); +} + +void BookCtrlBaseTestCase::Selection() +{ + wxBookCtrlBase * const base = GetBase(); + + base->SetSelection(0); + + CPPUNIT_ASSERT_EQUAL(0, base->GetSelection()); + CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel1, wxWindow), base->GetCurrentPage()); + + base->AdvanceSelection(false); + + CPPUNIT_ASSERT_EQUAL(2, base->GetSelection()); + CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel3, wxWindow), base->GetCurrentPage()); + + base->AdvanceSelection(); + + CPPUNIT_ASSERT_EQUAL(0, base->GetSelection()); + CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel1, wxWindow), base->GetCurrentPage()); + + base->ChangeSelection(1); + + CPPUNIT_ASSERT_EQUAL(1, base->GetSelection()); + CPPUNIT_ASSERT_EQUAL(wxStaticCast(m_panel2, wxWindow), base->GetCurrentPage()); +} + +void BookCtrlBaseTestCase::Text() +{ + wxBookCtrlBase * const base = GetBase(); + + CPPUNIT_ASSERT_EQUAL("Panel 1", base->GetPageText(0)); + + base->SetPageText(1, "Some other string"); + + CPPUNIT_ASSERT_EQUAL("Some other string", base->GetPageText(1)); + + base->SetPageText(2, "string with /nline break"); + + CPPUNIT_ASSERT_EQUAL("string with /nline break", base->GetPageText(2)); +} + +void BookCtrlBaseTestCase::PageManagement() +{ + wxBookCtrlBase * const base = GetBase(); + + base->InsertPage(0, new wxPanel(base), "New Panel", true, 0); + + //We need to realize the toolbar if we ware running the wxToolbook tests + wxToolbook *book = wxDynamicCast(base, wxToolbook); + + if(book) + book->GetToolBar()->Realize(); + + CPPUNIT_ASSERT_EQUAL(0, base->GetSelection()); + CPPUNIT_ASSERT_EQUAL(4, base->GetPageCount()); + + base->DeletePage(1); + + CPPUNIT_ASSERT_EQUAL(3, base->GetPageCount()); + + base->RemovePage(0); + + CPPUNIT_ASSERT_EQUAL(2, base->GetPageCount()); + + base->DeleteAllPages(); + + CPPUNIT_ASSERT_EQUAL(0, base->GetPageCount()); + + AddPanels(); +} + +void BookCtrlBaseTestCase::ChangeEvents() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + wxBookCtrlBase * const base = GetBase(); + + base->SetSelection(0); + + EventCounter count(base, GetChangingEvent()); + EventCounter count1(base, GetChangedEvent()); + + base->SetSelection(1); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent())); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent())); + + base->ChangeSelection(2); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangingEvent())); + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(GetChangedEvent())); + + base->AdvanceSelection(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent())); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent())); + + base->AdvanceSelection(false); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangingEvent())); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(GetChangedEvent())); +} + +void BookCtrlBaseTestCase::Image() +{ + wxBookCtrlBase * const base = GetBase(); + + //Check AddPanels() set things correctly + CPPUNIT_ASSERT_EQUAL(m_list, base->GetImageList()); + CPPUNIT_ASSERT_EQUAL(0, base->GetPageImage(0)); + CPPUNIT_ASSERT_EQUAL(1, base->GetPageImage(1)); + CPPUNIT_ASSERT_EQUAL(2, base->GetPageImage(2)); + + base->SetPageImage(0, 2); + + CPPUNIT_ASSERT_EQUAL(2, base->GetPageImage(2)); +} diff --git a/tests/controls/bookctrlbasetest.h b/tests/controls/bookctrlbasetest.h new file mode 100644 index 0000000000..b72a5b47c2 --- /dev/null +++ b/tests/controls/bookctrlbasetest.h @@ -0,0 +1,61 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/bookctrlbasetest.cpp +// Purpose: wxBookCtrlBase unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TESTS_CONTROLS_BOOKCTRLBASETEST_H_ +#define _WX_TESTS_CONTROLS_BOOKCTRLBASETEST_H_ + +class BookCtrlBaseTestCase +{ +public: + BookCtrlBaseTestCase() { } + virtual ~BookCtrlBaseTestCase() { } + +protected: + // this function must be overridden by the derived classes to return the + // text entry object we're testing, typically this is done by creating a + // control implementing wxBookCtrlBase interface in setUp() virtual method and + // just returning it from here + virtual wxBookCtrlBase *GetBase() const = 0; + + virtual wxEventType GetChangedEvent() const = 0; + + virtual wxEventType GetChangingEvent() const = 0; + + // this should be inserted in the derived class CPPUNIT_TEST_SUITE + // definition to run all wxBookCtrlBase tests as part of it + #define wxBOOK_CTRL_BASE_TESTS() \ + CPPUNIT_TEST( Selection ); \ + CPPUNIT_TEST( Text ); \ + CPPUNIT_TEST( PageManagement ); \ + CPPUNIT_TEST( ChangeEvents ) + + void Selection(); + void Text(); + void PageManagement(); + void ChangeEvents(); + + //You need to add CPPUNIT_TEST( Image ) specifically if you want it to be + //tested as only wxNotebook and wxTreebook support images correctly + void Image(); + + //Call this from the setUp function of a specific test to add panels to + //the ctrl. + void AddPanels(); + + wxPanel* m_panel1; + wxPanel* m_panel2; + wxPanel* m_panel3; + + wxImageList* m_list; + +private: + wxDECLARE_NO_COPY_CLASS(BookCtrlBaseTestCase); +}; + +#endif // _WX_TESTS_CONTROLS_BOOKCTRLBASETEST_H_ diff --git a/tests/controls/buttontest.cpp b/tests/controls/buttontest.cpp new file mode 100644 index 0000000000..bb540b2cfc --- /dev/null +++ b/tests/controls/buttontest.cpp @@ -0,0 +1,185 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/buttontest.cpp +// Purpose: wxButton unit test +// Author: Steven Lamerton +// Created: 2010-06-21 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_BUTTON + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/button.h" +#endif // WX_PRECOMP + +#include "testableframe.h" +#include "wx/uiaction.h" +#include "wx/artprov.h" +//For CPPUNIT_ASSERT_EQUAL to work a class must have a stream output function +//for those classes which do not have them by default we define them in +//asserthelper.h so they can be reused +#include "asserthelper.h" + +class ButtonTestCase : public CppUnit::TestCase +{ +public: + ButtonTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( ButtonTestCase ); + //We add tests that use wxUIActionSimulator with WXUISIM_TEST so they + //are not run on platofrms were wxUIActionSimulator isn't supported + WXUISIM_TEST( Click ); + WXUISIM_TEST( Disabled ); + CPPUNIT_TEST( Auth ); + CPPUNIT_TEST( BitmapMargins ); + CPPUNIT_TEST( Bitmap ); + CPPUNIT_TEST_SUITE_END(); + + void Click(); + void Disabled(); + void Auth(); + void BitmapMargins(); + void Bitmap(); + + wxButton* m_button; + + DECLARE_NO_COPY_CLASS(ButtonTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ButtonTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ButtonTestCase, "ButtonTestCase" ); + +void ButtonTestCase::setUp() +{ + //We use wxTheApp->GetTopWindow() as there is only a single testable frame + //so it will always be returned + m_button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY, "wxButton"); +} + +void ButtonTestCase::tearDown() +{ + wxDELETE(m_button); +} + +#if wxUSE_UIACTIONSIMULATOR + +void ButtonTestCase::Click() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + //We use the internal class EventCounter which handles connecting and + //disconnecting the control to the wxTestableFrame + EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED); + + wxUIActionSimulator sim; + + //We move in slightly to account for window decorations, we need to yield + //after every wxUIActionSimulator action to keep everything working in GTK + sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10)); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); +} + +void ButtonTestCase::Disabled() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED); + + wxUIActionSimulator sim; + + //In this test we disable the button and check events are not sent + m_button->Disable(); + + sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10)); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() ); +} + +#endif // wxUSE_UIACTIONSIMULATOR + +void ButtonTestCase::Auth() +{ + //Some functions only work on specific operating system versions, for + //this we need a runtime check + int major = 0; + + if(wxGetOsVersion(&major) != wxOS_WINDOWS_NT || major < 6) + return; + + //We are running Windows Vista or newer + CPPUNIT_ASSERT(!m_button->GetAuthNeeded()); + + m_button->SetAuthNeeded(); + + CPPUNIT_ASSERT(m_button->GetAuthNeeded()); + + //We test both states + m_button->SetAuthNeeded(false); + + CPPUNIT_ASSERT(!m_button->GetAuthNeeded()); +} + +void ButtonTestCase::BitmapMargins() +{ + //Some functions only work on specific platfroms in which case we can use + //a preprocessor check +#ifdef __WXMSW__ + //We must set a bitmap before we can set its margins, when writing unit + //tests it is easiest to use an image from wxArtProvider + m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, + wxSize(32, 32))); + + m_button->SetBitmapMargins(15, 15); + + CPPUNIT_ASSERT_EQUAL(wxSize(15, 15), m_button->GetBitmapMargins()); + + m_button->SetBitmapMargins(wxSize(20, 20)); + + CPPUNIT_ASSERT_EQUAL(wxSize(20, 20), m_button->GetBitmapMargins()); +#endif +} + +void ButtonTestCase::Bitmap() +{ +#if !defined(__WXGTK__) && !defined(__WXOSX__) + //We start with no bitmaps + CPPUNIT_ASSERT(!m_button->GetBitmap().IsOk()); + + //Set bitmap should set a bitmap for all states + m_button->SetBitmap(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, + wxSize(32, 32))); + + CPPUNIT_ASSERT(m_button->GetBitmapDisabled().IsOk()); + CPPUNIT_ASSERT(m_button->GetBitmapPressed().IsOk()); + CPPUNIT_ASSERT(m_button->GetBitmapCurrent().IsOk()); + CPPUNIT_ASSERT(m_button->GetBitmapFocus().IsOk()); +#endif +} + +#endif //wxUSE_BUTTON diff --git a/tests/controls/checkboxtest.cpp b/tests/controls/checkboxtest.cpp new file mode 100644 index 0000000000..1e1ba92cc7 --- /dev/null +++ b/tests/controls/checkboxtest.cpp @@ -0,0 +1,138 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/checkboxtest.cpp +// Purpose: wCheckBox unit test +// Author: Steven Lamerton +// Created: 2010-07-14 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_CHECKBOX + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/checkbox.h" +#endif // WX_PRECOMP + +#include "testableframe.h" + +class CheckBoxTestCase : public CppUnit::TestCase +{ +public: + CheckBoxTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( CheckBoxTestCase ); + CPPUNIT_TEST( Check ); + CPPUNIT_TEST( ThirdState ); + CPPUNIT_TEST( ThirdStateUser ); + CPPUNIT_TEST_SUITE_END(); + + void Check(); + void ThirdState(); + void ThirdStateUser(); + + wxCheckBox* m_check; + + DECLARE_NO_COPY_CLASS(CheckBoxTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( CheckBoxTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CheckBoxTestCase, "CheckBoxTestCase" ); + +void CheckBoxTestCase::setUp() +{ + m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box"); +} + +void CheckBoxTestCase::tearDown() +{ + delete m_check; +} + +void CheckBoxTestCase::Check() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_check, wxEVT_COMMAND_CHECKBOX_CLICKED); + + //We should be unchecked by default + CPPUNIT_ASSERT(!m_check->IsChecked()); + + m_check->SetValue(true); + + CPPUNIT_ASSERT(m_check->IsChecked()); + + m_check->SetValue(false); + + CPPUNIT_ASSERT(!m_check->IsChecked()); + + m_check->Set3StateValue(wxCHK_CHECKED); + + CPPUNIT_ASSERT(m_check->IsChecked()); + + m_check->Set3StateValue(wxCHK_UNCHECKED); + + CPPUNIT_ASSERT(!m_check->IsChecked()); + + //None of these should send events + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +} + +void CheckBoxTestCase::ThirdState() +{ +#if !defined(__WXMGL__) && !defined(__WXPM__) && !defined(__WXGTK12__) + wxDELETE(m_check); + m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box", + wxDefaultPosition, wxDefaultSize, wxCHK_3STATE); + + CPPUNIT_ASSERT_EQUAL(wxCHK_UNCHECKED, m_check->Get3StateValue()); + CPPUNIT_ASSERT(m_check->Is3State()); + CPPUNIT_ASSERT(!m_check->Is3rdStateAllowedForUser()); + + m_check->SetValue(true); + + CPPUNIT_ASSERT_EQUAL(wxCHK_CHECKED, m_check->Get3StateValue()); + + m_check->Set3StateValue(wxCHK_UNDETERMINED); + + CPPUNIT_ASSERT_EQUAL(wxCHK_UNDETERMINED, m_check->Get3StateValue()); +#endif +} + +void CheckBoxTestCase::ThirdStateUser() +{ +#if !defined(__WXMGL__) && !defined(__WXPM__) && !defined(__WXGTK12__) + wxDELETE(m_check); + m_check = new wxCheckBox(wxTheApp->GetTopWindow(), wxID_ANY, "Check box", + wxDefaultPosition, wxDefaultSize, + wxCHK_3STATE | wxCHK_ALLOW_3RD_STATE_FOR_USER); + + CPPUNIT_ASSERT_EQUAL(wxCHK_UNCHECKED, m_check->Get3StateValue()); + CPPUNIT_ASSERT(m_check->Is3State()); + CPPUNIT_ASSERT(m_check->Is3rdStateAllowedForUser()); + + m_check->SetValue(true); + + CPPUNIT_ASSERT_EQUAL(wxCHK_CHECKED, m_check->Get3StateValue()); + + m_check->Set3StateValue(wxCHK_UNDETERMINED); + + CPPUNIT_ASSERT_EQUAL(wxCHK_UNDETERMINED, m_check->Get3StateValue()); +#endif +} + +#endif //wxUSE_CHECKBOX diff --git a/tests/controls/checklistboxtest.cpp b/tests/controls/checklistboxtest.cpp new file mode 100644 index 0000000000..86f0348224 --- /dev/null +++ b/tests/controls/checklistboxtest.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/checklistlistbox.cpp +// Purpose: wxCheckListBox unit test +// Author: Steven Lamerton +// Created: 2010-06-30 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_CHECKLISTBOX + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/checklst.h" +#endif // WX_PRECOMP + +#include "itemcontainertest.h" +#include "testableframe.h" + +class CheckListBoxTestCase : public ItemContainerTestCase, public CppUnit::TestCase +{ +public: + CheckListBoxTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxItemContainer *GetContainer() const { return m_check; } + virtual wxWindow *GetContainerWindow() const { return m_check; } + + CPPUNIT_TEST_SUITE( CheckListBoxTestCase ); + wxITEM_CONTAINER_TESTS(); + CPPUNIT_TEST( Check ); + CPPUNIT_TEST_SUITE_END(); + + void Check(); + + wxCheckListBox* m_check; + + DECLARE_NO_COPY_CLASS(CheckListBoxTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( CheckListBoxTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( CheckListBoxTestCase, "CheckListBoxTestCase" ); + +void CheckListBoxTestCase::setUp() +{ + m_check = new wxCheckListBox(wxTheApp->GetTopWindow(), wxID_ANY); +} + +void CheckListBoxTestCase::tearDown() +{ + wxDELETE(m_check); +} + +void CheckListBoxTestCase::Check() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_check, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + testitems.Add("item 3"); + + m_check->Append(testitems); + + m_check->Check(0); + m_check->Check(1); + m_check->Check(1, false); + + //We should not get any events when changing this from code + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); + CPPUNIT_ASSERT_EQUAL(true, m_check->IsChecked(0)); + CPPUNIT_ASSERT_EQUAL(false, m_check->IsChecked(1)); + + //Make sure a double check of an items doesn't deselect it + m_check->Check(0); + + CPPUNIT_ASSERT_EQUAL(true, m_check->IsChecked(0)); +} + +#endif // wxUSE_CHECKLISTBOX diff --git a/tests/controls/choicebooktest.cpp b/tests/controls/choicebooktest.cpp new file mode 100644 index 0000000000..c61499a8aa --- /dev/null +++ b/tests/controls/choicebooktest.cpp @@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/choicebooktest.cpp +// Purpose: wxChoicebook unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_CHOICEBOOK + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/panel.h" +#endif // WX_PRECOMP + +#include "wx/choicebk.h" +#include "bookctrlbasetest.h" + +class ChoicebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase +{ +public: + ChoicebookTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxBookCtrlBase *GetBase() const { return m_choicebook; } + + virtual wxEventType GetChangedEvent() const + { return wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED; } + + virtual wxEventType GetChangingEvent() const + { return wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING; } + + CPPUNIT_TEST_SUITE( ChoicebookTestCase ); + wxBOOK_CTRL_BASE_TESTS(); + CPPUNIT_TEST( Choice ); + CPPUNIT_TEST_SUITE_END(); + + void Choice(); + + wxChoicebook *m_choicebook; + + DECLARE_NO_COPY_CLASS(ChoicebookTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ChoicebookTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoicebookTestCase, "ChoicebookTestCase" ); + +void ChoicebookTestCase::setUp() +{ + m_choicebook = new wxChoicebook(wxTheApp->GetTopWindow(), wxID_ANY); + AddPanels(); +} + +void ChoicebookTestCase::tearDown() +{ + wxDELETE(m_choicebook); +} + +void ChoicebookTestCase::Choice() +{ + wxChoice* choice = m_choicebook->GetChoiceCtrl(); + + CPPUNIT_ASSERT(choice); + CPPUNIT_ASSERT_EQUAL(3, choice->GetCount()); + CPPUNIT_ASSERT_EQUAL("Panel 1", choice->GetString(0)); +} + +#endif //wxUSE_CHOICEBOOK diff --git a/tests/controls/choicetest.cpp b/tests/controls/choicetest.cpp new file mode 100644 index 0000000000..846dc0d229 --- /dev/null +++ b/tests/controls/choicetest.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/choice.cpp +// Purpose: wxChoice unit test +// Author: Steven Lamerton +// Created: 2010-06-29 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_CHOICE + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/choice.h" +#endif // WX_PRECOMP + +#include "itemcontainertest.h" + +class ChoiceTestCase : public ItemContainerTestCase, public CppUnit::TestCase +{ +public: + ChoiceTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxItemContainer *GetContainer() const { return m_choice; } + virtual wxWindow *GetContainerWindow() const { return m_choice; } + + CPPUNIT_TEST_SUITE( ChoiceTestCase ); + wxITEM_CONTAINER_TESTS(); + CPPUNIT_TEST( Sort ); + CPPUNIT_TEST_SUITE_END(); + + void Sort(); + + wxChoice* m_choice; + + DECLARE_NO_COPY_CLASS(ChoiceTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ChoiceTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ChoiceTestCase, "ChoiceTestCase" ); + +void ChoiceTestCase::setUp() +{ + m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY); +} + +void ChoiceTestCase::tearDown() +{ + wxDELETE(m_choice); +} + +void ChoiceTestCase::Sort() +{ +#if !defined(__WXGTK__) && !defined(__WXOSX__) + wxDELETE(m_choice); + m_choice = new wxChoice(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, 0, 0, + wxCB_SORT); + + wxArrayString testitems; + testitems.Add("aaa"); + testitems.Add("Aaa"); + testitems.Add("aba"); + testitems.Add("aaab"); + testitems.Add("aab"); + testitems.Add("AAA"); + + m_choice->Append(testitems); + + CPPUNIT_ASSERT_EQUAL("AAA", m_choice->GetString(0)); + CPPUNIT_ASSERT_EQUAL("Aaa", m_choice->GetString(1)); + CPPUNIT_ASSERT_EQUAL("aaa", m_choice->GetString(2)); + CPPUNIT_ASSERT_EQUAL("aaab", m_choice->GetString(3)); + CPPUNIT_ASSERT_EQUAL("aab", m_choice->GetString(4)); + CPPUNIT_ASSERT_EQUAL("aba", m_choice->GetString(5)); + + m_choice->Append("a"); + + CPPUNIT_ASSERT_EQUAL("a", m_choice->GetString(0)); +#endif +} + +#endif //wxUSE_CHOICE diff --git a/tests/controls/comboboxtest.cpp b/tests/controls/comboboxtest.cpp index 512c1e12c1..65e4161835 100644 --- a/tests/controls/comboboxtest.cpp +++ b/tests/controls/comboboxtest.cpp @@ -13,6 +13,8 @@ #include "testprec.h" +#if wxUSE_COMBOBOX + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -23,12 +25,15 @@ #endif // WX_PRECOMP #include "textentrytest.h" +#include "itemcontainertest.h" +#include "testableframe.h" // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- -class ComboBoxTestCase : public TextEntryTestCase +class ComboBoxTestCase : public TextEntryTestCase, public ItemContainerTestCase, + public CppUnit::TestCase { public: ComboBoxTestCase() { } @@ -40,6 +45,9 @@ private: virtual wxTextEntry *GetTestEntry() const { return m_combo; } virtual wxWindow *GetTestWindow() const { return m_combo; } + virtual wxItemContainer *GetContainer() const { return m_combo; } + virtual wxWindow *GetContainerWindow() const { return m_combo; } + virtual void CheckStringSelection(const char * WXUNUSED(sel)) { // do nothing here, as explained in TextEntryTestCase comment, our @@ -49,11 +57,17 @@ private: CPPUNIT_TEST_SUITE( ComboBoxTestCase ); wxTEXT_ENTRY_TESTS(); - + wxITEM_CONTAINER_TESTS(); CPPUNIT_TEST( Size ); + CPPUNIT_TEST( PopDismiss ); + CPPUNIT_TEST( Sort ); + CPPUNIT_TEST( ReadOnly ); CPPUNIT_TEST_SUITE_END(); void Size(); + void PopDismiss(); + void Sort(); + void ReadOnly(); wxComboBox *m_combo; @@ -110,3 +124,74 @@ void ComboBoxTestCase::Size() CPPUNIT_ASSERT_EQUAL( heightOrig, m_combo->GetSize().y ); } +void ComboBoxTestCase::PopDismiss() +{ +#if defined(__WXMSW__) || defined(__WXGTK210__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_combo, wxEVT_COMMAND_COMBOBOX_DROPDOWN); + EventCounter count1(m_combo, wxEVT_COMMAND_COMBOBOX_CLOSEUP); + + m_combo->Popup(); + m_combo->Dismiss(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_DROPDOWN)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_COMBOBOX_CLOSEUP)); +#endif +} + +void ComboBoxTestCase::Sort() +{ +#if !defined(__WXGTK__) && !defined(__WXOSX__) + m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, 0, NULL, + wxCB_SORT); + + m_combo->Append("aaa"); + m_combo->Append("Aaa"); + m_combo->Append("aba"); + m_combo->Append("aaab"); + m_combo->Append("aab"); + m_combo->Append("AAA"); + + CPPUNIT_ASSERT_EQUAL("AAA", m_combo->GetString(0)); + CPPUNIT_ASSERT_EQUAL("Aaa", m_combo->GetString(1)); + CPPUNIT_ASSERT_EQUAL("aaa", m_combo->GetString(2)); + CPPUNIT_ASSERT_EQUAL("aaab", m_combo->GetString(3)); + CPPUNIT_ASSERT_EQUAL("aab", m_combo->GetString(4)); + CPPUNIT_ASSERT_EQUAL("aba", m_combo->GetString(5)); + + m_combo->Append("a"); + + CPPUNIT_ASSERT_EQUAL("a", m_combo->GetString(0)); +#endif +} + +void ComboBoxTestCase::ReadOnly() +{ +#ifndef __WXOSX__ + wxArrayString testitems; + testitems.Add("item 1"); + testitems.Add("item 2"); + + m_combo = new wxComboBox(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, testitems, + wxCB_READONLY); + + m_combo->SetValue("item 1"); + + CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue()); + + m_combo->SetValue("not an item"); + + CPPUNIT_ASSERT_EQUAL("item 1", m_combo->GetValue()); + + // Since this uses FindString it is case insensitive + m_combo->SetValue("ITEM 2"); + + CPPUNIT_ASSERT_EQUAL("item 2", m_combo->GetValue()); +#endif +} + +#endif //wxUSE_COMBOBOX diff --git a/tests/controls/frametest.cpp b/tests/controls/frametest.cpp new file mode 100644 index 0000000000..0cce6e3040 --- /dev/null +++ b/tests/controls/frametest.cpp @@ -0,0 +1,87 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/frametest.cpp +// Purpose: wxFrame unit test +// Author: Steven Lamerton +// Created: 2010-07-10 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/frame.h" +#endif // WX_PRECOMP + +#include "testableframe.h" + +class FrameTestCase : public CppUnit::TestCase +{ +public: + FrameTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( FrameTestCase ); + CPPUNIT_TEST( Iconize ); + CPPUNIT_TEST( Close ); + CPPUNIT_TEST_SUITE_END(); + + void Iconize(); + void Close(); + + wxFrame *m_frame; + + DECLARE_NO_COPY_CLASS(FrameTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( FrameTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FrameTestCase, "FrameTestCase" ); + +void FrameTestCase::setUp() +{ + m_frame = new wxFrame(NULL, wxID_ANY, "test frame"); + m_frame->Show(); +} + +void FrameTestCase::tearDown() +{ + wxDELETE(m_frame); +} + +void FrameTestCase::Iconize() +{ +#ifdef __WXMSW__ + wxTestableFrame* testframe = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_frame, wxEVT_ICONIZE); + + m_frame->Iconize(); + m_frame->Iconize(false); + + CPPUNIT_ASSERT_EQUAL(2, testframe->GetEventCount()); +#endif +} + +void FrameTestCase::Close() +{ + wxTestableFrame* testframe = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_frame, wxEVT_CLOSE_WINDOW); + + m_frame->Close(); + + CPPUNIT_ASSERT_EQUAL(1, testframe->GetEventCount()); +} diff --git a/tests/controls/gaugetest.cpp b/tests/controls/gaugetest.cpp new file mode 100644 index 0000000000..f112e6c47d --- /dev/null +++ b/tests/controls/gaugetest.cpp @@ -0,0 +1,111 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/gaugetest.cpp +// Purpose: wxGauge unit test +// Author: Steven Lamerton +// Created: 2010-07-15 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_GAUGE + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/gauge.h" +#endif // WX_PRECOMP + +class GaugeTestCase : public CppUnit::TestCase +{ +public: + GaugeTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( GaugeTestCase ); + CPPUNIT_TEST( Direction ); + CPPUNIT_TEST( Range ); + CPPUNIT_TEST( Value ); + CPPUNIT_TEST_SUITE_END(); + + void Direction(); + void Range(); + void Value(); + + wxGauge* m_gauge; + + DECLARE_NO_COPY_CLASS(GaugeTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( GaugeTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GaugeTestCase, "GaugeTestCase" ); + +void GaugeTestCase::setUp() +{ + m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100); +} + +void GaugeTestCase::tearDown() +{ + wxTheApp->GetTopWindow()->DestroyChildren(); +} + +void GaugeTestCase::Direction() +{ + //We should default to a horizontal gauge + CPPUNIT_ASSERT(!m_gauge->IsVertical()); + + wxDELETE(m_gauge); + m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100, + wxDefaultPosition, wxDefaultSize, wxGA_VERTICAL); + + CPPUNIT_ASSERT(m_gauge->IsVertical()); + + wxDELETE(m_gauge); + m_gauge = new wxGauge(wxTheApp->GetTopWindow(), wxID_ANY, 100, + wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL); + + CPPUNIT_ASSERT(!m_gauge->IsVertical()); +} + +void GaugeTestCase::Range() +{ + CPPUNIT_ASSERT_EQUAL(100, m_gauge->GetRange()); + + m_gauge->SetRange(50); + + CPPUNIT_ASSERT_EQUAL(50, m_gauge->GetRange()); + + m_gauge->SetRange(0); + + CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetRange()); +} + +void GaugeTestCase::Value() +{ + CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetValue()); + + m_gauge->SetValue(50); + + CPPUNIT_ASSERT_EQUAL(50, m_gauge->GetValue()); + + m_gauge->SetValue(0); + + CPPUNIT_ASSERT_EQUAL(0, m_gauge->GetValue()); + + m_gauge->SetValue(100); + + CPPUNIT_ASSERT_EQUAL(100, m_gauge->GetValue()); +} + +#endif //wxUSE_GAUGE diff --git a/tests/controls/gridtest.cpp b/tests/controls/gridtest.cpp new file mode 100644 index 0000000000..fca5d58340 --- /dev/null +++ b/tests/controls/gridtest.cpp @@ -0,0 +1,738 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/gridtest.cpp +// Purpose: wxGrid unit test +// Author: Steven Lamerton +// Created: 2010-06-25 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_GRID + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/grid.h" +#include "testableframe.h" +#include "asserthelper.h" +#include "wx/uiaction.h" + +class GridTestCase : public CppUnit::TestCase +{ +public: + GridTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + CPPUNIT_TEST_SUITE( GridTestCase ); + WXUISIM_TEST( CellEdit ); + WXUISIM_TEST( CellClick ); + WXUISIM_TEST( CellSelect ); + WXUISIM_TEST( LabelClick ); + WXUISIM_TEST( SortClick ); + WXUISIM_TEST( Size ); + WXUISIM_TEST( RangeSelect ); + CPPUNIT_TEST( Cursor ); + CPPUNIT_TEST( Selection ); + CPPUNIT_TEST( AddRowCol ); + CPPUNIT_TEST( ColumnOrder ); + CPPUNIT_TEST( LineFormatting ); + CPPUNIT_TEST( SortSupport ); + CPPUNIT_TEST( Labels ); + CPPUNIT_TEST( SelectionMode ); + CPPUNIT_TEST( CellFormatting ); + WXUISIM_TEST( Editable ); + WXUISIM_TEST( ReadOnly ); + CPPUNIT_TEST( PseudoTest_NativeHeader ); + WXUISIM_TEST( LabelClick ); + WXUISIM_TEST( SortClick ); + CPPUNIT_TEST( ColumnOrder ); + CPPUNIT_TEST( PseudoTest_NativeLabels ); + WXUISIM_TEST( LabelClick ); + WXUISIM_TEST( SortClick ); + CPPUNIT_TEST( ColumnOrder ); + CPPUNIT_TEST_SUITE_END(); + + void CellEdit(); + void CellClick(); + void CellSelect(); + void LabelClick(); + void SortClick(); + void Size(); + void RangeSelect(); + void Cursor(); + void Selection(); + void AddRowCol(); + void ColumnOrder(); + void LineFormatting(); + void SortSupport(); + void Labels(); + void SelectionMode(); + void CellFormatting(); + void Editable(); + void ReadOnly(); + void PseudoTest_NativeHeader() { ms_nativeheader = true; } + void PseudoTest_NativeLabels() { ms_nativeheader = false; + ms_nativelabels = true; } + + static bool ms_nativeheader; + static bool ms_nativelabels; + + wxGrid *m_grid; + + DECLARE_NO_COPY_CLASS(GridTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( GridTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GridTestCase, "GridTestCase" ); + +//initialise the static variable +bool GridTestCase::ms_nativeheader = false; +bool GridTestCase::ms_nativelabels = false; + +void GridTestCase::setUp() +{ + m_grid = new wxGrid(wxTheApp->GetTopWindow(), wxID_ANY); + m_grid->CreateGrid(10, 2); + m_grid->SetSize(400, 200); + + if( ms_nativeheader ) + m_grid->UseNativeColHeader(); + + if( ms_nativelabels ) + m_grid->SetUseNativeColLabels(); + + m_grid->Refresh(); + m_grid->Update(); +} + +void GridTestCase::tearDown() +{ + wxDELETE(m_grid); +} + +void GridTestCase::CellEdit() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_CELL_CHANGING); + EventCounter count1(m_grid, wxEVT_GRID_CELL_CHANGED); + EventCounter count2(m_grid, wxEVT_GRID_EDITOR_CREATED); + + wxUIActionSimulator sim; + + m_grid->SetFocus(); + m_grid->SetGridCursor(1, 1); + m_grid->ShowCellEditControl(); + + sim.Text("abab"); + sim.Char(WXK_RETURN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_EDITOR_CREATED)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_CHANGING)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_CHANGED)); +#endif +} + +void GridTestCase::CellClick() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_CELL_LEFT_CLICK); + EventCounter count1(m_grid, wxEVT_GRID_CELL_LEFT_DCLICK); + EventCounter count2(m_grid, wxEVT_GRID_CELL_RIGHT_CLICK); + EventCounter count3(m_grid, wxEVT_GRID_CELL_RIGHT_DCLICK); + + + wxUIActionSimulator sim; + + wxRect rect = m_grid->CellToRect(0, 0); + wxPoint point = m_grid->CalcScrolledPosition(rect.GetPosition()); + point = frame->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(), + m_grid->GetColLabelSize()) + + wxPoint(2, 2)); + + sim.MouseMove(point); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_LEFT_CLICK)); + + sim.MouseDblClick(); + wxYield(); + + //A double click event sends a single click event first + //test to ensure this still happens in the future + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_LEFT_CLICK)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_LEFT_DCLICK)); + + sim.MouseClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_RIGHT_CLICK)); + + sim.MouseDblClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_RIGHT_CLICK)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_CELL_RIGHT_DCLICK)); +#endif +} + +void GridTestCase::CellSelect() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_SELECT_CELL); + + wxUIActionSimulator sim; + + wxRect rect = m_grid->CellToRect(0, 0); + wxPoint point = m_grid->CalcScrolledPosition(rect.GetPosition()); + point = frame->ClientToScreen(point + wxPoint(m_grid->GetRowLabelSize(), + m_grid->GetColLabelSize()) + + wxPoint(4, 4)); + + sim.MouseMove(point); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_SELECT_CELL)); + + m_grid->SetGridCursor(1, 1); + m_grid->GoToCell(1, 0); + + sim.MouseMove(point); + wxYield(); + + sim.MouseDblClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(3, frame->GetEventCount(wxEVT_GRID_SELECT_CELL)); +#endif +} + +void GridTestCase::LabelClick() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_LABEL_LEFT_CLICK); + EventCounter count1(m_grid, wxEVT_GRID_LABEL_LEFT_DCLICK); + EventCounter count2(m_grid, wxEVT_GRID_LABEL_RIGHT_CLICK); + EventCounter count3(m_grid, wxEVT_GRID_LABEL_RIGHT_DCLICK); + + wxUIActionSimulator sim; + + wxPoint pos(m_grid->GetRowLabelSize() + 2, 2); + pos = m_grid->ClientToScreen(pos); + + sim.MouseMove(pos); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_LEFT_CLICK)); + + sim.MouseDblClick(); + wxYield(); + + //A double click event sends a single click event first + //test to ensure this still happens in the future + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_LEFT_CLICK)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_LEFT_DCLICK)); + + sim.MouseClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK)); + + sim.MouseDblClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + if( ms_nativeheader ) + { + //Right double click not supported with native headers so we get two + //right click events + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK)); + } + else + { + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_LABEL_RIGHT_DCLICK)); + } +#endif +} + +void GridTestCase::SortClick() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + m_grid->SetSortingColumn(0); + + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_COL_SORT); + + wxUIActionSimulator sim; + + wxPoint pos(m_grid->GetRowLabelSize() + 4, 4); + pos = m_grid->ClientToScreen(pos); + + sim.MouseMove(pos); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + + m_grid->SetSortingColumn(wxNOT_FOUND); +#endif +} + +void GridTestCase::Size() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_COL_SIZE); + EventCounter count1(m_grid, wxEVT_GRID_ROW_SIZE); + + wxUIActionSimulator sim; + + wxPoint pt = m_grid->ClientToScreen(wxPoint(m_grid->GetRowLabelSize() + + m_grid->GetColSize(0), 5)); + + sim.MouseMove(pt); + wxYield(); + + sim.MouseDown(); + wxYield(); + + sim.MouseMove(pt.x + 50, pt.y); + wxYield(); + + sim.MouseUp(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_COL_SIZE)); + + pt = m_grid->ClientToScreen(wxPoint(5, m_grid->GetColLabelSize() + + m_grid->GetRowSize(0))); + + sim.MouseDragDrop(pt.x, pt.y, pt.x, pt.y + 50); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_ROW_SIZE)); +#endif +} + +void GridTestCase::RangeSelect() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_grid, wxEVT_GRID_RANGE_SELECT); + + wxUIActionSimulator sim; + + //We add the extra 10 to ensure that we are inside the cell + wxPoint pt = m_grid->ClientToScreen(wxPoint(m_grid->GetRowLabelSize() + 10, + m_grid->GetColLabelSize() + 10) + ); + + sim.MouseMove(pt); + wxYield(); + + sim.MouseDown(); + wxYield(); + + sim.MouseMove(pt.x + 50, pt.y + 50); + wxYield(); + + sim.MouseUp(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_GRID_RANGE_SELECT)); +#endif +} + +void GridTestCase::Cursor() +{ + m_grid->SetGridCursor(1, 1); + + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetGridCursorCol()); + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetGridCursorRow()); + + m_grid->MoveCursorDown(false); + m_grid->MoveCursorLeft(false); + m_grid->MoveCursorUp(false); + m_grid->MoveCursorUp(false); + m_grid->MoveCursorRight(false); + + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetGridCursorCol()); + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetGridCursorRow()); + + m_grid->SetCellValue(0, 0, "some text"); + m_grid->SetCellValue(3, 0, "other text"); + m_grid->SetCellValue(0, 1, "more text"); + m_grid->SetCellValue(3, 1, "extra text"); + + m_grid->Update(); + m_grid->Refresh(); + + m_grid->MoveCursorLeftBlock(false); + + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetGridCursorCol()); + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetGridCursorRow()); + + m_grid->MoveCursorDownBlock(false); + + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetGridCursorCol()); + CPPUNIT_ASSERT_EQUAL(3, m_grid->GetGridCursorRow()); + + m_grid->MoveCursorRightBlock(false); + + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetGridCursorCol()); + CPPUNIT_ASSERT_EQUAL(3, m_grid->GetGridCursorRow()); + + m_grid->MoveCursorUpBlock(false); + + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetGridCursorCol()); + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetGridCursorRow()); +} + +void GridTestCase::Selection() +{ + m_grid->SelectAll(); + + CPPUNIT_ASSERT(m_grid->IsSelection()); + CPPUNIT_ASSERT(m_grid->IsInSelection(0, 0)); + CPPUNIT_ASSERT(m_grid->IsInSelection(9, 1)); + + m_grid->SelectBlock(1, 0, 3, 1); + + wxGridCellCoordsArray topleft = m_grid->GetSelectionBlockTopLeft(); + wxGridCellCoordsArray bottomright = m_grid->GetSelectionBlockBottomRight(); + + CPPUNIT_ASSERT_EQUAL(1, topleft.Count()); + CPPUNIT_ASSERT_EQUAL(1, bottomright.Count()); + + CPPUNIT_ASSERT_EQUAL(0, topleft.Item(0).GetCol()); + CPPUNIT_ASSERT_EQUAL(1, topleft.Item(0).GetRow()); + CPPUNIT_ASSERT_EQUAL(1, bottomright.Item(0).GetCol()); + CPPUNIT_ASSERT_EQUAL(3, bottomright.Item(0).GetRow()); + + m_grid->SelectCol(1); + + CPPUNIT_ASSERT(m_grid->IsInSelection(0, 1)); + CPPUNIT_ASSERT(m_grid->IsInSelection(9, 1)); + CPPUNIT_ASSERT(!m_grid->IsInSelection(3, 0)); + + m_grid->SelectRow(4); + + CPPUNIT_ASSERT(m_grid->IsInSelection(4, 0)); + CPPUNIT_ASSERT(m_grid->IsInSelection(4, 1)); + CPPUNIT_ASSERT(!m_grid->IsInSelection(3, 0)); +} + +void GridTestCase::AddRowCol() +{ + CPPUNIT_ASSERT_EQUAL(10, m_grid->GetNumberRows()); + CPPUNIT_ASSERT_EQUAL(2, m_grid->GetNumberCols()); + + m_grid->AppendCols(); + m_grid->AppendRows(); + + CPPUNIT_ASSERT_EQUAL(11, m_grid->GetNumberRows()); + CPPUNIT_ASSERT_EQUAL(3, m_grid->GetNumberCols()); + + m_grid->AppendCols(2); + m_grid->AppendRows(2); + + CPPUNIT_ASSERT_EQUAL(13, m_grid->GetNumberRows()); + CPPUNIT_ASSERT_EQUAL(5, m_grid->GetNumberCols()); + + m_grid->InsertCols(1, 2); + m_grid->InsertRows(2, 3); + + CPPUNIT_ASSERT_EQUAL(16, m_grid->GetNumberRows()); + CPPUNIT_ASSERT_EQUAL(7, m_grid->GetNumberCols()); +} + +void GridTestCase::ColumnOrder() +{ + m_grid->AppendCols(2); + + CPPUNIT_ASSERT_EQUAL(4, m_grid->GetNumberCols()); + + wxArrayInt neworder; + neworder.push_back(1); + neworder.push_back(3); + neworder.push_back(2); + neworder.push_back(0); + + m_grid->SetColumnsOrder(neworder); + + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetColPos(1)); + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetColPos(3)); + CPPUNIT_ASSERT_EQUAL(2, m_grid->GetColPos(2)); + CPPUNIT_ASSERT_EQUAL(3, m_grid->GetColPos(0)); + + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetColAt(0)); + CPPUNIT_ASSERT_EQUAL(3, m_grid->GetColAt(1)); + CPPUNIT_ASSERT_EQUAL(2, m_grid->GetColAt(2)); + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetColAt(3)); + + m_grid->ResetColPos(); + + CPPUNIT_ASSERT_EQUAL(0, m_grid->GetColPos(0)); + CPPUNIT_ASSERT_EQUAL(1, m_grid->GetColPos(1)); + CPPUNIT_ASSERT_EQUAL(2, m_grid->GetColPos(2)); + CPPUNIT_ASSERT_EQUAL(3, m_grid->GetColPos(3)); +} + +void GridTestCase::LineFormatting() +{ + CPPUNIT_ASSERT(m_grid->GridLinesEnabled()); + + m_grid->EnableGridLines(false); + + CPPUNIT_ASSERT(!m_grid->GridLinesEnabled()); + + m_grid->EnableGridLines(); + + m_grid->SetGridLineColour(*wxRED); + + CPPUNIT_ASSERT_EQUAL(m_grid->GetGridLineColour(), *wxRED); +} + +void GridTestCase::SortSupport() +{ + CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, m_grid->GetSortingColumn()); + + m_grid->SetSortingColumn(1); + + CPPUNIT_ASSERT(!m_grid->IsSortingBy(0)); + CPPUNIT_ASSERT(m_grid->IsSortingBy(1)); + CPPUNIT_ASSERT(m_grid->IsSortOrderAscending()); + + m_grid->SetSortingColumn(0, false); + + CPPUNIT_ASSERT(m_grid->IsSortingBy(0)); + CPPUNIT_ASSERT(!m_grid->IsSortingBy(1)); + CPPUNIT_ASSERT(!m_grid->IsSortOrderAscending()); + + m_grid->UnsetSortingColumn(); + + CPPUNIT_ASSERT(!m_grid->IsSortingBy(0)); + CPPUNIT_ASSERT(!m_grid->IsSortingBy(1)); +} + +void GridTestCase::Labels() +{ + CPPUNIT_ASSERT_EQUAL("A", m_grid->GetColLabelValue(0)); + CPPUNIT_ASSERT_EQUAL("1", m_grid->GetRowLabelValue(0)); + + m_grid->SetColLabelValue(0, "Column 1"); + m_grid->SetRowLabelValue(0, "Row 1"); + + CPPUNIT_ASSERT_EQUAL("Column 1", m_grid->GetColLabelValue(0)); + CPPUNIT_ASSERT_EQUAL("Row 1", m_grid->GetRowLabelValue(0)); + + m_grid->SetLabelTextColour(*wxGREEN); + m_grid->SetLabelBackgroundColour(*wxRED); + + CPPUNIT_ASSERT_EQUAL(*wxGREEN, m_grid->GetLabelTextColour()); + CPPUNIT_ASSERT_EQUAL(*wxRED, m_grid->GetLabelBackgroundColour()); + + m_grid->SetColLabelTextOrientation(wxVERTICAL); + + CPPUNIT_ASSERT_EQUAL(static_cast(wxVERTICAL), + static_cast(m_grid->GetColLabelTextOrientation())); +} + +void GridTestCase::SelectionMode() +{ + //We already test this mode in Select + CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectCells, + m_grid->GetSelectionMode()); + + //Test row selection be selecting a single cell and checking the whole + //row is selected + m_grid->SetSelectionMode(wxGrid::wxGridSelectRows); + m_grid->SelectBlock(3, 1, 3, 1); + + wxGridCellCoordsArray topleft = m_grid->GetSelectionBlockTopLeft(); + wxGridCellCoordsArray bottomright = m_grid->GetSelectionBlockBottomRight(); + + CPPUNIT_ASSERT_EQUAL(1, topleft.Count()); + CPPUNIT_ASSERT_EQUAL(1, bottomright.Count()); + + CPPUNIT_ASSERT_EQUAL(0, topleft.Item(0).GetCol()); + CPPUNIT_ASSERT_EQUAL(3, topleft.Item(0).GetRow()); + CPPUNIT_ASSERT_EQUAL(1, bottomright.Item(0).GetCol()); + CPPUNIT_ASSERT_EQUAL(3, bottomright.Item(0).GetRow()); + + CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectRows, + m_grid->GetSelectionMode()); + + + //Test column selection be selecting a single cell and checking the whole + //column is selected + m_grid->SetSelectionMode(wxGrid::wxGridSelectColumns); + m_grid->SelectBlock(3, 1, 3, 1); + + topleft = m_grid->GetSelectionBlockTopLeft(); + bottomright = m_grid->GetSelectionBlockBottomRight(); + + CPPUNIT_ASSERT_EQUAL(1, topleft.Count()); + CPPUNIT_ASSERT_EQUAL(1, bottomright.Count()); + + CPPUNIT_ASSERT_EQUAL(1, topleft.Item(0).GetCol()); + CPPUNIT_ASSERT_EQUAL(0, topleft.Item(0).GetRow()); + CPPUNIT_ASSERT_EQUAL(1, bottomright.Item(0).GetCol()); + CPPUNIT_ASSERT_EQUAL(9, bottomright.Item(0).GetRow()); + + CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectColumns, + m_grid->GetSelectionMode()); +} + +void GridTestCase::CellFormatting() +{ + //Check that initial alignment is default + int horiz, cellhoriz, vert, cellvert; + + m_grid->GetDefaultCellAlignment(&horiz, &vert); + m_grid->GetCellAlignment(0, 0, &cellhoriz, &cellvert); + + CPPUNIT_ASSERT_EQUAL(cellhoriz, horiz); + CPPUNIT_ASSERT_EQUAL(cellvert, vert); + + //Check initial text colour and background colour are default + wxColour text, back; + + back = m_grid->GetDefaultCellBackgroundColour(); + + CPPUNIT_ASSERT_EQUAL(back, m_grid->GetCellBackgroundColour(0, 0)); + + back = m_grid->GetDefaultCellTextColour(); + + CPPUNIT_ASSERT_EQUAL(back, m_grid->GetCellTextColour(0, 0)); + + m_grid->SetCellAlignment(wxALIGN_CENTRE, 0, 0); + m_grid->GetCellAlignment(0, 0, &cellhoriz, &cellvert); + + CPPUNIT_ASSERT_EQUAL(static_cast(wxALIGN_CENTRE), cellhoriz); + CPPUNIT_ASSERT_EQUAL(static_cast(wxALIGN_CENTRE), cellvert); + + m_grid->SetCellAlignment(0, 0, wxALIGN_LEFT, wxALIGN_BOTTOM); + m_grid->GetCellAlignment(0, 0, &cellhoriz, &cellvert); + + CPPUNIT_ASSERT_EQUAL(static_cast(wxALIGN_LEFT), cellhoriz); + CPPUNIT_ASSERT_EQUAL(static_cast(wxALIGN_BOTTOM), cellvert); + + m_grid->SetCellTextColour(*wxRED, 0, 0); + + CPPUNIT_ASSERT_EQUAL(*wxRED, m_grid->GetCellTextColour(0, 0)); + + m_grid->SetCellTextColour(0, 0, *wxGREEN); + + CPPUNIT_ASSERT_EQUAL(*wxGREEN, m_grid->GetCellTextColour(0, 0)); +} + +void GridTestCase::Editable() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + //As the grid is not editable we shouldn't create an editor + EventCounter count(m_grid, wxEVT_GRID_EDITOR_CREATED); + + wxUIActionSimulator sim; + + CPPUNIT_ASSERT(m_grid->IsEditable()); + + m_grid->EnableEditing(false); + + CPPUNIT_ASSERT(!m_grid->IsEditable()); + + m_grid->SetFocus(); + m_grid->SetGridCursor(1, 1); + m_grid->ShowCellEditControl(); + + sim.Text("abab"); + wxYield(); + + sim.Char(WXK_RETURN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +#endif +} + +void GridTestCase::ReadOnly() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + //As the cell is readonly we shouldn't create an editor + EventCounter count(m_grid, wxEVT_GRID_EDITOR_CREATED); + + wxUIActionSimulator sim; + + CPPUNIT_ASSERT(!m_grid->IsReadOnly(1, 1)); + + m_grid->SetReadOnly(1, 1); + + CPPUNIT_ASSERT(m_grid->IsReadOnly(1, 1)); + + m_grid->SetFocus(); + m_grid->SetGridCursor(1, 1); + + CPPUNIT_ASSERT(m_grid->IsCurrentCellReadOnly()); + + m_grid->ShowCellEditControl(); + + sim.Text("abab"); + wxYield(); + + sim.Char(WXK_RETURN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +#endif +} + +#endif //wxUSE_GRID diff --git a/tests/controls/hyperlinkctrltest.cpp b/tests/controls/hyperlinkctrltest.cpp new file mode 100644 index 0000000000..2d5fda3577 --- /dev/null +++ b/tests/controls/hyperlinkctrltest.cpp @@ -0,0 +1,114 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/hyperlinkctrltest.cpp +// Purpose: wxHyperlinkCtrl unit test +// Author: Steven Lamerton +// Created: 2010-08-05 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_HYPERLINKCTRL + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/hyperlink.h" +#include "wx/uiaction.h" +#include "testableframe.h" +#include "asserthelper.h" + +class HyperlinkCtrlTestCase : public CppUnit::TestCase +{ +public: + HyperlinkCtrlTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( HyperlinkCtrlTestCase ); + CPPUNIT_TEST( Colour ); + CPPUNIT_TEST( Url ); + WXUISIM_TEST( Click ); + CPPUNIT_TEST_SUITE_END(); + + void Colour(); + void Url(); + void Click(); + + wxHyperlinkCtrl* m_hyperlink; + + DECLARE_NO_COPY_CLASS(HyperlinkCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( HyperlinkCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HyperlinkCtrlTestCase, "HyperlinkCtrlTestCase" ); + +void HyperlinkCtrlTestCase::setUp() +{ + m_hyperlink = new wxHyperlinkCtrl(wxTheApp->GetTopWindow(), wxID_ANY, + "wxWidgets", "http://wxwidgets.org"); +} + +void HyperlinkCtrlTestCase::tearDown() +{ + wxDELETE(m_hyperlink); +} + +void HyperlinkCtrlTestCase::Colour() +{ +#ifndef __WXGTK__ + CPPUNIT_ASSERT(m_hyperlink->GetHoverColour().IsOk()); + CPPUNIT_ASSERT(m_hyperlink->GetNormalColour().IsOk()); + CPPUNIT_ASSERT(m_hyperlink->GetVisitedColour().IsOk()); + + m_hyperlink->SetHoverColour(*wxGREEN); + m_hyperlink->SetNormalColour(*wxRED); + m_hyperlink->SetVisitedColour(*wxBLUE); + + CPPUNIT_ASSERT_EQUAL(*wxGREEN, m_hyperlink->GetHoverColour()); + CPPUNIT_ASSERT_EQUAL(*wxRED, m_hyperlink->GetNormalColour()); + CPPUNIT_ASSERT_EQUAL(*wxBLUE, m_hyperlink->GetVisitedColour()); +#endif +} + +void HyperlinkCtrlTestCase::Url() +{ + CPPUNIT_ASSERT_EQUAL("http://wxwidgets.org", m_hyperlink->GetURL()); + + m_hyperlink->SetURL("http://google.com"); + + CPPUNIT_ASSERT_EQUAL("http://google.com", m_hyperlink->GetURL()); +} + +void HyperlinkCtrlTestCase::Click() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_hyperlink, wxEVT_COMMAND_HYPERLINK); + + wxUIActionSimulator sim; + + sim.MouseMove(m_hyperlink->GetScreenPosition() + wxPoint(10, 10)); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +#endif +} + +#endif //wxUSE_HYPERLINKCTRL diff --git a/tests/controls/itemcontainertest.cpp b/tests/controls/itemcontainertest.cpp new file mode 100644 index 0000000000..b405e64a69 --- /dev/null +++ b/tests/controls/itemcontainertest.cpp @@ -0,0 +1,245 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/itemcontainertest.cpp +// Purpose: wxItemContainer unit test +// Author: Steven Lamerton +// Created: 2010-06-29 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/ctrlsub.h" +#endif // WX_PRECOMP + +#include "itemcontainertest.h" + +void ItemContainerTestCase::Append() +{ + wxItemContainer * const container = GetContainer(); + + container->Append("item 0"); + + CPPUNIT_ASSERT_EQUAL("item 0", container->GetString(0)); + + wxArrayString testitems; + testitems.Add("item 1"); + testitems.Add("item 2"); + + container->Append(testitems); + + CPPUNIT_ASSERT_EQUAL("item 1", container->GetString(1)); + CPPUNIT_ASSERT_EQUAL("item 2", container->GetString(2)); + + wxString arritems[] = { "item 3", "item 4" }; + + container->Append(2, arritems); + + CPPUNIT_ASSERT_EQUAL("item 3", container->GetString(3)); + CPPUNIT_ASSERT_EQUAL("item 4", container->GetString(4)); +} + +void ItemContainerTestCase::Insert() +{ + wxItemContainer * const container = GetContainer(); + + container->Insert("item 0", 0); + + CPPUNIT_ASSERT_EQUAL("item 0", container->GetString(0)); + + wxArrayString testitems; + testitems.Add("item 1"); + testitems.Add("item 2"); + + container->Insert(testitems, 0); + + CPPUNIT_ASSERT_EQUAL("item 1", container->GetString(0)); + CPPUNIT_ASSERT_EQUAL("item 2", container->GetString(1)); + + wxString arritems[] = { "item 3", "item 4" }; + + container->Insert(2, arritems, 1); + + CPPUNIT_ASSERT_EQUAL("item 3", container->GetString(1)); + CPPUNIT_ASSERT_EQUAL("item 4", container->GetString(2)); +} + +void ItemContainerTestCase::Count() +{ + wxItemContainer * const container = GetContainer(); + + CPPUNIT_ASSERT(container->IsEmpty()); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + testitems.Add("item 3"); + + container->Append(testitems); + + CPPUNIT_ASSERT(!container->IsEmpty()); + CPPUNIT_ASSERT_EQUAL(4, container->GetCount()); + + container->Delete(0); + + CPPUNIT_ASSERT_EQUAL(3, container->GetCount()); + + container->Delete(0); + container->Delete(0); + + CPPUNIT_ASSERT_EQUAL(1, container->GetCount()); + + container->Insert(testitems, 1); + + CPPUNIT_ASSERT_EQUAL(5, container->GetCount()); +} + +void ItemContainerTestCase::ItemSelection() +{ + wxItemContainer * const container = GetContainer(); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + testitems.Add("item 3"); + + container->Append(testitems); + + container->SetSelection(wxNOT_FOUND); + + CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, container->GetSelection()); + CPPUNIT_ASSERT_EQUAL("", container->GetStringSelection()); + + container->SetSelection(1); + + CPPUNIT_ASSERT_EQUAL(1, container->GetSelection()); + CPPUNIT_ASSERT_EQUAL("item 1", container->GetStringSelection()); + + container->SetStringSelection("item 2"); + + CPPUNIT_ASSERT_EQUAL(2, container->GetSelection()); + CPPUNIT_ASSERT_EQUAL("item 2", container->GetStringSelection()); +} + +void ItemContainerTestCase::FindString() +{ + wxItemContainer * const container = GetContainer(); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + testitems.Add("item 3"); + + container->Append(testitems); + + CPPUNIT_ASSERT_EQUAL(1, container->FindString("item 1")); + CPPUNIT_ASSERT_EQUAL(1, container->FindString("ITEM 1")); + CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, container->FindString("ITEM 1", true)); +} + +void ItemContainerTestCase::ClientData() +{ + wxItemContainer * const container = GetContainer(); + + wxStringClientData* item0data = new wxStringClientData("item0data"); + wxStringClientData* item1data = new wxStringClientData("item1data"); + wxStringClientData* item2data = new wxStringClientData("item2data"); + + container->Append("item 0", item0data); + + CPPUNIT_ASSERT_EQUAL(static_cast(item0data), + container->GetClientObject(0)); + + container->Append("item 1"); + container->SetClientObject(1, item1data); + + CPPUNIT_ASSERT_EQUAL(static_cast(item1data), + container->GetClientObject(1)); + + container->Insert("item 2", 2, item2data); + + CPPUNIT_ASSERT_EQUAL(static_cast(item2data), + container->GetClientObject(2)); +} + +void ItemContainerTestCase::VoidData() +{ + wxItemContainer * const container = GetContainer(); + + wxString item0data("item0data"), item1data("item0data"), + item2data("item0data"); + + void* item0 = &item0data; + void* item1 = &item1data; + void* item2 = &item2data; + + container->Append("item 0", item0); + + CPPUNIT_ASSERT_EQUAL(item0, container->GetClientData(0)); + + container->Append("item 1"); + container->SetClientData(1, item1); + + CPPUNIT_ASSERT_EQUAL(item1, container->GetClientData(1)); + + container->Insert("item 2", 2, item2); + + CPPUNIT_ASSERT_EQUAL(item2, container->GetClientData(2)); +} + +void ItemContainerTestCase::Set() +{ + wxItemContainer * const container = GetContainer(); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + + container->Append(testitems); + + wxArrayString newtestitems; + newtestitems.Add("new item 0"); + newtestitems.Add("new item 1"); + newtestitems.Add("new item 2"); + newtestitems.Add("new item 3"); + + container->Set(newtestitems); + + CPPUNIT_ASSERT_EQUAL(4, container->GetCount()); + CPPUNIT_ASSERT_EQUAL("new item 1", container->GetString(1)); + + wxString arrnewitems[] = { "even newer 0", "event newer 1" }; + + container->Set(2, arrnewitems); + + CPPUNIT_ASSERT_EQUAL(2, container->GetCount()); + CPPUNIT_ASSERT_EQUAL("even newer 0", container->GetString(0)); +} + +void ItemContainerTestCase::SetString() +{ + wxItemContainer * const container = GetContainer(); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + testitems.Add("item 3"); + + container->Append(testitems); + + container->SetString(0, "new item 0"); +#ifndef __WXOSX__ + container->SetString(2, ""); +#endif + + CPPUNIT_ASSERT_EQUAL("new item 0", container->GetString(0)); +#ifndef __WXOSX__ + CPPUNIT_ASSERT_EQUAL("", container->GetString(2)); +#endif +} diff --git a/tests/controls/itemcontainertest.h b/tests/controls/itemcontainertest.h new file mode 100644 index 0000000000..86d0801a5d --- /dev/null +++ b/tests/controls/itemcontainertest.h @@ -0,0 +1,58 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/itemcontainertest.h +// Purpose: wxItemContainer unit test +// Author: Steven Lamerton +// Created: 2010-06-29 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TESTS_CONTROLS_ITEMCONTAINERTEST_H_ +#define _WX_TESTS_CONTROLS_ITEMCONTAINERTEST_H_ + +class ItemContainerTestCase +{ +public: + ItemContainerTestCase() { } + virtual ~ItemContainerTestCase() { } + +protected: + // this function must be overridden by the derived classes to return the + // text entry object we're testing, typically this is done by creating a + // control implementing wxItemContainer interface in setUp() virtual method and + // just returning it from here + virtual wxItemContainer *GetContainer() const = 0; + + // and this one must be overridden to return the window which implements + // wxItemContainer interface -- usually it will return the same pointer as + // GetTestEntry(), just as a different type + virtual wxWindow *GetContainerWindow() const = 0; + + // this should be inserted in the derived class CPPUNIT_TEST_SUITE + // definition to run all wxItemContainer tests as part of it + #define wxITEM_CONTAINER_TESTS() \ + CPPUNIT_TEST( Append ); \ + CPPUNIT_TEST( Insert ); \ + CPPUNIT_TEST( Count ); \ + CPPUNIT_TEST( ItemSelection ); \ + CPPUNIT_TEST( FindString ); \ + CPPUNIT_TEST( ClientData ); \ + CPPUNIT_TEST( VoidData ); \ + CPPUNIT_TEST( Set ); \ + CPPUNIT_TEST( SetString ) + + void Append(); + void Insert(); + void Count(); + void ItemSelection(); + void FindString(); + void ClientData(); + void VoidData(); + void Set(); + void SetString(); + +private: + wxDECLARE_NO_COPY_CLASS(ItemContainerTestCase); +}; + +#endif // _WX_TESTS_CONTROLS_ITEMCONTAINERTEST_H_ diff --git a/tests/controls/label.cpp b/tests/controls/label.cpp index 2cc8afccbb..73144e2c37 100644 --- a/tests/controls/label.cpp +++ b/tests/controls/label.cpp @@ -210,4 +210,6 @@ void LabelTestCase::Statics() CPPUNIT_ASSERT_EQUAL( "&mnemonic", wxControl::RemoveMnemonics("&&mnemonic") ); CPPUNIT_ASSERT_EQUAL( "&mnemonic", wxControl::RemoveMnemonics("&&&mnemonic") ); CPPUNIT_ASSERT_EQUAL( "", wxStaticText::RemoveMarkup("") ); + CPPUNIT_ASSERT_EQUAL( "<b></b>&""'", + wxStaticText::EscapeMarkup("&\"\"'") ); } diff --git a/tests/controls/listbasetest.cpp b/tests/controls/listbasetest.cpp new file mode 100644 index 0000000000..173f405f76 --- /dev/null +++ b/tests/controls/listbasetest.cpp @@ -0,0 +1,465 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/listbasetest.cpp +// Purpose: Base class for wxListCtrl and wxListView tests +// Author: Steven Lamerton +// Created: 2010-07-20 +// RCS-ID: $Id$ +// Copyright: (c) 2008 Vadim Zeitlin , +// (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_LISTCTRL + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/listctrl.h" +#include "listbasetest.h" +#include "testableframe.h" +#include "asserthelper.h" +#include "wx/uiaction.h" +#include "wx/imaglist.h" +#include "wx/artprov.h" + +void ListBaseTestCase::ColumnsOrder() +{ +#ifdef wxHAS_LISTCTRL_COLUMN_ORDER + wxListCtrl* const list = GetList(); + + int n; + wxListItem li; + li.SetMask(wxLIST_MASK_TEXT); + + // first set up some columns + static const int NUM_COLS = 3; + + list->InsertColumn(0, "Column 0"); + list->InsertColumn(1, "Column 1"); + list->InsertColumn(2, "Column 2"); + + // and a couple of test items too + list->InsertItem(0, "Item 0"); + list->SetItem(0, 1, "first in first"); + + list->InsertItem(1, "Item 1"); + list->SetItem(1, 2, "second in second"); + + + // check that the order is natural in the beginning + const wxArrayInt orderOrig = list->GetColumnsOrder(); + for ( n = 0; n < NUM_COLS; n++ ) + CPPUNIT_ASSERT_EQUAL( n, orderOrig[n] ); + + // then rearrange them: using { 2, 0, 1 } order means that column 2 is + // shown first, then column 0 and finally column 1 + wxArrayInt order(3); + order[0] = 2; + order[1] = 0; + order[2] = 1; + list->SetColumnsOrder(order); + + // check that we get back the same order as we set + const wxArrayInt orderNew = list->GetColumnsOrder(); + for ( n = 0; n < NUM_COLS; n++ ) + CPPUNIT_ASSERT_EQUAL( order[n], orderNew[n] ); + + // and the order -> index mappings for individual columns + for ( n = 0; n < NUM_COLS; n++ ) + CPPUNIT_ASSERT_EQUAL( order[n], list->GetColumnIndexFromOrder(n) ); + + // and also the reverse mapping + CPPUNIT_ASSERT_EQUAL( 1, list->GetColumnOrder(0) ); + CPPUNIT_ASSERT_EQUAL( 2, list->GetColumnOrder(1) ); + CPPUNIT_ASSERT_EQUAL( 0, list->GetColumnOrder(2) ); + + + // finally check that accessors still use indices, not order + CPPUNIT_ASSERT( list->GetColumn(0, li) ); + CPPUNIT_ASSERT_EQUAL( "Column 0", li.GetText() ); + + li.SetId(0); + li.SetColumn(1); + CPPUNIT_ASSERT( list->GetItem(li) ); + CPPUNIT_ASSERT_EQUAL( "first in first", li.GetText() ); + + li.SetId(1); + li.SetColumn(2); + CPPUNIT_ASSERT( list->GetItem(li) ); + CPPUNIT_ASSERT_EQUAL( "second in second", li.GetText() ); + + //tidy up when we are finished + list->ClearAll(); +#endif // wxHAS_LISTCTRL_COLUMN_ORDER +} + + + +void ListBaseTestCase::ItemRect() +{ + wxListCtrl* const list = GetList(); + + // set up for the test + list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); + list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); + list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); + + list->InsertItem(0, "Item 0"); + list->SetItem(0, 1, "first column"); + list->SetItem(0, 1, "second column"); + + // do test + wxRect r; + WX_ASSERT_FAILS_WITH_ASSERT( list->GetItemRect(1, r) ); + CPPUNIT_ASSERT( list->GetItemRect(0, r) ); + CPPUNIT_ASSERT_EQUAL( 150, r.GetWidth() ); + + CPPUNIT_ASSERT( list->GetSubItemRect(0, 0, r) ); + CPPUNIT_ASSERT_EQUAL( 60, r.GetWidth() ); + + CPPUNIT_ASSERT( list->GetSubItemRect(0, 1, r) ); + CPPUNIT_ASSERT_EQUAL( 50, r.GetWidth() ); + + CPPUNIT_ASSERT( list->GetSubItemRect(0, 2, r) ); + CPPUNIT_ASSERT_EQUAL( 40, r.GetWidth() ); + + WX_ASSERT_FAILS_WITH_ASSERT( list->GetSubItemRect(0, 3, r) ); + + //tidy up when we are finished + list->ClearAll(); +} + +void ListBaseTestCase::ItemText() +{ + wxListCtrl* const list = GetList(); + + list->InsertColumn(0, "First"); + list->InsertColumn(1, "Second"); + + list->InsertItem(0, "0,0"); + CPPUNIT_ASSERT_EQUAL( "0,0", list->GetItemText(0) ); + CPPUNIT_ASSERT_EQUAL( "", list->GetItemText(0, 1) ); + + list->SetItem(0, 1, "0,1"); + CPPUNIT_ASSERT_EQUAL( "0,1", list->GetItemText(0, 1) ); +} + +void ListBaseTestCase::ChangeMode() +{ + wxListCtrl* const list = GetList(); + + list->InsertColumn(0, "Header"); + list->InsertItem(0, "First"); + list->InsertItem(1, "Second"); + CPPUNIT_ASSERT_EQUAL( 2, list->GetItemCount() ); + + // check that switching the mode preserves the items + list->SetWindowStyle(wxLC_ICON); + CPPUNIT_ASSERT_EQUAL( 2, list->GetItemCount() ); + CPPUNIT_ASSERT_EQUAL( "First", list->GetItemText(0) ); + + // and so does switching back + list->SetWindowStyle(wxLC_REPORT); + CPPUNIT_ASSERT_EQUAL( 2, list->GetItemCount() ); + CPPUNIT_ASSERT_EQUAL( "First", list->GetItemText(0) ); + + //tidy up when we are finished + list->ClearAll(); +} + +void ListBaseTestCase::ItemClick() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + wxListCtrl* const list = GetList(); + + EventCounter count(list, wxEVT_COMMAND_LIST_ITEM_SELECTED); + EventCounter count1(list, wxEVT_COMMAND_LIST_ITEM_FOCUSED); + EventCounter count2(list, wxEVT_COMMAND_LIST_ITEM_ACTIVATED); + EventCounter count3(list, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK); + + list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); + list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); + list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); + + list->InsertItem(0, "Item 0"); + list->SetItem(0, 1, "first column"); + list->SetItem(0, 2, "second column"); + + wxUIActionSimulator sim; + + wxRect pos; + list->GetItemRect(0, pos); + + //We move in slightly so we are not on the edge + wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(2, 2); + + sim.MouseMove(point); + wxYield(); + + sim.MouseClick(); + wxYield(); + + sim.MouseDblClick(); + wxYield(); + + sim.MouseClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + // when the first item was selected the focus changes to it, but not + // on subsequent clicks + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_FOCUSED)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_SELECTED)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)); + + //tidy up when we are finished + list->ClearAll(); +#endif // wxUSE_UIACTIONSIMULATOR +} + +void ListBaseTestCase::KeyDown() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + wxListCtrl* const list = GetList(); + + EventCounter count(list, wxEVT_COMMAND_LIST_KEY_DOWN); + + wxUIActionSimulator sim; + + list->SetFocus(); + wxYield(); + + sim.Text("aAbB"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(4, frame->GetEventCount()); +#endif +} + +void ListBaseTestCase::DeleteItems() +{ +#ifndef __WXOSX__ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + wxListCtrl* const list = GetList(); + + EventCounter count(list, wxEVT_COMMAND_LIST_DELETE_ITEM); + EventCounter count1(list, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS); + + + list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); + list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); + list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); + + list->InsertItem(0, "Item 0"); + list->InsertItem(1, "Item 1"); + list->InsertItem(2, "Item 1"); + + list->DeleteItem(0); + list->DeleteItem(0); + list->DeleteAllItems(); + + //Add some new items to tests ClearAll with + list->InsertColumn(0, "Column 0"); + list->InsertItem(0, "Item 0"); + list->InsertItem(1, "Item 1"); + + //Check that ClearAll actually sends a DELETE_ALL_ITEMS event + list->ClearAll(); + + //ClearAll and DeleteAllItems shouldn't send an event if there was nothing + //to clear + list->ClearAll(); + list->DeleteAllItems(); + + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_DELETE_ITEM)); + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)); +#endif +} + +void ListBaseTestCase::InsertItem() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + wxListCtrl* const list = GetList(); + + EventCounter count(list, wxEVT_COMMAND_LIST_INSERT_ITEM); + + list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); + + wxListItem item; + item.SetId(0); + item.SetText("some text"); + + list->InsertItem(item); + list->InsertItem(1, "more text"); + + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_LIST_INSERT_ITEM)); +} + +void ListBaseTestCase::Find() +{ + wxListCtrl* const list = GetList(); + + // set up for the test + list->InsertColumn(0, "Column 0"); + list->InsertColumn(1, "Column 1"); + + list->InsertItem(0, "Item 0"); + list->SetItem(0, 1, "first column"); + + list->InsertItem(1, "Item 1"); + list->SetItem(1, 1, "first column"); + + list->InsertItem(2, "Item 40"); + list->SetItem(2, 1, "first column"); + + list->InsertItem(3, "ITEM 01"); + list->SetItem(3, 1, "first column"); + + CPPUNIT_ASSERT_EQUAL(1, list->FindItem(-1, "Item 1")); + CPPUNIT_ASSERT_EQUAL(2, list->FindItem(-1, "Item 4", true)); + CPPUNIT_ASSERT_EQUAL(2, list->FindItem(1, "Item 40")); + CPPUNIT_ASSERT_EQUAL(3, list->FindItem(2, "Item 0", true)); +} + +void ListBaseTestCase::Visible() +{ + wxListCtrl* const list = GetList(); + + list->InsertColumn(0, "Column 0"); + + int count = list->GetCountPerPage(); + + for( int i = 0; i < count + 10; i++ ) + { + list->InsertItem(i, wxString::Format("string %d", i)); + } + + CPPUNIT_ASSERT_EQUAL(count + 10, list->GetItemCount()); + CPPUNIT_ASSERT_EQUAL(0, list->GetTopItem()); + + list->EnsureVisible(count + 9); + + CPPUNIT_ASSERT(list->GetTopItem() != 0); +} + +void ListBaseTestCase::ItemFormatting() +{ + wxListCtrl* const list = GetList(); + + list->InsertColumn(0, "Column 0"); + + list->InsertItem(0, "Item 0"); + list->InsertItem(1, "Item 1"); + list->InsertItem(2, "Item 2"); + + list->SetTextColour(*wxYELLOW); + list->SetBackgroundColour(*wxGREEN); + list->SetItemTextColour(0, *wxRED); + list->SetItemBackgroundColour(1, *wxBLUE); + + CPPUNIT_ASSERT_EQUAL(*wxGREEN, list->GetBackgroundColour()); + CPPUNIT_ASSERT_EQUAL(*wxBLUE,list->GetItemBackgroundColour(1)); + + CPPUNIT_ASSERT_EQUAL(*wxYELLOW, list->GetTextColour()); + CPPUNIT_ASSERT_EQUAL(*wxRED, list->GetItemTextColour(0)); +} + +void ListBaseTestCase::EditLabel() +{ +#if wxUSE_UIACTIONSIMULATOR + wxListCtrl* const list = GetList(); + + list->SetWindowStyleFlag(wxLC_REPORT | wxLC_EDIT_LABELS); + + list->InsertColumn(0, "Column 0"); + + list->InsertItem(0, "Item 0"); + list->InsertItem(1, "Item 1"); + + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(list, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT); + EventCounter count1(list, wxEVT_COMMAND_LIST_END_LABEL_EDIT); + + wxUIActionSimulator sim; + + list->EditLabel(0); + + sim.Text("sometext"); + sim.Char(WXK_RETURN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_END_LABEL_EDIT)); +#endif +} + +void ListBaseTestCase::ImageList() +{ + wxListCtrl* const list = GetList(); + + wxSize size(32, 32); + + wxImageList* imglist = new wxImageList(size.x, size.y); + imglist->Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, size)); + imglist->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size)); + imglist->Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, size)); + + list->AssignImageList(imglist, wxIMAGE_LIST_NORMAL); + + CPPUNIT_ASSERT_EQUAL(imglist, list->GetImageList(wxIMAGE_LIST_NORMAL)); +} + +namespace +{ + //From the sample but fixed so it actually inverts + int wxCALLBACK + MyCompareFunction(long item1, long item2, wxIntPtr WXUNUSED(sortData)) + { + // inverse the order + if (item1 < item2) + return 1; + if (item1 > item2) + return -1; + + return 0; + } + +} + +void ListBaseTestCase::Sort() +{ + wxListCtrl* const list = GetList(); + + list->InsertColumn(0, "Column 0"); + + list->InsertItem(0, "Item 0"); + list->SetItemData(0, 0); + list->InsertItem(1, "Item 1"); + list->SetItemData(1, 1); + + list->SortItems(MyCompareFunction, 0); + + CPPUNIT_ASSERT_EQUAL("Item 1", list->GetItemText(0)); + CPPUNIT_ASSERT_EQUAL("Item 0", list->GetItemText(1)); +} + +#endif //wxUSE_LISTCTRL diff --git a/tests/controls/listbasetest.h b/tests/controls/listbasetest.h new file mode 100644 index 0000000000..e9be89e2e9 --- /dev/null +++ b/tests/controls/listbasetest.h @@ -0,0 +1,57 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/listbasetest.cpp +// Purpose: Base class for wxListCtrl and wxListView tests +// Author: Steven Lamerton +// Created: 2010-07-20 +// RCS-ID: $Id$ +// Copyright: (c) 2008 Vadim Zeitlin , +// (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TESTS_CONTROLS_LISTBASETEST_H_ +#define _WX_TESTS_CONTROLS_LISTBASETEST_H_ + +class ListBaseTestCase +{ +public: + ListBaseTestCase() { } + virtual ~ListBaseTestCase() { } + +protected: + virtual wxListCtrl *GetList() const = 0; + + #define wxLIST_BASE_TESTS() \ + CPPUNIT_TEST( ColumnsOrder ); \ + CPPUNIT_TEST( ItemRect ); \ + CPPUNIT_TEST( ItemText ); \ + CPPUNIT_TEST( ChangeMode ); \ + WXUISIM_TEST( ItemClick ); \ + WXUISIM_TEST( KeyDown ); \ + CPPUNIT_TEST( DeleteItems ); \ + CPPUNIT_TEST( InsertItem ); \ + CPPUNIT_TEST( Find ); \ + CPPUNIT_TEST( Visible ); \ + CPPUNIT_TEST( ItemFormatting ); \ + WXUISIM_TEST( EditLabel ); \ + CPPUNIT_TEST( ImageList ); \ + CPPUNIT_TEST( Sort ) + + void ColumnsOrder(); + void ItemRect(); + void ItemText(); + void ChangeMode(); + void ItemClick(); + void KeyDown(); + void DeleteItems(); + void InsertItem(); + void Find(); + void Visible(); + void ItemFormatting(); + void EditLabel(); + void ImageList(); + void Sort(); + + wxDECLARE_NO_COPY_CLASS(ListBaseTestCase); +}; + +#endif diff --git a/tests/controls/listbooktest.cpp b/tests/controls/listbooktest.cpp new file mode 100644 index 0000000000..ca9ce19e10 --- /dev/null +++ b/tests/controls/listbooktest.cpp @@ -0,0 +1,83 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/listbooktest.cpp +// Purpose: wxListbook unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_LISTBOOK + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/panel.h" +#endif // WX_PRECOMP + +#include "wx/listbook.h" +#include "wx/listctrl.h" +#include "bookctrlbasetest.h" + +class ListbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase +{ +public: + ListbookTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxBookCtrlBase *GetBase() const { return m_listbook; } + + virtual wxEventType GetChangedEvent() const + { return wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; } + + virtual wxEventType GetChangingEvent() const + { return wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; } + + CPPUNIT_TEST_SUITE( ListbookTestCase ); + wxBOOK_CTRL_BASE_TESTS(); + CPPUNIT_TEST( ListView ); + CPPUNIT_TEST_SUITE_END(); + + void ListView(); + + wxListbook *m_listbook; + + DECLARE_NO_COPY_CLASS(ListbookTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ListbookTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListbookTestCase, "ListbookTestCase" ); + +void ListbookTestCase::setUp() +{ + m_listbook = new wxListbook(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxSize(400, 300)); + AddPanels(); +} + +void ListbookTestCase::tearDown() +{ + wxDELETE(m_listbook); +} + +void ListbookTestCase::ListView() +{ + wxListView* listview = m_listbook->GetListView(); + + CPPUNIT_ASSERT(listview); + CPPUNIT_ASSERT_EQUAL(3, listview->GetItemCount()); + CPPUNIT_ASSERT_EQUAL("Panel 1", listview->GetItemText(0)); +} + +#endif //wxUSE_LISTBOOK diff --git a/tests/controls/listboxtest.cpp b/tests/controls/listboxtest.cpp new file mode 100644 index 0000000000..68ce0d7941 --- /dev/null +++ b/tests/controls/listboxtest.cpp @@ -0,0 +1,264 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/listbox.cpp +// Purpose: wxListBox unit test +// Author: Steven Lamerton +// Created: 2010-06-29 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_LISTBOX + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/listbox.h" +#endif // WX_PRECOMP + +#include "itemcontainertest.h" +#include "testableframe.h" +#include "wx/uiaction.h" + +class ListBoxTestCase : public ItemContainerTestCase, public CppUnit::TestCase +{ +public: + ListBoxTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxItemContainer *GetContainer() const { return m_list; } + virtual wxWindow *GetContainerWindow() const { return m_list; } + + CPPUNIT_TEST_SUITE( ListBoxTestCase ); + wxITEM_CONTAINER_TESTS(); + CPPUNIT_TEST( Sort ); + CPPUNIT_TEST( MultipleSelect ); + WXUISIM_TEST( ClickEvents ); + WXUISIM_TEST( ClickNotOnItem ); + CPPUNIT_TEST( HitTest ); + //We also run all tests as an ownerdrawn list box we do not need to + //run the wxITEM_CONTAINER_TESTS as they are tested with wxCheckListBox +#ifdef __WXMSW__ + CPPUNIT_TEST( PseudoTest_OwnerDrawn ); + CPPUNIT_TEST( Sort ); + CPPUNIT_TEST( MultipleSelect ); + WXUISIM_TEST( ClickEvents ); + WXUISIM_TEST( ClickNotOnItem ); + CPPUNIT_TEST( HitTest ); +#endif + CPPUNIT_TEST_SUITE_END(); + + void Sort(); + void MultipleSelect(); + void ClickEvents(); + void ClickNotOnItem(); + void HitTest(); + void PseudoTest_OwnerDrawn() { ms_ownerdrawn = true; } + + static bool ms_ownerdrawn; + + wxListBox* m_list; + + DECLARE_NO_COPY_CLASS(ListBoxTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ListBoxTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListBoxTestCase, "ListBoxTestCase" ); + +//initialise the static variable +bool ListBoxTestCase::ms_ownerdrawn = false; + +void ListBoxTestCase::setUp() +{ + if( ms_ownerdrawn ) + { + m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxSize(300, 200), 0, NULL, + wxLB_OWNERDRAW); + } + else + { + m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxSize(300, 200)); + } +} + +void ListBoxTestCase::tearDown() +{ + wxDELETE(m_list); +} + +void ListBoxTestCase::Sort() +{ +#if !defined(__WXGTK__) && !defined(__WXOSX__) + wxDELETE(m_list); + m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, 0, 0, + wxLB_SORT); + + wxArrayString testitems; + testitems.Add("aaa"); + testitems.Add("Aaa"); + testitems.Add("aba"); + testitems.Add("aaab"); + testitems.Add("aab"); + testitems.Add("AAA"); + + m_list->Append(testitems); + + CPPUNIT_ASSERT_EQUAL("AAA", m_list->GetString(0)); + CPPUNIT_ASSERT_EQUAL("Aaa", m_list->GetString(1)); + CPPUNIT_ASSERT_EQUAL("aaa", m_list->GetString(2)); + CPPUNIT_ASSERT_EQUAL("aaab", m_list->GetString(3)); + CPPUNIT_ASSERT_EQUAL("aab", m_list->GetString(4)); + CPPUNIT_ASSERT_EQUAL("aba", m_list->GetString(5)); + + m_list->Append("a"); + + CPPUNIT_ASSERT_EQUAL("a", m_list->GetString(0)); +#endif +} + +void ListBoxTestCase::MultipleSelect() +{ + wxDELETE(m_list); + m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, 0, 0, + wxLB_MULTIPLE); + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + testitems.Add("item 3"); + + m_list->Append(testitems); + + m_list->SetSelection(0); + + wxArrayInt selected; + m_list->GetSelections(selected); + + CPPUNIT_ASSERT_EQUAL(1, selected.Count()); + CPPUNIT_ASSERT_EQUAL(0, selected.Item(0)); + + m_list->SetSelection(2); + + m_list->GetSelections(selected); + + CPPUNIT_ASSERT_EQUAL(2, selected.Count()); + CPPUNIT_ASSERT_EQUAL(2, selected.Item(1)); + + m_list->Deselect(0); + + m_list->GetSelections(selected); + + CPPUNIT_ASSERT_EQUAL(1, selected.Count()); + CPPUNIT_ASSERT_EQUAL(2, selected.Item(0)); + + CPPUNIT_ASSERT(!m_list->IsSelected(0)); + CPPUNIT_ASSERT(!m_list->IsSelected(1)); + CPPUNIT_ASSERT(m_list->IsSelected(2)); + CPPUNIT_ASSERT(!m_list->IsSelected(3)); +} + +void ListBoxTestCase::ClickEvents() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(frame, wxEVT_COMMAND_LISTBOX_SELECTED); + EventCounter count1(frame, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED); + + wxUIActionSimulator sim; + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + + m_list->Append(testitems); + + m_list->Update(); + m_list->Refresh(); + + sim.MouseMove(m_list->ClientToScreen(wxPoint(10, 10))); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + + sim.MouseDblClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +#endif +} + +void ListBoxTestCase::ClickNotOnItem() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(frame, wxEVT_COMMAND_LISTBOX_SELECTED); + EventCounter count1(frame, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED); + + wxUIActionSimulator sim; + + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + + m_list->Append(testitems); + + m_list->Update(); + m_list->Refresh(); + + sim.MouseMove(m_list->ClientToScreen(wxPoint(m_list->GetSize().x - 10, m_list->GetSize().y - 10))); + wxYield(); + + sim.MouseClick(); + wxYield(); + + sim.MouseDblClick(); + wxYield(); + + //If we are not clicking on an item we shouldn't have any events + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +#endif +} + +void ListBoxTestCase::HitTest() +{ +#if defined(__WXMSW__) || defined(__WXOSX__) + wxArrayString testitems; + testitems.Add("item 0"); + testitems.Add("item 1"); + testitems.Add("item 2"); + + m_list->Append(testitems); + + CPPUNIT_ASSERT(m_list->HitTest(wxPoint(10, 10)) != wxNOT_FOUND); + CPPUNIT_ASSERT(m_list->HitTest(10, 10) != wxNOT_FOUND); + + CPPUNIT_ASSERT(m_list->HitTest(wxPoint(290, 190)) == wxNOT_FOUND); + CPPUNIT_ASSERT(m_list->HitTest(290, 190) == wxNOT_FOUND); +#endif +} + +#endif //wxUSE_LISTBOX diff --git a/tests/controls/listctrltest.cpp b/tests/controls/listctrltest.cpp index 93f0756a74..cb61633002 100644 --- a/tests/controls/listctrltest.cpp +++ b/tests/controls/listctrltest.cpp @@ -5,6 +5,7 @@ // Created: 2008-11-26 // RCS-ID: $Id$ // Copyright: (c) 2008 Vadim Zeitlin +// (c) 2010 Steven Lamerton /////////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- @@ -13,6 +14,8 @@ #include "testprec.h" +#if wxUSE_LISTCTRL + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -22,12 +25,15 @@ #endif // WX_PRECOMP #include "wx/listctrl.h" +#include "listbasetest.h" +#include "testableframe.h" +#include "wx/uiaction.h" // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- -class ListCtrlTestCase : public CppUnit::TestCase +class ListCtrlTestCase : public ListBaseTestCase, public CppUnit::TestCase { public: ListCtrlTestCase() { } @@ -35,22 +41,21 @@ public: virtual void setUp(); virtual void tearDown(); + virtual wxListCtrl *GetList() const { return m_list; } + private: CPPUNIT_TEST_SUITE( ListCtrlTestCase ); -#ifdef wxHAS_LISTCTRL_COLUMN_ORDER - CPPUNIT_TEST( ColumnsOrder ); -#endif // wxHAS_LISTCTRL_COLUMN_ORDER - CPPUNIT_TEST( ItemRect ); - CPPUNIT_TEST( ItemText ); - CPPUNIT_TEST( ChangeMode ); + wxLIST_BASE_TESTS(); + WXUISIM_TEST( ColumnClick ); + WXUISIM_TEST( ColumnDrag ); CPPUNIT_TEST_SUITE_END(); -#ifdef wxHAS_LISTCTRL_COLUMN_ORDER - void ColumnsOrder(); -#endif // wxHAS_LISTCTRL_COLUMN_ORDER - void ItemRect(); - void ItemText(); - void ChangeMode(); +#if wxUSE_UIACTIONSIMULATOR + // Column events are only supported in wxListCtrl currently so we test them + // here rather than in ListBaseTest + void ColumnClick(); + void ColumnDrag(); +#endif // wxUSE_UIACTIONSIMULATOR wxListCtrl *m_list; @@ -71,6 +76,7 @@ void ListCtrlTestCase::setUp() { m_list = new wxListCtrl(wxTheApp->GetTopWindow()); m_list->SetWindowStyle(wxLC_REPORT); + m_list->SetSize(400, 200); } void ListCtrlTestCase::tearDown() @@ -79,135 +85,70 @@ void ListCtrlTestCase::tearDown() m_list = NULL; } -// ---------------------------------------------------------------------------- -// the tests themselves -// ---------------------------------------------------------------------------- - -#ifdef wxHAS_LISTCTRL_COLUMN_ORDER - -void ListCtrlTestCase::ColumnsOrder() +#if wxUSE_UIACTIONSIMULATOR +void ListCtrlTestCase::ColumnDrag() { - int n; - wxListItem li; - li.SetMask(wxLIST_MASK_TEXT); + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); - // first set up some columns - static const int NUM_COLS = 3; + EventCounter count(m_list, wxEVT_COMMAND_LIST_COL_BEGIN_DRAG); + EventCounter count1(m_list, wxEVT_COMMAND_LIST_COL_DRAGGING); + EventCounter count2(m_list, wxEVT_COMMAND_LIST_COL_END_DRAG); m_list->InsertColumn(0, "Column 0"); m_list->InsertColumn(1, "Column 1"); m_list->InsertColumn(2, "Column 2"); + m_list->Update(); + m_list->SetFocus(); - // and a couple of test items too - m_list->InsertItem(0, "Item 0"); - m_list->SetItem(0, 1, "first in first"); + wxUIActionSimulator sim; - m_list->InsertItem(1, "Item 1"); - m_list->SetItem(1, 2, "second in second"); + wxPoint pt = m_list->ClientToScreen(wxPoint(m_list->GetColumnWidth(0), 5)); + sim.MouseMove(pt); + wxYield(); - // check that the order is natural in the beginning - const wxArrayInt orderOrig = m_list->GetColumnsOrder(); - for ( n = 0; n < NUM_COLS; n++ ) - CPPUNIT_ASSERT_EQUAL( n, orderOrig[n] ); + sim.MouseDown(); + wxYield(); - // then rearrange them: using { 2, 0, 1 } order means that column 2 is - // shown first, then column 0 and finally column 1 - wxArrayInt order(3); - order[0] = 2; - order[1] = 0; - order[2] = 1; - m_list->SetColumnsOrder(order); + sim.MouseMove(pt.x + 50, pt.y); + wxYield(); - // check that we get back the same order as we set - const wxArrayInt orderNew = m_list->GetColumnsOrder(); - for ( n = 0; n < NUM_COLS; n++ ) - CPPUNIT_ASSERT_EQUAL( order[n], orderNew[n] ); + sim.MouseUp(); + wxYield(); - // and the order -> index mappings for individual columns - for ( n = 0; n < NUM_COLS; n++ ) - CPPUNIT_ASSERT_EQUAL( order[n], m_list->GetColumnIndexFromOrder(n) ); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)); + CPPUNIT_ASSERT(frame->GetEventCount(wxEVT_COMMAND_LIST_COL_DRAGGING) > 0); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_END_DRAG)); - // and also the reverse mapping - CPPUNIT_ASSERT_EQUAL( 1, m_list->GetColumnOrder(0) ); - CPPUNIT_ASSERT_EQUAL( 2, m_list->GetColumnOrder(1) ); - CPPUNIT_ASSERT_EQUAL( 0, m_list->GetColumnOrder(2) ); - - - // finally check that accessors still use indices, not order - CPPUNIT_ASSERT( m_list->GetColumn(0, li) ); - CPPUNIT_ASSERT_EQUAL( "Column 0", li.GetText() ); - - li.SetId(0); - li.SetColumn(1); - CPPUNIT_ASSERT( m_list->GetItem(li) ); - CPPUNIT_ASSERT_EQUAL( "first in first", li.GetText() ); - - li.SetId(1); - li.SetColumn(2); - CPPUNIT_ASSERT( m_list->GetItem(li) ); - CPPUNIT_ASSERT_EQUAL( "second in second", li.GetText() ); + m_list->ClearAll(); } -#endif // wxHAS_LISTCTRL_COLUMN_ORDER - -void ListCtrlTestCase::ItemRect() +void ListCtrlTestCase::ColumnClick() { - // set up for the test - m_list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); - m_list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50); - m_list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40); - - m_list->InsertItem(0, "Item 0"); - m_list->SetItem(0, 1, "first column"); - m_list->SetItem(0, 1, "second column"); - - // do test - wxRect r; - WX_ASSERT_FAILS_WITH_ASSERT( m_list->GetItemRect(1, r) ); - CPPUNIT_ASSERT( m_list->GetItemRect(0, r) ); - CPPUNIT_ASSERT_EQUAL( 150, r.GetWidth() ); + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); - CPPUNIT_ASSERT( m_list->GetSubItemRect(0, 0, r) ); - CPPUNIT_ASSERT_EQUAL( 60, r.GetWidth() ); + EventCounter count(m_list, wxEVT_COMMAND_LIST_COL_CLICK); + EventCounter count1(m_list, wxEVT_COMMAND_LIST_COL_RIGHT_CLICK); - CPPUNIT_ASSERT( m_list->GetSubItemRect(0, 1, r) ); - CPPUNIT_ASSERT_EQUAL( 50, r.GetWidth() ); - - CPPUNIT_ASSERT( m_list->GetSubItemRect(0, 2, r) ); - CPPUNIT_ASSERT_EQUAL( 40, r.GetWidth() ); - - WX_ASSERT_FAILS_WITH_ASSERT( m_list->GetSubItemRect(0, 3, r) ); -} -void ListCtrlTestCase::ItemText() -{ - m_list->InsertColumn(0, "First"); - m_list->InsertColumn(1, "Second"); + m_list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60); - m_list->InsertItem(0, "0,0"); - CPPUNIT_ASSERT_EQUAL( "0,0", m_list->GetItemText(0) ); - CPPUNIT_ASSERT_EQUAL( "", m_list->GetItemText(0, 1) ); + wxUIActionSimulator sim; - m_list->SetItem(0, 1, "0,1"); - CPPUNIT_ASSERT_EQUAL( "0,1", m_list->GetItemText(0, 1) ); -} + sim.MouseMove(m_list->ClientToScreen(wxPoint(4, 4))); + wxYield(); -void ListCtrlTestCase::ChangeMode() -{ - m_list->InsertColumn(0, "Header"); - m_list->InsertItem(0, "First"); - m_list->InsertItem(1, "Second"); - CPPUNIT_ASSERT_EQUAL( 2, m_list->GetItemCount() ); + sim.MouseClick(); + sim.MouseClick(wxMOUSE_BTN_RIGHT); + wxYield(); - // check that switching the mode preserves the items - m_list->SetWindowStyle(wxLC_ICON); - CPPUNIT_ASSERT_EQUAL( 2, m_list->GetItemCount() ); - CPPUNIT_ASSERT_EQUAL( "First", m_list->GetItemText(0) ); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_CLICK)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)); - // and so does switching back - m_list->SetWindowStyle(wxLC_REPORT); - CPPUNIT_ASSERT_EQUAL( 2, m_list->GetItemCount() ); - CPPUNIT_ASSERT_EQUAL( "First", m_list->GetItemText(0) ); + m_list->ClearAll(); } +#endif // wxUSE_UIACTIONSIMULATOR +#endif // wxUSE_LISTCTRL diff --git a/tests/controls/listviewtest.cpp b/tests/controls/listviewtest.cpp new file mode 100644 index 0000000000..294c557ea9 --- /dev/null +++ b/tests/controls/listviewtest.cpp @@ -0,0 +1,118 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/listviewtest.cpp +// Purpose: wxListView unit test +// Author: Steven Lamerton +// Created: 2010-07-10 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/listctrl.h" +#include "listbasetest.h" + +class ListViewTestCase : public ListBaseTestCase, public CppUnit::TestCase +{ +public: + ListViewTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + + virtual wxListCtrl *GetList() const { return m_list; } + +private: + CPPUNIT_TEST_SUITE( ListViewTestCase ); + wxLIST_BASE_TESTS(); + CPPUNIT_TEST( Selection ); + CPPUNIT_TEST( Focus ); + CPPUNIT_TEST_SUITE_END(); + + void Selection(); + void Focus(); + + wxListView *m_list; + + DECLARE_NO_COPY_CLASS(ListViewTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ListViewTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ListViewTestCase, "ListViewTestCase" ); + +void ListViewTestCase::setUp() +{ + m_list = new wxListView(wxTheApp->GetTopWindow()); + m_list->SetWindowStyle(wxLC_REPORT); + m_list->SetSize(400, 200); +} + +void ListViewTestCase::tearDown() +{ + wxDELETE(m_list); +} + +void ListViewTestCase::Selection() +{ + m_list->InsertColumn(0, "Column 0"); + + m_list->InsertItem(0, "Item 0"); + m_list->InsertItem(1, "Item 1"); + m_list->InsertItem(2, "Item 2"); + m_list->InsertItem(3, "Item 3"); + + m_list->Select(0); + m_list->Select(2); + m_list->Select(3); + + CPPUNIT_ASSERT(m_list->IsSelected(0)); + CPPUNIT_ASSERT(!m_list->IsSelected(1)); + + long sel = m_list->GetFirstSelected(); + + CPPUNIT_ASSERT_EQUAL(0, sel); + + sel = m_list->GetNextSelected(sel); + + CPPUNIT_ASSERT_EQUAL(2, sel); + + sel = m_list->GetNextSelected(sel); + + CPPUNIT_ASSERT_EQUAL(3, sel); + + sel = m_list->GetNextSelected(sel); + + CPPUNIT_ASSERT_EQUAL(-1, sel); + + m_list->Select(0, false); + + CPPUNIT_ASSERT(!m_list->IsSelected(0)); + CPPUNIT_ASSERT_EQUAL(2, m_list->GetFirstSelected()); +} + +void ListViewTestCase::Focus() +{ + m_list->InsertColumn(0, "Column 0"); + + m_list->InsertItem(0, "Item 0"); + m_list->InsertItem(1, "Item 1"); + m_list->InsertItem(2, "Item 2"); + m_list->InsertItem(3, "Item 3"); + + CPPUNIT_ASSERT_EQUAL(-1, m_list->GetFocusedItem()); + + m_list->Focus(0); + + CPPUNIT_ASSERT_EQUAL(0, m_list->GetFocusedItem()); +} diff --git a/tests/controls/notebooktest.cpp b/tests/controls/notebooktest.cpp new file mode 100644 index 0000000000..c7c3fad381 --- /dev/null +++ b/tests/controls/notebooktest.cpp @@ -0,0 +1,94 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/notebooktest.cpp +// Purpose: wxNotebook unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_NOTEBOOK + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/panel.h" +#endif // WX_PRECOMP + +#include "wx/notebook.h" +#include "bookctrlbasetest.h" + +class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase +{ +public: + NotebookTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxBookCtrlBase *GetBase() const { return m_notebook; } + + virtual wxEventType GetChangedEvent() const + { return wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; } + + virtual wxEventType GetChangingEvent() const + { return wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; } + + + CPPUNIT_TEST_SUITE( NotebookTestCase ); + wxBOOK_CTRL_BASE_TESTS(); + CPPUNIT_TEST( Image ); + CPPUNIT_TEST( RowCount ); + CPPUNIT_TEST_SUITE_END(); + + void RowCount(); + + wxNotebook *m_notebook; + + DECLARE_NO_COPY_CLASS(NotebookTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( NotebookTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( NotebookTestCase, "NotebookTestCase" ); + +void NotebookTestCase::setUp() +{ + m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxSize(400, 200)); + AddPanels(); +} + +void NotebookTestCase::tearDown() +{ + wxDELETE(m_notebook); +} + +void NotebookTestCase::RowCount() +{ + CPPUNIT_ASSERT_EQUAL(1, m_notebook->GetRowCount()); + +#ifdef __WXMSW__ + wxDELETE(m_notebook); + m_notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxSize(400, 200), + wxNB_MULTILINE); + + for( unsigned int i = 0; i < 10; i++ ) + { + m_notebook->AddPage(new wxPanel(m_notebook), "Panel", false, 0); + } + + CPPUNIT_ASSERT( m_notebook->GetRowCount() != 1 ); +#endif +} + +#endif //wxUSE_NOTEBOOK diff --git a/tests/controls/pickerbasetest.cpp b/tests/controls/pickerbasetest.cpp new file mode 100644 index 0000000000..a4a70785b3 --- /dev/null +++ b/tests/controls/pickerbasetest.cpp @@ -0,0 +1,66 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/pickerbasetest.cpp +// Purpose: wxPickerBase unit test +// Author: Steven Lamerton +// Created: 2010-08-07 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#include "wx/pickerbase.h" +#include "pickerbasetest.h" + +void PickerBaseTestCase::Margin() +{ + wxPickerBase* const base = GetBase(); + + CPPUNIT_ASSERT(base->HasTextCtrl()); + CPPUNIT_ASSERT(base->GetInternalMargin() >= 0); + + base->SetInternalMargin(15); + + CPPUNIT_ASSERT_EQUAL(15, base->GetInternalMargin()); +} + +void PickerBaseTestCase::Proportion() +{ + wxPickerBase* const base = GetBase(); + + CPPUNIT_ASSERT(base->HasTextCtrl()); + + base->SetPickerCtrlProportion(1); + base->SetTextCtrlProportion(1); + + CPPUNIT_ASSERT_EQUAL(1, base->GetPickerCtrlProportion()); + CPPUNIT_ASSERT_EQUAL(1, base->GetTextCtrlProportion()); +} + +void PickerBaseTestCase::Growable() +{ + wxPickerBase* const base = GetBase(); + + CPPUNIT_ASSERT(base->HasTextCtrl()); + + base->SetPickerCtrlGrowable(); + base->SetTextCtrlGrowable(); + + CPPUNIT_ASSERT(base->IsPickerCtrlGrowable()); + CPPUNIT_ASSERT(base->IsTextCtrlGrowable()); + + base->SetPickerCtrlGrowable(false); + base->SetTextCtrlGrowable(false); + + CPPUNIT_ASSERT(!base->IsPickerCtrlGrowable()); + CPPUNIT_ASSERT(!base->IsTextCtrlGrowable()); +} + +void PickerBaseTestCase::Controls() +{ + wxPickerBase* const base = GetBase(); + + CPPUNIT_ASSERT(base->HasTextCtrl()); + CPPUNIT_ASSERT(base->GetTextCtrl() != NULL); + CPPUNIT_ASSERT(base->GetPickerCtrl() != NULL); +} diff --git a/tests/controls/pickerbasetest.h b/tests/controls/pickerbasetest.h new file mode 100644 index 0000000000..f1689fc665 --- /dev/null +++ b/tests/controls/pickerbasetest.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/pickerbasetest.cpp +// Purpose: wxPickerBase unit test +// Author: Steven Lamerton +// Created: 2010-08-07 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_TESTS_CONTROLS_PICKERBASETEST_H_ +#define _WX_TESTS_CONTROLS_PICKERBASETEST_H_ + +class PickerBaseTestCase +{ +public: + PickerBaseTestCase() { } + virtual ~PickerBaseTestCase() { } + +protected: + // this function must be overridden by the derived classes to return the + // text entry object we're testing, typically this is done by creating a + // control implementing wxPickerBase interface in setUp() virtual method and + // just returning it from here + virtual wxPickerBase *GetBase() const = 0; + + // this should be inserted in the derived class CPPUNIT_TEST_SUITE + // definition to run all wxPickerBase tests as part of it + #define wxPICKER_BASE_TESTS() \ + CPPUNIT_TEST( Margin ); \ + CPPUNIT_TEST( Proportion ); \ + CPPUNIT_TEST( Growable ); \ + CPPUNIT_TEST( Controls ) + + void Margin(); + void Proportion(); + void Growable(); + void Controls(); + +private: + wxDECLARE_NO_COPY_CLASS(PickerBaseTestCase); +}; + +#endif // _WX_TESTS_CONTROLS_PICKERBASETEST_H_ diff --git a/tests/controls/pickertest.cpp b/tests/controls/pickertest.cpp new file mode 100644 index 0000000000..9202b03c1a --- /dev/null +++ b/tests/controls/pickertest.cpp @@ -0,0 +1,202 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/pickertest.cpp +// Purpose: Tests for various wxPickerBase based classes +// Author: Steven Lamerton +// Created: 2010-08-07 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/clrpicker.h" +#include "wx/filepicker.h" +#include "wx/fontpicker.h" +#include "pickerbasetest.h" + +#if wxUSE_COLOURPICKERCTRL + +class ColourPickerCtrlTestCase : public PickerBaseTestCase, + public CppUnit::TestCase +{ +public: + ColourPickerCtrlTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxPickerBase *GetBase() const { return m_colour; } + + CPPUNIT_TEST_SUITE( ColourPickerCtrlTestCase ); + wxPICKER_BASE_TESTS(); + CPPUNIT_TEST_SUITE_END(); + + wxColourPickerCtrl *m_colour; + + DECLARE_NO_COPY_CLASS(ColourPickerCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ColourPickerCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ColourPickerCtrlTestCase, + "ColourPickerCtrlTestCase" ); + +void ColourPickerCtrlTestCase::setUp() +{ + m_colour = new wxColourPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY, + *wxBLACK, wxDefaultPosition, + wxDefaultSize, wxCLRP_USE_TEXTCTRL); +} + +void ColourPickerCtrlTestCase::tearDown() +{ + wxDELETE(m_colour); +} + +#endif //wxUSE_COLOURPICKERCTRL + +#if wxUSE_DIRPICKERCTRL + +class DirPickerCtrlTestCase : public PickerBaseTestCase, + public CppUnit::TestCase +{ +public: + DirPickerCtrlTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxPickerBase *GetBase() const { return m_dir; } + + CPPUNIT_TEST_SUITE( DirPickerCtrlTestCase ); + wxPICKER_BASE_TESTS(); + CPPUNIT_TEST_SUITE_END(); + + wxDirPickerCtrl *m_dir; + + DECLARE_NO_COPY_CLASS(DirPickerCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( DirPickerCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( DirPickerCtrlTestCase, + "DirPickerCtrlTestCase" ); + +void DirPickerCtrlTestCase::setUp() +{ + m_dir = new wxDirPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY, + wxEmptyString, wxDirSelectorPromptStr, + wxDefaultPosition, wxDefaultSize, + wxDIRP_USE_TEXTCTRL); +} + +void DirPickerCtrlTestCase::tearDown() +{ + wxDELETE(m_dir); +} + +#endif //wxUSE_DIRPICKERCTRL + +#if wxUSE_FILEPICKERCTRL + +class FilePickerCtrlTestCase : public PickerBaseTestCase, + public CppUnit::TestCase +{ +public: + FilePickerCtrlTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxPickerBase *GetBase() const { return m_file; } + + CPPUNIT_TEST_SUITE( FilePickerCtrlTestCase ); + wxPICKER_BASE_TESTS(); + CPPUNIT_TEST_SUITE_END(); + + wxFilePickerCtrl *m_file; + + DECLARE_NO_COPY_CLASS(FilePickerCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( FilePickerCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FilePickerCtrlTestCase, + "FilePickerCtrlTestCase" ); + +void FilePickerCtrlTestCase::setUp() +{ + m_file = new wxFilePickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY, + wxEmptyString, wxFileSelectorPromptStr, + wxFileSelectorDefaultWildcardStr, + wxDefaultPosition, wxDefaultSize, + wxFLP_USE_TEXTCTRL); +} + +void FilePickerCtrlTestCase::tearDown() +{ + wxDELETE(m_file); +} + +#endif //wxUSE_FILEPICKERCTRL + +#if wxUSE_FONTPICKERCTRL + +class FontPickerCtrlTestCase : public PickerBaseTestCase, + public CppUnit::TestCase +{ +public: + FontPickerCtrlTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxPickerBase *GetBase() const { return m_font; } + + CPPUNIT_TEST_SUITE( FontPickerCtrlTestCase ); + wxPICKER_BASE_TESTS(); + CPPUNIT_TEST_SUITE_END(); + + wxFontPickerCtrl *m_font; + + DECLARE_NO_COPY_CLASS(FontPickerCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( FontPickerCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontPickerCtrlTestCase, + "FontPickerCtrlTestCase" ); + +void FontPickerCtrlTestCase::setUp() +{ + m_font = new wxFontPickerCtrl(wxTheApp->GetTopWindow(), wxID_ANY, + wxNullFont, wxDefaultPosition, wxDefaultSize, + wxFNTP_USE_TEXTCTRL); +} + +void FontPickerCtrlTestCase::tearDown() +{ + wxDELETE(m_font); +} + +#endif //wxUSE_FONTPICKERCTRL diff --git a/tests/controls/radioboxtest.cpp b/tests/controls/radioboxtest.cpp new file mode 100644 index 0000000000..c336613d5a --- /dev/null +++ b/tests/controls/radioboxtest.cpp @@ -0,0 +1,230 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/radioboxtest.cpp +// Purpose: wxRadioBox unit test +// Author: Steven Lamerton +// Created: 2010-07-14 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_RADIOBOX + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/radiobox.h" +#endif // WX_PRECOMP + +#include "wx/tooltip.h" + +class RadioBoxTestCase : public CppUnit::TestCase +{ +public: + RadioBoxTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( RadioBoxTestCase ); + CPPUNIT_TEST( FindString ); + CPPUNIT_TEST( RowColCount ); + CPPUNIT_TEST( Enable ); + CPPUNIT_TEST( Show ); + CPPUNIT_TEST( HelpText ); + CPPUNIT_TEST( ToolTip ); + CPPUNIT_TEST( Selection ); + CPPUNIT_TEST( Count ); + CPPUNIT_TEST( SetString ); + CPPUNIT_TEST_SUITE_END(); + + void FindString(); + void RowColCount(); + void Enable(); + void Show(); + void HelpText(); + void ToolTip(); + void Selection(); + void Count(); + void SetString(); + + wxRadioBox* m_radio; + + DECLARE_NO_COPY_CLASS(RadioBoxTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( RadioBoxTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RadioBoxTestCase, "RadioBoxTestCase" ); + +void RadioBoxTestCase::setUp() +{ + wxArrayString choices; + choices.push_back("item 0"); + choices.push_back("item 1"); + choices.push_back("item 2"); + + m_radio = new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "RadioBox", + wxDefaultPosition, wxDefaultSize, choices); +} + +void RadioBoxTestCase::tearDown() +{ + wxTheApp->GetTopWindow()->DestroyChildren(); +} + +void RadioBoxTestCase::FindString() +{ + CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, m_radio->FindString("not here")); + CPPUNIT_ASSERT_EQUAL(1, m_radio->FindString("item 1")); + CPPUNIT_ASSERT_EQUAL(2, m_radio->FindString("ITEM 2")); + CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND, m_radio->FindString("ITEM 2", true)); +} + +void RadioBoxTestCase::RowColCount() +{ +#ifndef __WXGTK__ + wxArrayString choices; + choices.push_back("item 0"); + choices.push_back("item 1"); + choices.push_back("item 2"); + + m_radio = new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "RadioBox", + wxDefaultPosition, wxDefaultSize, choices, 2); + + CPPUNIT_ASSERT_EQUAL(2, m_radio->GetColumnCount()); + CPPUNIT_ASSERT_EQUAL(2, m_radio->GetRowCount()); + + m_radio = new wxRadioBox(wxTheApp->GetTopWindow(), wxID_ANY, "RadioBox", + wxDefaultPosition, wxDefaultSize, choices, 1, + wxRA_SPECIFY_ROWS); + + CPPUNIT_ASSERT_EQUAL(3, m_radio->GetColumnCount()); + CPPUNIT_ASSERT_EQUAL(1, m_radio->GetRowCount()); +#endif +} + +void RadioBoxTestCase::Enable() +{ +#ifndef __WXOSX__ + m_radio->Enable(false); + + CPPUNIT_ASSERT(!m_radio->IsItemEnabled(0)); + + m_radio->Enable(1, true); + + CPPUNIT_ASSERT(!m_radio->IsItemEnabled(0)); + CPPUNIT_ASSERT(m_radio->IsItemEnabled(1)); + CPPUNIT_ASSERT(!m_radio->IsItemEnabled(2)); + + m_radio->Enable(true); + + CPPUNIT_ASSERT(m_radio->IsItemEnabled(0)); + CPPUNIT_ASSERT(m_radio->IsItemEnabled(1)); + CPPUNIT_ASSERT(m_radio->IsItemEnabled(2)); + + m_radio->Enable(0, false); + + CPPUNIT_ASSERT(!m_radio->IsItemEnabled(0)); + CPPUNIT_ASSERT(m_radio->IsItemEnabled(1)); + CPPUNIT_ASSERT(m_radio->IsItemEnabled(2)); +#endif +} + +void RadioBoxTestCase::Show() +{ + m_radio->Show(false); + + CPPUNIT_ASSERT(!m_radio->IsItemShown(0)); + + m_radio->Show(1, true); + + CPPUNIT_ASSERT(!m_radio->IsItemShown(0)); + CPPUNIT_ASSERT(m_radio->IsItemShown(1)); + CPPUNIT_ASSERT(!m_radio->IsItemShown(2)); + + m_radio->Show(true); + + CPPUNIT_ASSERT(m_radio->IsItemShown(0)); + CPPUNIT_ASSERT(m_radio->IsItemShown(1)); + CPPUNIT_ASSERT(m_radio->IsItemShown(2)); + + m_radio->Show(0, false); + + CPPUNIT_ASSERT(!m_radio->IsItemShown(0)); + CPPUNIT_ASSERT(m_radio->IsItemShown(1)); + CPPUNIT_ASSERT(m_radio->IsItemShown(2)); +} + +void RadioBoxTestCase::HelpText() +{ + CPPUNIT_ASSERT_EQUAL(wxEmptyString, m_radio->GetItemHelpText(0)); + + m_radio->SetItemHelpText(1, "Item 1 help"); + + CPPUNIT_ASSERT_EQUAL("Item 1 help", m_radio->GetItemHelpText(1)); + + m_radio->SetItemHelpText(1, ""); + + CPPUNIT_ASSERT_EQUAL(wxEmptyString, m_radio->GetItemHelpText(1)); +} + +void RadioBoxTestCase::ToolTip() +{ +#if defined (__WXMSW__) || defined(__WXGTK__) + //GetItemToolTip returns null if there is no tooltip set + CPPUNIT_ASSERT(!m_radio->GetItemToolTip(0)); + + m_radio->SetItemToolTip(1, "Item 1 help"); + + CPPUNIT_ASSERT_EQUAL("Item 1 help", m_radio->GetItemToolTip(1)->GetTip()); + + m_radio->SetItemToolTip(1, ""); + + //However if we set a blank tip this does count as a tooltip + CPPUNIT_ASSERT(!m_radio->GetItemToolTip(1)); +#endif +} + +void RadioBoxTestCase::Selection() +{ + //Until other item containers the first item is selected by default + CPPUNIT_ASSERT_EQUAL(0, m_radio->GetSelection()); + CPPUNIT_ASSERT_EQUAL("item 0", m_radio->GetStringSelection()); + + m_radio->SetSelection(1); + + CPPUNIT_ASSERT_EQUAL(1, m_radio->GetSelection()); + CPPUNIT_ASSERT_EQUAL("item 1", m_radio->GetStringSelection()); + + m_radio->SetStringSelection("item 2"); + + CPPUNIT_ASSERT_EQUAL(2, m_radio->GetSelection()); + CPPUNIT_ASSERT_EQUAL("item 2", m_radio->GetStringSelection()); +} + +void RadioBoxTestCase::Count() +{ + //A trivial test for the item count as items can neither + //be added or removed + CPPUNIT_ASSERT_EQUAL(3, m_radio->GetCount()); + CPPUNIT_ASSERT(!m_radio->IsEmpty()); +} + +void RadioBoxTestCase::SetString() +{ + m_radio->SetString(0, "new item 0"); + m_radio->SetString(2, ""); + + CPPUNIT_ASSERT_EQUAL("new item 0", m_radio->GetString(0)); + CPPUNIT_ASSERT_EQUAL("", m_radio->GetString(2)); +} + +#endif // wxUSE_RADIOBOX diff --git a/tests/controls/radiobuttontest.cpp b/tests/controls/radiobuttontest.cpp new file mode 100644 index 0000000000..603052f53d --- /dev/null +++ b/tests/controls/radiobuttontest.cpp @@ -0,0 +1,159 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/radiobuttontest.cpp +// Purpose: wxRadioButton unit test +// Author: Steven Lamerton +// Created: 2010-07-30 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_RADIOBTN + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/radiobut.h" +#endif // WX_PRECOMP + +#include "wx/uiaction.h" +#include "testableframe.h" + +class RadioButtonTestCase : public CppUnit::TestCase +{ +public: + RadioButtonTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( RadioButtonTestCase ); + WXUISIM_TEST( Click ); + CPPUNIT_TEST( Value ); + CPPUNIT_TEST( Group ); + CPPUNIT_TEST_SUITE_END(); + + void Click(); + void Value(); + void Group(); + + wxRadioButton* m_radio; + + DECLARE_NO_COPY_CLASS(RadioButtonTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( RadioButtonTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RadioButtonTestCase, + "RadioButtonTestCase" ); + +void RadioButtonTestCase::setUp() +{ + m_radio = new wxRadioButton(wxTheApp->GetTopWindow(), wxID_ANY, + "wxRadioButton"); + m_radio->Update(); + m_radio->Refresh(); +} + +void RadioButtonTestCase::tearDown() +{ + wxDELETE(m_radio); +} + +void RadioButtonTestCase::Click() +{ + // GTK does not support selecting a single radio button +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_radio, wxEVT_COMMAND_RADIOBUTTON_SELECTED); + + wxUIActionSimulator sim; + + sim.MouseMove(m_radio->GetScreenPosition() + wxPoint(10, 10)); + sim.MouseClick(); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); +#endif +} + +void RadioButtonTestCase::Value() +{ +#ifndef __WXGTK__ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_radio, wxEVT_COMMAND_RADIOBUTTON_SELECTED); + + m_radio->SetValue(true); + + CPPUNIT_ASSERT(m_radio->GetValue()); + + m_radio->SetValue(false); + + CPPUNIT_ASSERT(!m_radio->GetValue()); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +#endif +} + +void RadioButtonTestCase::Group() +{ + //Add another button to the first group and create another of two buttons + wxRadioButton* g1radio0 = new wxRadioButton(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton", + wxDefaultPosition, + wxDefaultSize, wxRB_GROUP); + + wxRadioButton* g1radio1 = new wxRadioButton(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton"); + + wxRadioButton* g2radio0 = new wxRadioButton(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton", + wxDefaultPosition, + wxDefaultSize, wxRB_GROUP); + + wxRadioButton* g2radio1 = new wxRadioButton(wxTheApp->GetTopWindow(), + wxID_ANY, "wxRadioButton"); + + g1radio0->SetValue(true); + g2radio0->SetValue(true); + + CPPUNIT_ASSERT(g1radio0->GetValue()); + CPPUNIT_ASSERT(!g1radio1->GetValue()); + CPPUNIT_ASSERT(g2radio0->GetValue()); + CPPUNIT_ASSERT(!g2radio1->GetValue()); + + g1radio1->SetValue(true); + g2radio1->SetValue(true); + + CPPUNIT_ASSERT(!g1radio0->GetValue()); + CPPUNIT_ASSERT(g1radio1->GetValue()); + CPPUNIT_ASSERT(!g2radio0->GetValue()); + CPPUNIT_ASSERT(g2radio1->GetValue()); + + g1radio0->SetValue(true); + g2radio0->SetValue(true); + + CPPUNIT_ASSERT(g1radio0->GetValue()); + CPPUNIT_ASSERT(!g1radio1->GetValue()); + CPPUNIT_ASSERT(g2radio0->GetValue()); + CPPUNIT_ASSERT(!g2radio1->GetValue()); + + wxDELETE(g1radio0); + wxDELETE(g1radio1); + wxDELETE(g2radio0); + wxDELETE(g2radio1); +} + +#endif //wxUSE_RADIOBTN diff --git a/tests/controls/rearrangelisttest.cpp b/tests/controls/rearrangelisttest.cpp new file mode 100644 index 0000000000..dbebb42839 --- /dev/null +++ b/tests/controls/rearrangelisttest.cpp @@ -0,0 +1,161 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/rearrangelisttest.cpp +// Purpose: wxRearrangeList unit test +// Author: Steven Lamerton +// Created: 2010-07-05 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/rearrangectrl.h" +#include "itemcontainertest.h" +#include "testableframe.h" + +class RearrangeListTestCase : public ItemContainerTestCase, public CppUnit::TestCase +{ +public: + RearrangeListTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxItemContainer *GetContainer() const { return m_rearrange; } + virtual wxWindow *GetContainerWindow() const { return m_rearrange; } + + CPPUNIT_TEST_SUITE( RearrangeListTestCase ); + wxITEM_CONTAINER_TESTS(); + CPPUNIT_TEST( Move ); + CPPUNIT_TEST( MoveClientData ); + CPPUNIT_TEST_SUITE_END(); + + void Move(); + void MoveClientData(); + + wxRearrangeList* m_rearrange; + + DECLARE_NO_COPY_CLASS(RearrangeListTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( RearrangeListTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RearrangeListTestCase, "RearrangeListTestCase" ); + +void RearrangeListTestCase::setUp() +{ + //We do not add items here as the wxITEM_CONTAINER_TESTS add their own + wxArrayInt order; + wxArrayString items; + + m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, order, + items); +} + +void RearrangeListTestCase::tearDown() +{ + wxDELETE(m_rearrange); +} + +void RearrangeListTestCase::Move() +{ + wxArrayInt order; + order.push_back(1); + order.push_back(~2); + order.push_back(0); + + wxArrayString items; + items.push_back("first"); + items.push_back("second"); + items.push_back("third"); + + wxDELETE(m_rearrange); + + m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, order, + items); + + //Confusingly setselection sets the physical item rather than the + //item specified in the constructor + m_rearrange->SetSelection(0); + + CPPUNIT_ASSERT(!m_rearrange->CanMoveCurrentUp()); + CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentDown()); + + m_rearrange->SetSelection(1); + + CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentUp()); + CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentDown()); + + m_rearrange->SetSelection(2); + + CPPUNIT_ASSERT(m_rearrange->CanMoveCurrentUp()); + CPPUNIT_ASSERT(!m_rearrange->CanMoveCurrentDown()); + + m_rearrange->MoveCurrentUp(); + m_rearrange->SetSelection(0); + m_rearrange->MoveCurrentDown(); + + wxArrayInt neworder = m_rearrange->GetCurrentOrder(); + + CPPUNIT_ASSERT_EQUAL(neworder[0], 0); + CPPUNIT_ASSERT_EQUAL(neworder[1], 1); + CPPUNIT_ASSERT_EQUAL(neworder[2], ~2); + + CPPUNIT_ASSERT_EQUAL("first", m_rearrange->GetString(0)); + CPPUNIT_ASSERT_EQUAL("second", m_rearrange->GetString(1)); + CPPUNIT_ASSERT_EQUAL("third", m_rearrange->GetString(2)); +} + +void RearrangeListTestCase::MoveClientData() +{ + wxArrayInt order; + order.push_back(0); + order.push_back(1); + order.push_back(2); + + wxArrayString items; + items.push_back("first"); + items.push_back("second"); + items.push_back("third"); + + wxClientData* item0data = new wxStringClientData("item0data"); + wxClientData* item1data = new wxStringClientData("item1data"); + wxClientData* item2data = new wxStringClientData("item2data"); + + wxDELETE(m_rearrange); + + m_rearrange = new wxRearrangeList(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxDefaultSize, order, + items); + + m_rearrange->SetClientObject(0, item0data); + m_rearrange->SetClientObject(1, item1data); + m_rearrange->SetClientObject(2, item2data); + + m_rearrange->SetSelection(0); + m_rearrange->MoveCurrentDown(); + + m_rearrange->SetSelection(2); + m_rearrange->MoveCurrentUp(); + + CPPUNIT_ASSERT_EQUAL(item1data, m_rearrange->GetClientObject(0)); + CPPUNIT_ASSERT_EQUAL(item2data, m_rearrange->GetClientObject(1)); + CPPUNIT_ASSERT_EQUAL(item0data, m_rearrange->GetClientObject(2)); + + CPPUNIT_ASSERT_EQUAL("second", m_rearrange->GetString(0)); + CPPUNIT_ASSERT_EQUAL("third", m_rearrange->GetString(1)); + CPPUNIT_ASSERT_EQUAL("first", m_rearrange->GetString(2)); +} diff --git a/tests/controls/richtextctrltest.cpp b/tests/controls/richtextctrltest.cpp new file mode 100644 index 0000000000..35b39ab7e7 --- /dev/null +++ b/tests/controls/richtextctrltest.cpp @@ -0,0 +1,755 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/richtextctrltest.cpp +// Purpose: wxRichTextCtrl unit test +// Author: Steven Lamerton +// Created: 2010-07-07 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_RICHTEXT + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/richtext/richtextctrl.h" +#include "wx/richtext/richtextstyles.h" +#include "testableframe.h" +#include "asserthelper.h" +#include "wx/uiaction.h" + +class RichTextCtrlTestCase : public CppUnit::TestCase +{ +public: + RichTextCtrlTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( RichTextCtrlTestCase ); + WXUISIM_TEST( CharacterEvent ); + WXUISIM_TEST( DeleteEvent ); + WXUISIM_TEST( ReturnEvent ); + CPPUNIT_TEST( StyleEvent ); + CPPUNIT_TEST( BufferResetEvent ); + WXUISIM_TEST( UrlEvent ); + WXUISIM_TEST( TextEvent ); + CPPUNIT_TEST( CutCopyPaste ); + CPPUNIT_TEST( UndoRedo ); + CPPUNIT_TEST( CaretPosition ); + CPPUNIT_TEST( Selection ); + WXUISIM_TEST( Editable ); + CPPUNIT_TEST( Range ); + CPPUNIT_TEST( Alignment ); + CPPUNIT_TEST( Bold ); + CPPUNIT_TEST( Italic ); + CPPUNIT_TEST( Underline ); + CPPUNIT_TEST( Indent ); + CPPUNIT_TEST( LineSpacing ); + CPPUNIT_TEST( ParagraphSpacing ); + CPPUNIT_TEST( TextColour ); + CPPUNIT_TEST( NumberedBullet ); + CPPUNIT_TEST( SymbolBullet ); + CPPUNIT_TEST( FontSize ); + CPPUNIT_TEST( Font ); + CPPUNIT_TEST( Delete ); + CPPUNIT_TEST( Url ); + CPPUNIT_TEST_SUITE_END(); + + void CharacterEvent(); + void DeleteEvent(); + void ReturnEvent(); + void StyleEvent(); + void BufferResetEvent(); + void UrlEvent(); + void TextEvent(); + void CutCopyPaste(); + void UndoRedo(); + void CaretPosition(); + void Selection(); + void Editable(); + void Range(); + void Alignment(); + void Bold(); + void Italic(); + void Underline(); + void Indent(); + void LineSpacing(); + void ParagraphSpacing(); + void TextColour(); + void NumberedBullet(); + void SymbolBullet(); + void FontSize(); + void Font(); + void Delete(); + void Url(); + + wxRichTextCtrl* m_rich; + + DECLARE_NO_COPY_CLASS(RichTextCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( RichTextCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RichTextCtrlTestCase, "RichTextCtrlTestCase" ); + +void RichTextCtrlTestCase::setUp() +{ + m_rich = new wxRichTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxSize(400, 200)); +} + +void RichTextCtrlTestCase::tearDown() +{ + wxDELETE(m_rich); +} + +void RichTextCtrlTestCase::CharacterEvent() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_CHARACTER); + EventCounter count1(m_rich, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED); + + m_rich->SetFocus(); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CHARACTER)); + CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED)); + + //As these are not characters they shouldn't count + sim.Char(WXK_RETURN); + sim.Char(WXK_SHIFT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CHARACTER)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED)); +#endif +} + +void RichTextCtrlTestCase::DeleteEvent() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_DELETE); + EventCounter count1(m_rich, wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED); + + m_rich->SetFocus(); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + sim.Char(WXK_BACK); + sim.Char(WXK_DELETE); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_DELETE)); + //Only one as the delete doesn't delete anthing + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED)); +#endif +} + +void RichTextCtrlTestCase::ReturnEvent() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_RETURN); + + m_rich->SetFocus(); + + wxUIActionSimulator sim; + sim.Char(WXK_RETURN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +#endif +} + +void RichTextCtrlTestCase::StyleEvent() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED); + + m_rich->SetValue("Sometext"); + m_rich->SetStyle(0, 8, wxTextAttr(*wxRED, *wxWHITE)); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED)); +} + +void RichTextCtrlTestCase::BufferResetEvent() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_RICHTEXT_BUFFER_RESET); + + m_rich->AppendText("more text!"); + m_rich->SetValue(""); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + + m_rich->AppendText("more text!"); + m_rich->Clear(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + + //We expect a buffer reset here as setvalue clears the existing text + m_rich->SetValue("replace"); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +} + +void RichTextCtrlTestCase::UrlEvent() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_TEXT_URL); + + m_rich->BeginURL("http://www.wxwidgets.org"); + m_rich->WriteText("http://www.wxwidgets.org"); + m_rich->EndURL(); + + wxUIActionSimulator sim; + sim.MouseMove(m_rich->ClientToScreen(wxPoint(5, 5))); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +#endif +} + +void RichTextCtrlTestCase::TextEvent() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_TEXT_UPDATED); + + m_rich->SetFocus(); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue()); + CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount()); +#endif +} + +void RichTextCtrlTestCase::CutCopyPaste() +{ +#ifndef __WXOSX__ + m_rich->AppendText("sometext"); + m_rich->SelectAll(); + + if(m_rich->CanCut() && m_rich->CanPaste()) + { + m_rich->Cut(); + CPPUNIT_ASSERT(m_rich->IsEmpty()); + + wxYield(); + + m_rich->Paste(); + CPPUNIT_ASSERT_EQUAL("sometext", m_rich->GetValue()); + } + + m_rich->SelectAll(); + + if(m_rich->CanCopy() && m_rich->CanPaste()) + { + m_rich->Copy(); + m_rich->Clear(); + CPPUNIT_ASSERT(m_rich->IsEmpty()); + + wxYield(); + + m_rich->Paste(); + CPPUNIT_ASSERT_EQUAL("sometext", m_rich->GetValue()); + } +#endif +} + +void RichTextCtrlTestCase::UndoRedo() +{ + m_rich->AppendText("sometext"); + + CPPUNIT_ASSERT(m_rich->CanUndo()); + + m_rich->Undo(); + + CPPUNIT_ASSERT(m_rich->IsEmpty()); + CPPUNIT_ASSERT(m_rich->CanRedo()); + + m_rich->Redo(); + + CPPUNIT_ASSERT_EQUAL("sometext", m_rich->GetValue()); + + m_rich->AppendText("Batch undo"); + m_rich->SelectAll(); + + //Also test batch operations + m_rich->BeginBatchUndo("batchtest"); + + m_rich->ApplyBoldToSelection(); + m_rich->ApplyItalicToSelection(); + + m_rich->EndBatchUndo(); + + CPPUNIT_ASSERT(m_rich->CanUndo()); + + m_rich->Undo(); + + CPPUNIT_ASSERT(!m_rich->IsSelectionBold()); + CPPUNIT_ASSERT(!m_rich->IsSelectionItalics()); + CPPUNIT_ASSERT(m_rich->CanRedo()); + + m_rich->Redo(); + + CPPUNIT_ASSERT(m_rich->IsSelectionBold()); + CPPUNIT_ASSERT(m_rich->IsSelectionItalics()); + + //And surpressing undo + m_rich->BeginSuppressUndo(); + + m_rich->AppendText("Can't undo this"); + + CPPUNIT_ASSERT(m_rich->CanUndo()); + + m_rich->EndSuppressUndo(); +} + +void RichTextCtrlTestCase::CaretPosition() +{ + m_rich->AddParagraph("This is paragraph one"); + m_rich->AddParagraph("Paragraph two\n has \nlots of\n lines"); + + m_rich->MoveCaret(1); + + CPPUNIT_ASSERT_EQUAL(1, m_rich->GetCaretPosition()); + + m_rich->MoveToParagraphStart(); + + CPPUNIT_ASSERT_EQUAL(0, m_rich->GetCaretPosition()); + + m_rich->MoveRight(); + m_rich->MoveRight(2); + m_rich->MoveLeft(1); + m_rich->MoveLeft(0); + + CPPUNIT_ASSERT_EQUAL(2, m_rich->GetCaretPosition()); + + m_rich->MoveToParagraphEnd(); + + CPPUNIT_ASSERT_EQUAL(21, m_rich->GetCaretPosition()); + + m_rich->MoveToLineStart(); + + CPPUNIT_ASSERT_EQUAL(0, m_rich->GetCaretPosition()); + + m_rich->MoveToLineEnd(); + + CPPUNIT_ASSERT_EQUAL(21, m_rich->GetCaretPosition()); +} + +void RichTextCtrlTestCase::Selection() +{ + m_rich->SetValue("some more text"); + + m_rich->SelectAll(); + + CPPUNIT_ASSERT_EQUAL("some more text", m_rich->GetStringSelection()); + + m_rich->SelectNone(); + + CPPUNIT_ASSERT_EQUAL("", m_rich->GetStringSelection()); + + m_rich->SelectWord(1); + + CPPUNIT_ASSERT_EQUAL("some", m_rich->GetStringSelection()); + + m_rich->SetSelection(5, 14); + + CPPUNIT_ASSERT_EQUAL("more text", m_rich->GetStringSelection()); + + wxRichTextRange range(5, 9); + + m_rich->SetSelectionRange(range); + + CPPUNIT_ASSERT_EQUAL("more", m_rich->GetStringSelection()); +} + +void RichTextCtrlTestCase::Editable() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_rich, wxEVT_COMMAND_TEXT_UPDATED); + + m_rich->SetFocus(); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue()); + CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount()); + + m_rich->SetEditable(false); + sim.Text("gh"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("abcdef", m_rich->GetValue()); + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +#endif +} + +void RichTextCtrlTestCase::Range() +{ + wxRichTextRange range(0, 10); + + CPPUNIT_ASSERT_EQUAL(0, range.GetStart()); + CPPUNIT_ASSERT_EQUAL(10, range.GetEnd()); + CPPUNIT_ASSERT_EQUAL(11, range.GetLength()); + CPPUNIT_ASSERT(range.Contains(5)); + + wxRichTextRange outside(12, 14); + + CPPUNIT_ASSERT(outside.IsOutside(range)); + + wxRichTextRange inside(6, 7); + + CPPUNIT_ASSERT(inside.IsWithin(range)); + + range.LimitTo(inside); + + CPPUNIT_ASSERT(inside == range); + CPPUNIT_ASSERT(inside + range == outside); + CPPUNIT_ASSERT(outside - range == inside); + + range.SetStart(4); + range.SetEnd(6); + + CPPUNIT_ASSERT_EQUAL(4, range.GetStart()); + CPPUNIT_ASSERT_EQUAL(6, range.GetEnd()); + CPPUNIT_ASSERT_EQUAL(3, range.GetLength()); + + inside.SetRange(6, 4); + inside.Swap(); + + CPPUNIT_ASSERT(inside == range); +} + +void RichTextCtrlTestCase::Alignment() +{ + m_rich->SetValue("text to align"); + m_rich->SelectAll(); + + m_rich->ApplyAlignmentToSelection(wxTEXT_ALIGNMENT_RIGHT); + + CPPUNIT_ASSERT(m_rich->IsSelectionAligned(wxTEXT_ALIGNMENT_RIGHT)); + + m_rich->BeginAlignment(wxTEXT_ALIGNMENT_CENTRE); + m_rich->AddParagraph("middle aligned"); + m_rich->EndAlignment(); + + m_rich->SetSelection(20, 25); + + CPPUNIT_ASSERT(m_rich->IsSelectionAligned(wxTEXT_ALIGNMENT_CENTRE)); +} + +void RichTextCtrlTestCase::Bold() +{ + m_rich->SetValue("text to bold"); + m_rich->SelectAll(); + m_rich->ApplyBoldToSelection(); + + CPPUNIT_ASSERT(m_rich->IsSelectionBold()); + + m_rich->BeginBold(); + m_rich->AddParagraph("bold paragraph"); + m_rich->EndBold(); + m_rich->AddParagraph("not bold paragraph"); + + m_rich->SetSelection(15, 20); + + CPPUNIT_ASSERT(m_rich->IsSelectionBold()); + + m_rich->SetSelection(30, 35); + + CPPUNIT_ASSERT(!m_rich->IsSelectionBold()); +} + +void RichTextCtrlTestCase::Italic() +{ + m_rich->SetValue("text to italic"); + m_rich->SelectAll(); + m_rich->ApplyItalicToSelection(); + + CPPUNIT_ASSERT(m_rich->IsSelectionItalics()); + + m_rich->BeginItalic(); + m_rich->AddParagraph("italic paragraph"); + m_rich->EndItalic(); + m_rich->AddParagraph("not italic paragraph"); + + m_rich->SetSelection(20, 25); + + CPPUNIT_ASSERT(m_rich->IsSelectionItalics()); + + m_rich->SetSelection(35, 40); + + CPPUNIT_ASSERT(!m_rich->IsSelectionItalics()); +} + +void RichTextCtrlTestCase::Underline() +{ + m_rich->SetValue("text to underline"); + m_rich->SelectAll(); + m_rich->ApplyUnderlineToSelection(); + + CPPUNIT_ASSERT(m_rich->IsSelectionUnderlined()); + + m_rich->BeginUnderline(); + m_rich->AddParagraph("underline paragraph"); + m_rich->EndUnderline(); + m_rich->AddParagraph("not underline paragraph"); + + m_rich->SetSelection(20, 25); + + CPPUNIT_ASSERT(m_rich->IsSelectionUnderlined()); + + m_rich->SetSelection(40, 45); + + CPPUNIT_ASSERT(!m_rich->IsSelectionUnderlined()); +} + +void RichTextCtrlTestCase::Indent() +{ + m_rich->BeginLeftIndent(12, -5); + m_rich->BeginRightIndent(14); + m_rich->AddParagraph("A paragraph with indents"); + m_rich->EndLeftIndent(); + m_rich->EndRightIndent(); + m_rich->AddParagraph("No more indent"); + + wxTextAttr indent; + m_rich->GetStyle(5, indent); + + CPPUNIT_ASSERT_EQUAL(12, indent.GetLeftIndent()); + CPPUNIT_ASSERT_EQUAL(-5, indent.GetLeftSubIndent()); + CPPUNIT_ASSERT_EQUAL(14, indent.GetRightIndent()); + + m_rich->GetStyle(35, indent); + + CPPUNIT_ASSERT_EQUAL(0, indent.GetLeftIndent()); + CPPUNIT_ASSERT_EQUAL(0, indent.GetLeftSubIndent()); + CPPUNIT_ASSERT_EQUAL(0, indent.GetRightIndent()); +} + +void RichTextCtrlTestCase::LineSpacing() +{ + m_rich->BeginLineSpacing(20); + m_rich->AddParagraph("double spaced"); + m_rich->EndLineSpacing(); + m_rich->BeginLineSpacing(wxTEXT_ATTR_LINE_SPACING_HALF); + m_rich->AddParagraph("1.5 spaced"); + m_rich->EndLineSpacing(); + m_rich->AddParagraph("normally spaced"); + + wxTextAttr spacing; + m_rich->GetStyle(5, spacing); + + CPPUNIT_ASSERT_EQUAL(20, spacing.GetLineSpacing()); + + m_rich->GetStyle(20, spacing); + + CPPUNIT_ASSERT_EQUAL(15, spacing.GetLineSpacing()); + + m_rich->GetStyle(30, spacing); + + CPPUNIT_ASSERT_EQUAL(10, spacing.GetLineSpacing()); +} + +void RichTextCtrlTestCase::ParagraphSpacing() +{ + m_rich->BeginParagraphSpacing(15, 20); + m_rich->AddParagraph("spaced paragraph"); + m_rich->EndParagraphSpacing(); + m_rich->AddParagraph("non-spaced paragraph"); + + wxTextAttr spacing; + m_rich->GetStyle(5, spacing); + + CPPUNIT_ASSERT_EQUAL(15, spacing.GetParagraphSpacingBefore()); + CPPUNIT_ASSERT_EQUAL(20, spacing.GetParagraphSpacingAfter()); + + m_rich->GetStyle(25, spacing); + + //Make sure we test against the defaults + CPPUNIT_ASSERT_EQUAL(m_rich->GetBasicStyle().GetParagraphSpacingBefore(), + spacing.GetParagraphSpacingBefore()); + CPPUNIT_ASSERT_EQUAL(m_rich->GetBasicStyle().GetParagraphSpacingAfter(), + spacing.GetParagraphSpacingAfter()); +} + +void RichTextCtrlTestCase::TextColour() +{ + m_rich->BeginTextColour(*wxRED); + m_rich->AddParagraph("red paragraph"); + m_rich->EndTextColour(); + m_rich->AddParagraph("default paragraph"); + + wxTextAttr colour; + m_rich->GetStyle(5, colour); + + CPPUNIT_ASSERT_EQUAL(*wxRED, colour.GetTextColour()); + + m_rich->GetStyle(25, colour); + + CPPUNIT_ASSERT_EQUAL(m_rich->GetBasicStyle().GetTextColour(), + colour.GetTextColour()); +} + +void RichTextCtrlTestCase::NumberedBullet() +{ + m_rich->BeginNumberedBullet(1, 15, 20); + m_rich->AddParagraph("bullet one"); + m_rich->EndNumberedBullet(); + m_rich->BeginNumberedBullet(2, 25, -5); + m_rich->AddParagraph("bullet two"); + m_rich->EndNumberedBullet(); + + wxTextAttr bullet; + m_rich->GetStyle(5, bullet); + + CPPUNIT_ASSERT(bullet.HasBulletStyle()); + CPPUNIT_ASSERT(bullet.HasBulletNumber()); + CPPUNIT_ASSERT_EQUAL(1, bullet.GetBulletNumber()); + CPPUNIT_ASSERT_EQUAL(15, bullet.GetLeftIndent()); + CPPUNIT_ASSERT_EQUAL(20, bullet.GetLeftSubIndent()); + + m_rich->GetStyle(15, bullet); + + CPPUNIT_ASSERT(bullet.HasBulletStyle()); + CPPUNIT_ASSERT(bullet.HasBulletNumber()); + CPPUNIT_ASSERT_EQUAL(2, bullet.GetBulletNumber()); + CPPUNIT_ASSERT_EQUAL(25, bullet.GetLeftIndent()); + CPPUNIT_ASSERT_EQUAL(-5, bullet.GetLeftSubIndent()); +} + +void RichTextCtrlTestCase::SymbolBullet() +{ + m_rich->BeginSymbolBullet("*", 15, 20); + m_rich->AddParagraph("bullet one"); + m_rich->EndSymbolBullet(); + m_rich->BeginSymbolBullet("%", 25, -5); + m_rich->AddParagraph("bullet two"); + m_rich->EndSymbolBullet(); + + wxTextAttr bullet; + m_rich->GetStyle(5, bullet); + + CPPUNIT_ASSERT(bullet.HasBulletStyle()); + CPPUNIT_ASSERT(bullet.HasBulletText()); + CPPUNIT_ASSERT_EQUAL("*", bullet.GetBulletText()); + CPPUNIT_ASSERT_EQUAL(15, bullet.GetLeftIndent()); + CPPUNIT_ASSERT_EQUAL(20, bullet.GetLeftSubIndent()); + + m_rich->GetStyle(15, bullet); + + CPPUNIT_ASSERT(bullet.HasBulletStyle()); + CPPUNIT_ASSERT(bullet.HasBulletText()); + CPPUNIT_ASSERT_EQUAL("%", bullet.GetBulletText()); + CPPUNIT_ASSERT_EQUAL(25, bullet.GetLeftIndent()); + CPPUNIT_ASSERT_EQUAL(-5, bullet.GetLeftSubIndent()); +} + +void RichTextCtrlTestCase::FontSize() +{ + m_rich->BeginFontSize(24); + m_rich->AddParagraph("Large text"); + m_rich->EndFontSize(); + + wxTextAttr size; + m_rich->GetStyle(5, size); + + CPPUNIT_ASSERT(size.HasFontSize()); + CPPUNIT_ASSERT_EQUAL(24, size.GetFontSize()); +} + +void RichTextCtrlTestCase::Font() +{ + wxFont font(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + m_rich->BeginFont(font); + m_rich->AddParagraph("paragraph with font"); + m_rich->EndFont(); + + wxTextAttr fontstyle; + m_rich->GetStyle(5, fontstyle); + + CPPUNIT_ASSERT_EQUAL(font, fontstyle.GetFont()); +} + +void RichTextCtrlTestCase::Delete() +{ + m_rich->AddParagraph("here is a long long line in a paragraph"); + m_rich->SetSelection(0, 6); + + CPPUNIT_ASSERT(m_rich->CanDeleteSelection()); + + m_rich->DeleteSelection(); + + CPPUNIT_ASSERT_EQUAL("is a long long line in a paragraph", m_rich->GetValue()); + + m_rich->SetSelection(0, 5); + + CPPUNIT_ASSERT(m_rich->CanDeleteSelection()); + + m_rich->DeleteSelectedContent(); + + CPPUNIT_ASSERT_EQUAL("long long line in a paragraph", m_rich->GetValue()); + + m_rich->Delete(wxRichTextRange(14, 29)); + + CPPUNIT_ASSERT_EQUAL("long long line", m_rich->GetValue()); +} + +void RichTextCtrlTestCase::Url() +{ + m_rich->BeginURL("http://www.wxwidgets.org"); + m_rich->WriteText("http://www.wxwidgets.org"); + m_rich->EndURL(); + + wxTextAttr url; + m_rich->GetStyle(5, url); + + CPPUNIT_ASSERT(url.HasURL()); + CPPUNIT_ASSERT_EQUAL("http://www.wxwidgets.org", url.GetURL()); +} + +#endif //wxUSE_RICHTEXT diff --git a/tests/controls/slidertest.cpp b/tests/controls/slidertest.cpp new file mode 100644 index 0000000000..536166c8fc --- /dev/null +++ b/tests/controls/slidertest.cpp @@ -0,0 +1,207 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/slidertest.cpp +// Purpose: wxSlider unit test +// Author: Steven Lamerton +// Created: 2010-07-20 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_SLIDER + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/slider.h" +#endif // WX_PRECOMP + +#include "wx/uiaction.h" +#include "testableframe.h" + +class SliderTestCase : public CppUnit::TestCase +{ +public: + SliderTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( SliderTestCase ); + WXUISIM_TEST( PageUpDown ); + WXUISIM_TEST( LineUpDown ); + WXUISIM_TEST( LinePageSize ); + CPPUNIT_TEST( Value ); + CPPUNIT_TEST( Range ); + WXUISIM_TEST( Thumb ); + CPPUNIT_TEST_SUITE_END(); + + void PageUpDown(); + void LineUpDown(); + void LinePageSize(); + void Value(); + void Range(); + void Thumb(); + + wxSlider* m_slider; + + DECLARE_NO_COPY_CLASS(SliderTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( SliderTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SliderTestCase, "SliderTestCase" ); + +void SliderTestCase::setUp() +{ + m_slider = new wxSlider(wxTheApp->GetTopWindow(), wxID_ANY, 50, 0, 100); +} + +void SliderTestCase::tearDown() +{ + wxDELETE(m_slider); +} + +void SliderTestCase::PageUpDown() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_slider, wxEVT_SCROLL_PAGEUP); + EventCounter count1(m_slider, wxEVT_SCROLL_PAGEDOWN); + + wxUIActionSimulator sim; + + m_slider->SetFocus(); + + sim.Char(WXK_PAGEUP); + sim.Char(WXK_PAGEDOWN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_PAGEUP)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_PAGEDOWN)); +#endif +} + +void SliderTestCase::LineUpDown() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_slider, wxEVT_SCROLL_LINEUP); + EventCounter count1(m_slider, wxEVT_SCROLL_LINEDOWN); + + wxUIActionSimulator sim; + + m_slider->SetFocus(); + + sim.Char(WXK_UP); + sim.Char(WXK_DOWN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_LINEUP)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_LINEDOWN)); +#endif +} + +void SliderTestCase::LinePageSize() +{ +#if wxUSE_UIACTIONSIMULATOR + wxUIActionSimulator sim; + m_slider->SetFocus(); + + m_slider->SetPageSize(20); + + sim.Char(WXK_PAGEUP); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(20, m_slider->GetPageSize()); + CPPUNIT_ASSERT_EQUAL(30, m_slider->GetValue()); + + m_slider->SetLineSize(2); + + sim.Char(WXK_UP); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(2, m_slider->GetLineSize()); + CPPUNIT_ASSERT_EQUAL(28, m_slider->GetValue()); +#endif +} + +void SliderTestCase::Value() +{ + m_slider->SetValue(30); + + CPPUNIT_ASSERT_EQUAL(30, m_slider->GetValue()); + + //When setting a value larger that max or smaller than min + //max and min are set + m_slider->SetValue(-1); + + CPPUNIT_ASSERT_EQUAL(0, m_slider->GetValue()); + + m_slider->SetValue(110); + + CPPUNIT_ASSERT_EQUAL(100, m_slider->GetValue()); +} + +void SliderTestCase::Range() +{ + CPPUNIT_ASSERT_EQUAL(0, m_slider->GetMin()); + CPPUNIT_ASSERT_EQUAL(100, m_slider->GetMax()); + + //Test negative ranges + m_slider->SetRange(-50, 0); + + CPPUNIT_ASSERT_EQUAL(-50, m_slider->GetMin()); + CPPUNIT_ASSERT_EQUAL(0, m_slider->GetMax()); +} + +void SliderTestCase::Thumb() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_slider, wxEVT_SCROLL_THUMBTRACK); + EventCounter count1(m_slider, wxEVT_SCROLL_THUMBRELEASE); + EventCounter count2(m_slider, wxEVT_SCROLL_CHANGED); + + wxUIActionSimulator sim; + + m_slider->SetValue(0); + + sim.MouseMove(m_slider->ClientToScreen(wxPoint(10, 10))); + wxYield(); + + sim.MouseDown(); + wxYield(); + + sim.MouseMove(m_slider->ClientToScreen(wxPoint(50, 10))); + wxYield(); + + sim.MouseUp(); + wxYield(); + + CPPUNIT_ASSERT(frame->GetEventCount(wxEVT_SCROLL_THUMBTRACK) != 0); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_THUMBRELEASE)); +#ifdef __WXMSW__ + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SCROLL_CHANGED)); +#endif +#endif +} + +#endif diff --git a/tests/controls/spinctrldbltest.cpp b/tests/controls/spinctrldbltest.cpp new file mode 100644 index 0000000000..36ff97482e --- /dev/null +++ b/tests/controls/spinctrldbltest.cpp @@ -0,0 +1,183 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/spinctrldbltest.cpp +// Purpose: wxSpinCtrlDouble unit test +// Author: Steven Lamerton +// Created: 2010-07-22 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "testableframe.h" +#include "wx/uiaction.h" +#include "wx/spinctrl.h" + +class SpinCtrlDoubleTestCase : public CppUnit::TestCase +{ +public: + SpinCtrlDoubleTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( SpinCtrlDoubleTestCase ); + WXUISIM_TEST( Arrows ); + WXUISIM_TEST( Wrap ); + CPPUNIT_TEST( Range ); + CPPUNIT_TEST( Value ); + WXUISIM_TEST( Increment ); + CPPUNIT_TEST( Digits ); + CPPUNIT_TEST_SUITE_END(); + + void Arrows(); + void Wrap(); + void Range(); + void Value(); + void Increment(); + void Digits(); + + wxSpinCtrlDouble* m_spin; + + DECLARE_NO_COPY_CLASS(SpinCtrlDoubleTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( SpinCtrlDoubleTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SpinCtrlDoubleTestCase, "SpinCtrlDoubleTestCase" ); + +void SpinCtrlDoubleTestCase::setUp() +{ + m_spin = new wxSpinCtrlDouble(wxTheApp->GetTopWindow()); +} + +void SpinCtrlDoubleTestCase::tearDown() +{ + wxDELETE(m_spin); +} + +void SpinCtrlDoubleTestCase::Arrows() +{ +#ifndef __WXGTK__ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_spin, wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED); + + wxUIActionSimulator sim; + + m_spin->SetFocus(); + wxYield(); + + sim.Char(WXK_UP); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT_EQUAL(1.0, m_spin->GetValue()); + + sim.Char(WXK_DOWN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT_EQUAL(0.0, m_spin->GetValue()); +#endif +} + +void SpinCtrlDoubleTestCase::Wrap() +{ +#if wxUSE_UIACTIONSIMULATOR + wxDELETE(m_spin); + m_spin = new wxSpinCtrlDouble(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, + wxSP_ARROW_KEYS | wxSP_WRAP); + + wxUIActionSimulator sim; + + m_spin->SetFocus(); + + sim.Char(WXK_DOWN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(100.0, m_spin->GetValue()); + + sim.Char(WXK_UP); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0.0, m_spin->GetValue()); +#endif +} + +void SpinCtrlDoubleTestCase::Range() +{ + CPPUNIT_ASSERT_EQUAL(0.0, m_spin->GetMin()); + CPPUNIT_ASSERT_EQUAL(100.0, m_spin->GetMax()); + + //Test neagtive ranges + m_spin->SetRange(-10.0, 10.0); + + CPPUNIT_ASSERT_EQUAL(-10.0, m_spin->GetMin()); + CPPUNIT_ASSERT_EQUAL(10.0, m_spin->GetMax()); + + //Test backwards ranges + m_spin->SetRange(75.0, 50.0); + + CPPUNIT_ASSERT_EQUAL(75.0, m_spin->GetMin()); + CPPUNIT_ASSERT_EQUAL(50.0, m_spin->GetMax()); +} + +void SpinCtrlDoubleTestCase::Value() +{ + m_spin->SetDigits(2); + m_spin->SetIncrement(0.1); + + CPPUNIT_ASSERT_EQUAL(0.0, m_spin->GetValue()); + + m_spin->SetValue(50.0); + + CPPUNIT_ASSERT_EQUAL(50.0, m_spin->GetValue()); + + m_spin->SetValue(49.1); + + CPPUNIT_ASSERT_EQUAL(49.1, m_spin->GetValue()); +} + +void SpinCtrlDoubleTestCase::Increment() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + CPPUNIT_ASSERT_EQUAL(1.0, m_spin->GetIncrement()); + + m_spin->SetIncrement(0.1); + + CPPUNIT_ASSERT_EQUAL(0.1, m_spin->GetIncrement()); + + wxUIActionSimulator sim; + + m_spin->SetFocus(); + + sim.Char(WXK_UP); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0.1, m_spin->GetValue()); +#endif +} + +void SpinCtrlDoubleTestCase::Digits() +{ + m_spin->SetDigits(5); + + CPPUNIT_ASSERT_EQUAL(5, m_spin->GetDigits()); +} diff --git a/tests/controls/spinctrltest.cpp b/tests/controls/spinctrltest.cpp new file mode 100644 index 0000000000..25b6424c64 --- /dev/null +++ b/tests/controls/spinctrltest.cpp @@ -0,0 +1,157 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/spinctrltest.cpp +// Purpose: wxSpinCtrl unit test +// Author: Steven Lamerton +// Created: 2010-07-21 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_SPINCTRL + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "testableframe.h" +#include "wx/uiaction.h" +#include "wx/spinctrl.h" + +class SpinCtrlTestCase : public CppUnit::TestCase +{ +public: + SpinCtrlTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( SpinCtrlTestCase ); + WXUISIM_TEST( Arrows ); + WXUISIM_TEST( Wrap ); + CPPUNIT_TEST( Range ); + CPPUNIT_TEST( Value ); + CPPUNIT_TEST_SUITE_END(); + + void Arrows(); + void Wrap(); + void Range(); + void Value(); + + wxSpinCtrl* m_spin; + + DECLARE_NO_COPY_CLASS(SpinCtrlTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( SpinCtrlTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SpinCtrlTestCase, "SpinCtrlTestCase" ); + +void SpinCtrlTestCase::setUp() +{ + m_spin = new wxSpinCtrl(wxTheApp->GetTopWindow()); +} + +void SpinCtrlTestCase::tearDown() +{ + wxDELETE(m_spin); +} + +void SpinCtrlTestCase::Arrows() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_spin, wxEVT_COMMAND_SPINCTRL_UPDATED); + + wxUIActionSimulator sim; + + m_spin->SetFocus(); + + sim.Char(WXK_UP); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT_EQUAL(1, m_spin->GetValue()); + + sim.Char(WXK_DOWN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT_EQUAL(0, m_spin->GetValue()); +#endif +} + +void SpinCtrlTestCase::Wrap() +{ +#if wxUSE_UIACTIONSIMULATOR + wxDELETE(m_spin); + m_spin = new wxSpinCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, + wxSP_ARROW_KEYS | wxSP_WRAP); + + wxUIActionSimulator sim; + + m_spin->SetFocus(); + + sim.Char(WXK_DOWN); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(100, m_spin->GetValue()); + + sim.Char(WXK_UP); + + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, m_spin->GetValue()); +#endif +} + +void SpinCtrlTestCase::Range() +{ + CPPUNIT_ASSERT_EQUAL(0, m_spin->GetMin()); + CPPUNIT_ASSERT_EQUAL(100, m_spin->GetMax()); + + //Test neagtive ranges + m_spin->SetRange(-10, 10); + + CPPUNIT_ASSERT_EQUAL(-10, m_spin->GetMin()); + CPPUNIT_ASSERT_EQUAL(10, m_spin->GetMax()); + + //Test backwards ranges + m_spin->SetRange(75, 50); + + CPPUNIT_ASSERT_EQUAL(75, m_spin->GetMin()); + CPPUNIT_ASSERT_EQUAL(50, m_spin->GetMax()); +} + +void SpinCtrlTestCase::Value() +{ + CPPUNIT_ASSERT_EQUAL(0, m_spin->GetValue()); + + m_spin->SetValue(50); + + CPPUNIT_ASSERT_EQUAL(50, m_spin->GetValue()); + + m_spin->SetValue(-10); + + CPPUNIT_ASSERT_EQUAL(0, m_spin->GetValue()); + + m_spin->SetValue(110); + + CPPUNIT_ASSERT_EQUAL(100, m_spin->GetValue()); +} + +#endif diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index 5f2cc77f4e..393bda2a84 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -13,6 +13,8 @@ #include "testprec.h" +#if wxUSE_TEXTCTRL + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -23,12 +25,15 @@ #endif // WX_PRECOMP #include "textentrytest.h" +#include "testableframe.h" +#include "asserthelper.h" +#include "wx/uiaction.h" // ---------------------------------------------------------------------------- // test class // ---------------------------------------------------------------------------- -class TextCtrlTestCase : public TextEntryTestCase +class TextCtrlTestCase : public TextEntryTestCase, public CppUnit::TestCase { public: TextCtrlTestCase() { } @@ -43,9 +48,27 @@ private: CPPUNIT_TEST_SUITE( TextCtrlTestCase ); wxTEXT_ENTRY_TESTS(); CPPUNIT_TEST( MultiLineReplace ); + WXUISIM_TEST( ReadOnly ); + WXUISIM_TEST( MaxLength ); + CPPUNIT_TEST( StreamInput ); + CPPUNIT_TEST( Redirector ); + //WXUISIM_TEST( ProcessEnter ); + WXUISIM_TEST( Url ); + CPPUNIT_TEST( Style ); + CPPUNIT_TEST( Lines ); + CPPUNIT_TEST( LogTextCtrl ); CPPUNIT_TEST_SUITE_END(); void MultiLineReplace(); + void ReadOnly(); + void MaxLength(); + void StreamInput(); + void Redirector(); + //void ProcessEnter(); + void Url(); + void Style(); + void Lines(); + void LogTextCtrl(); wxTextCtrl *m_text; @@ -69,8 +92,7 @@ void TextCtrlTestCase::setUp() void TextCtrlTestCase::tearDown() { - delete m_text; - m_text = NULL; + wxDELETE(m_text); } // ---------------------------------------------------------------------------- @@ -99,5 +121,297 @@ void TextCtrlTestCase::MultiLineReplace() m_text->Replace(13, -1, ""); CPPUNIT_ASSERT_EQUAL("Hello changed", m_text->GetValue()); CPPUNIT_ASSERT_EQUAL(13, m_text->GetInsertionPoint()); + + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY); +} + +void TextCtrlTestCase::ReadOnly() +{ +#if wxUSE_UIACTIONSIMULATOR + // we need a read only control for this test so recreate it + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, + wxTE_READONLY); + + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_text, wxEVT_COMMAND_TEXT_UPDATED); + + m_text->SetFocus(); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("", m_text->GetValue()); + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); + + // SetEditable() is supposed to override wxTE_READONLY + m_text->SetEditable(true); + + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("abcdef", m_text->GetValue()); + CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount()); + + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY); +#endif +} + +void TextCtrlTestCase::MaxLength() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_text, wxEVT_COMMAND_TEXT_UPDATED); + EventCounter count1(m_text, wxEVT_COMMAND_TEXT_MAXLEN); + + m_text->SetFocus(); + m_text->SetMaxLength(10); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); + + sim.Text("ghij"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); + CPPUNIT_ASSERT_EQUAL(10, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED)); + + sim.Text("k"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED)); + + m_text->SetMaxLength(0); + + sim.Text("k"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_MAXLEN)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_UPDATED)); +#endif +} + +void TextCtrlTestCase::StreamInput() +{ +#ifndef __WXOSX__ + *m_text << "stringinput" + << 10 + << 1000L + << 3.14f + << 2.71 + << 'a' + << L'b'; + + CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71ab", m_text->GetValue()); + + m_text->SetValue(""); + +#if wxHAS_TEXT_WINDOW_STREAM + + std::ostream stream(m_text); + + // We don't test a wide character as this is not a wide stream + stream << "stringinput" + << 10 + << 1000L + << 3.14f + << 2.71 + << 'a'; + + stream.flush(); + + CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71a", m_text->GetValue()); + +#endif +#endif +} + +void TextCtrlTestCase::Redirector() +{ +#if wxHAS_TEXT_WINDOW_STREAM && wxUSE_STD_IOSTREAM + + wxStreamToTextRedirector redirect(m_text); + + std::cout << "stringinput" + << 10 + << 1000L + << 3.14f + << 2.71 + << 'a'; + + CPPUNIT_ASSERT_EQUAL("stringinput1010003.142.71a", m_text->GetValue()); + +#endif +} + +#if 0 +void TextCtrlTestCase::ProcessEnter() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_text, wxEVT_COMMAND_TEXT_ENTER); + + m_text->SetFocus(); + + wxUIActionSimulator sim; + sim.Char(WXK_RETURN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount(wxEVT_COMMAND_TEXT_ENTER)); + + // we need a text control with wxTE_PROCESS_ENTER for this test + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, + wxTE_PROCESS_ENTER); + + m_text->SetFocus(); + + sim.Char(WXK_RETURN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TEXT_ENTER)); +#endif +} +#endif + +void TextCtrlTestCase::Url() +{ +#if wxUSE_UIACTIONSIMULATOR && defined(__WXMSW__) + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE | wxTE_RICH | wxTE_AUTO_URL); + + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_text, wxEVT_COMMAND_TEXT_URL); + + m_text->AppendText("http://www.wxwidgets.org"); + + wxUIActionSimulator sim; + sim.MouseMove(m_text->ClientToScreen(wxPoint(5, 5))); + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +#endif +} + +void TextCtrlTestCase::Style() +{ +#ifndef __WXOSX__ + delete m_text; + // We need wxTE_RICH under windows for style support + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxDefaultSize, wxTE_RICH); + + // Red text on a white background + m_text->SetDefaultStyle(wxTextAttr(*wxRED, *wxWHITE)); + + CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetTextColour(), *wxRED); + CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetBackgroundColour(), + *wxWHITE); + + m_text->AppendText("red on white "); + + // Red text on a grey background + m_text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY)); + + CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetTextColour(), *wxRED); + CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetBackgroundColour(), + *wxLIGHT_GREY); + + m_text->AppendText("red on grey "); + + // Blue text on a grey background + m_text->SetDefaultStyle(wxTextAttr(*wxBLUE)); + + + CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetTextColour(), *wxBLUE); + CPPUNIT_ASSERT_EQUAL(m_text->GetDefaultStyle().GetBackgroundColour(), + *wxLIGHT_GREY); + + m_text->AppendText("blue on grey"); + + // Get getting the style at a specific location + wxTextAttr style; + + // We have to check that styles are supported + if(m_text->GetStyle(3, style)) + { + CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED); + CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE); + } + + // And then setting the style + if(m_text->SetStyle(15, 18, style)) + { + m_text->GetStyle(17, style); + + CPPUNIT_ASSERT_EQUAL(style.GetTextColour(), *wxRED); + CPPUNIT_ASSERT_EQUAL(style.GetBackgroundColour(), *wxWHITE); + } +#endif +} + +void TextCtrlTestCase::Lines() +{ +#ifndef __WXOSX__ + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxSize(400, 200), wxTE_MULTILINE | wxTE_DONTWRAP); + + m_text->SetValue("line1\nline2\nlong long line 3"); + m_text->Refresh(); + m_text->Update(); + + CPPUNIT_ASSERT_EQUAL(3, m_text->GetNumberOfLines()); + CPPUNIT_ASSERT_EQUAL(5, m_text->GetLineLength(0)); + CPPUNIT_ASSERT_EQUAL("line2", m_text->GetLineText(1)); + CPPUNIT_ASSERT_EQUAL(16, m_text->GetLineLength(2)); + + m_text->AppendText("\n\nMore text on line 5"); + + CPPUNIT_ASSERT_EQUAL(5, m_text->GetNumberOfLines()); + CPPUNIT_ASSERT_EQUAL(0, m_text->GetLineLength(3)); + CPPUNIT_ASSERT_EQUAL("", m_text->GetLineText(3)); +#endif +} + +void TextCtrlTestCase::LogTextCtrl() +{ + delete m_text; + m_text = new wxTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY, "", + wxDefaultPosition, wxSize(400, 200), + wxTE_MULTILINE); + + CPPUNIT_ASSERT(m_text->IsEmpty()); + + wxLogTextCtrl* logtext = new wxLogTextCtrl(m_text); + + wxLog* old = wxLog::SetActiveTarget(logtext); + + logtext->LogText("text"); + + delete wxLog::SetActiveTarget(old); + + CPPUNIT_ASSERT(!m_text->IsEmpty()); } +#endif //wxUSE_TEXTCTRL diff --git a/tests/controls/textentrytest.cpp b/tests/controls/textentrytest.cpp index fcd911cf8c..e28fc4809f 100644 --- a/tests/controls/textentrytest.cpp +++ b/tests/controls/textentrytest.cpp @@ -10,12 +10,15 @@ #include "testprec.h" #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/event.h" #include "wx/textentry.h" #include "wx/window.h" #endif // WX_PRECOMP #include "textentrytest.h" +#include "testableframe.h" +#include "wx/uiaction.h" void TextEntryTestCase::SetValue() { @@ -36,69 +39,42 @@ void TextEntryTestCase::SetValue() CPPUNIT_ASSERT_EQUAL( "bye", entry->GetValue() ); } -namespace -{ - class TextTestEventHandler : public wxEvtHandler - { - public: - TextTestEventHandler() { m_events = 0; } - - // calling this automatically resets the events counter - int GetEvents() - { - const int events = m_events; - m_events = 0; - return events; - } - - void OnText(wxCommandEvent& WXUNUSED(event)) { m_events++; } - - private: - int m_events; - }; -} - void TextEntryTestCase::TextChangeEvents() { - TextTestEventHandler handler; + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); - GetTestWindow()->Connect - ( - wxEVT_COMMAND_TEXT_UPDATED, - wxCommandEventHandler(TextTestEventHandler::OnText), - NULL, - &handler - ); + EventCounter count(GetTestWindow(), wxEVT_COMMAND_TEXT_UPDATED); wxTextEntry * const entry = GetTestEntry(); // notice that SetValue() generates an event even if the text didn't change entry->SetValue(""); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->SetValue("foo"); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->SetValue("foo"); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->ChangeValue("bar"); - CPPUNIT_ASSERT_EQUAL( 0, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() ); entry->AppendText("bar"); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->Replace(3, 6, "baz"); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->Remove(0, 3); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->WriteText("foo"); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); entry->Clear(); - CPPUNIT_ASSERT_EQUAL( 1, handler.GetEvents() ); + CPPUNIT_ASSERT_EQUAL( 1, frame->GetEventCount() ); } void TextEntryTestCase::CheckStringSelection(const char *sel) @@ -194,3 +170,79 @@ void TextEntryTestCase::Replace() CPPUNIT_ASSERT_EQUAL(2, entry->GetInsertionPoint()); } +void TextEntryTestCase::Editable() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + wxTextEntry * const entry = GetTestEntry(); + wxWindow * const window = GetTestWindow(); + + EventCounter count(window, wxEVT_COMMAND_TEXT_UPDATED); + + window->SetFocus(); + wxYield(); + + wxUIActionSimulator sim; + sim.Text("abcdef"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue()); + CPPUNIT_ASSERT_EQUAL(6, frame->GetEventCount()); + + entry->SetEditable(false); + sim.Text("gh"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL("abcdef", entry->GetValue()); + CPPUNIT_ASSERT_EQUAL(0, frame->GetEventCount()); +#endif +} + +void TextEntryTestCase::Hint() +{ + GetTestEntry()->SetHint("This is a hint"); + CPPUNIT_ASSERT_EQUAL("", GetTestEntry()->GetValue()); +} + +void TextEntryTestCase::CopyPaste() +{ +#ifndef __WXOSX__ + wxTextEntry * const entry = GetTestEntry(); + + entry->AppendText("sometext"); + entry->SelectAll(); + + if(entry->CanCopy() && entry->CanPaste()) + { + entry->Copy(); + entry->Clear(); + CPPUNIT_ASSERT(entry->IsEmpty()); + + wxYield(); + + entry->Paste(); + CPPUNIT_ASSERT_EQUAL("sometext", entry->GetValue()); + } +#endif +} + +void TextEntryTestCase::UndoRedo() +{ + wxTextEntry * const entry = GetTestEntry(); + + entry->AppendText("sometext"); + + if(entry->CanUndo()) + { + entry->Undo(); + CPPUNIT_ASSERT(entry->IsEmpty()); + + if(entry->CanRedo()) + { + entry->Redo(); + CPPUNIT_ASSERT_EQUAL("sometext", entry->GetValue()); + } + } +} diff --git a/tests/controls/textentrytest.h b/tests/controls/textentrytest.h index 8814772020..928f848591 100644 --- a/tests/controls/textentrytest.h +++ b/tests/controls/textentrytest.h @@ -14,10 +14,11 @@ // abstract base class testing wxTextEntry methods // ---------------------------------------------------------------------------- -class TextEntryTestCase : public CppUnit::TestCase +class TextEntryTestCase { public: TextEntryTestCase() { } + virtual ~TextEntryTestCase() { } protected: // this function must be overridden by the derived classes to return the @@ -38,13 +39,21 @@ protected: CPPUNIT_TEST( TextChangeEvents ); \ CPPUNIT_TEST( Selection ); \ CPPUNIT_TEST( InsertionPoint ); \ - CPPUNIT_TEST( Replace ) + CPPUNIT_TEST( Replace ); \ + WXUISIM_TEST( Editable ); \ + CPPUNIT_TEST( Hint ); \ + CPPUNIT_TEST( CopyPaste ); \ + CPPUNIT_TEST( UndoRedo ) void SetValue(); void TextChangeEvents(); void Selection(); void InsertionPoint(); void Replace(); + void Editable(); + void Hint(); + void CopyPaste(); + void UndoRedo(); private: // Selection() test helper: verify that selection is as described by the @@ -60,7 +69,7 @@ private: // wxChoice part of the control, not the selected text virtual void CheckStringSelection(const char *sel); - DECLARE_NO_COPY_CLASS(TextEntryTestCase) + wxDECLARE_NO_COPY_CLASS(TextEntryTestCase); }; #endif // _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_ diff --git a/tests/controls/togglebuttontest.cpp b/tests/controls/togglebuttontest.cpp new file mode 100644 index 0000000000..9d41429465 --- /dev/null +++ b/tests/controls/togglebuttontest.cpp @@ -0,0 +1,110 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/togglebuttontest.cpp +// Purpose: wxToggleButton unit test +// Author: Steven Lamerton +// Created: 2010-07-14 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_TOGGLEBTN + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "testableframe.h" +#include "wx/uiaction.h" +#include "wx/tglbtn.h" + +class ToggleButtonTestCase : public CppUnit::TestCase +{ +public: + ToggleButtonTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( ToggleButtonTestCase ); + WXUISIM_TEST( Click ); + CPPUNIT_TEST( Value ); + CPPUNIT_TEST_SUITE_END(); + + void Click(); + void Value(); + + wxToggleButton* m_button; + + DECLARE_NO_COPY_CLASS(ToggleButtonTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ToggleButtonTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ToggleButtonTestCase, "ToggleButtonTestCase" ); + +void ToggleButtonTestCase::setUp() +{ + m_button = new wxToggleButton(wxTheApp->GetTopWindow(), wxID_ANY, "wxToggleButton"); +} + +void ToggleButtonTestCase::tearDown() +{ + wxDELETE(m_button); +} + +void ToggleButtonTestCase::Click() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_button, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED); + + wxUIActionSimulator sim; + + //We move in slightly to account for window decorations + sim.MouseMove(m_button->GetScreenPosition() + wxPoint(10, 10)); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT(m_button->GetValue()); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + CPPUNIT_ASSERT(!m_button->GetValue()); +#endif +} + +void ToggleButtonTestCase::Value() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_button, wxEVT_COMMAND_BUTTON_CLICKED); + + m_button->SetValue(true); + + CPPUNIT_ASSERT(m_button->GetValue()); + + m_button->SetValue(false); + + CPPUNIT_ASSERT(!m_button->GetValue()); + + CPPUNIT_ASSERT_EQUAL( 0, frame->GetEventCount() ); +} + +#endif //wxUSE_TOGGLEBTN diff --git a/tests/controls/toolbooktest.cpp b/tests/controls/toolbooktest.cpp new file mode 100644 index 0000000000..858440556c --- /dev/null +++ b/tests/controls/toolbooktest.cpp @@ -0,0 +1,81 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/toolbooktest.cpp +// Purpose: wxToolbook unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_TOOLBOOK + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/panel.h" +#endif // WX_PRECOMP + +#include "wx/toolbook.h" +#include "wx/toolbar.h" +#include "bookctrlbasetest.h" + +class ToolbookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase +{ +public: + ToolbookTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxBookCtrlBase *GetBase() const { return m_toolbook; } + + virtual wxEventType GetChangedEvent() const + { return wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED; } + + virtual wxEventType GetChangingEvent() const + { return wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING; } + + CPPUNIT_TEST_SUITE( ToolbookTestCase ); + wxBOOK_CTRL_BASE_TESTS(); + CPPUNIT_TEST( ToolBar ); + CPPUNIT_TEST_SUITE_END(); + + void ToolBar(); + + wxToolbook *m_toolbook; + + DECLARE_NO_COPY_CLASS(ToolbookTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( ToolbookTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ToolbookTestCase, "ToolbookTestCase" ); + +void ToolbookTestCase::setUp() +{ + m_toolbook = new wxToolbook(wxTheApp->GetTopWindow(), wxID_ANY, wxDefaultPosition, wxSize(400, 200)); + AddPanels(); +} + +void ToolbookTestCase::tearDown() +{ + wxDELETE(m_toolbook); +} + +void ToolbookTestCase::ToolBar() +{ + wxToolBar* toolbar = static_cast(m_toolbook->GetToolBar()); + + CPPUNIT_ASSERT(toolbar); + CPPUNIT_ASSERT_EQUAL(3, toolbar->GetToolsCount()); +} + +#endif //wxUSE_TOOLBOOK diff --git a/tests/controls/treebooktest.cpp b/tests/controls/treebooktest.cpp new file mode 100644 index 0000000000..43bb91eacf --- /dev/null +++ b/tests/controls/treebooktest.cpp @@ -0,0 +1,147 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/treebooktest.cpp +// Purpose: wxtreebook unit test +// Author: Steven Lamerton +// Created: 2010-07-02 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_TREEBOOK + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/panel.h" +#endif // WX_PRECOMP + +#include "wx/treebook.h" +#include "bookctrlbasetest.h" + +class TreebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase +{ +public: + TreebookTestCase() { } + + virtual void setUp(); + virtual void tearDown(); + +private: + virtual wxBookCtrlBase *GetBase() const { return m_treebook; } + + virtual wxEventType GetChangedEvent() const + { return wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED; } + + virtual wxEventType GetChangingEvent() const + { return wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING; } + + CPPUNIT_TEST_SUITE( TreebookTestCase ); + wxBOOK_CTRL_BASE_TESTS(); + CPPUNIT_TEST( Image ); + CPPUNIT_TEST( SubPages ); + CPPUNIT_TEST( Expand ); + CPPUNIT_TEST( Delete ); + CPPUNIT_TEST_SUITE_END(); + + void SubPages(); + void Expand(); + void Delete(); + + wxTreebook *m_treebook; + + DECLARE_NO_COPY_CLASS(TreebookTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( TreebookTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreebookTestCase, "TreebookTestCase" ); + +void TreebookTestCase::setUp() +{ + m_treebook = new wxTreebook(wxTheApp->GetTopWindow(), wxID_ANY); + AddPanels(); +} + +void TreebookTestCase::tearDown() +{ + wxDELETE(m_treebook); +} + +void TreebookTestCase::SubPages() +{ + wxPanel* subpanel1 = new wxPanel(m_treebook); + wxPanel* subpanel2 = new wxPanel(m_treebook); + wxPanel* subpanel3 = new wxPanel(m_treebook); + + m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0); + + CPPUNIT_ASSERT_EQUAL(2, m_treebook->GetPageParent(3)); + + m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1); + + CPPUNIT_ASSERT_EQUAL(1, m_treebook->GetPageParent(2)); + + m_treebook->AddSubPage(subpanel3, "Subpanel 3", false, 2); + + CPPUNIT_ASSERT_EQUAL(3, m_treebook->GetPageParent(5)); +} + +void TreebookTestCase::Expand() +{ + wxPanel* subpanel1 = new wxPanel(m_treebook); + wxPanel* subpanel2 = new wxPanel(m_treebook); + wxPanel* subpanel3 = new wxPanel(m_treebook); + + m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0); + m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1); + m_treebook->AddSubPage(subpanel3, "Subpanel 3", false, 2); + + CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(1)); + CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(3)); + + m_treebook->CollapseNode(1); + + CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(1)); + + m_treebook->ExpandNode(3, false); + + CPPUNIT_ASSERT(!m_treebook->IsNodeExpanded(3)); + + m_treebook->ExpandNode(1); + + CPPUNIT_ASSERT(m_treebook->IsNodeExpanded(1)); +} + +void TreebookTestCase::Delete() +{ + wxPanel* subpanel1 = new wxPanel(m_treebook); + wxPanel* subpanel2 = new wxPanel(m_treebook); + wxPanel* subpanel3 = new wxPanel(m_treebook); + + m_treebook->AddSubPage(subpanel1, "Subpanel 1", false, 0); + m_treebook->InsertSubPage(1, subpanel2, "Subpanel 2", false, 1); + m_treebook->AddSubPage(subpanel3, "Subpanel 3", false, 2); + + CPPUNIT_ASSERT_EQUAL(6, m_treebook->GetPageCount()); + + m_treebook->DeletePage(3); + + CPPUNIT_ASSERT_EQUAL(3, m_treebook->GetPageCount()); + + m_treebook->DeletePage(1); + + CPPUNIT_ASSERT_EQUAL(1, m_treebook->GetPageCount()); + + m_treebook->DeletePage(0); + + CPPUNIT_ASSERT_EQUAL(0, m_treebook->GetPageCount()); +} + +#endif // wxUSE_TREEBOOK diff --git a/tests/controls/treectrltest.cpp b/tests/controls/treectrltest.cpp index 3c5d2c6a52..77b0b8b2e2 100644 --- a/tests/controls/treectrltest.cpp +++ b/tests/controls/treectrltest.cpp @@ -5,6 +5,7 @@ // Created: 2008-11-26 // RCS-ID: $Id$ // Copyright: (c) 2008 Vadim Zeitlin +// (c) 2010 Steven Lamerton /////////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- @@ -13,6 +14,8 @@ #include "testprec.h" +#if wxUSE_TREECTRL + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -21,7 +24,11 @@ #include "wx/app.h" #endif // WX_PRECOMP +#include "wx/artprov.h" +#include "wx/imaglist.h" #include "wx/treectrl.h" +#include "wx/uiaction.h" +#include "testableframe.h" // ---------------------------------------------------------------------------- // test class @@ -37,6 +44,25 @@ public: private: CPPUNIT_TEST_SUITE( TreeCtrlTestCase ); + WXUISIM_TEST( ItemClick ); + CPPUNIT_TEST( DeleteItem ); + WXUISIM_TEST( LabelEdit ); + WXUISIM_TEST( KeyDown ); +#ifndef __WXGTK__ + WXUISIM_TEST( CollapseExpandEvents ); + WXUISIM_TEST( SelectionChange ); +#endif // !__WXGTK__ + WXUISIM_TEST( Menu ); + CPPUNIT_TEST( ItemData ); + CPPUNIT_TEST( Iteration ); + CPPUNIT_TEST( Parent ); + CPPUNIT_TEST( CollapseExpand ); + CPPUNIT_TEST( AssignImageList ); + CPPUNIT_TEST( Focus ); + CPPUNIT_TEST( Bold ); + CPPUNIT_TEST( Visible ); + CPPUNIT_TEST( Sort ); + WXUISIM_TEST( KeyNavigation ); CPPUNIT_TEST( HasChildren ); CPPUNIT_TEST( SelectItemSingle ); CPPUNIT_TEST( PseudoTest_MultiSelect ); @@ -45,6 +71,25 @@ private: CPPUNIT_TEST( HasChildren ); CPPUNIT_TEST_SUITE_END(); + void ItemClick(); + void DeleteItem(); + void LabelEdit(); + void KeyDown(); +#ifndef __WXGTK__ + void CollapseExpandEvents(); + void SelectionChange(); +#endif // !__WXGTK__ + void Menu(); + void ItemData(); + void Iteration(); + void Parent(); + void CollapseExpand(); + void AssignImageList(); + void Focus(); + void Bold(); + void Visible(); + void Sort(); + void KeyNavigation(); void HasChildren(); void SelectItemSingle(); void SelectItemMulti(); @@ -81,7 +126,11 @@ bool TreeCtrlTestCase::ms_hiddenRoot = false; void TreeCtrlTestCase::setUp() { - m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow()); + m_tree = new wxTreeCtrl(wxTheApp->GetTopWindow(), + wxID_ANY, + wxDefaultPosition, + wxSize(400, 200), + wxTR_DEFAULT_STYLE | wxTR_EDIT_LABELS); if ( ms_multiSelect ) m_tree->ToggleWindowStyle(wxTR_MULTIPLE); @@ -93,6 +142,11 @@ void TreeCtrlTestCase::setUp() m_child1 = m_tree->AppendItem(m_root, "child1"); m_child2 = m_tree->AppendItem(m_root, "child2"); m_grandchild = m_tree->AppendItem(m_child1, "grandchild"); + + m_tree->SetSize(400, 200); + m_tree->ExpandAll(); + m_tree->Refresh(); + m_tree->Update(); } void TreeCtrlTestCase::tearDown() @@ -182,3 +236,386 @@ void TreeCtrlTestCase::SelectItemMulti() CPPUNIT_ASSERT( m_tree->IsSelected(m_child2) ); } +void TreeCtrlTestCase::ItemClick() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_ACTIVATED); + EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK); + + wxUIActionSimulator sim; + + wxRect pos; + m_tree->GetBoundingRect(m_child1, pos, true); + + // We move in slightly so we are not on the edge + wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4); + + sim.MouseMove(point); + wxYield(); + + sim.MouseDblClick(); + wxYield(); + + sim.MouseClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_ACTIVATED)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK)); +#endif // wxUSE_UIACTIONSIMULATOR +} + +void TreeCtrlTestCase::DeleteItem() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_DELETE_ITEM); + + wxTreeItemId todelete = m_tree->AppendItem(m_root, "deleteme"); + m_tree->Delete(todelete); + // We do not test DeleteAllItems() as under some versions of Windows events + // are not generated. + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +} + +#if wxUSE_UIACTIONSIMULATOR + +void TreeCtrlTestCase::LabelEdit() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT); + EventCounter count1(m_tree, wxEVT_COMMAND_TREE_END_LABEL_EDIT); + + wxUIActionSimulator sim; + + m_tree->SetFocusedItem(m_tree->GetRootItem()); + m_tree->EditLabel(m_tree->GetRootItem()); + + sim.Text("newroottext"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); + + sim.Char(WXK_RETURN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +} + +void TreeCtrlTestCase::KeyDown() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_KEY_DOWN); + + wxUIActionSimulator sim; + + m_tree->SetFocus(); + sim.Text("aAbB"); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(4, frame->GetEventCount()); +} + +#if !defined(__WXGTK__) + +void TreeCtrlTestCase::CollapseExpandEvents() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + m_tree->CollapseAll(); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSED); + EventCounter count1(m_tree, wxEVT_COMMAND_TREE_ITEM_COLLAPSING); + EventCounter count2(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDED); + EventCounter count3(m_tree, wxEVT_COMMAND_TREE_ITEM_EXPANDING); + + wxUIActionSimulator sim; + + wxRect pos; + m_tree->GetBoundingRect(m_root, pos, true); + + // We move in slightly so we are not on the edge + wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4); + + sim.MouseMove(point); + wxYield(); + + sim.MouseDblClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDING)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_EXPANDED)); + + sim.MouseDblClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSING)); + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_COLLAPSED)); +} + +void TreeCtrlTestCase::SelectionChange() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + m_tree->ExpandAll(); + m_tree->UnselectAll(); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGED); + EventCounter count1(m_tree, wxEVT_COMMAND_TREE_SEL_CHANGING); + + wxUIActionSimulator sim; + + wxRect poschild1, poschild2; + m_tree->GetBoundingRect(m_child1, poschild1, true); + m_tree->GetBoundingRect(m_child1, poschild2, true); + + // We move in slightly so we are not on the edge + wxPoint point1 = m_tree->ClientToScreen(poschild1.GetPosition()) + wxPoint(4, 4); + wxPoint point2 = m_tree->ClientToScreen(poschild2.GetPosition()) + wxPoint(4, 4); + + sim.MouseMove(point1); + wxYield(); + + sim.MouseClick(); + wxYield(); + + sim.MouseMove(point2); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGED)); + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount(wxEVT_COMMAND_TREE_SEL_CHANGING)); +} + +#endif // !__WXGTK__ + +void TreeCtrlTestCase::Menu() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_tree, wxEVT_COMMAND_TREE_ITEM_MENU); + wxUIActionSimulator sim; + + wxRect pos; + m_tree->GetBoundingRect(m_child1, pos, true); + + // We move in slightly so we are not on the edge + wxPoint point = m_tree->ClientToScreen(pos.GetPosition()) + wxPoint(4, 4); + + sim.MouseMove(point); + wxYield(); + + sim.MouseClick(wxMOUSE_BTN_RIGHT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_TREE_ITEM_MENU)); +} + +#endif // wxUSE_UIACTIONSIMULATOR + +void TreeCtrlTestCase::ItemData() +{ + wxTreeItemData* child1data = new wxTreeItemData(); + wxTreeItemData* appenddata = new wxTreeItemData(); + wxTreeItemData* insertdata = new wxTreeItemData(); + + m_tree->SetItemData(m_child1, child1data); + + CPPUNIT_ASSERT_EQUAL(child1data, m_tree->GetItemData(m_child1)); + CPPUNIT_ASSERT_EQUAL(m_child1, child1data->GetId()); + + wxTreeItemId append = m_tree->AppendItem(m_root, "new", -1, -1, appenddata); + + CPPUNIT_ASSERT_EQUAL(appenddata, m_tree->GetItemData(append)); + CPPUNIT_ASSERT_EQUAL(append, appenddata->GetId()); + + wxTreeItemId insert = m_tree->InsertItem(m_root, m_child1, "new", -1, -1, + insertdata); + + CPPUNIT_ASSERT_EQUAL(insertdata, m_tree->GetItemData(insert)); + CPPUNIT_ASSERT_EQUAL(insert, insertdata->GetId()); +} + +void TreeCtrlTestCase::Iteration() +{ + // Get first / next / last child + wxTreeItemIdValue cookie; + CPPUNIT_ASSERT_EQUAL(m_tree->GetFirstChild(m_root, cookie), m_child1); + CPPUNIT_ASSERT_EQUAL(m_tree->GetNextChild(m_root, cookie), + m_tree->GetLastChild(m_root)); + CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetLastChild(m_root)); + + // Get next / previous sibling + CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetNextSibling(m_child1)); + CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetPrevSibling(m_child2)); +} + +void TreeCtrlTestCase::Parent() +{ + CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetRootItem()); + CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetItemParent(m_child1)); + CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetItemParent(m_child2)); + CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetItemParent(m_grandchild)); +} + +void TreeCtrlTestCase::CollapseExpand() +{ + m_tree->ExpandAll(); + + CPPUNIT_ASSERT(m_tree->IsExpanded(m_root)); + CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1)); + + m_tree->CollapseAll(); + + CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root)); + CPPUNIT_ASSERT(!m_tree->IsExpanded(m_child1)); + + m_tree->ExpandAllChildren(m_root); + + CPPUNIT_ASSERT(m_tree->IsExpanded(m_root)); + CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1)); + + m_tree->CollapseAllChildren(m_child1); + + CPPUNIT_ASSERT(!m_tree->IsExpanded(m_child1)); + + m_tree->Expand(m_child1); + + CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1)); + + m_tree->Collapse(m_root); + + CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root)); + CPPUNIT_ASSERT(m_tree->IsExpanded(m_child1)); + + m_tree->CollapseAndReset(m_root); + + CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root)); +} + +void TreeCtrlTestCase::AssignImageList() +{ + wxSize size(16, 16); + + wxImageList *imagelist = new wxImageList(size.x, size.y); + imagelist->Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, size)); + + wxImageList *statelist = new wxImageList(size.x, size.y); + statelist->Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, size)); + + m_tree->AssignImageList(imagelist); + m_tree->AssignStateImageList(statelist); + + CPPUNIT_ASSERT_EQUAL(imagelist, m_tree->GetImageList()); + CPPUNIT_ASSERT_EQUAL(statelist, m_tree->GetStateImageList()); +} + +void TreeCtrlTestCase::Focus() +{ +#if !defined(__WXGTK__) && !defined(__WXOSX__) + m_tree->SetFocusedItem(m_child1); + + CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetFocusedItem()); + + m_tree->ClearFocusedItem(); + + CPPUNIT_ASSERT(!m_tree->GetFocusedItem()); +#endif +} + +void TreeCtrlTestCase::Bold() +{ + CPPUNIT_ASSERT(!m_tree->IsBold(m_child1)); + + m_tree->SetItemBold(m_child1); + + CPPUNIT_ASSERT(m_tree->IsBold(m_child1)); + + m_tree->SetItemBold(m_child1, false); + + CPPUNIT_ASSERT(!m_tree->IsBold(m_child1)); +} + +void TreeCtrlTestCase::Visible() +{ + m_tree->CollapseAll(); + + CPPUNIT_ASSERT(m_tree->IsVisible(m_root)); + CPPUNIT_ASSERT(!m_tree->IsVisible(m_child1)); + + m_tree->EnsureVisible(m_grandchild); + + CPPUNIT_ASSERT(m_tree->IsVisible(m_grandchild)); + + m_tree->ExpandAll(); + + CPPUNIT_ASSERT_EQUAL(m_root, m_tree->GetFirstVisibleItem()); + CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetNextVisible(m_root)); + CPPUNIT_ASSERT_EQUAL(m_grandchild, m_tree->GetNextVisible(m_child1)); + CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetNextVisible(m_grandchild)); + + CPPUNIT_ASSERT(!m_tree->GetNextVisible(m_child2)); + CPPUNIT_ASSERT(!m_tree->GetPrevVisible(m_root)); +} + +void TreeCtrlTestCase::Sort() +{ + wxTreeItemId zitem = m_tree->AppendItem(m_root, "zzzz"); + wxTreeItemId aitem = m_tree->AppendItem(m_root, "aaaa"); + + m_tree->SortChildren(m_root); + + wxTreeItemIdValue cookie; + + CPPUNIT_ASSERT_EQUAL(aitem, m_tree->GetFirstChild(m_root, cookie)); + CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetNextChild(m_root, cookie)); + CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetNextChild(m_root, cookie)); + CPPUNIT_ASSERT_EQUAL(zitem, m_tree->GetNextChild(m_root, cookie)); +} + +void TreeCtrlTestCase::KeyNavigation() +{ +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) + wxUIActionSimulator sim; + + m_tree->CollapseAll(); + + m_tree->SelectItem(m_root); + + sim.Char(WXK_RIGHT); + wxYield(); + + CPPUNIT_ASSERT(m_tree->IsExpanded(m_root)); + + sim.Char(WXK_LEFT); + wxYield(); + + CPPUNIT_ASSERT(!m_tree->IsExpanded(m_root)); + + sim.Char(WXK_RIGHT); + sim.Char(WXK_DOWN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(m_child1, m_tree->GetSelection()); + + sim.Char(WXK_DOWN); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(m_child2, m_tree->GetSelection()); +#endif +} + +#endif //wxUSE_TREECTRL diff --git a/tests/controls/windowtest.cpp b/tests/controls/windowtest.cpp new file mode 100644 index 0000000000..72266b2753 --- /dev/null +++ b/tests/controls/windowtest.cpp @@ -0,0 +1,389 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/windowtest.cpp +// Purpose: wxWindow unit test +// Author: Steven Lamerton +// Created: 2010-07-10 +// RCS-ID: $Id$ +// Copyright: (c) 2010 Steven Lamerton +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/window.h" + #include "wx/button.h" +#endif // WX_PRECOMP + +#include "asserthelper.h" +#include "testableframe.h" +#include "wx/uiaction.h" +#include "wx/caret.h" +#include "wx/cshelp.h" +#include "wx/tooltip.h" + +class WindowTestCase : public CppUnit::TestCase +{ +public: + WindowTestCase() { } + + void setUp(); + void tearDown(); + +private: + CPPUNIT_TEST_SUITE( WindowTestCase ); + CPPUNIT_TEST( ShowHideEvent ); + WXUISIM_TEST( KeyEvent ); + CPPUNIT_TEST( FocusEvent ); + CPPUNIT_TEST( Mouse ); + CPPUNIT_TEST( Properties ); + CPPUNIT_TEST( ToolTip ); + CPPUNIT_TEST( Help ); + CPPUNIT_TEST( Parent ); + CPPUNIT_TEST( Siblings ); + CPPUNIT_TEST( Children ); + CPPUNIT_TEST( Focus ); + CPPUNIT_TEST( Positioning ); + CPPUNIT_TEST( Show ); + CPPUNIT_TEST( Enable ); + CPPUNIT_TEST( FindWindowBy ); + CPPUNIT_TEST_SUITE_END(); + + void ShowHideEvent(); + void KeyEvent(); + void FocusEvent(); + void Mouse(); + void Properties(); + void ToolTip(); + void Help(); + void Parent(); + void Siblings(); + void Children(); + void Focus(); + void Positioning(); + void Show(); + void Enable(); + void FindWindowBy(); + + wxWindow *m_window; + + DECLARE_NO_COPY_CLASS(WindowTestCase) +}; + +// register in the unnamed registry so that these tests are run by default +CPPUNIT_TEST_SUITE_REGISTRATION( WindowTestCase ); + +// also include in it's own registry so that these tests can be run alone +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( WindowTestCase, "WindowTestCase" ); + +void WindowTestCase::setUp() +{ + m_window = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY); +} + +void WindowTestCase::tearDown() +{ + wxTheApp->GetTopWindow()->DestroyChildren(); +} + +void WindowTestCase::ShowHideEvent() +{ +#if defined(__WXMSW__) || defined (__WXPM__) + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_window, wxEVT_SHOW); + + CPPUNIT_ASSERT(m_window->IsShown()); + + m_window->Show(false); + + CPPUNIT_ASSERT(!m_window->IsShown()); + + m_window->Show(); + + CPPUNIT_ASSERT(m_window->IsShown()); + + CPPUNIT_ASSERT_EQUAL(2, frame->GetEventCount()); +#endif +} + +void WindowTestCase::KeyEvent() +{ +#if wxUSE_UIACTIONSIMULATOR + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_window, wxEVT_KEY_DOWN); + EventCounter count1(m_window, wxEVT_KEY_UP); + EventCounter count2(m_window, wxEVT_CHAR); + + wxUIActionSimulator sim; + + m_window->SetFocus(); + + sim.Text("text"); + sim.Char(WXK_SHIFT); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(5, frame->GetEventCount(wxEVT_KEY_DOWN)); + CPPUNIT_ASSERT_EQUAL(5, frame->GetEventCount(wxEVT_KEY_UP)); + CPPUNIT_ASSERT_EQUAL(4, frame->GetEventCount(wxEVT_CHAR)); +#endif +} + +void WindowTestCase::FocusEvent() +{ +#ifndef __WXOSX__ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count(m_window, wxEVT_SET_FOCUS); + EventCounter count1(m_window, wxEVT_KILL_FOCUS); + + m_window->SetFocus(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_SET_FOCUS)); + CPPUNIT_ASSERT(m_window->HasFocus()); + + wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY); + + button->SetFocus(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_KILL_FOCUS)); + CPPUNIT_ASSERT(!m_window->HasFocus()); +#endif +} + +void WindowTestCase::Mouse() +{ + wxCursor cursor(wxCURSOR_CHAR); + m_window->SetCursor(cursor); + + CPPUNIT_ASSERT(m_window->GetCursor().IsOk()); + + //A plain window doesn't have a caret + CPPUNIT_ASSERT(!m_window->GetCaret()); + + wxCaret* caret = new wxCaret(m_window, 16, 16); + m_window->SetCaret(caret); + + CPPUNIT_ASSERT(m_window->GetCaret()->IsOk()); + + m_window->CaptureMouse(); + + CPPUNIT_ASSERT(m_window->HasCapture()); + + m_window->ReleaseMouse(); + + CPPUNIT_ASSERT(!m_window->HasCapture()); +} + +void WindowTestCase::Properties() +{ +#ifndef __WXGTK__ + m_window->SetLabel("label"); + + CPPUNIT_ASSERT_EQUAL("label", m_window->GetLabel()); +#endif + + m_window->SetName("name"); + + CPPUNIT_ASSERT_EQUAL("name", m_window->GetName()); + + //As we used wxID_ANY we should have a negative id + CPPUNIT_ASSERT(m_window->GetId() < 0); + + m_window->SetId(wxID_HIGHEST + 10); + + CPPUNIT_ASSERT_EQUAL(wxID_HIGHEST + 10, m_window->GetId()); +} + +void WindowTestCase::ToolTip() +{ + CPPUNIT_ASSERT(!m_window->GetToolTip()); + CPPUNIT_ASSERT_EQUAL("", m_window->GetToolTipText()); + + m_window->SetToolTip("text tip"); + + CPPUNIT_ASSERT_EQUAL("text tip", m_window->GetToolTipText()); + + m_window->UnsetToolTip(); + + CPPUNIT_ASSERT(!m_window->GetToolTip()); + CPPUNIT_ASSERT_EQUAL("", m_window->GetToolTipText()); + + wxToolTip* tip = new wxToolTip("other tip"); + + m_window->SetToolTip(tip); + + CPPUNIT_ASSERT_EQUAL(tip, m_window->GetToolTip()); + CPPUNIT_ASSERT_EQUAL("other tip", m_window->GetToolTipText()); +} + +void WindowTestCase::Help() +{ + wxHelpProvider::Set(new wxSimpleHelpProvider()); + + CPPUNIT_ASSERT_EQUAL("", m_window->GetHelpText()); + + m_window->SetHelpText("helptext"); + + CPPUNIT_ASSERT_EQUAL("helptext", m_window->GetHelpText()); +} + +void WindowTestCase::Parent() +{ + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), m_window->GetGrandParent()); + CPPUNIT_ASSERT_EQUAL(wxTheApp->GetTopWindow(), m_window->GetParent()); +} + +void WindowTestCase::Siblings() +{ + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), m_window->GetNextSibling()); + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), m_window->GetPrevSibling()); + + wxWindow* newwin = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY); + + CPPUNIT_ASSERT_EQUAL(newwin, m_window->GetNextSibling()); + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), m_window->GetPrevSibling()); + + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), newwin->GetNextSibling()); + CPPUNIT_ASSERT_EQUAL(m_window, newwin->GetPrevSibling()); + + wxDELETE(newwin); +} + +void WindowTestCase::Children() +{ + CPPUNIT_ASSERT_EQUAL(0, m_window->GetChildren().GetCount()); + + wxWindow* child1 = new wxWindow(m_window, wxID_ANY); + + CPPUNIT_ASSERT_EQUAL(1, m_window->GetChildren().GetCount()); + + m_window->RemoveChild(child1); + + CPPUNIT_ASSERT_EQUAL(0, m_window->GetChildren().GetCount()); + + child1->SetId(wxID_HIGHEST + 1); + child1->SetName("child1"); + + m_window->AddChild(child1); + + CPPUNIT_ASSERT_EQUAL(1, m_window->GetChildren().GetCount()); + CPPUNIT_ASSERT_EQUAL(child1, m_window->FindWindow(wxID_HIGHEST + 1)); + CPPUNIT_ASSERT_EQUAL(child1, m_window->FindWindow("child1")); + + m_window->DestroyChildren(); + + CPPUNIT_ASSERT_EQUAL(0, m_window->GetChildren().GetCount()); +} + +void WindowTestCase::Focus() +{ +#ifndef __WXOSX__ + CPPUNIT_ASSERT(!m_window->HasFocus()); + + if ( m_window->AcceptsFocus() ) + { + m_window->SetFocus(); + CPPUNIT_ASSERT(m_window->HasFocus()); + } + + //Set the focus back to the main window + wxTheApp->GetTopWindow()->SetFocus(); + + if ( m_window->AcceptsFocusFromKeyboard() ) + { + m_window->SetFocusFromKbd(); + CPPUNIT_ASSERT(m_window->HasFocus()); + } +#endif +} + +void WindowTestCase::Positioning() +{ + //Some basic tests for consistency + int x, y; + m_window->GetPosition(&x, &y); + + CPPUNIT_ASSERT_EQUAL(x, m_window->GetPosition().x); + CPPUNIT_ASSERT_EQUAL(y, m_window->GetPosition().y); + CPPUNIT_ASSERT_EQUAL(m_window->GetPosition(), + m_window->GetRect().GetTopLeft()); + + m_window->GetScreenPosition(&x, &y); + CPPUNIT_ASSERT_EQUAL(x, m_window->GetScreenPosition().x); + CPPUNIT_ASSERT_EQUAL(y, m_window->GetScreenPosition().y); + CPPUNIT_ASSERT_EQUAL(m_window->GetScreenPosition(), + m_window->GetScreenRect().GetTopLeft()); +} + +void WindowTestCase::Show() +{ + CPPUNIT_ASSERT(m_window->IsShown()); + + m_window->Hide(); + + CPPUNIT_ASSERT(!m_window->IsShown()); + + m_window->Show(); + + CPPUNIT_ASSERT(m_window->IsShown()); + + m_window->Show(false); + + CPPUNIT_ASSERT(!m_window->IsShown()); + + m_window->ShowWithEffect(wxSHOW_EFFECT_BLEND); + + CPPUNIT_ASSERT(m_window->IsShown()); + + m_window->HideWithEffect(wxSHOW_EFFECT_BLEND); + + CPPUNIT_ASSERT(!m_window->IsShown()); +} + +void WindowTestCase::Enable() +{ + CPPUNIT_ASSERT(m_window->IsEnabled()); + + m_window->Disable(); + + CPPUNIT_ASSERT(!m_window->IsEnabled()); + + m_window->Enable(); + + CPPUNIT_ASSERT(m_window->IsEnabled()); + + m_window->Enable(false); + + CPPUNIT_ASSERT(!m_window->IsEnabled()); +} + +void WindowTestCase::FindWindowBy() +{ + m_window->SetId(wxID_HIGHEST + 1); + m_window->SetName("name"); +#ifndef __WXGTK__ + m_window->SetLabel("label"); +#endif + + CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowById(wxID_HIGHEST + 1)); + CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowByName("name")); +#ifndef __WXGTK__ + CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowByLabel("label")); +#endif + + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), + wxWindow::FindWindowById(wxID_HIGHEST + 3)); + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), + wxWindow::FindWindowByName("noname")); + CPPUNIT_ASSERT_EQUAL(static_cast(NULL), + wxWindow::FindWindowByLabel("nolabel")); +} diff --git a/tests/events/stopwatch.cpp b/tests/events/stopwatch.cpp index d26566f1ad..a590dc326d 100644 --- a/tests/events/stopwatch.cpp +++ b/tests/events/stopwatch.cpp @@ -55,27 +55,45 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StopWatchTestCase, "StopWatchTestCase" ); void StopWatchTestCase::Misc() { + static const long tolerance = 100; // in ms + wxStopWatch sw; - long tmp; + long t; sw.Pause(); // pause it immediately wxSleep(2); - tmp = sw.Time(); - CPPUNIT_ASSERT(tmp >= 0 && tmp < 100); - // should not have counted while paused! + t = sw.Time(); + + // check that the stop watch doesn't advance while paused + WX_ASSERT_MESSAGE + ( + ("Actual time value is %ld", t), + t >= 0 && t < tolerance + ); sw.Resume(); wxSleep(3); - tmp = sw.Time(); - CPPUNIT_ASSERT(tmp >= 3000 && tmp < 4000); + t = sw.Time(); + // check that it did advance now by ~3s + WX_ASSERT_MESSAGE + ( + ("Actual time value is %ld", t), + t > 3000 - tolerance && t < 3000 + tolerance + ); sw.Pause(); sw.Resume(); wxSleep(2); - tmp = sw.Time(); - CPPUNIT_ASSERT(tmp >= 5000 && tmp < 6000); + t = sw.Time(); + + // and it should advance again + WX_ASSERT_MESSAGE + ( + ("Actual time value is %ld", t), + t > 5000 - tolerance && t < 5000 + tolerance + ); } void StopWatchTestCase::BackwardsClockBug() diff --git a/tests/graphics/colour.cpp b/tests/graphics/colour.cpp index 0269e6bc1b..2f06919409 100644 --- a/tests/graphics/colour.cpp +++ b/tests/graphics/colour.cpp @@ -18,50 +18,7 @@ #endif #include "wx/colour.h" - -// ---------------------------------------------------------------------------- -// helper functions -// ---------------------------------------------------------------------------- - -namespace -{ - // by default colour components values are output incorrectly because they - // are unsigned chars, define a small helper struct which formats them in - // a more useful way - struct ColourChannel - { - ColourChannel(unsigned char value) : m_value(value) { } - - unsigned char m_value; - }; - - std::ostream& operator<<(std::ostream& os, const ColourChannel& cc) - { - os.width(2); - os.fill('0'); - os << static_cast(cc.m_value); - return os; - } -} // anonymous namespace - -// this operator is needed to use CPPUNIT_ASSERT_EQUAL with wxColour objects -std::ostream& operator<<(std::ostream& os, const wxColour& c) -{ - os << std::hex << std::noshowbase - << "(" - << ColourChannel(c.Red()) << ", " - << ColourChannel(c.Green()) << ", " - << ColourChannel(c.Blue()); - - if ( const unsigned char a = c.Alpha() ) - { - os << ", " << ColourChannel(a); - } - - os << ")"; - - return os; -} +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class diff --git a/tests/html/htmlwindow.cpp b/tests/html/htmlwindow.cpp index 936954fe0c..f713676ef9 100644 --- a/tests/html/htmlwindow.cpp +++ b/tests/html/htmlwindow.cpp @@ -13,6 +13,8 @@ #include "testprec.h" +#if wxUSE_HTML + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -22,6 +24,8 @@ #endif // WX_PRECOMP #include "wx/html/htmlwin.h" +#include "wx/uiaction.h" +#include "testableframe.h" // ---------------------------------------------------------------------------- // test class @@ -38,9 +42,19 @@ public: private: CPPUNIT_TEST_SUITE( HtmlWindowTestCase ); CPPUNIT_TEST( SelectionToText ); + CPPUNIT_TEST( Title ); +#if wxUSE_UIACTIONSIMULATOR + WXUISIM_TEST( CellClick ); + WXUISIM_TEST( LinkClick ); +#endif // wxUSE_UIACTIONSIMULATOR + CPPUNIT_TEST( AppendToPage ); CPPUNIT_TEST_SUITE_END(); void SelectionToText(); + void Title(); + void CellClick(); + void LinkClick(); + void AppendToPage(); wxHtmlWindow *m_win; @@ -59,13 +73,13 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HtmlWindowTestCase, "HtmlWindowTestCase" void HtmlWindowTestCase::setUp() { - m_win = new wxHtmlWindow(wxTheApp->GetTopWindow(), wxID_ANY); + m_win = new wxHtmlWindow(wxTheApp->GetTopWindow(), wxID_ANY, + wxDefaultPosition, wxSize(400, 200)); } void HtmlWindowTestCase::tearDown() { - m_win->Destroy(); - m_win = NULL; + wxDELETE(m_win); } // ---------------------------------------------------------------------------- @@ -74,11 +88,17 @@ void HtmlWindowTestCase::tearDown() static const char *TEST_MARKUP = "" + "Page" " Title

" " A longer line
" " and the last line." ""; +static const char *TEST_MARKUP_LINK = + "" + "link<\\a> " + ""; + static const char *TEST_PLAIN_TEXT = "Title\nA longer line\nand the last line."; @@ -89,3 +109,66 @@ void HtmlWindowTestCase::SelectionToText() CPPUNIT_ASSERT_EQUAL( TEST_PLAIN_TEXT, m_win->SelectionToText() ); } + +void HtmlWindowTestCase::Title() +{ + m_win->SetPage(TEST_MARKUP); + + CPPUNIT_ASSERT_EQUAL("Page", m_win->GetOpenedPageTitle()); +} + +#if wxUSE_UIACTIONSIMULATOR +void HtmlWindowTestCase::CellClick() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count1(m_win, wxEVT_COMMAND_HTML_CELL_CLICKED); + + wxUIActionSimulator sim; + + m_win->SetPage(TEST_MARKUP); + m_win->Update(); + m_win->Refresh(); + + sim.MouseMove(m_win->ClientToScreen(wxPoint(15, 15))); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +} + +void HtmlWindowTestCase::LinkClick() +{ + wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + EventCounter count1(m_win, wxEVT_COMMAND_HTML_LINK_CLICKED); + + wxUIActionSimulator sim; + + m_win->SetPage(TEST_MARKUP_LINK); + m_win->Update(); + m_win->Refresh(); + + sim.MouseMove(m_win->ClientToScreen(wxPoint(15, 15))); + wxYield(); + + sim.MouseClick(); + wxYield(); + + CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount()); +} +#endif // wxUSE_UIACTIONSIMULATOR + +void HtmlWindowTestCase::AppendToPage() +{ + m_win->SetPage(TEST_MARKUP_LINK); + m_win->AppendToPage("A new paragraph"); + + CPPUNIT_ASSERT_EQUAL("link A new paragraph", m_win->ToText()); +} + +#endif //wxUSE_HTML diff --git a/tests/image/image.cpp b/tests/image/image.cpp index 644cc6c745..a8c4adba0d 100644 --- a/tests/image/image.cpp +++ b/tests/image/image.cpp @@ -14,6 +14,8 @@ #include "testprec.h" +#if wxUSE_IMAGE + #ifdef __BORLANDC__ #pragma hdrstop #endif @@ -823,6 +825,8 @@ void ImageTestCase::SizeImage() } } +#endif //wxUSE_IMAGE + /* TODO: add lots of more tests to wxImage functions diff --git a/tests/makefile.bcc b/tests/makefile.bcc index 1396fe55b7..a53967ef05 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -129,7 +129,9 @@ TEST_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(CXXFLAGS) TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_dummy.obj \ + $(OBJS)\test_gui_asserthelper.obj \ $(OBJS)\test_gui_test.obj \ + $(OBJS)\test_gui_testableframe.obj \ $(OBJS)\test_gui_rect.obj \ $(OBJS)\test_gui_size.obj \ $(OBJS)\test_gui_point.obj \ @@ -138,13 +140,44 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_ellipsization.obj \ $(OBJS)\test_gui_measuring.obj \ $(OBJS)\test_gui_config.obj \ + $(OBJS)\test_gui_bitmapcomboboxtest.obj \ + $(OBJS)\test_gui_bitmaptogglebuttontest.obj \ + $(OBJS)\test_gui_bookctrlbasetest.obj \ + $(OBJS)\test_gui_buttontest.obj \ + $(OBJS)\test_gui_checkboxtest.obj \ + $(OBJS)\test_gui_checklistboxtest.obj \ + $(OBJS)\test_gui_choicebooktest.obj \ + $(OBJS)\test_gui_choicetest.obj \ $(OBJS)\test_gui_comboboxtest.obj \ + $(OBJS)\test_gui_frametest.obj \ + $(OBJS)\test_gui_gaugetest.obj \ + $(OBJS)\test_gui_gridtest.obj \ $(OBJS)\test_gui_headerctrltest.obj \ + $(OBJS)\test_gui_hyperlinkctrltest.obj \ + $(OBJS)\test_gui_itemcontainertest.obj \ $(OBJS)\test_gui_label.obj \ + $(OBJS)\test_gui_listbasetest.obj \ + $(OBJS)\test_gui_listbooktest.obj \ + $(OBJS)\test_gui_listboxtest.obj \ $(OBJS)\test_gui_listctrltest.obj \ + $(OBJS)\test_gui_listviewtest.obj \ + $(OBJS)\test_gui_notebooktest.obj \ + $(OBJS)\test_gui_pickerbasetest.obj \ + $(OBJS)\test_gui_pickertest.obj \ + $(OBJS)\test_gui_radioboxtest.obj \ + $(OBJS)\test_gui_radiobuttontest.obj \ + $(OBJS)\test_gui_rearrangelisttest.obj \ + $(OBJS)\test_gui_richtextctrltest.obj \ + $(OBJS)\test_gui_slidertest.obj \ + $(OBJS)\test_gui_spinctrldbltest.obj \ + $(OBJS)\test_gui_spinctrltest.obj \ $(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textentrytest.obj \ + $(OBJS)\test_gui_togglebuttontest.obj \ + $(OBJS)\test_gui_toolbooktest.obj \ + $(OBJS)\test_gui_treebooktest.obj \ $(OBJS)\test_gui_treectrltest.obj \ + $(OBJS)\test_gui_windowtest.obj \ $(OBJS)\test_gui_clone.obj \ $(OBJS)\test_gui_propagation.obj \ $(OBJS)\test_gui_fonttest.obj \ @@ -228,6 +261,10 @@ ____CAIRO_INCLUDEDIR_FILENAMES_3_p = -i$(CAIRO_ROOT)\include\cairo !if "$(SHARED)" == "1" __DLLFLAG_p_3 = -dWXUSINGDLL !endif +!if "$(MONOLITHIC)" == "0" +__WXLIB_RICHTEXT_p = \ + wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext.lib +!endif !if "$(MONOLITHIC)" == "0" && "$(USE_MEDIA)" == "1" __WXLIB_MEDIA_p = \ wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media.lib @@ -392,7 +429,7 @@ $(OBJS)\test.exe: $(OBJS)\test_dummy.obj $(TEST_OBJECTS) !if "$(USE_GUI)" == "1" $(OBJS)\test_gui.exe: $(OBJS)\test_gui_dummy.obj $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample.res ilink32 -Tpe -q -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(__DEBUGINFO) -L$(LIBDIRNAME) $(CPPUNIT_LIBS) -ap $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @&&| - c0x32.obj $(TEST_GUI_OBJECTS),$@,, $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) ole2w32.lib oleacc.lib import32.lib cw32$(__THREADSFLAG)$(__RUNTIME_LIBS_0).lib,, $(OBJS)\test_gui_sample.res + c0x32.obj $(TEST_GUI_OBJECTS),$@,, $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) ole2w32.lib oleacc.lib import32.lib cw32$(__THREADSFLAG)$(__RUNTIME_LIBS_0).lib,, $(OBJS)\test_gui_sample.res | !endif @@ -659,9 +696,15 @@ $(OBJS)\test_gui_sample.res: .\..\samples\sample.rc $(OBJS)\test_gui_dummy.obj: .\dummy.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) -H .\dummy.cpp +$(OBJS)\test_gui_asserthelper.obj: .\asserthelper.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\asserthelper.cpp + $(OBJS)\test_gui_test.obj: .\test.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\test.cpp +$(OBJS)\test_gui_testableframe.obj: .\testableframe.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\testableframe.cpp + $(OBJS)\test_gui_rect.obj: .\geometry\rect.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\geometry\rect.cpp @@ -686,27 +729,120 @@ $(OBJS)\test_gui_measuring.obj: .\graphics\measuring.cpp $(OBJS)\test_gui_config.obj: .\config\config.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp +$(OBJS)\test_gui_bitmapcomboboxtest.obj: .\controls\bitmapcomboboxtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\bitmapcomboboxtest.cpp + +$(OBJS)\test_gui_bitmaptogglebuttontest.obj: .\controls\bitmaptogglebuttontest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\bitmaptogglebuttontest.cpp + +$(OBJS)\test_gui_bookctrlbasetest.obj: .\controls\bookctrlbasetest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\bookctrlbasetest.cpp + +$(OBJS)\test_gui_buttontest.obj: .\controls\buttontest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\buttontest.cpp + +$(OBJS)\test_gui_checkboxtest.obj: .\controls\checkboxtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\checkboxtest.cpp + +$(OBJS)\test_gui_checklistboxtest.obj: .\controls\checklistboxtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\checklistboxtest.cpp + +$(OBJS)\test_gui_choicebooktest.obj: .\controls\choicebooktest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\choicebooktest.cpp + +$(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\choicetest.cpp + $(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp +$(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp + +$(OBJS)\test_gui_gaugetest.obj: .\controls\gaugetest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\gaugetest.cpp + +$(OBJS)\test_gui_gridtest.obj: .\controls\gridtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\gridtest.cpp + $(OBJS)\test_gui_headerctrltest.obj: .\controls\headerctrltest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\headerctrltest.cpp +$(OBJS)\test_gui_hyperlinkctrltest.obj: .\controls\hyperlinkctrltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\hyperlinkctrltest.cpp + +$(OBJS)\test_gui_itemcontainertest.obj: .\controls\itemcontainertest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\itemcontainertest.cpp + $(OBJS)\test_gui_label.obj: .\controls\label.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\label.cpp +$(OBJS)\test_gui_listbasetest.obj: .\controls\listbasetest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listbasetest.cpp + +$(OBJS)\test_gui_listbooktest.obj: .\controls\listbooktest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listbooktest.cpp + +$(OBJS)\test_gui_listboxtest.obj: .\controls\listboxtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listboxtest.cpp + $(OBJS)\test_gui_listctrltest.obj: .\controls\listctrltest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listctrltest.cpp +$(OBJS)\test_gui_listviewtest.obj: .\controls\listviewtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\listviewtest.cpp + +$(OBJS)\test_gui_notebooktest.obj: .\controls\notebooktest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\notebooktest.cpp + +$(OBJS)\test_gui_pickerbasetest.obj: .\controls\pickerbasetest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\pickerbasetest.cpp + +$(OBJS)\test_gui_pickertest.obj: .\controls\pickertest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\pickertest.cpp + +$(OBJS)\test_gui_radioboxtest.obj: .\controls\radioboxtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\radioboxtest.cpp + +$(OBJS)\test_gui_radiobuttontest.obj: .\controls\radiobuttontest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\radiobuttontest.cpp + +$(OBJS)\test_gui_rearrangelisttest.obj: .\controls\rearrangelisttest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\rearrangelisttest.cpp + +$(OBJS)\test_gui_richtextctrltest.obj: .\controls\richtextctrltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\richtextctrltest.cpp + +$(OBJS)\test_gui_slidertest.obj: .\controls\slidertest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\slidertest.cpp + +$(OBJS)\test_gui_spinctrldbltest.obj: .\controls\spinctrldbltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\spinctrldbltest.cpp + +$(OBJS)\test_gui_spinctrltest.obj: .\controls\spinctrltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\spinctrltest.cpp + $(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp $(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textentrytest.cpp +$(OBJS)\test_gui_togglebuttontest.obj: .\controls\togglebuttontest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\togglebuttontest.cpp + +$(OBJS)\test_gui_toolbooktest.obj: .\controls\toolbooktest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\toolbooktest.cpp + +$(OBJS)\test_gui_treebooktest.obj: .\controls\treebooktest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\treebooktest.cpp + $(OBJS)\test_gui_treectrltest.obj: .\controls\treectrltest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\treectrltest.cpp +$(OBJS)\test_gui_windowtest.obj: .\controls\windowtest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\windowtest.cpp + $(OBJS)\test_gui_clone.obj: .\events\clone.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\events\clone.cpp diff --git a/tests/makefile.gcc b/tests/makefile.gcc index c29a2f0eae..bf03f298bb 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -122,7 +122,9 @@ TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_sample_rc.o \ $(OBJS)\test_gui_dummy.o \ + $(OBJS)\test_gui_asserthelper.o \ $(OBJS)\test_gui_test.o \ + $(OBJS)\test_gui_testableframe.o \ $(OBJS)\test_gui_rect.o \ $(OBJS)\test_gui_size.o \ $(OBJS)\test_gui_point.o \ @@ -131,13 +133,44 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_ellipsization.o \ $(OBJS)\test_gui_measuring.o \ $(OBJS)\test_gui_config.o \ + $(OBJS)\test_gui_bitmapcomboboxtest.o \ + $(OBJS)\test_gui_bitmaptogglebuttontest.o \ + $(OBJS)\test_gui_bookctrlbasetest.o \ + $(OBJS)\test_gui_buttontest.o \ + $(OBJS)\test_gui_checkboxtest.o \ + $(OBJS)\test_gui_checklistboxtest.o \ + $(OBJS)\test_gui_choicebooktest.o \ + $(OBJS)\test_gui_choicetest.o \ $(OBJS)\test_gui_comboboxtest.o \ + $(OBJS)\test_gui_frametest.o \ + $(OBJS)\test_gui_gaugetest.o \ + $(OBJS)\test_gui_gridtest.o \ $(OBJS)\test_gui_headerctrltest.o \ + $(OBJS)\test_gui_hyperlinkctrltest.o \ + $(OBJS)\test_gui_itemcontainertest.o \ $(OBJS)\test_gui_label.o \ + $(OBJS)\test_gui_listbasetest.o \ + $(OBJS)\test_gui_listbooktest.o \ + $(OBJS)\test_gui_listboxtest.o \ $(OBJS)\test_gui_listctrltest.o \ + $(OBJS)\test_gui_listviewtest.o \ + $(OBJS)\test_gui_notebooktest.o \ + $(OBJS)\test_gui_pickerbasetest.o \ + $(OBJS)\test_gui_pickertest.o \ + $(OBJS)\test_gui_radioboxtest.o \ + $(OBJS)\test_gui_radiobuttontest.o \ + $(OBJS)\test_gui_rearrangelisttest.o \ + $(OBJS)\test_gui_richtextctrltest.o \ + $(OBJS)\test_gui_slidertest.o \ + $(OBJS)\test_gui_spinctrldbltest.o \ + $(OBJS)\test_gui_spinctrltest.o \ $(OBJS)\test_gui_textctrltest.o \ $(OBJS)\test_gui_textentrytest.o \ + $(OBJS)\test_gui_togglebuttontest.o \ + $(OBJS)\test_gui_toolbooktest.o \ + $(OBJS)\test_gui_treebooktest.o \ $(OBJS)\test_gui_treectrltest.o \ + $(OBJS)\test_gui_windowtest.o \ $(OBJS)\test_gui_clone.o \ $(OBJS)\test_gui_propagation.o \ $(OBJS)\test_gui_fonttest.o \ @@ -225,6 +258,10 @@ ifeq ($(SHARED),1) __DLLFLAG_p_3 = --define WXUSINGDLL endif ifeq ($(MONOLITHIC),0) +__WXLIB_RICHTEXT_p = \ + -lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext +endif +ifeq ($(MONOLITHIC),0) ifeq ($(USE_MEDIA),1) __WXLIB_MEDIA_p = \ -lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media @@ -374,7 +411,7 @@ $(OBJS)\test.exe: $(TEST_OBJECTS) ifeq ($(USE_GUI),1) $(OBJS)\test_gui.exe: $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample_rc.o - $(CXX) -o $@ $(TEST_GUI_OBJECTS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(CPPUNIT_LIBS) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwininet + $(CXX) -o $@ $(TEST_GUI_OBJECTS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(CPPUNIT_LIBS) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwininet endif data: @@ -640,9 +677,15 @@ $(OBJS)\test_gui_sample_rc.o: ./../samples/sample.rc $(OBJS)\test_gui_dummy.o: ./dummy.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_asserthelper.o: ./asserthelper.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_test.o: ./test.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_testableframe.o: ./testableframe.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_rect.o: ./geometry/rect.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< @@ -667,27 +710,120 @@ $(OBJS)\test_gui_measuring.o: ./graphics/measuring.cpp $(OBJS)\test_gui_config.o: ./config/config.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_bitmapcomboboxtest.o: ./controls/bitmapcomboboxtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_bitmaptogglebuttontest.o: ./controls/bitmaptogglebuttontest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_bookctrlbasetest.o: ./controls/bookctrlbasetest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_buttontest.o: ./controls/buttontest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_checkboxtest.o: ./controls/checkboxtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_checklistboxtest.o: ./controls/checklistboxtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_choicebooktest.o: ./controls/choicebooktest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_choicetest.o: ./controls/choicetest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_comboboxtest.o: ./controls/comboboxtest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_frametest.o: ./controls/frametest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_gaugetest.o: ./controls/gaugetest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_gridtest.o: ./controls/gridtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_headerctrltest.o: ./controls/headerctrltest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_hyperlinkctrltest.o: ./controls/hyperlinkctrltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_itemcontainertest.o: ./controls/itemcontainertest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_label.o: ./controls/label.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_listbasetest.o: ./controls/listbasetest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_listbooktest.o: ./controls/listbooktest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_listboxtest.o: ./controls/listboxtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_listctrltest.o: ./controls/listctrltest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_listviewtest.o: ./controls/listviewtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_notebooktest.o: ./controls/notebooktest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_pickerbasetest.o: ./controls/pickerbasetest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_pickertest.o: ./controls/pickertest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_radioboxtest.o: ./controls/radioboxtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_radiobuttontest.o: ./controls/radiobuttontest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_rearrangelisttest.o: ./controls/rearrangelisttest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_richtextctrltest.o: ./controls/richtextctrltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_slidertest.o: ./controls/slidertest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_spinctrldbltest.o: ./controls/spinctrldbltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_spinctrltest.o: ./controls/spinctrltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_textctrltest.o: ./controls/textctrltest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< $(OBJS)\test_gui_textentrytest.o: ./controls/textentrytest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_togglebuttontest.o: ./controls/togglebuttontest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_toolbooktest.o: ./controls/toolbooktest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\test_gui_treebooktest.o: ./controls/treebooktest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_treectrltest.o: ./controls/treectrltest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_windowtest.o: ./controls/windowtest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_clone.o: ./events/clone.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index 0e67b396e2..e209e1b064 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -124,7 +124,9 @@ TEST_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_27)$(__DEBUGRUNTIME) /DWIN32 \ /Yu"testprec.h" /Fp"$(OBJS)\testprec_test_gui.pch" $(CPPFLAGS) $(CXXFLAGS) TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_dummy.obj \ + $(OBJS)\test_gui_asserthelper.obj \ $(OBJS)\test_gui_test.obj \ + $(OBJS)\test_gui_testableframe.obj \ $(OBJS)\test_gui_rect.obj \ $(OBJS)\test_gui_size.obj \ $(OBJS)\test_gui_point.obj \ @@ -133,13 +135,44 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_ellipsization.obj \ $(OBJS)\test_gui_measuring.obj \ $(OBJS)\test_gui_config.obj \ + $(OBJS)\test_gui_bitmapcomboboxtest.obj \ + $(OBJS)\test_gui_bitmaptogglebuttontest.obj \ + $(OBJS)\test_gui_bookctrlbasetest.obj \ + $(OBJS)\test_gui_buttontest.obj \ + $(OBJS)\test_gui_checkboxtest.obj \ + $(OBJS)\test_gui_checklistboxtest.obj \ + $(OBJS)\test_gui_choicebooktest.obj \ + $(OBJS)\test_gui_choicetest.obj \ $(OBJS)\test_gui_comboboxtest.obj \ + $(OBJS)\test_gui_frametest.obj \ + $(OBJS)\test_gui_gaugetest.obj \ + $(OBJS)\test_gui_gridtest.obj \ $(OBJS)\test_gui_headerctrltest.obj \ + $(OBJS)\test_gui_hyperlinkctrltest.obj \ + $(OBJS)\test_gui_itemcontainertest.obj \ $(OBJS)\test_gui_label.obj \ + $(OBJS)\test_gui_listbasetest.obj \ + $(OBJS)\test_gui_listbooktest.obj \ + $(OBJS)\test_gui_listboxtest.obj \ $(OBJS)\test_gui_listctrltest.obj \ + $(OBJS)\test_gui_listviewtest.obj \ + $(OBJS)\test_gui_notebooktest.obj \ + $(OBJS)\test_gui_pickerbasetest.obj \ + $(OBJS)\test_gui_pickertest.obj \ + $(OBJS)\test_gui_radioboxtest.obj \ + $(OBJS)\test_gui_radiobuttontest.obj \ + $(OBJS)\test_gui_rearrangelisttest.obj \ + $(OBJS)\test_gui_richtextctrltest.obj \ + $(OBJS)\test_gui_slidertest.obj \ + $(OBJS)\test_gui_spinctrldbltest.obj \ + $(OBJS)\test_gui_spinctrltest.obj \ $(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textentrytest.obj \ + $(OBJS)\test_gui_togglebuttontest.obj \ + $(OBJS)\test_gui_toolbooktest.obj \ + $(OBJS)\test_gui_treebooktest.obj \ $(OBJS)\test_gui_treectrltest.obj \ + $(OBJS)\test_gui_windowtest.obj \ $(OBJS)\test_gui_clone.obj \ $(OBJS)\test_gui_propagation.obj \ $(OBJS)\test_gui_fonttest.obj \ @@ -309,6 +342,10 @@ ____CAIRO_INCLUDEDIR_FILENAMES_3_p = /i $(CAIRO_ROOT)\include\cairo !if "$(SHARED)" == "1" __DLLFLAG_p_3 = /d WXUSINGDLL !endif +!if "$(MONOLITHIC)" == "0" +__WXLIB_RICHTEXT_p = \ + wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext.lib +!endif !if "$(MONOLITHIC)" == "0" && "$(USE_MEDIA)" == "1" __WXLIB_MEDIA_p = \ wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media.lib @@ -518,7 +555,7 @@ $(OBJS)\test.exe: $(OBJS)\test_dummy.obj $(TEST_OBJECTS) !if "$(USE_GUI)" == "1" $(OBJS)\test_gui.exe: $(OBJS)\test_gui_dummy.obj $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample.res link /NOLOGO /OUT:$@ $(__DEBUGINFO_1) /pdb:"$(OBJS)\test_gui.pdb" $(__DEBUGINFO_19) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) $(CPPUNIT_LIBS) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<< - $(TEST_GUI_OBJECTS) $(TEST_GUI_RESOURCES) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib + $(TEST_GUI_OBJECTS) $(TEST_GUI_RESOURCES) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__UNICOWS_LIB_p) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib << !endif @@ -785,9 +822,15 @@ $(OBJS)\test_gui_dummy.obj: .\dummy.cpp $(OBJS)\test_gui_sample.res: .\..\samples\sample.rc rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_20_p_1) $(__NO_VC_CRTDBG_p_3) /d __WXMSW__ $(__WXUNIV_DEFINE_p_3) $(__DEBUG_DEFINE_p_3) $(__NDEBUG_DEFINE_p_3) $(__EXCEPTIONS_DEFINE_p_3) $(__RTTI_DEFINE_p_3) $(__THREAD_DEFINE_p_3) $(__UNICODE_DEFINE_p_3) $(__MSLU_DEFINE_p_3) /i $(SETUPHDIR) /i .\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_3_p) /i . $(__DLLFLAG_p_3) /i .\..\samples /d NOPCH /d _CONSOLE .\..\samples\sample.rc +$(OBJS)\test_gui_asserthelper.obj: .\asserthelper.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\asserthelper.cpp + $(OBJS)\test_gui_test.obj: .\test.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\test.cpp +$(OBJS)\test_gui_testableframe.obj: .\testableframe.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\testableframe.cpp + $(OBJS)\test_gui_rect.obj: .\geometry\rect.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\geometry\rect.cpp @@ -812,27 +855,120 @@ $(OBJS)\test_gui_measuring.obj: .\graphics\measuring.cpp $(OBJS)\test_gui_config.obj: .\config\config.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp +$(OBJS)\test_gui_bitmapcomboboxtest.obj: .\controls\bitmapcomboboxtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\bitmapcomboboxtest.cpp + +$(OBJS)\test_gui_bitmaptogglebuttontest.obj: .\controls\bitmaptogglebuttontest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\bitmaptogglebuttontest.cpp + +$(OBJS)\test_gui_bookctrlbasetest.obj: .\controls\bookctrlbasetest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\bookctrlbasetest.cpp + +$(OBJS)\test_gui_buttontest.obj: .\controls\buttontest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\buttontest.cpp + +$(OBJS)\test_gui_checkboxtest.obj: .\controls\checkboxtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\checkboxtest.cpp + +$(OBJS)\test_gui_checklistboxtest.obj: .\controls\checklistboxtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\checklistboxtest.cpp + +$(OBJS)\test_gui_choicebooktest.obj: .\controls\choicebooktest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\choicebooktest.cpp + +$(OBJS)\test_gui_choicetest.obj: .\controls\choicetest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\choicetest.cpp + $(OBJS)\test_gui_comboboxtest.obj: .\controls\comboboxtest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\comboboxtest.cpp +$(OBJS)\test_gui_frametest.obj: .\controls\frametest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\frametest.cpp + +$(OBJS)\test_gui_gaugetest.obj: .\controls\gaugetest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\gaugetest.cpp + +$(OBJS)\test_gui_gridtest.obj: .\controls\gridtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\gridtest.cpp + $(OBJS)\test_gui_headerctrltest.obj: .\controls\headerctrltest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\headerctrltest.cpp +$(OBJS)\test_gui_hyperlinkctrltest.obj: .\controls\hyperlinkctrltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\hyperlinkctrltest.cpp + +$(OBJS)\test_gui_itemcontainertest.obj: .\controls\itemcontainertest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\itemcontainertest.cpp + $(OBJS)\test_gui_label.obj: .\controls\label.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\label.cpp +$(OBJS)\test_gui_listbasetest.obj: .\controls\listbasetest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listbasetest.cpp + +$(OBJS)\test_gui_listbooktest.obj: .\controls\listbooktest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listbooktest.cpp + +$(OBJS)\test_gui_listboxtest.obj: .\controls\listboxtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listboxtest.cpp + $(OBJS)\test_gui_listctrltest.obj: .\controls\listctrltest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listctrltest.cpp +$(OBJS)\test_gui_listviewtest.obj: .\controls\listviewtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\listviewtest.cpp + +$(OBJS)\test_gui_notebooktest.obj: .\controls\notebooktest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\notebooktest.cpp + +$(OBJS)\test_gui_pickerbasetest.obj: .\controls\pickerbasetest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\pickerbasetest.cpp + +$(OBJS)\test_gui_pickertest.obj: .\controls\pickertest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\pickertest.cpp + +$(OBJS)\test_gui_radioboxtest.obj: .\controls\radioboxtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\radioboxtest.cpp + +$(OBJS)\test_gui_radiobuttontest.obj: .\controls\radiobuttontest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\radiobuttontest.cpp + +$(OBJS)\test_gui_rearrangelisttest.obj: .\controls\rearrangelisttest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\rearrangelisttest.cpp + +$(OBJS)\test_gui_richtextctrltest.obj: .\controls\richtextctrltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\richtextctrltest.cpp + +$(OBJS)\test_gui_slidertest.obj: .\controls\slidertest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\slidertest.cpp + +$(OBJS)\test_gui_spinctrldbltest.obj: .\controls\spinctrldbltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\spinctrldbltest.cpp + +$(OBJS)\test_gui_spinctrltest.obj: .\controls\spinctrltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\spinctrltest.cpp + $(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp $(OBJS)\test_gui_textentrytest.obj: .\controls\textentrytest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textentrytest.cpp +$(OBJS)\test_gui_togglebuttontest.obj: .\controls\togglebuttontest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\togglebuttontest.cpp + +$(OBJS)\test_gui_toolbooktest.obj: .\controls\toolbooktest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\toolbooktest.cpp + +$(OBJS)\test_gui_treebooktest.obj: .\controls\treebooktest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\treebooktest.cpp + $(OBJS)\test_gui_treectrltest.obj: .\controls\treectrltest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\treectrltest.cpp +$(OBJS)\test_gui_windowtest.obj: .\controls\windowtest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\windowtest.cpp + $(OBJS)\test_gui_clone.obj: .\events\clone.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\events\clone.cpp diff --git a/tests/makefile.wat b/tests/makefile.wat index ed945c5b81..2aeaea969c 100644 --- a/tests/makefile.wat +++ b/tests/makefile.wat @@ -72,6 +72,11 @@ __test_gui___depname = !ifeq USE_GUI 1 __test_gui___depname = $(OBJS)\test_gui.exe !endif +__WXLIB_RICHTEXT_p = +!ifeq MONOLITHIC 0 +__WXLIB_RICHTEXT_p = & + wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext.lib +!endif __WXLIB_MEDIA_p = !ifeq MONOLITHIC 0 !ifeq USE_MEDIA 1 @@ -359,7 +364,9 @@ TEST_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) & $(CPPFLAGS) $(CXXFLAGS) TEST_GUI_OBJECTS = & $(OBJS)\test_gui_dummy.obj & + $(OBJS)\test_gui_asserthelper.obj & $(OBJS)\test_gui_test.obj & + $(OBJS)\test_gui_testableframe.obj & $(OBJS)\test_gui_rect.obj & $(OBJS)\test_gui_size.obj & $(OBJS)\test_gui_point.obj & @@ -368,13 +375,44 @@ TEST_GUI_OBJECTS = & $(OBJS)\test_gui_ellipsization.obj & $(OBJS)\test_gui_measuring.obj & $(OBJS)\test_gui_config.obj & + $(OBJS)\test_gui_bitmapcomboboxtest.obj & + $(OBJS)\test_gui_bitmaptogglebuttontest.obj & + $(OBJS)\test_gui_bookctrlbasetest.obj & + $(OBJS)\test_gui_buttontest.obj & + $(OBJS)\test_gui_checkboxtest.obj & + $(OBJS)\test_gui_checklistboxtest.obj & + $(OBJS)\test_gui_choicebooktest.obj & + $(OBJS)\test_gui_choicetest.obj & $(OBJS)\test_gui_comboboxtest.obj & + $(OBJS)\test_gui_frametest.obj & + $(OBJS)\test_gui_gaugetest.obj & + $(OBJS)\test_gui_gridtest.obj & $(OBJS)\test_gui_headerctrltest.obj & + $(OBJS)\test_gui_hyperlinkctrltest.obj & + $(OBJS)\test_gui_itemcontainertest.obj & $(OBJS)\test_gui_label.obj & + $(OBJS)\test_gui_listbasetest.obj & + $(OBJS)\test_gui_listbooktest.obj & + $(OBJS)\test_gui_listboxtest.obj & $(OBJS)\test_gui_listctrltest.obj & + $(OBJS)\test_gui_listviewtest.obj & + $(OBJS)\test_gui_notebooktest.obj & + $(OBJS)\test_gui_pickerbasetest.obj & + $(OBJS)\test_gui_pickertest.obj & + $(OBJS)\test_gui_radioboxtest.obj & + $(OBJS)\test_gui_radiobuttontest.obj & + $(OBJS)\test_gui_rearrangelisttest.obj & + $(OBJS)\test_gui_richtextctrltest.obj & + $(OBJS)\test_gui_slidertest.obj & + $(OBJS)\test_gui_spinctrldbltest.obj & + $(OBJS)\test_gui_spinctrltest.obj & $(OBJS)\test_gui_textctrltest.obj & $(OBJS)\test_gui_textentrytest.obj & + $(OBJS)\test_gui_togglebuttontest.obj & + $(OBJS)\test_gui_toolbooktest.obj & + $(OBJS)\test_gui_treebooktest.obj & $(OBJS)\test_gui_treectrltest.obj & + $(OBJS)\test_gui_windowtest.obj & $(OBJS)\test_gui_clone.obj & $(OBJS)\test_gui_propagation.obj & $(OBJS)\test_gui_fonttest.obj & @@ -428,7 +466,7 @@ $(OBJS)\test_gui.exe : $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample.res @%append $(OBJS)\test_gui.lbc option caseexact @%append $(OBJS)\test_gui.lbc $(__DEBUGINFO_1) libpath $(LIBDIRNAME) $(CPPUNIT_LIBS) system nt ref 'main_' $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @for %i in ($(TEST_GUI_OBJECTS)) do @%append $(OBJS)\test_gui.lbc file %i - @for %i in ( $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib) do @%append $(OBJS)\test_gui.lbc library %i + @for %i in ( $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_ADV_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib) do @%append $(OBJS)\test_gui.lbc library %i @%append $(OBJS)\test_gui.lbc option resource=$(OBJS)\test_gui_sample.res @for %i in () do @%append $(OBJS)\test_gui.lbc option stack=%i wlink @$(OBJS)\test_gui.lbc @@ -697,9 +735,15 @@ $(OBJS)\test_gui_sample.res : .AUTODEPEND .\..\samples\sample.rc $(OBJS)\test_gui_dummy.obj : .AUTODEPEND .\dummy.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_asserthelper.obj : .AUTODEPEND .\asserthelper.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_test.obj : .AUTODEPEND .\test.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_testableframe.obj : .AUTODEPEND .\testableframe.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_rect.obj : .AUTODEPEND .\geometry\rect.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< @@ -724,27 +768,120 @@ $(OBJS)\test_gui_measuring.obj : .AUTODEPEND .\graphics\measuring.cpp $(OBJS)\test_gui_config.obj : .AUTODEPEND .\config\config.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_bitmapcomboboxtest.obj : .AUTODEPEND .\controls\bitmapcomboboxtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_bitmaptogglebuttontest.obj : .AUTODEPEND .\controls\bitmaptogglebuttontest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_bookctrlbasetest.obj : .AUTODEPEND .\controls\bookctrlbasetest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_buttontest.obj : .AUTODEPEND .\controls\buttontest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_checkboxtest.obj : .AUTODEPEND .\controls\checkboxtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_checklistboxtest.obj : .AUTODEPEND .\controls\checklistboxtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_choicebooktest.obj : .AUTODEPEND .\controls\choicebooktest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_choicetest.obj : .AUTODEPEND .\controls\choicetest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_comboboxtest.obj : .AUTODEPEND .\controls\comboboxtest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_frametest.obj : .AUTODEPEND .\controls\frametest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_gaugetest.obj : .AUTODEPEND .\controls\gaugetest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_gridtest.obj : .AUTODEPEND .\controls\gridtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_headerctrltest.obj : .AUTODEPEND .\controls\headerctrltest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_hyperlinkctrltest.obj : .AUTODEPEND .\controls\hyperlinkctrltest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_itemcontainertest.obj : .AUTODEPEND .\controls\itemcontainertest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_label.obj : .AUTODEPEND .\controls\label.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_listbasetest.obj : .AUTODEPEND .\controls\listbasetest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_listbooktest.obj : .AUTODEPEND .\controls\listbooktest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_listboxtest.obj : .AUTODEPEND .\controls\listboxtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_listctrltest.obj : .AUTODEPEND .\controls\listctrltest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_listviewtest.obj : .AUTODEPEND .\controls\listviewtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_notebooktest.obj : .AUTODEPEND .\controls\notebooktest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_pickerbasetest.obj : .AUTODEPEND .\controls\pickerbasetest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_pickertest.obj : .AUTODEPEND .\controls\pickertest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_radioboxtest.obj : .AUTODEPEND .\controls\radioboxtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_radiobuttontest.obj : .AUTODEPEND .\controls\radiobuttontest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_rearrangelisttest.obj : .AUTODEPEND .\controls\rearrangelisttest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_richtextctrltest.obj : .AUTODEPEND .\controls\richtextctrltest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_slidertest.obj : .AUTODEPEND .\controls\slidertest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_spinctrldbltest.obj : .AUTODEPEND .\controls\spinctrldbltest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_spinctrltest.obj : .AUTODEPEND .\controls\spinctrltest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_textctrltest.obj : .AUTODEPEND .\controls\textctrltest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< $(OBJS)\test_gui_textentrytest.obj : .AUTODEPEND .\controls\textentrytest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_togglebuttontest.obj : .AUTODEPEND .\controls\togglebuttontest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_toolbooktest.obj : .AUTODEPEND .\controls\toolbooktest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + +$(OBJS)\test_gui_treebooktest.obj : .AUTODEPEND .\controls\treebooktest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_treectrltest.obj : .AUTODEPEND .\controls\treectrltest.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< +$(OBJS)\test_gui_windowtest.obj : .AUTODEPEND .\controls\windowtest.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< + $(OBJS)\test_gui_clone.obj : .AUTODEPEND .\events\clone.cpp $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $< diff --git a/tests/net/socket.cpp b/tests/net/socket.cpp index 67d8b5157b..aece666280 100644 --- a/tests/net/socket.cpp +++ b/tests/net/socket.cpp @@ -68,17 +68,23 @@ private: { m_useLoop = useLoop; if ( useLoop ) + { + m_evtLoopOld = wxEventLoopBase::GetActive(); SetActive(this); + } } virtual ~SocketTestEventLoop() { if ( m_useLoop ) - SetActive(NULL); + { + wxEventLoopBase::SetActive(m_evtLoopOld); + } } private: bool m_useLoop; + wxEventLoopBase *m_evtLoopOld; }; // get the address to connect to, if NULL is returned it means that the diff --git a/tests/sizers/boxsizer.cpp b/tests/sizers/boxsizer.cpp index 9e7cc5191e..313dafa3de 100644 --- a/tests/sizers/boxsizer.cpp +++ b/tests/sizers/boxsizer.cpp @@ -22,10 +22,7 @@ #include "wx/sizer.h" #endif // WX_PRECOMP -inline std::ostream& operator<<(std::ostream& o, const wxSize& s) -{ - return o << s.x << 'x' << s.y; -} +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class diff --git a/tests/test.bkl b/tests/test.bkl index 4532306a73..555fba32e3 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -125,7 +125,9 @@ console + asserthelper.cpp test.cpp + testableframe.cpp geometry/rect.cpp geometry/size.cpp geometry/point.cpp @@ -134,13 +136,44 @@ graphics/ellipsization.cpp graphics/measuring.cpp config/config.cpp + controls/bitmapcomboboxtest.cpp + controls/bitmaptogglebuttontest.cpp + controls/bookctrlbasetest.cpp + controls/buttontest.cpp + controls/checkboxtest.cpp + controls/checklistboxtest.cpp + controls/choicebooktest.cpp + controls/choicetest.cpp controls/comboboxtest.cpp + controls/frametest.cpp + controls/gaugetest.cpp + controls/gridtest.cpp controls/headerctrltest.cpp + controls/hyperlinkctrltest.cpp + controls/itemcontainertest.cpp controls/label.cpp + controls/listbasetest.cpp + controls/listbooktest.cpp + controls/listboxtest.cpp controls/listctrltest.cpp + controls/listviewtest.cpp + controls/notebooktest.cpp + controls/pickerbasetest.cpp + controls/pickertest.cpp + controls/radioboxtest.cpp + controls/radiobuttontest.cpp + controls/rearrangelisttest.cpp + controls/richtextctrltest.cpp + controls/slidertest.cpp + controls/spinctrldbltest.cpp + controls/spinctrltest.cpp controls/textctrltest.cpp controls/textentrytest.cpp + controls/togglebuttontest.cpp + controls/toolbooktest.cpp + controls/treebooktest.cpp controls/treectrltest.cpp + controls/windowtest.cpp events/clone.cpp events/propagation.cpp font/fonttest.cpp @@ -161,6 +194,7 @@ window/clientsize.cpp window/setsize.cpp + richtext media xrc xml diff --git a/tests/test.cpp b/tests/test.cpp index 37626d780b..a8208adb1a 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -51,7 +51,12 @@ #include "wx/osx/private.h" #endif +#if wxUSE_GUI + #include "testableframe.h" +#endif + #include "wx/socket.h" +#include "wx/evtloop.h" using namespace std; @@ -284,6 +289,9 @@ private: wxArrayString m_registries; wxLocale *m_locale; + // event loop for GUI tests + wxEventLoop* m_eventloop; + // event handling hooks FilterEventFunc m_filterEventFunc; ProcessEventFunc m_processEventFunc; @@ -400,6 +408,7 @@ TestApp::TestApp() m_processEventFunc = NULL; m_locale = NULL; + m_eventloop = NULL; } // Init @@ -418,7 +427,11 @@ bool TestApp::OnInit() #if wxUSE_GUI // create a hidden parent window to be used as parent for the GUI controls - new wxFrame(NULL, wxID_ANY, "Hidden wx test frame"); + wxTestableFrame* frame = new wxTestableFrame(); + frame->Show(); + + m_eventloop = new wxEventLoop; + wxEventLoop::SetActive(m_eventloop); #endif // wxUSE_GUI return true; @@ -595,6 +608,8 @@ int TestApp::OnExit() #if wxUSE_GUI delete GetTopWindow(); + wxEventLoop::SetActive(NULL); + delete m_eventloop; #endif // wxUSE_GUI return 0; diff --git a/tests/test_test_gui.dsp b/tests/test_test_gui.dsp index a22cc6ce74..dfa18f4493 100644 --- a/tests/test_test_gui.dsp +++ b/tests/test_test_gui.dsp @@ -54,8 +54,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivudll\test_gui.exe" /debug /pdb:"vc_mswunivudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console -# ADD LINK32 wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivudll\test_gui.exe" /debug /pdb:"vc_mswunivudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD BASE LINK32 wxmswuniv29u_richtext.lib wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivudll\test_gui.exe" /debug /pdb:"vc_mswunivudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD LINK32 wxmswuniv29u_richtext.lib wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivudll\test_gui.exe" /debug /pdb:"vc_mswunivudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 DLL Universal Debug" @@ -77,8 +77,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivuddll\test_gui.exe" /debug /pdb:"vc_mswunivuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console -# ADD LINK32 wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivuddll\test_gui.exe" /debug /pdb:"vc_mswunivuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD BASE LINK32 wxmswuniv29ud_richtext.lib wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivuddll\test_gui.exe" /debug /pdb:"vc_mswunivuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD LINK32 wxmswuniv29ud_richtext.lib wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivuddll\test_gui.exe" /debug /pdb:"vc_mswunivuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 DLL Release" @@ -100,8 +100,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswudll\test_gui.exe" /debug /pdb:"vc_mswudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console -# ADD LINK32 wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswudll\test_gui.exe" /debug /pdb:"vc_mswudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD BASE LINK32 wxmsw29u_richtext.lib wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswudll\test_gui.exe" /debug /pdb:"vc_mswudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD LINK32 wxmsw29u_richtext.lib wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswudll\test_gui.exe" /debug /pdb:"vc_mswudll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 DLL Debug" @@ -123,8 +123,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswuddll\test_gui.exe" /debug /pdb:"vc_mswuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console -# ADD LINK32 wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswuddll\test_gui.exe" /debug /pdb:"vc_mswuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD BASE LINK32 wxmsw29ud_richtext.lib wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswuddll\test_gui.exe" /debug /pdb:"vc_mswuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console +# ADD LINK32 wxmsw29ud_richtext.lib wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswuddll\test_gui.exe" /debug /pdb:"vc_mswuddll\test_gui.pdb" /libpath:".\..\lib\vc_dll" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 Universal Release" @@ -146,8 +146,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivu\test_gui.exe" /debug /pdb:"vc_mswunivu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console -# ADD LINK32 wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivu\test_gui.exe" /debug /pdb:"vc_mswunivu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD BASE LINK32 wxmswuniv29u_richtext.lib wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivu\test_gui.exe" /debug /pdb:"vc_mswunivu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD LINK32 wxmswuniv29u_richtext.lib wxmswuniv29u_media.lib wxmswuniv29u_xrc.lib wxbase29u_xml.lib wxmswuniv29u_adv.lib wxmswuniv29u_html.lib wxmswuniv29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivu\test_gui.exe" /debug /pdb:"vc_mswunivu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 Universal Debug" @@ -169,8 +169,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivud\test_gui.exe" /debug /pdb:"vc_mswunivud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console -# ADD LINK32 wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivud\test_gui.exe" /debug /pdb:"vc_mswunivud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD BASE LINK32 wxmswuniv29ud_richtext.lib wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivud\test_gui.exe" /debug /pdb:"vc_mswunivud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD LINK32 wxmswuniv29ud_richtext.lib wxmswuniv29ud_media.lib wxmswuniv29ud_xrc.lib wxbase29ud_xml.lib wxmswuniv29ud_adv.lib wxmswuniv29ud_html.lib wxmswuniv29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswunivud\test_gui.exe" /debug /pdb:"vc_mswunivud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 Release" @@ -192,8 +192,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswu\test_gui.exe" /debug /pdb:"vc_mswu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console -# ADD LINK32 wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswu\test_gui.exe" /debug /pdb:"vc_mswu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD BASE LINK32 wxmsw29u_richtext.lib wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswu\test_gui.exe" /debug /pdb:"vc_mswu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD LINK32 wxmsw29u_richtext.lib wxmsw29u_media.lib wxmsw29u_xrc.lib wxbase29u_xml.lib wxmsw29u_adv.lib wxmsw29u_html.lib wxmsw29u_core.lib wxbase29u_net.lib wxbase29u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswu\test_gui.exe" /debug /pdb:"vc_mswu\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console !ELSEIF "$(CFG)" == "test_gui - Win32 Debug" @@ -215,8 +215,8 @@ BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswud\test_gui.exe" /debug /pdb:"vc_mswud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console -# ADD LINK32 wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswud\test_gui.exe" /debug /pdb:"vc_mswud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD BASE LINK32 wxmsw29ud_richtext.lib wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswud\test_gui.exe" /debug /pdb:"vc_mswud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console +# ADD LINK32 wxmsw29ud_richtext.lib wxmsw29ud_media.lib wxmsw29ud_xrc.lib wxbase29ud_xml.lib wxmsw29ud_adv.lib wxmsw29ud_html.lib wxmsw29ud_core.lib wxbase29ud_net.lib wxbase29ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib wininet.lib /nologo /machine:i386 /out:"vc_mswud\test_gui.exe" /debug /pdb:"vc_mswud\test_gui.pdb" /libpath:".\..\lib\vc_lib" /subsystem:console !ENDIF @@ -235,14 +235,50 @@ LINK32=link.exe # PROP Default_Filter "" # Begin Source File +SOURCE=.\asserthelper.cpp +# End Source File +# Begin Source File + SOURCE=.\graphics\bitmap.cpp # End Source File # Begin Source File +SOURCE=.\controls\bitmapcomboboxtest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\bitmaptogglebuttontest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\bookctrlbasetest.cpp +# End Source File +# Begin Source File + SOURCE=.\sizers\boxsizer.cpp # End Source File # Begin Source File +SOURCE=.\controls\buttontest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\checkboxtest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\checklistboxtest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\choicebooktest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\choicetest.cpp +# End Source File +# Begin Source File + SOURCE=.\window\clientsize.cpp # End Source File # Begin Source File @@ -277,10 +313,22 @@ SOURCE=.\font\fonttest.cpp # End Source File # Begin Source File +SOURCE=.\controls\frametest.cpp +# End Source File +# Begin Source File + SOURCE=.\misc\garbage.cpp # End Source File # Begin Source File +SOURCE=.\controls\gaugetest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\gridtest.cpp +# End Source File +# Begin Source File + SOURCE=.\misc\guifuncs.cpp # End Source File # Begin Source File @@ -293,22 +341,58 @@ SOURCE=.\html\htmlwindow.cpp # End Source File # Begin Source File +SOURCE=.\controls\hyperlinkctrltest.cpp +# End Source File +# Begin Source File + SOURCE=.\image\image.cpp # End Source File # Begin Source File +SOURCE=.\controls\itemcontainertest.cpp +# End Source File +# Begin Source File + SOURCE=.\controls\label.cpp # End Source File # Begin Source File +SOURCE=.\controls\listbasetest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\listbooktest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\listboxtest.cpp +# End Source File +# Begin Source File + SOURCE=.\controls\listctrltest.cpp # End Source File # Begin Source File +SOURCE=.\controls\listviewtest.cpp +# End Source File +# Begin Source File + SOURCE=.\graphics\measuring.cpp # End Source File # Begin Source File +SOURCE=.\controls\notebooktest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\pickerbasetest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\pickertest.cpp +# End Source File +# Begin Source File + SOURCE=.\geometry\point.cpp # End Source File # Begin Source File @@ -317,14 +401,30 @@ SOURCE=.\events\propagation.cpp # End Source File # Begin Source File +SOURCE=.\controls\radioboxtest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\radiobuttontest.cpp +# End Source File +# Begin Source File + SOURCE=.\image\rawbmp.cpp # End Source File # Begin Source File +SOURCE=.\controls\rearrangelisttest.cpp +# End Source File +# Begin Source File + SOURCE=.\geometry\rect.cpp # End Source File # Begin Source File +SOURCE=.\controls\richtextctrltest.cpp +# End Source File +# Begin Source File + SOURCE=.\..\samples\sample.rc # End Source File # Begin Source File @@ -345,14 +445,30 @@ SOURCE=.\geometry\size.cpp # End Source File # Begin Source File +SOURCE=.\controls\slidertest.cpp +# End Source File +# Begin Source File + SOURCE=.\net\socket.cpp # End Source File # Begin Source File +SOURCE=.\controls\spinctrldbltest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\spinctrltest.cpp +# End Source File +# Begin Source File + SOURCE=.\test.cpp # End Source File # Begin Source File +SOURCE=.\testableframe.cpp +# End Source File +# Begin Source File + SOURCE=.\controls\textctrltest.cpp # End Source File # Begin Source File @@ -361,8 +477,24 @@ SOURCE=.\controls\textentrytest.cpp # End Source File # Begin Source File +SOURCE=.\controls\togglebuttontest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\toolbooktest.cpp +# End Source File +# Begin Source File + +SOURCE=.\controls\treebooktest.cpp +# End Source File +# Begin Source File + SOURCE=.\controls\treectrltest.cpp # End Source File +# Begin Source File + +SOURCE=.\controls\windowtest.cpp +# End Source File # End Group # End Target # End Project diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj index b738bb5100..82e33c436c 100644 --- a/tests/test_vc7_test_gui.vcproj +++ b/tests/test_vc7_test_gui.vcproj @@ -49,7 +49,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -932,10 +968,22 @@ > + + + + + + @@ -948,22 +996,58 @@ > + + + + + + + + + + + + + + + + + + @@ -972,14 +1056,30 @@ > + + + + + + + + @@ -996,14 +1096,30 @@ > + + + + + + + + @@ -1012,9 +1128,25 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -904,10 +940,22 @@ > + + + + + + @@ -920,22 +968,58 @@ > + + + + + + + + + + + + + + + + + + @@ -944,14 +1028,30 @@ > + + + + + + + + @@ -968,14 +1068,30 @@ > + + + + + + + + @@ -984,9 +1100,25 @@ > + + + + + + + + second; + iter->second = 0; + } + + return total; + } + else + { + long count = m_count[type]; + m_count[type] = 0; + return count; + } +} + +EventCounter::EventCounter(wxWindow* win, wxEventType type) : m_type(type), + m_win(win) + +{ + m_frame = wxStaticCast(wxTheApp->GetTopWindow(), + wxTestableFrame); + + m_win->Connect(m_type, + wxEventHandler(wxTestableFrame::OnEvent), + NULL, + m_frame); +} + +EventCounter::~EventCounter() +{ + m_win->Disconnect(m_type, + wxEventHandler(wxTestableFrame::OnEvent), + NULL, + m_frame); + + m_frame = NULL; + m_win = NULL; +} diff --git a/tests/testableframe.h b/tests/testableframe.h new file mode 100644 index 0000000000..ad676a12fc --- /dev/null +++ b/tests/testableframe.h @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: testableframe.h +// Purpose: An improved wxFrame for unit-testing +// Author: Steven Lamerton +// RCS-ID: $Id:$ +// Copyright: (c) 2010 Steven Lamerton +// Licence: wxWidgets licence +/////////////////////////////////////////////////////////////////////////////// + +#include "wx/frame.h" +#include "wx/hashmap.h" +#include "wx/event.h" + +class wxTestableFrame : public wxFrame +{ +public: + wxTestableFrame(); + + void OnEvent(wxEvent& evt); + + //wxEVT_ANY get the count for all events or a type can be specified + int GetEventCount(wxEventType type = wxEVT_ANY); + +private: + wxLongToLongHashMap m_count; +}; + +class EventCounter +{ +public: + EventCounter(wxWindow* win, wxEventType type); + ~EventCounter(); + +private: + wxEventType m_type; + wxTestableFrame* m_frame; + wxWindow* m_win; +}; diff --git a/tests/testprec.h b/tests/testprec.h index f7d0e66c5c..f6010fe4c1 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -1,6 +1,19 @@ #include "wx/wxprec.h" #include "wx/cppunit.h" +// Custom test macro that is only defined when wxUIActionSimulator is available +// this allows the tests that do not rely on it to run on platforms that don't +// support it. +// +// FIXME: And while OS X does support it, more or less, too many tests +// currently fail under it so disable all interactive tests there. They +// should, of course, be reenabled a.s.a.p. +#if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__) + #define WXUISIM_TEST(test) CPPUNIT_TEST(test) +#else + #define WXUISIM_TEST(test) (void)0 +#endif + // define wxHAVE_U_ESCAPE if the compiler supports \uxxxx character constants #if (defined(__VISUALC__) && (__VISUALC__ >= 1300)) || \ (defined(__GNUC__) && (__GNUC__ >= 3)) diff --git a/tests/window/setsize.cpp b/tests/window/setsize.cpp index 122cb0749a..16468d22bc 100644 --- a/tests/window/setsize.cpp +++ b/tests/window/setsize.cpp @@ -22,10 +22,7 @@ #include "wx/window.h" #endif // WX_PRECOMP -inline std::ostream& operator<<(std::ostream& o, const wxSize& s) -{ - return o << s.x << 'x' << s.y; -} +#include "asserthelper.h" // ---------------------------------------------------------------------------- // test class -- 2.45.2