1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/gridtest.cpp
3 // Purpose: wxGrid unit test
4 // Author: Steven Lamerton
6 // Copyright: (c) 2010 Steven Lamerton
7 ///////////////////////////////////////////////////////////////////////////////
22 #include "testableframe.h"
23 #include "asserthelper.h"
24 #include "wx/uiaction.h"
26 // FIXME: A lot of mouse-related tests sporadically fail in wxGTK. This happens
27 // almost all the time but sometimes the tests do pass and the failure
28 // doesn't happen when debugging so this looks like some kind of event
29 // dispatching/simulating problem rather than a real problem in wxGrid.
31 // Just disable these tests for now but it would be really great to
32 // really fix the problem.
34 #define NONGTK_TEST(test)
36 #define NONGTK_TEST(test) WXUISIM_TEST(test)
40 class GridTestCase
: public CppUnit::TestCase
46 virtual void tearDown();
49 CPPUNIT_TEST_SUITE( GridTestCase
);
50 WXUISIM_TEST( CellEdit
);
51 NONGTK_TEST( CellClick
);
52 NONGTK_TEST( CellSelect
);
53 NONGTK_TEST( LabelClick
);
54 NONGTK_TEST( SortClick
);
56 NONGTK_TEST( RangeSelect
);
57 CPPUNIT_TEST( Cursor
);
58 CPPUNIT_TEST( Selection
);
59 CPPUNIT_TEST( AddRowCol
);
60 CPPUNIT_TEST( ColumnOrder
);
61 CPPUNIT_TEST( ColumnVisibility
);
62 CPPUNIT_TEST( LineFormatting
);
63 CPPUNIT_TEST( SortSupport
);
64 CPPUNIT_TEST( Labels
);
65 CPPUNIT_TEST( SelectionMode
);
66 CPPUNIT_TEST( CellFormatting
);
67 WXUISIM_TEST( Editable
);
68 WXUISIM_TEST( ReadOnly
);
69 CPPUNIT_TEST( PseudoTest_NativeHeader
);
70 NONGTK_TEST( LabelClick
);
71 NONGTK_TEST( SortClick
);
72 CPPUNIT_TEST( ColumnOrder
);
73 CPPUNIT_TEST( PseudoTest_NativeLabels
);
74 NONGTK_TEST( LabelClick
);
75 NONGTK_TEST( SortClick
);
76 CPPUNIT_TEST( ColumnOrder
);
77 CPPUNIT_TEST_SUITE_END();
90 void ColumnVisibility();
91 void LineFormatting();
95 void CellFormatting();
98 void PseudoTest_NativeHeader() { ms_nativeheader
= true; }
99 void PseudoTest_NativeLabels() { ms_nativeheader
= false;
100 ms_nativelabels
= true; }
102 static bool ms_nativeheader
;
103 static bool ms_nativelabels
;
107 DECLARE_NO_COPY_CLASS(GridTestCase
)
110 // register in the unnamed registry so that these tests are run by default
111 CPPUNIT_TEST_SUITE_REGISTRATION( GridTestCase
);
113 // also include in its own registry so that these tests can be run alone
114 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GridTestCase
, "GridTestCase" );
116 //initialise the static variable
117 bool GridTestCase::ms_nativeheader
= false;
118 bool GridTestCase::ms_nativelabels
= false;
120 void GridTestCase::setUp()
122 m_grid
= new wxGrid(wxTheApp
->GetTopWindow(), wxID_ANY
);
123 m_grid
->CreateGrid(10, 2);
124 m_grid
->SetSize(400, 200);
126 if( ms_nativeheader
)
127 m_grid
->UseNativeColHeader();
129 if( ms_nativelabels
)
130 m_grid
->SetUseNativeColLabels();
136 void GridTestCase::tearDown()
138 // This is just a hack to continue the rest of the tests to run: if we
139 // destroy the header control while it has capture, this results in an
140 // assert failure and while handling an exception from it more bad things
141 // happen (as it's thrown from a dtor), resulting in simply aborting
142 // everything. So ensure that it doesn't have capture in any case.
144 // Of course, the right thing to do would be to understand why does it
145 // still have capture when the grid is destroyed sometimes.
146 wxWindow
* const win
= wxWindow::GetCapture();
153 void GridTestCase::CellEdit()
155 // TODO on OSX when running the grid test suite solo this works
156 // but not when running it together with other tests
157 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__)
158 EventCounter
changing(m_grid
, wxEVT_GRID_CELL_CHANGING
);
159 EventCounter
changed(m_grid
, wxEVT_GRID_CELL_CHANGED
);
160 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
162 wxUIActionSimulator sim
;
165 m_grid
->SetGridCursor(1, 1);
166 m_grid
->ShowCellEditControl();
169 sim
.Char(WXK_RETURN
);
173 CPPUNIT_ASSERT_EQUAL(1, created
.GetCount());
174 CPPUNIT_ASSERT_EQUAL(1, changing
.GetCount());
175 CPPUNIT_ASSERT_EQUAL(1, changed
.GetCount());
179 void GridTestCase::CellClick()
181 #if wxUSE_UIACTIONSIMULATOR
182 EventCounter
lclick(m_grid
, wxEVT_GRID_CELL_LEFT_CLICK
);
183 EventCounter
ldclick(m_grid
, wxEVT_GRID_CELL_LEFT_DCLICK
);
184 EventCounter
rclick(m_grid
, wxEVT_GRID_CELL_RIGHT_CLICK
);
185 EventCounter
rdclick(m_grid
, wxEVT_GRID_CELL_RIGHT_DCLICK
);
188 wxUIActionSimulator sim
;
190 wxRect rect
= m_grid
->CellToRect(0, 0);
191 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
192 point
= m_grid
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
193 m_grid
->GetColLabelSize())
196 sim
.MouseMove(point
);
202 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
208 //A double click event sends a single click event first
209 //test to ensure this still happens in the future
210 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
211 CPPUNIT_ASSERT_EQUAL(1, ldclick
.GetCount());
213 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
216 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
219 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
222 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
223 CPPUNIT_ASSERT_EQUAL(1, rdclick
.GetCount());
227 void GridTestCase::CellSelect()
229 #if wxUSE_UIACTIONSIMULATOR
230 EventCounter
cell(m_grid
, wxEVT_GRID_SELECT_CELL
);
232 wxUIActionSimulator sim
;
234 wxRect rect
= m_grid
->CellToRect(0, 0);
235 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
236 point
= m_grid
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
237 m_grid
->GetColLabelSize())
240 sim
.MouseMove(point
);
246 CPPUNIT_ASSERT_EQUAL(1, cell
.GetCount());
250 m_grid
->SetGridCursor(1, 1);
251 m_grid
->GoToCell(1, 0);
253 sim
.MouseMove(point
);
259 CPPUNIT_ASSERT_EQUAL(3, cell
.GetCount());
263 void GridTestCase::LabelClick()
265 #if wxUSE_UIACTIONSIMULATOR
266 EventCounter
lclick(m_grid
, wxEVT_GRID_LABEL_LEFT_CLICK
);
267 EventCounter
ldclick(m_grid
, wxEVT_GRID_LABEL_LEFT_DCLICK
);
268 EventCounter
rclick(m_grid
, wxEVT_GRID_LABEL_RIGHT_CLICK
);
269 EventCounter
rdclick(m_grid
, wxEVT_GRID_LABEL_RIGHT_DCLICK
);
271 wxUIActionSimulator sim
;
273 wxPoint
pos(m_grid
->GetRowLabelSize() + 2, 2);
274 pos
= m_grid
->ClientToScreen(pos
);
282 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
287 CPPUNIT_ASSERT_EQUAL(1, ldclick
.GetCount());
289 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
292 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
295 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
298 if( ms_nativeheader
)
300 //Right double click not supported with native headers so we get two
302 CPPUNIT_ASSERT_EQUAL(2, rclick
.GetCount());
306 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
307 CPPUNIT_ASSERT_EQUAL(1, rdclick
.GetCount());
312 void GridTestCase::SortClick()
314 #if wxUSE_UIACTIONSIMULATOR
315 m_grid
->SetSortingColumn(0);
317 EventCounter
sort(m_grid
, wxEVT_GRID_COL_SORT
);
319 wxUIActionSimulator sim
;
321 wxPoint
pos(m_grid
->GetRowLabelSize() + 4, 4);
322 pos
= m_grid
->ClientToScreen(pos
);
330 CPPUNIT_ASSERT_EQUAL(1, sort
.GetCount());
334 void GridTestCase::Size()
336 // TODO on OSX resizing interactively works, but not automated
337 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) && !defined(__WXOSX__)
338 EventCounter
colsize(m_grid
, wxEVT_GRID_COL_SIZE
);
339 EventCounter
rowsize(m_grid
, wxEVT_GRID_ROW_SIZE
);
341 wxUIActionSimulator sim
;
343 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() +
344 m_grid
->GetColSize(0), 5));
352 sim
.MouseMove(pt
.x
+ 50, pt
.y
);
358 CPPUNIT_ASSERT_EQUAL(1, colsize
.GetCount());
360 pt
= m_grid
->ClientToScreen(wxPoint(5, m_grid
->GetColLabelSize() +
361 m_grid
->GetRowSize(0)));
363 sim
.MouseDragDrop(pt
.x
, pt
.y
, pt
.x
, pt
.y
+ 50);
366 CPPUNIT_ASSERT_EQUAL(1, rowsize
.GetCount());
370 void GridTestCase::RangeSelect()
372 #if wxUSE_UIACTIONSIMULATOR
373 EventCounter
select(m_grid
, wxEVT_GRID_RANGE_SELECT
);
375 wxUIActionSimulator sim
;
377 //We add the extra 10 to ensure that we are inside the cell
378 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() + 10,
379 m_grid
->GetColLabelSize() + 10)
388 sim
.MouseMove(pt
.x
+ 50, pt
.y
+ 50);
394 CPPUNIT_ASSERT_EQUAL(1, select
.GetCount());
398 void GridTestCase::Cursor()
400 m_grid
->SetGridCursor(1, 1);
402 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
403 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorRow());
405 m_grid
->MoveCursorDown(false);
406 m_grid
->MoveCursorLeft(false);
407 m_grid
->MoveCursorUp(false);
408 m_grid
->MoveCursorUp(false);
409 m_grid
->MoveCursorRight(false);
411 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
412 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
414 m_grid
->SetCellValue(0, 0, "some text");
415 m_grid
->SetCellValue(3, 0, "other text");
416 m_grid
->SetCellValue(0, 1, "more text");
417 m_grid
->SetCellValue(3, 1, "extra text");
422 m_grid
->MoveCursorLeftBlock(false);
424 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
425 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
427 m_grid
->MoveCursorDownBlock(false);
429 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
430 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
432 m_grid
->MoveCursorRightBlock(false);
434 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
435 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
437 m_grid
->MoveCursorUpBlock(false);
439 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
440 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
443 void GridTestCase::Selection()
447 CPPUNIT_ASSERT(m_grid
->IsSelection());
448 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 0));
449 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
451 m_grid
->SelectBlock(1, 0, 3, 1);
453 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
454 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
456 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
457 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
459 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
460 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetRow());
461 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
462 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
464 m_grid
->SelectCol(1);
466 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 1));
467 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
468 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
470 m_grid
->SelectRow(4);
472 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 0));
473 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 1));
474 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
477 void GridTestCase::AddRowCol()
479 CPPUNIT_ASSERT_EQUAL(10, m_grid
->GetNumberRows());
480 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetNumberCols());
482 m_grid
->AppendCols();
483 m_grid
->AppendRows();
485 CPPUNIT_ASSERT_EQUAL(11, m_grid
->GetNumberRows());
486 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetNumberCols());
488 m_grid
->AppendCols(2);
489 m_grid
->AppendRows(2);
491 CPPUNIT_ASSERT_EQUAL(13, m_grid
->GetNumberRows());
492 CPPUNIT_ASSERT_EQUAL(5, m_grid
->GetNumberCols());
494 m_grid
->InsertCols(1, 2);
495 m_grid
->InsertRows(2, 3);
497 CPPUNIT_ASSERT_EQUAL(16, m_grid
->GetNumberRows());
498 CPPUNIT_ASSERT_EQUAL(7, m_grid
->GetNumberCols());
501 void GridTestCase::ColumnOrder()
503 m_grid
->AppendCols(2);
505 CPPUNIT_ASSERT_EQUAL(4, m_grid
->GetNumberCols());
508 neworder
.push_back(1);
509 neworder
.push_back(3);
510 neworder
.push_back(2);
511 neworder
.push_back(0);
513 m_grid
->SetColumnsOrder(neworder
);
515 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(1));
516 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(3));
517 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
518 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(0));
520 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColAt(0));
521 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColAt(1));
522 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColAt(2));
523 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColAt(3));
525 m_grid
->ResetColPos();
527 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(0));
528 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(1));
529 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
530 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(3));
533 void GridTestCase::ColumnVisibility()
535 m_grid
->AppendCols(3);
536 CPPUNIT_ASSERT( m_grid
->IsColShown(1) );
539 CPPUNIT_ASSERT( !m_grid
->IsColShown(1) );
540 CPPUNIT_ASSERT( m_grid
->IsColShown(2) );
543 CPPUNIT_ASSERT( m_grid
->IsColShown(1) );
546 void GridTestCase::LineFormatting()
548 CPPUNIT_ASSERT(m_grid
->GridLinesEnabled());
550 m_grid
->EnableGridLines(false);
552 CPPUNIT_ASSERT(!m_grid
->GridLinesEnabled());
554 m_grid
->EnableGridLines();
556 m_grid
->SetGridLineColour(*wxRED
);
558 CPPUNIT_ASSERT_EQUAL(m_grid
->GetGridLineColour(), *wxRED
);
561 void GridTestCase::SortSupport()
563 CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND
, m_grid
->GetSortingColumn());
565 m_grid
->SetSortingColumn(1);
567 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
568 CPPUNIT_ASSERT(m_grid
->IsSortingBy(1));
569 CPPUNIT_ASSERT(m_grid
->IsSortOrderAscending());
571 m_grid
->SetSortingColumn(0, false);
573 CPPUNIT_ASSERT(m_grid
->IsSortingBy(0));
574 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
575 CPPUNIT_ASSERT(!m_grid
->IsSortOrderAscending());
577 m_grid
->UnsetSortingColumn();
579 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
580 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
583 void GridTestCase::Labels()
585 CPPUNIT_ASSERT_EQUAL("A", m_grid
->GetColLabelValue(0));
586 CPPUNIT_ASSERT_EQUAL("1", m_grid
->GetRowLabelValue(0));
588 m_grid
->SetColLabelValue(0, "Column 1");
589 m_grid
->SetRowLabelValue(0, "Row 1");
591 CPPUNIT_ASSERT_EQUAL("Column 1", m_grid
->GetColLabelValue(0));
592 CPPUNIT_ASSERT_EQUAL("Row 1", m_grid
->GetRowLabelValue(0));
594 m_grid
->SetLabelTextColour(*wxGREEN
);
595 m_grid
->SetLabelBackgroundColour(*wxRED
);
597 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetLabelTextColour());
598 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetLabelBackgroundColour());
600 m_grid
->SetColLabelTextOrientation(wxVERTICAL
);
602 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxVERTICAL
),
603 static_cast<int>(m_grid
->GetColLabelTextOrientation()));
606 void GridTestCase::SelectionMode()
608 //We already test this mode in Select
609 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectCells
,
610 m_grid
->GetSelectionMode());
612 //Test row selection be selecting a single cell and checking the whole
614 m_grid
->SetSelectionMode(wxGrid::wxGridSelectRows
);
615 m_grid
->SelectBlock(3, 1, 3, 1);
617 wxArrayInt selectedRows
= m_grid
->GetSelectedRows();
618 CPPUNIT_ASSERT_EQUAL(1, selectedRows
.Count());
619 CPPUNIT_ASSERT_EQUAL(3, selectedRows
[0]);
621 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectRows
,
622 m_grid
->GetSelectionMode());
625 //Test column selection be selecting a single cell and checking the whole
627 m_grid
->SetSelectionMode(wxGrid::wxGridSelectColumns
);
628 m_grid
->SelectBlock(3, 1, 3, 1);
630 wxArrayInt selectedCols
= m_grid
->GetSelectedCols();
631 CPPUNIT_ASSERT_EQUAL(1, selectedCols
.Count());
632 CPPUNIT_ASSERT_EQUAL(1, selectedCols
[0]);
634 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectColumns
,
635 m_grid
->GetSelectionMode());
638 void GridTestCase::CellFormatting()
640 //Check that initial alignment is default
641 int horiz
, cellhoriz
, vert
, cellvert
;
643 m_grid
->GetDefaultCellAlignment(&horiz
, &vert
);
644 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
646 CPPUNIT_ASSERT_EQUAL(cellhoriz
, horiz
);
647 CPPUNIT_ASSERT_EQUAL(cellvert
, vert
);
649 //Check initial text colour and background colour are default
652 back
= m_grid
->GetDefaultCellBackgroundColour();
654 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellBackgroundColour(0, 0));
656 back
= m_grid
->GetDefaultCellTextColour();
658 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellTextColour(0, 0));
660 #if WXWIN_COMPATIBILITY_2_8
661 m_grid
->SetCellAlignment(wxALIGN_CENTRE
, 0, 0);
662 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
664 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellhoriz
);
665 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellvert
);
666 #endif // WXWIN_COMPATIBILITY_2_8
668 m_grid
->SetCellAlignment(0, 0, wxALIGN_LEFT
, wxALIGN_BOTTOM
);
669 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
671 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_LEFT
), cellhoriz
);
672 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_BOTTOM
), cellvert
);
674 #if WXWIN_COMPATIBILITY_2_8
675 m_grid
->SetCellTextColour(*wxRED
, 0, 0);
676 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetCellTextColour(0, 0));
677 #endif // WXWIN_COMPATIBILITY_2_8
679 m_grid
->SetCellTextColour(0, 0, *wxGREEN
);
680 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetCellTextColour(0, 0));
683 void GridTestCase::Editable()
685 #if wxUSE_UIACTIONSIMULATOR
686 //As the grid is not editable we shouldn't create an editor
687 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
689 wxUIActionSimulator sim
;
691 CPPUNIT_ASSERT(m_grid
->IsEditable());
693 m_grid
->EnableEditing(false);
695 CPPUNIT_ASSERT(!m_grid
->IsEditable());
698 m_grid
->SetGridCursor(1, 1);
699 m_grid
->ShowCellEditControl();
704 sim
.Char(WXK_RETURN
);
707 CPPUNIT_ASSERT_EQUAL(0, created
.GetCount());
711 void GridTestCase::ReadOnly()
713 #if wxUSE_UIACTIONSIMULATOR
714 //As the cell is readonly we shouldn't create an editor
715 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
717 wxUIActionSimulator sim
;
719 CPPUNIT_ASSERT(!m_grid
->IsReadOnly(1, 1));
721 m_grid
->SetReadOnly(1, 1);
723 CPPUNIT_ASSERT(m_grid
->IsReadOnly(1, 1));
726 m_grid
->SetGridCursor(1, 1);
728 CPPUNIT_ASSERT(m_grid
->IsCurrentCellReadOnly());
730 m_grid
->ShowCellEditControl();
735 sim
.Char(WXK_RETURN
);
738 CPPUNIT_ASSERT_EQUAL(0, created
.GetCount());