1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/controls/gridtest.cpp
3 // Purpose: wxGrid unit test
4 // Author: Steven Lamerton
7 // Copyright: (c) 2010 Steven Lamerton
8 ///////////////////////////////////////////////////////////////////////////////
23 #include "testableframe.h"
24 #include "asserthelper.h"
25 #include "wx/uiaction.h"
27 // FIXME: A lot of mouse-related tests sporadically fail in wxGTK. This happens
28 // almost all the time but sometimes the tests do pass and the failure
29 // doesn't happen when debugging so this looks like some kind of event
30 // dispatching/simulating problem rather than a real problem in wxGrid.
32 // Just disable these tests for now but it would be really great to
33 // really fix the problem.
35 #define NONGTK_TEST(test)
37 #define NONGTK_TEST(test) WXUISIM_TEST(test)
41 class GridTestCase
: public CppUnit::TestCase
47 virtual void tearDown();
50 CPPUNIT_TEST_SUITE( GridTestCase
);
51 WXUISIM_TEST( CellEdit
);
52 NONGTK_TEST( CellClick
);
53 NONGTK_TEST( CellSelect
);
54 NONGTK_TEST( LabelClick
);
55 NONGTK_TEST( SortClick
);
57 NONGTK_TEST( RangeSelect
);
58 CPPUNIT_TEST( Cursor
);
59 CPPUNIT_TEST( Selection
);
60 CPPUNIT_TEST( AddRowCol
);
61 CPPUNIT_TEST( ColumnOrder
);
62 CPPUNIT_TEST( ColumnVisibility
);
63 CPPUNIT_TEST( LineFormatting
);
64 CPPUNIT_TEST( SortSupport
);
65 CPPUNIT_TEST( Labels
);
66 CPPUNIT_TEST( SelectionMode
);
67 CPPUNIT_TEST( CellFormatting
);
68 WXUISIM_TEST( Editable
);
69 WXUISIM_TEST( ReadOnly
);
70 CPPUNIT_TEST( PseudoTest_NativeHeader
);
71 NONGTK_TEST( LabelClick
);
72 NONGTK_TEST( SortClick
);
73 CPPUNIT_TEST( ColumnOrder
);
74 CPPUNIT_TEST( PseudoTest_NativeLabels
);
75 NONGTK_TEST( LabelClick
);
76 NONGTK_TEST( SortClick
);
77 CPPUNIT_TEST( ColumnOrder
);
78 CPPUNIT_TEST_SUITE_END();
91 void ColumnVisibility();
92 void LineFormatting();
96 void CellFormatting();
99 void PseudoTest_NativeHeader() { ms_nativeheader
= true; }
100 void PseudoTest_NativeLabels() { ms_nativeheader
= false;
101 ms_nativelabels
= true; }
103 static bool ms_nativeheader
;
104 static bool ms_nativelabels
;
108 DECLARE_NO_COPY_CLASS(GridTestCase
)
111 // register in the unnamed registry so that these tests are run by default
112 CPPUNIT_TEST_SUITE_REGISTRATION( GridTestCase
);
114 // also include in its own registry so that these tests can be run alone
115 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GridTestCase
, "GridTestCase" );
117 //initialise the static variable
118 bool GridTestCase::ms_nativeheader
= false;
119 bool GridTestCase::ms_nativelabels
= false;
121 void GridTestCase::setUp()
123 m_grid
= new wxGrid(wxTheApp
->GetTopWindow(), wxID_ANY
);
124 m_grid
->CreateGrid(10, 2);
125 m_grid
->SetSize(400, 200);
127 if( ms_nativeheader
)
128 m_grid
->UseNativeColHeader();
130 if( ms_nativelabels
)
131 m_grid
->SetUseNativeColLabels();
137 void GridTestCase::tearDown()
139 // This is just a hack to continue the rest of the tests to run: if we
140 // destroy the header control while it has capture, this results in an
141 // assert failure and while handling an exception from it more bad things
142 // happen (as it's thrown from a dtor), resulting in simply aborting
143 // everything. So ensure that it doesn't have capture in any case.
145 // Of course, the right thing to do would be to understand why does it
146 // still have capture when the grid is destroyed sometimes.
147 wxWindow
* const win
= wxWindow::GetCapture();
154 void GridTestCase::CellEdit()
156 // TODO on OSX when running the grid test suite solo this works
157 // but not when running it together with other tests
158 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXOSX__)
159 EventCounter
changing(m_grid
, wxEVT_GRID_CELL_CHANGING
);
160 EventCounter
changed(m_grid
, wxEVT_GRID_CELL_CHANGED
);
161 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
163 wxUIActionSimulator sim
;
166 m_grid
->SetGridCursor(1, 1);
167 m_grid
->ShowCellEditControl();
170 sim
.Char(WXK_RETURN
);
174 CPPUNIT_ASSERT_EQUAL(1, created
.GetCount());
175 CPPUNIT_ASSERT_EQUAL(1, changing
.GetCount());
176 CPPUNIT_ASSERT_EQUAL(1, changed
.GetCount());
180 void GridTestCase::CellClick()
182 #if wxUSE_UIACTIONSIMULATOR
183 EventCounter
lclick(m_grid
, wxEVT_GRID_CELL_LEFT_CLICK
);
184 EventCounter
ldclick(m_grid
, wxEVT_GRID_CELL_LEFT_DCLICK
);
185 EventCounter
rclick(m_grid
, wxEVT_GRID_CELL_RIGHT_CLICK
);
186 EventCounter
rdclick(m_grid
, wxEVT_GRID_CELL_RIGHT_DCLICK
);
189 wxUIActionSimulator sim
;
191 wxRect rect
= m_grid
->CellToRect(0, 0);
192 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
193 point
= m_grid
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
194 m_grid
->GetColLabelSize())
197 sim
.MouseMove(point
);
203 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
209 //A double click event sends a single click event first
210 //test to ensure this still happens in the future
211 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
212 CPPUNIT_ASSERT_EQUAL(1, ldclick
.GetCount());
214 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
217 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
220 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
223 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
224 CPPUNIT_ASSERT_EQUAL(1, rdclick
.GetCount());
228 void GridTestCase::CellSelect()
230 #if wxUSE_UIACTIONSIMULATOR
231 EventCounter
cell(m_grid
, wxEVT_GRID_SELECT_CELL
);
233 wxUIActionSimulator sim
;
235 wxRect rect
= m_grid
->CellToRect(0, 0);
236 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
237 point
= m_grid
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
238 m_grid
->GetColLabelSize())
241 sim
.MouseMove(point
);
247 CPPUNIT_ASSERT_EQUAL(1, cell
.GetCount());
251 m_grid
->SetGridCursor(1, 1);
252 m_grid
->GoToCell(1, 0);
254 sim
.MouseMove(point
);
260 CPPUNIT_ASSERT_EQUAL(3, cell
.GetCount());
264 void GridTestCase::LabelClick()
266 #if wxUSE_UIACTIONSIMULATOR
267 EventCounter
lclick(m_grid
, wxEVT_GRID_LABEL_LEFT_CLICK
);
268 EventCounter
ldclick(m_grid
, wxEVT_GRID_LABEL_LEFT_DCLICK
);
269 EventCounter
rclick(m_grid
, wxEVT_GRID_LABEL_RIGHT_CLICK
);
270 EventCounter
rdclick(m_grid
, wxEVT_GRID_LABEL_RIGHT_DCLICK
);
272 wxUIActionSimulator sim
;
274 wxPoint
pos(m_grid
->GetRowLabelSize() + 2, 2);
275 pos
= m_grid
->ClientToScreen(pos
);
283 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
288 CPPUNIT_ASSERT_EQUAL(1, ldclick
.GetCount());
290 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
293 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
296 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
299 if( ms_nativeheader
)
301 //Right double click not supported with native headers so we get two
303 CPPUNIT_ASSERT_EQUAL(2, rclick
.GetCount());
307 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
308 CPPUNIT_ASSERT_EQUAL(1, rdclick
.GetCount());
313 void GridTestCase::SortClick()
315 #if wxUSE_UIACTIONSIMULATOR
316 m_grid
->SetSortingColumn(0);
318 EventCounter
sort(m_grid
, wxEVT_GRID_COL_SORT
);
320 wxUIActionSimulator sim
;
322 wxPoint
pos(m_grid
->GetRowLabelSize() + 4, 4);
323 pos
= m_grid
->ClientToScreen(pos
);
331 CPPUNIT_ASSERT_EQUAL(1, sort
.GetCount());
335 void GridTestCase::Size()
337 // TODO on OSX resizing interactively works, but not automated
338 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__) && !defined(__WXOSX__)
339 EventCounter
colsize(m_grid
, wxEVT_GRID_COL_SIZE
);
340 EventCounter
rowsize(m_grid
, wxEVT_GRID_ROW_SIZE
);
342 wxUIActionSimulator sim
;
344 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() +
345 m_grid
->GetColSize(0), 5));
353 sim
.MouseMove(pt
.x
+ 50, pt
.y
);
359 CPPUNIT_ASSERT_EQUAL(1, colsize
.GetCount());
361 pt
= m_grid
->ClientToScreen(wxPoint(5, m_grid
->GetColLabelSize() +
362 m_grid
->GetRowSize(0)));
364 sim
.MouseDragDrop(pt
.x
, pt
.y
, pt
.x
, pt
.y
+ 50);
367 CPPUNIT_ASSERT_EQUAL(1, rowsize
.GetCount());
371 void GridTestCase::RangeSelect()
373 #if wxUSE_UIACTIONSIMULATOR
374 EventCounter
select(m_grid
, wxEVT_GRID_RANGE_SELECT
);
376 wxUIActionSimulator sim
;
378 //We add the extra 10 to ensure that we are inside the cell
379 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() + 10,
380 m_grid
->GetColLabelSize() + 10)
389 sim
.MouseMove(pt
.x
+ 50, pt
.y
+ 50);
395 CPPUNIT_ASSERT_EQUAL(1, select
.GetCount());
399 void GridTestCase::Cursor()
401 m_grid
->SetGridCursor(1, 1);
403 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
404 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorRow());
406 m_grid
->MoveCursorDown(false);
407 m_grid
->MoveCursorLeft(false);
408 m_grid
->MoveCursorUp(false);
409 m_grid
->MoveCursorUp(false);
410 m_grid
->MoveCursorRight(false);
412 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
413 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
415 m_grid
->SetCellValue(0, 0, "some text");
416 m_grid
->SetCellValue(3, 0, "other text");
417 m_grid
->SetCellValue(0, 1, "more text");
418 m_grid
->SetCellValue(3, 1, "extra text");
423 m_grid
->MoveCursorLeftBlock(false);
425 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
426 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
428 m_grid
->MoveCursorDownBlock(false);
430 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
431 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
433 m_grid
->MoveCursorRightBlock(false);
435 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
436 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
438 m_grid
->MoveCursorUpBlock(false);
440 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
441 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
444 void GridTestCase::Selection()
448 CPPUNIT_ASSERT(m_grid
->IsSelection());
449 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 0));
450 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
452 m_grid
->SelectBlock(1, 0, 3, 1);
454 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
455 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
457 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
458 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
460 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
461 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetRow());
462 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
463 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
465 m_grid
->SelectCol(1);
467 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 1));
468 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
469 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
471 m_grid
->SelectRow(4);
473 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 0));
474 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 1));
475 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
478 void GridTestCase::AddRowCol()
480 CPPUNIT_ASSERT_EQUAL(10, m_grid
->GetNumberRows());
481 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetNumberCols());
483 m_grid
->AppendCols();
484 m_grid
->AppendRows();
486 CPPUNIT_ASSERT_EQUAL(11, m_grid
->GetNumberRows());
487 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetNumberCols());
489 m_grid
->AppendCols(2);
490 m_grid
->AppendRows(2);
492 CPPUNIT_ASSERT_EQUAL(13, m_grid
->GetNumberRows());
493 CPPUNIT_ASSERT_EQUAL(5, m_grid
->GetNumberCols());
495 m_grid
->InsertCols(1, 2);
496 m_grid
->InsertRows(2, 3);
498 CPPUNIT_ASSERT_EQUAL(16, m_grid
->GetNumberRows());
499 CPPUNIT_ASSERT_EQUAL(7, m_grid
->GetNumberCols());
502 void GridTestCase::ColumnOrder()
504 m_grid
->AppendCols(2);
506 CPPUNIT_ASSERT_EQUAL(4, m_grid
->GetNumberCols());
509 neworder
.push_back(1);
510 neworder
.push_back(3);
511 neworder
.push_back(2);
512 neworder
.push_back(0);
514 m_grid
->SetColumnsOrder(neworder
);
516 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(1));
517 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(3));
518 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
519 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(0));
521 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColAt(0));
522 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColAt(1));
523 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColAt(2));
524 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColAt(3));
526 m_grid
->ResetColPos();
528 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(0));
529 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(1));
530 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
531 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(3));
534 void GridTestCase::ColumnVisibility()
536 m_grid
->AppendCols(3);
537 CPPUNIT_ASSERT( m_grid
->IsColShown(1) );
540 CPPUNIT_ASSERT( !m_grid
->IsColShown(1) );
541 CPPUNIT_ASSERT( m_grid
->IsColShown(2) );
544 CPPUNIT_ASSERT( m_grid
->IsColShown(1) );
547 void GridTestCase::LineFormatting()
549 CPPUNIT_ASSERT(m_grid
->GridLinesEnabled());
551 m_grid
->EnableGridLines(false);
553 CPPUNIT_ASSERT(!m_grid
->GridLinesEnabled());
555 m_grid
->EnableGridLines();
557 m_grid
->SetGridLineColour(*wxRED
);
559 CPPUNIT_ASSERT_EQUAL(m_grid
->GetGridLineColour(), *wxRED
);
562 void GridTestCase::SortSupport()
564 CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND
, m_grid
->GetSortingColumn());
566 m_grid
->SetSortingColumn(1);
568 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
569 CPPUNIT_ASSERT(m_grid
->IsSortingBy(1));
570 CPPUNIT_ASSERT(m_grid
->IsSortOrderAscending());
572 m_grid
->SetSortingColumn(0, false);
574 CPPUNIT_ASSERT(m_grid
->IsSortingBy(0));
575 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
576 CPPUNIT_ASSERT(!m_grid
->IsSortOrderAscending());
578 m_grid
->UnsetSortingColumn();
580 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
581 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
584 void GridTestCase::Labels()
586 CPPUNIT_ASSERT_EQUAL("A", m_grid
->GetColLabelValue(0));
587 CPPUNIT_ASSERT_EQUAL("1", m_grid
->GetRowLabelValue(0));
589 m_grid
->SetColLabelValue(0, "Column 1");
590 m_grid
->SetRowLabelValue(0, "Row 1");
592 CPPUNIT_ASSERT_EQUAL("Column 1", m_grid
->GetColLabelValue(0));
593 CPPUNIT_ASSERT_EQUAL("Row 1", m_grid
->GetRowLabelValue(0));
595 m_grid
->SetLabelTextColour(*wxGREEN
);
596 m_grid
->SetLabelBackgroundColour(*wxRED
);
598 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetLabelTextColour());
599 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetLabelBackgroundColour());
601 m_grid
->SetColLabelTextOrientation(wxVERTICAL
);
603 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxVERTICAL
),
604 static_cast<int>(m_grid
->GetColLabelTextOrientation()));
607 void GridTestCase::SelectionMode()
609 //We already test this mode in Select
610 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectCells
,
611 m_grid
->GetSelectionMode());
613 //Test row selection be selecting a single cell and checking the whole
615 m_grid
->SetSelectionMode(wxGrid::wxGridSelectRows
);
616 m_grid
->SelectBlock(3, 1, 3, 1);
618 wxArrayInt selectedRows
= m_grid
->GetSelectedRows();
619 CPPUNIT_ASSERT_EQUAL(1, selectedRows
.Count());
620 CPPUNIT_ASSERT_EQUAL(3, selectedRows
[0]);
622 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectRows
,
623 m_grid
->GetSelectionMode());
626 //Test column selection be selecting a single cell and checking the whole
628 m_grid
->SetSelectionMode(wxGrid::wxGridSelectColumns
);
629 m_grid
->SelectBlock(3, 1, 3, 1);
631 wxArrayInt selectedCols
= m_grid
->GetSelectedCols();
632 CPPUNIT_ASSERT_EQUAL(1, selectedCols
.Count());
633 CPPUNIT_ASSERT_EQUAL(1, selectedCols
[0]);
635 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectColumns
,
636 m_grid
->GetSelectionMode());
639 void GridTestCase::CellFormatting()
641 //Check that initial alignment is default
642 int horiz
, cellhoriz
, vert
, cellvert
;
644 m_grid
->GetDefaultCellAlignment(&horiz
, &vert
);
645 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
647 CPPUNIT_ASSERT_EQUAL(cellhoriz
, horiz
);
648 CPPUNIT_ASSERT_EQUAL(cellvert
, vert
);
650 //Check initial text colour and background colour are default
653 back
= m_grid
->GetDefaultCellBackgroundColour();
655 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellBackgroundColour(0, 0));
657 back
= m_grid
->GetDefaultCellTextColour();
659 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellTextColour(0, 0));
661 #if WXWIN_COMPATIBILITY_2_8
662 m_grid
->SetCellAlignment(wxALIGN_CENTRE
, 0, 0);
663 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
665 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellhoriz
);
666 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellvert
);
667 #endif // WXWIN_COMPATIBILITY_2_8
669 m_grid
->SetCellAlignment(0, 0, wxALIGN_LEFT
, wxALIGN_BOTTOM
);
670 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
672 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_LEFT
), cellhoriz
);
673 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_BOTTOM
), cellvert
);
675 #if WXWIN_COMPATIBILITY_2_8
676 m_grid
->SetCellTextColour(*wxRED
, 0, 0);
677 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetCellTextColour(0, 0));
678 #endif // WXWIN_COMPATIBILITY_2_8
680 m_grid
->SetCellTextColour(0, 0, *wxGREEN
);
681 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetCellTextColour(0, 0));
684 void GridTestCase::Editable()
686 #if wxUSE_UIACTIONSIMULATOR
687 //As the grid is not editable we shouldn't create an editor
688 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
690 wxUIActionSimulator sim
;
692 CPPUNIT_ASSERT(m_grid
->IsEditable());
694 m_grid
->EnableEditing(false);
696 CPPUNIT_ASSERT(!m_grid
->IsEditable());
699 m_grid
->SetGridCursor(1, 1);
700 m_grid
->ShowCellEditControl();
705 sim
.Char(WXK_RETURN
);
708 CPPUNIT_ASSERT_EQUAL(0, created
.GetCount());
712 void GridTestCase::ReadOnly()
714 #if wxUSE_UIACTIONSIMULATOR
715 //As the cell is readonly we shouldn't create an editor
716 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
718 wxUIActionSimulator sim
;
720 CPPUNIT_ASSERT(!m_grid
->IsReadOnly(1, 1));
722 m_grid
->SetReadOnly(1, 1);
724 CPPUNIT_ASSERT(m_grid
->IsReadOnly(1, 1));
727 m_grid
->SetGridCursor(1, 1);
729 CPPUNIT_ASSERT(m_grid
->IsCurrentCellReadOnly());
731 m_grid
->ShowCellEditControl();
736 sim
.Char(WXK_RETURN
);
739 CPPUNIT_ASSERT_EQUAL(0, created
.GetCount());