From 5bd9c5b65b15e3390292d6fbe0b067b9ddd321d5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 17 Jul 2019 22:15:03 +0200 Subject: [PATCH] Test wxTextCtrl::HitTest() with negative coordinates under wxGTK In wxGTK using negative coordinates with HitTest() happens to work and it's useful to test that it does, as this test will run when the control is scrolled even under Travis CI, unlike the test with positive coordinates which doesn't work under Xvfb there and was disabled in the previous commit. Also document that passing negative coordinates to this function only works in wxGTK. --- interface/wx/textctrl.h | 2 ++ tests/controls/textctrltest.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index a0b6b7464f..3bf15e7e5e 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1347,6 +1347,8 @@ public: @param pt The position of the point to check, in window device coordinates. + In wxGTK, and only there, the coordinates can be negative, but in + portable code only positive values should be used. @param pos Receives the position of the character at the given position. May be @NULL. diff --git a/tests/controls/textctrltest.cpp b/tests/controls/textctrltest.cpp index f24bed5c89..141f7d9e8c 100644 --- a/tests/controls/textctrltest.cpp +++ b/tests/controls/textctrltest.cpp @@ -392,6 +392,13 @@ void TextCtrlTestCase::HitTestSingleLine() REQUIRE( m_text->HitTest(wxPoint(2*sizeChar.x, yMid), &pos) == wxTE_HT_ON_TEXT ); CHECK( pos > 3 ); } + + // Using negative coordinates works even under Xvfb, so test at least + // for this -- however this only works in wxGTK, not wxMSW. +#ifdef __WXGTK__ + REQUIRE( m_text->HitTest(wxPoint(-2*sizeChar.x, yMid), &pos) == wxTE_HT_ON_TEXT ); + CHECK( pos > 3 ); +#endif // __WXGTK__ } #endif }