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:
@@ -1670,20 +1670,27 @@ bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsig
|
|||||||
GTK_TREE_MODEL(wxgtk_model), &iter ));
|
GTK_TREE_MODEL(wxgtk_model), &iter ));
|
||||||
GdkRectangle cell_area;
|
GdkRectangle cell_area;
|
||||||
gtk_tree_view_get_cell_area( widget, path, gcolumn, &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;
|
// Don't try to redraw the column if it's invisible, this just
|
||||||
gtk_widget_get_allocation(GTK_WIDGET(gtk_tree_view_column_get_button(gcolumn)), &a);
|
// results in "BUG" messages from pixman_region32_init_rect()
|
||||||
int ydiff = a.height;
|
// and would be useful even if it didn't anyhow.
|
||||||
// Redraw
|
if ( cell_area.width > 0 && cell_area.height > 0 )
|
||||||
gtk_widget_queue_draw_area( GTK_WIDGET(widget),
|
{
|
||||||
cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height );
|
#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 );
|
m_internal->ValueChanged( item, model_column );
|
||||||
|
@@ -115,7 +115,14 @@ static void pizza_size_allocate(GtkWidget* widget, GtkAllocation* alloc)
|
|||||||
child_alloc.height = child->height;
|
child_alloc.height = child->height;
|
||||||
if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
|
if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
|
||||||
child_alloc.x = w - child_alloc.x - child_alloc.width;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -145,10 +145,16 @@ void ComboBoxTestCase::PopDismiss()
|
|||||||
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
|
EventCounter close(m_combo, wxEVT_COMBOBOX_CLOSEUP);
|
||||||
|
|
||||||
m_combo->Popup();
|
m_combo->Popup();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(1, drop.GetCount());
|
||||||
|
|
||||||
m_combo->Dismiss();
|
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());
|
CPPUNIT_ASSERT_EQUAL(1, close.GetCount());
|
||||||
|
#endif // wxGTK2
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,6 +79,13 @@ void ModalDialogsTestCase::FileDialog()
|
|||||||
CPPUNIT_ASSERT_EQUAL((int)wxID_OK, rc);
|
CPPUNIT_ASSERT_EQUAL((int)wxID_OK, rc);
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL("test.txt", dlg.GetFilename());
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -211,21 +211,6 @@ private:
|
|||||||
|
|
||||||
void TextEntryTestCase::Editable()
|
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();
|
wxTextEntry * const entry = GetTestEntry();
|
||||||
wxWindow * const window = GetTestWindow();
|
wxWindow * const window = GetTestWindow();
|
||||||
|
|
||||||
@@ -234,6 +219,13 @@ void TextEntryTestCase::Editable()
|
|||||||
window->SetFocus();
|
window->SetFocus();
|
||||||
wxYield();
|
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.
|
// Check that we get the expected number of events.
|
||||||
wxUIActionSimulator sim;
|
wxUIActionSimulator sim;
|
||||||
sim.Text("abcdef");
|
sim.Text("abcdef");
|
||||||
|
@@ -36,7 +36,9 @@ GraphicsContextDrawingTestCase::ms_drawingFontTc = {
|
|||||||
void GraphicsContextDrawingTestCase::DoFontDrawings (wxGraphicsContext *gc)
|
void GraphicsContextDrawingTestCase::DoFontDrawings (wxGraphicsContext *gc)
|
||||||
{
|
{
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
|
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||||
g_type_init();
|
g_type_init();
|
||||||
|
wxGCC_WARNING_RESTORE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This test is expected to treat about fonts/texts. Fonts are a bit special
|
// This test is expected to treat about fonts/texts. Fonts are a bit special
|
||||||
|
@@ -114,10 +114,14 @@ void FontTestCase::Construct()
|
|||||||
#pragma warning(disable:4996)
|
#pragma warning(disable:4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||||
|
|
||||||
// Tests relying on the soon-to-be-deprecated ctor taking ints and not
|
// Tests relying on the soon-to-be-deprecated ctor taking ints and not
|
||||||
// wxFontXXX enum elements.
|
// wxFontXXX enum elements.
|
||||||
CPPUNIT_ASSERT( wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL).IsOk() );
|
CPPUNIT_ASSERT( wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL).IsOk() );
|
||||||
|
|
||||||
|
wxGCC_WARNING_RESTORE()
|
||||||
|
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
@@ -86,7 +86,8 @@ void EllipsizationTestCase::NormalCase()
|
|||||||
wxELLIPSIZE_END
|
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++ )
|
for ( unsigned int s = 0; s < WXSIZEOF(stringsToTest); s++ )
|
||||||
{
|
{
|
||||||
@@ -110,8 +111,10 @@ void EllipsizationTestCase::NormalCase()
|
|||||||
WX_ASSERT_MESSAGE
|
WX_ASSERT_MESSAGE
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
"invalid ellipsization for \"%s\" (%dpx, should be <=%dpx)",
|
"Test #(%u,%u.%u): \"%s\" -> \"%s\"; width=%dpx > %dpx",
|
||||||
|
s, f, m,
|
||||||
str,
|
str,
|
||||||
|
ret,
|
||||||
dc.GetMultiLineTextExtent(ret).GetWidth(),
|
dc.GetMultiLineTextExtent(ret).GetWidth(),
|
||||||
widthsToTest[w]
|
widthsToTest[w]
|
||||||
),
|
),
|
||||||
|
@@ -19,9 +19,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dcmemory.h"
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/html/htmlpars.h"
|
#include "wx/html/winpars.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// test class
|
// 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.
|
// Test that parsing invalid HTML simply fails but doesn't crash for example.
|
||||||
void HtmlParserTestCase::Invalid()
|
void HtmlParserTestCase::Invalid()
|
||||||
{
|
{
|
||||||
class NullParser : public wxHtmlParser
|
class NullParser : public wxHtmlWinParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual wxObject *GetProduct() { return NULL; }
|
virtual wxObject *GetProduct() { return NULL; }
|
||||||
@@ -65,6 +66,9 @@ void HtmlParserTestCase::Invalid()
|
|||||||
};
|
};
|
||||||
|
|
||||||
NullParser p;
|
NullParser p;
|
||||||
|
wxMemoryDC dc;
|
||||||
|
p.SetDC(&dc);
|
||||||
|
|
||||||
p.Parse("<");
|
p.Parse("<");
|
||||||
p.Parse("<foo");
|
p.Parse("<foo");
|
||||||
p.Parse("<!--");
|
p.Parse("<!--");
|
||||||
|
@@ -499,6 +499,12 @@ void MenuTestCase::Events()
|
|||||||
m_frame->SetFocus();
|
m_frame->SetFocus();
|
||||||
wxYield();
|
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;
|
wxUIActionSimulator sim;
|
||||||
sim.KeyDown(WXK_F1);
|
sim.KeyDown(WXK_F1);
|
||||||
sim.KeyUp(WXK_F1);
|
sim.KeyUp(WXK_F1);
|
||||||
|
@@ -559,9 +559,8 @@ bool TestApp::OnInit()
|
|||||||
cout << std::endl;
|
cout << std::endl;
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
// create a hidden parent window to be used as parent for the GUI controls
|
// create a parent window to be used as parent for the GUI controls
|
||||||
wxTestableFrame* frame = new wxTestableFrame();
|
new wxTestableFrame();
|
||||||
frame->Show();
|
|
||||||
|
|
||||||
Connect(wxEVT_IDLE, wxIdleEventHandler(TestApp::OnIdle));
|
Connect(wxEVT_IDLE, wxIdleEventHandler(TestApp::OnIdle));
|
||||||
#endif // wxUSE_GUI
|
#endif // wxUSE_GUI
|
||||||
|
@@ -20,6 +20,8 @@ wxTestableFrame::wxTestableFrame() : wxFrame(NULL, wxID_ANY, "Test Frame")
|
|||||||
{
|
{
|
||||||
// Use fixed position to facilitate debugging.
|
// Use fixed position to facilitate debugging.
|
||||||
Move(200, 200);
|
Move(200, 200);
|
||||||
|
|
||||||
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTestableFrame::OnEvent(wxEvent& evt)
|
void wxTestableFrame::OnEvent(wxEvent& evt)
|
||||||
|
Reference in New Issue
Block a user