Merge several fixes to wxGTK GUI test suite

The test suite now mostly passes for GTK+ 2 and at least doesn't crash (but
still has many failures) with GTK+ 3.

Closes https://github.com/wxWidgets/wxWidgets/pull/235
This commit is contained in:
Vadim Zeitlin
2016-02-27 18:04:17 +01:00
12 changed files with 76 additions and 37 deletions

View File

@@ -1670,20 +1670,27 @@ bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsig
GTK_TREE_MODEL(wxgtk_model), &iter ));
GdkRectangle cell_area;
gtk_tree_view_get_cell_area( widget, path, gcolumn, &cell_area );
#ifdef __WXGTK3__
GtkAdjustment* hadjust = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(widget));
#else
GtkAdjustment* hadjust = gtk_tree_view_get_hadjustment( widget );
#endif
double d = gtk_adjustment_get_value( hadjust );
int xdiff = (int) d;
GtkAllocation a;
gtk_widget_get_allocation(GTK_WIDGET(gtk_tree_view_column_get_button(gcolumn)), &a);
int ydiff = a.height;
// Redraw
gtk_widget_queue_draw_area( GTK_WIDGET(widget),
cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height );
// Don't try to redraw the column if it's invisible, this just
// results in "BUG" messages from pixman_region32_init_rect()
// and would be useful even if it didn't anyhow.
if ( cell_area.width > 0 && cell_area.height > 0 )
{
#ifdef __WXGTK3__
GtkAdjustment* hadjust = gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(widget));
#else
GtkAdjustment* hadjust = gtk_tree_view_get_hadjustment( widget );
#endif
double d = gtk_adjustment_get_value( hadjust );
int xdiff = (int) d;
GtkAllocation a;
gtk_widget_get_allocation(GTK_WIDGET(gtk_tree_view_column_get_button(gcolumn)), &a);
int ydiff = a.height;
// Redraw
gtk_widget_queue_draw_area( GTK_WIDGET(widget),
cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height );
}
}
m_internal->ValueChanged( item, model_column );

View File

@@ -115,7 +115,14 @@ static void pizza_size_allocate(GtkWidget* widget, GtkAllocation* alloc)
child_alloc.height = child->height;
if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
child_alloc.x = w - child_alloc.x - child_alloc.width;
gtk_widget_size_allocate(child->widget, &child_alloc);
// GTK+3 doesn't like allocating 0 size, so don't do it.
#ifdef __WXGTK3__
if (child_alloc.width && child_alloc.height)
#endif
{
gtk_widget_size_allocate(child->widget, &child_alloc);
}
}
}
}

View File

@@ -145,10 +145,16 @@ void ComboBoxTestCase::PopDismiss()
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
m_combo->Popup();
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
m_combo->Dismiss();
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
#if defined(__WXGTK__) && !defined(__WXGTK3__)
// Under wxGTK2, the event is sent only during idle time and not
// immediately, so we need this yield to get it.
wxYield();
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
#endif // wxGTK2
#endif
}

View File

@@ -79,6 +79,13 @@ void ModalDialogsTestCase::FileDialog()
CPPUNIT_ASSERT_EQUAL((int)wxID_OK, rc);
CPPUNIT_ASSERT_EQUAL("test.txt", dlg.GetFilename());
#ifdef __WXGTK3__
// The native file dialog in GTK+ 3 launches an async operation which tries
// to dereference the already deleted dialog object if we don't let it to
// complete before leaving this function.
wxYield();
#endif
}

View File

