1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        tests/controls/textentrytest.h
3 // Purpose:     Base class implementing wxTextEntry unit tests
4 // Author:      Vadim Zeitlin
5 // Created:     2008-09-19 (extracted from textctrltest.cpp)
6 // Copyright:   (c) 2007, 2008 Vadim Zeitlin <vadim@wxwidgets.org>
7 ///////////////////////////////////////////////////////////////////////////////
8 
9 #ifndef _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_
10 #define _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_
11 
12 class WXDLLIMPEXP_FWD_CORE wxTextEntry;
13 
14 // ----------------------------------------------------------------------------
15 // abstract base class testing wxTextEntry methods
16 // ----------------------------------------------------------------------------
17 
18 class TextEntryTestCase
19 {
20 public:
TextEntryTestCase()21     TextEntryTestCase() { }
~TextEntryTestCase()22     virtual ~TextEntryTestCase() { }
23 
24 protected:
25     // this function must be overridden by the derived classes to return the
26     // text entry object we're testing, typically this is done by creating a
27     // control implementing wxTextEntry interface in setUp() virtual method and
28     // just returning it from here
29     virtual wxTextEntry *GetTestEntry() const = 0;
30 
31     // and this one must be overridden to return the window which implements
32     // wxTextEntry interface -- usually it will return the same pointer as
33     // GetTestEntry(), just as a different type
34     virtual wxWindow *GetTestWindow() const = 0;
35 
36     // this should be inserted in the derived class CPPUNIT_TEST_SUITE
37     // definition to run all wxTextEntry tests as part of it
38     #define wxTEXT_ENTRY_TESTS() \
39         CPPUNIT_TEST( SetValue ); \
40         CPPUNIT_TEST( TextChangeEvents ); \
41         CPPUNIT_TEST( Selection ); \
42         CPPUNIT_TEST( InsertionPoint ); \
43         CPPUNIT_TEST( Replace ); \
44         WXUISIM_TEST( Editable ); \
45         CPPUNIT_TEST( Hint ); \
46         CPPUNIT_TEST( CopyPaste ); \
47         CPPUNIT_TEST( UndoRedo )
48 
49     void SetValue();
50     void TextChangeEvents();
51     void Selection();
52     void InsertionPoint();
53     void Replace();
54     void Editable();
55     void Hint();
56     void CopyPaste();
57     void UndoRedo();
58 
59 private:
60     // Selection() test helper: verify that selection is as described by the
61     // function parameters
62     void AssertSelection(int from, int to, const char *sel);
63 
64     // helper of AssertSelection(): check that the text selected in the control
65     // is the given one
66     //
67     // this is necessary to disable testing this in wxComboBox test as it
68     // doesn't provide any way to access the string selection directly, its
69     // GetStringSelection() method returns the currently selected string in the
70     // wxChoice part of the control, not the selected text
71     virtual void CheckStringSelection(const char *sel);
72 
73     wxDECLARE_NO_COPY_CLASS(TextEntryTestCase);
74 };
75 
76 #endif // _WX_TESTS_CONTROLS_TEXTENTRYTEST_H_
77