textentrytest.h 2.8 KB

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