@@ -211,21 +211,6 @@ private:
void TextEntryTestCase::Editable()
{
#ifdef __WXGTK__
// FIXME: For some reason this test regularly (although not always) fails
// in wxGTK build bot builds when testing wxBitmapComboBox, but I
// can't reproduce the failure locally. For now, disable this check
// to let the entire test suite pass in automatic tests instead of
// failing sporadically.
if ( wxStrcmp(GetTestWindow()->GetClassInfo()->GetClassName(),
"wxBitmapComboBox") == 0 &&
IsAutomaticTest() )
{
return;
}
#endif // __WGTK__
wxTextEntry * const entry = GetTestEntry();
wxWindow * const window = GetTestWindow();
@@ -234,6 +219,13 @@ void TextEntryTestCase::Editable()
window->SetFocus();
wxYield();
#ifdef __WXGTK__
// For some reason, wxBitmapComboBox doesn't appear on the screen without
// this (due to wxTLW size hacks perhaps?). It would be nice to avoid doing
// this, but without this hack the test often (although not always) fails.
wxMilliSleep(50);
#endif // __WGTK__
// Check that we get the expected number of events.
wxUIActionSimulator sim;
sim.Text("abcdef");

View File

@@ -36,7 +36,9 @@ GraphicsContextDrawingTestCase::ms_drawingFontTc = {
void GraphicsContextDrawingTestCase::DoFontDrawings (wxGraphicsContext *gc)
{
#ifdef __WXGTK__
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
g_type_init();
wxGCC_WARNING_RESTORE()
#endif
// This test is expected to treat about fonts/texts. Fonts are a bit special

View File

@@ -114,10 +114,14 @@ void FontTestCase::Construct()
#pragma warning(disable:4996)
#endif
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
// Tests relying on the soon-to-be-deprecated ctor taking ints and not
// wxFontXXX enum elements.
CPPUNIT_ASSERT( wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL).IsOk() );
wxGCC_WARNING_RESTORE()
#ifdef __VISUALC__
#pragma warning(pop)
#endif

View File

@@ -86,7 +86,8 @@ void EllipsizationTestCase::NormalCase()
wxELLIPSIZE_END
};
int widthsToTest[] = { 50, 100, 150 };
const int charWidth = dc.GetCharWidth();
int widthsToTest[] = { 6*charWidth, 10*charWidth, 15*charWidth };
for ( unsigned int s = 0; s < WXSIZEOF(stringsToTest); s++ )
{
@@ -110,8 +111,10 @@ void EllipsizationTestCase::NormalCase()
WX_ASSERT_MESSAGE
(
(
"invalid ellipsization for \"%s\" (%dpx, should be <=%dpx)",
"Test #(%u,%u.%u): \"%s\" -> \"%s\"; width=%dpx > %dpx",
s, f, m,
str,
ret,
dc.GetMultiLineTextExtent(ret).GetWidth(),
widthsToTest[w]
),

View File

@@ -19,9 +19,10 @@
#endif
#ifndef WX_PRECOMP
#include "wx/dcmemory.h"
#endif // WX_PRECOMP
#include "wx/html/htmlpars.h"
#include "wx/html/winpars.h"
// ----------------------------------------------------------------------------
// test class
@@ -55,7 +56,7 @@ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( HtmlParserTestCase, "HtmlParserTestCase"
// Test that parsing invalid HTML simply fails but doesn't crash for example.
void HtmlParserTestCase::Invalid()
{
class NullParser : public wxHtmlParser
class NullParser : public wxHtmlWinParser
{
public:
virtual wxObject *GetProduct() { return NULL; }
@@ -65,6 +66,9 @@ void HtmlParserTestCase::Invalid()
};
NullParser p;
wxMemoryDC dc;
p.SetDC(&dc);
p.Parse("<");
p.Parse("<foo");
p.Parse("<!--");

View File

@@ -499,6 +499,12 @@ void MenuTestCase::Events()
m_frame->SetFocus();
wxYield();
#ifdef __WXGTK__
// This is another test which fails with wxGTK without this delay because
// the frame doesn't appear on screen in time.
wxMilliSleep(50);
#endif // __WXGTK__
wxUIActionSimulator sim;
sim.KeyDown(WXK_F1);
sim.KeyUp(WXK_F1);

View File

@@ -559,9 +559,8 @@ bool TestApp::OnInit()
cout << std::endl;
#if wxUSE_GUI
// create a hidden parent window to be used as parent for the GUI controls
wxTestableFrame* frame = new wxTestableFrame();
frame->Show();
// create a parent window to be used as parent for the GUI controls
new wxTestableFrame();
Connect(wxEVT_IDLE, wxIdleEventHandler(TestApp::OnIdle));
#endif // wxUSE_GUI

View File

@@ -20,6 +20,8 @@ wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame")
{
// Use fixed position to facilitate debugging.
Move(200, 200);
Show();
}
void wxTestableFrame::OnEvent(wxEvent& evt)