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 #if wxUSE_UIACTIONSIMULATOR
157 EventCounter
changing(m_grid
, wxEVT_GRID_CELL_CHANGING
);
158 EventCounter
changed(m_grid
, wxEVT_GRID_CELL_CHANGED
);
159 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
161 wxUIActionSimulator sim
;
164 m_grid
->SetGridCursor(1, 1);
165 m_grid
->ShowCellEditControl();
168 sim
.Char(WXK_RETURN
);
172 CPPUNIT_ASSERT_EQUAL(1, created
.GetCount());
173 CPPUNIT_ASSERT_EQUAL(1, changing
.GetCount());
174 CPPUNIT_ASSERT_EQUAL(1, changed
.GetCount());
178 void GridTestCase::CellClick()
180 #if wxUSE_UIACTIONSIMULATOR
181 EventCounter
lclick(m_grid
, wxEVT_GRID_CELL_LEFT_CLICK
);
182 EventCounter
ldclick(m_grid
, wxEVT_GRID_CELL_LEFT_DCLICK
);
183 EventCounter
rclick(m_grid
, wxEVT_GRID_CELL_RIGHT_CLICK
);
184 EventCounter
rdclick(m_grid
, wxEVT_GRID_CELL_RIGHT_DCLICK
);
187 wxUIActionSimulator sim
;
189 wxRect rect
= m_grid
->CellToRect(0, 0);
190 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
191 point
= m_grid
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
192 m_grid
->GetColLabelSize())
195 sim
.MouseMove(point
);
201 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
207 //A double click event sends a single click event first
208 //test to ensure this still happens in the future
209 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
210 CPPUNIT_ASSERT_EQUAL(1, ldclick
.GetCount());
212 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
215 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
218 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
221 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
222 CPPUNIT_ASSERT_EQUAL(1, rdclick
.GetCount());
226 void GridTestCase::CellSelect()
228 #if wxUSE_UIACTIONSIMULATOR
229 EventCounter
cell(m_grid
, wxEVT_GRID_SELECT_CELL
);
231 wxUIActionSimulator sim
;
233 wxRect rect
= m_grid
->CellToRect(0, 0);
234 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
235 point
= m_grid
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
236 m_grid
->GetColLabelSize())
239 sim
.MouseMove(point
);
245 CPPUNIT_ASSERT_EQUAL(1, cell
.GetCount());
249 m_grid
->SetGridCursor(1, 1);
250 m_grid
->GoToCell(1, 0);
252 sim
.MouseMove(point
);
258 CPPUNIT_ASSERT_EQUAL(3, cell
.GetCount());
262 void GridTestCase::LabelClick()
264 #if wxUSE_UIACTIONSIMULATOR
265 EventCounter
lclick(m_grid
, wxEVT_GRID_LABEL_LEFT_CLICK
);
266 EventCounter
ldclick(m_grid
, wxEVT_GRID_LABEL_LEFT_DCLICK
);
267 EventCounter
rclick(m_grid
, wxEVT_GRID_LABEL_RIGHT_CLICK
);
268 EventCounter
rdclick(m_grid
, wxEVT_GRID_LABEL_RIGHT_DCLICK
);
270 wxUIActionSimulator sim
;
272 wxPoint
pos(m_grid
->GetRowLabelSize() + 2, 2);
273 pos
= m_grid
->ClientToScreen(pos
);
281 CPPUNIT_ASSERT_EQUAL(1, lclick
.GetCount());
286 CPPUNIT_ASSERT_EQUAL(1, ldclick
.GetCount());
288 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
291 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
294 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
297 if( ms_nativeheader
)
299 //Right double click not supported with native headers so we get two
301 CPPUNIT_ASSERT_EQUAL(2, rclick
.GetCount());
305 CPPUNIT_ASSERT_EQUAL(1, rclick
.GetCount());
306 CPPUNIT_ASSERT_EQUAL(1, rdclick
.GetCount());
311 void GridTestCase::SortClick()
313 #if wxUSE_UIACTIONSIMULATOR
314 m_grid
->SetSortingColumn(0);
316 EventCounter
sort(m_grid
, wxEVT_GRID_COL_SORT
);
318 wxUIActionSimulator sim
;
320 wxPoint
pos(m_grid
->GetRowLabelSize() + 4, 4);
321 pos
= m_grid
->ClientToScreen(pos
);
329 CPPUNIT_ASSERT_EQUAL(1, sort
.GetCount());
333 void GridTestCase::Size()
335 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
336 EventCounter
colsize(m_grid
, wxEVT_GRID_COL_SIZE
);
337 EventCounter
rowsize(m_grid
, wxEVT_GRID_ROW_SIZE
);
339 wxUIActionSimulator sim
;
341 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() +
342 m_grid
->GetColSize(0), 5));
350 sim
.MouseMove(pt
.x
+ 50, pt
.y
);
356 CPPUNIT_ASSERT_EQUAL(1, colsize
.GetCount());
358 pt
= m_grid
->ClientToScreen(wxPoint(5, m_grid
->GetColLabelSize() +
359 m_grid
->GetRowSize(0)));
361 sim
.MouseDragDrop(pt
.x
, pt
.y
, pt
.x
, pt
.y
+ 50);
364 CPPUNIT_ASSERT_EQUAL(1, rowsize
.GetCount());
368 void GridTestCase::RangeSelect()
370 #if wxUSE_UIACTIONSIMULATOR
371 EventCounter
select(m_grid
, wxEVT_GRID_RANGE_SELECT
);
373 wxUIActionSimulator sim
;
375 //We add the extra 10 to ensure that we are inside the cell
376 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() + 10,
377 m_grid
->GetColLabelSize() + 10)
386 sim
.MouseMove(pt
.x
+ 50, pt
.y
+ 50);
392 CPPUNIT_ASSERT_EQUAL(1, select
.GetCount());
396 void GridTestCase::Cursor()
398 m_grid
->SetGridCursor(1, 1);
400 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
401 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorRow());
403 m_grid
->MoveCursorDown(false);
404 m_grid
->MoveCursorLeft(false);
405 m_grid
->MoveCursorUp(false);
406 m_grid
->MoveCursorUp(false);
407 m_grid
->MoveCursorRight(false);
409 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
410 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
412 m_grid
->SetCellValue(0, 0, "some text");
413 m_grid
->SetCellValue(3, 0, "other text");
414 m_grid
->SetCellValue(0, 1, "more text");
415 m_grid
->SetCellValue(3, 1, "extra text");
420 m_grid
->MoveCursorLeftBlock(false);
422 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
423 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
425 m_grid
->MoveCursorDownBlock(false);
427 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
428 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
430 m_grid
->MoveCursorRightBlock(false);
432 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
433 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
435 m_grid
->MoveCursorUpBlock(false);
437 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
438 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
441 void GridTestCase::Selection()
445 CPPUNIT_ASSERT(m_grid
->IsSelection());
446 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 0));
447 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
449 m_grid
->SelectBlock(1, 0, 3, 1);
451 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
452 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
454 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
455 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
457 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
458 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetRow());
459 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
460 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
462 m_grid
->SelectCol(1);
464 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 1));
465 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
466 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
468 m_grid
->SelectRow(4);
470 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 0));
471 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 1));
472 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
475 void GridTestCase::AddRowCol()
477 CPPUNIT_ASSERT_EQUAL(10, m_grid
->GetNumberRows());
478 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetNumberCols());
480 m_grid
->AppendCols();
481 m_grid
->AppendRows();
483 CPPUNIT_ASSERT_EQUAL(11, m_grid
->GetNumberRows());
484 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetNumberCols());
486 m_grid
->AppendCols(2);
487 m_grid
->AppendRows(2);
489 CPPUNIT_ASSERT_EQUAL(13, m_grid
->GetNumberRows());
490 CPPUNIT_ASSERT_EQUAL(5, m_grid
->GetNumberCols());
492 m_grid
->InsertCols(1, 2);
493 m_grid
->InsertRows(2, 3);
495 CPPUNIT_ASSERT_EQUAL(16, m_grid
->GetNumberRows());
496 CPPUNIT_ASSERT_EQUAL(7, m_grid
->GetNumberCols());
499 void GridTestCase::ColumnOrder()
501 m_grid
->AppendCols(2);
503 CPPUNIT_ASSERT_EQUAL(4, m_grid
->GetNumberCols());
506 neworder
.push_back(1);
507 neworder
.push_back(3);
508 neworder
.push_back(2);
509 neworder
.push_back(0);
511 m_grid
->SetColumnsOrder(neworder
);
513 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(1));
514 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(3));
515 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
516 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(0));
518 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColAt(0));
519 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColAt(1));
520 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColAt(2));
521 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColAt(3));
523 m_grid
->ResetColPos();
525 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(0));
526 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(1));
527 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
528 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(3));
531 void GridTestCase::ColumnVisibility()
533 m_grid
->AppendCols(3);
534 CPPUNIT_ASSERT( m_grid
->IsColShown(1) );
537 CPPUNIT_ASSERT( !m_grid
->IsColShown(1) );
538 CPPUNIT_ASSERT( m_grid
->IsColShown(2) );
541 CPPUNIT_ASSERT( m_grid
->IsColShown(1) );
544 void GridTestCase::LineFormatting()
546 CPPUNIT_ASSERT(m_grid
->GridLinesEnabled());
548 m_grid
->EnableGridLines(false);
550 CPPUNIT_ASSERT(!m_grid
->GridLinesEnabled());
552 m_grid
->EnableGridLines();
554 m_grid
->SetGridLineColour(*wxRED
);
556 CPPUNIT_ASSERT_EQUAL(m_grid
->GetGridLineColour(), *wxRED
);
559 void GridTestCase::SortSupport()
561 CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND
, m_grid
->GetSortingColumn());
563 m_grid
->SetSortingColumn(1);
565 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
566 CPPUNIT_ASSERT(m_grid
->IsSortingBy(1));
567 CPPUNIT_ASSERT(m_grid
->IsSortOrderAscending());
569 m_grid
->SetSortingColumn(0, false);
571 CPPUNIT_ASSERT(m_grid
->IsSortingBy(0));
572 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
573 CPPUNIT_ASSERT(!m_grid
->IsSortOrderAscending());
575 m_grid
->UnsetSortingColumn();
577 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
578 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
581 void GridTestCase::Labels()
583 CPPUNIT_ASSERT_EQUAL("A", m_grid
->GetColLabelValue(0));
584 CPPUNIT_ASSERT_EQUAL("1", m_grid
->GetRowLabelValue(0));
586 m_grid
->SetColLabelValue(0, "Column 1");
587 m_grid
->SetRowLabelValue(0, "Row 1");
589 CPPUNIT_ASSERT_EQUAL("Column 1", m_grid
->GetColLabelValue(0));
590 CPPUNIT_ASSERT_EQUAL("Row 1", m_grid
->GetRowLabelValue(0));
592 m_grid
->SetLabelTextColour(*wxGREEN
);
593 m_grid
->SetLabelBackgroundColour(*wxRED
);
595 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetLabelTextColour());
596 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetLabelBackgroundColour());
598 m_grid
->SetColLabelTextOrientation(wxVERTICAL
);
600 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxVERTICAL
),
601 static_cast<int>(m_grid
->GetColLabelTextOrientation()));
604 void GridTestCase::SelectionMode()
606 //We already test this mode in Select
607 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectCells
,
608 m_grid
->GetSelectionMode());
610 //Test row selection be selecting a single cell and checking the whole
612 m_grid
->SetSelectionMode(wxGrid::wxGridSelectRows
);
613 m_grid
->SelectBlock(3, 1, 3, 1);
615 wxArrayInt selectedRows
= m_grid
->GetSelectedRows();
616 CPPUNIT_ASSERT_EQUAL(1, selectedRows
.Count());
617 CPPUNIT_ASSERT_EQUAL(3, selectedRows
[0]);
619 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectRows
,
620 m_grid
->GetSelectionMode());
623 //Test column selection be selecting a single cell and checking the whole
625 m_grid
->SetSelectionMode(wxGrid::wxGridSelectColumns
);
626 m_grid
->SelectBlock(3, 1, 3, 1);
628 wxArrayInt selectedCols
= m_grid
->GetSelectedCols();
629 CPPUNIT_ASSERT_EQUAL(1, selectedCols
.Count());
630 CPPUNIT_ASSERT_EQUAL(1, selectedCols
[0]);
632 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectColumns
,
633 m_grid
->GetSelectionMode());
636 void GridTestCase::CellFormatting()
638 //Check that initial alignment is default
639 int horiz
, cellhoriz
, vert
, cellvert
;
641 m_grid
->GetDefaultCellAlignment(&horiz
, &vert
);
642 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
644 CPPUNIT_ASSERT_EQUAL(cellhoriz
, horiz
);
645 CPPUNIT_ASSERT_EQUAL(cellvert
, vert
);
647 //Check initial text colour and background colour are default
650 back
= m_grid
->GetDefaultCellBackgroundColour();
652 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellBackgroundColour(0, 0));
654 back
= m_grid
->GetDefaultCellTextColour();
656 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellTextColour(0, 0));
658 #if WXWIN_COMPATIBILITY_2_8
659 m_grid
->SetCellAlignment(wxALIGN_CENTRE
, 0, 0);
660 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
662 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellhoriz
);
663 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellvert
);
664 #endif // WXWIN_COMPATIBILITY_2_8
666 m_grid
->SetCellAlignment(0, 0, wxALIGN_LEFT
, wxALIGN_BOTTOM
);
667 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
669 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_LEFT
), cellhoriz
);
670 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_BOTTOM
), cellvert
);
672 #if WXWIN_COMPATIBILITY_2_8
673 m_grid
->SetCellTextColour(*wxRED
, 0, 0);
674 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetCellTextColour(0, 0));
675 #endif // WXWIN_COMPATIBILITY_2_8
677 m_grid
->SetCellTextColour(0, 0, *wxGREEN
);
678 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetCellTextColour(0, 0));
681 void GridTestCase::Editable()
683 #if wxUSE_UIACTIONSIMULATOR
684 //As the grid is not editable we shouldn't create an editor
685 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
687 wxUIActionSimulator sim
;
689 CPPUNIT_ASSERT(m_grid
->IsEditable());
691 m_grid
->EnableEditing(false);
693 CPPUNIT_ASSERT(!m_grid
->IsEditable());
696 m_grid
->SetGridCursor(1, 1);
697 m_grid
->ShowCellEditControl();
702 sim
.Char(WXK_RETURN
);
705 CPPUNIT_ASSERT_EQUAL(0, created
.GetCount());
709 void GridTestCase::ReadOnly()
711 #if wxUSE_UIACTIONSIMULATOR
712 //As the cell is readonly we shouldn't create an editor
713 EventCounter
created(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
715 wxUIActionSimulator sim
;
717 CPPUNIT_ASSERT(!m_grid
->IsReadOnly(1, 1));
719 m_grid
->SetReadOnly(1, 1);
721 CPPUNIT_ASSERT(m_grid
->IsReadOnly(1, 1));
724 m_grid
->SetGridCursor(1, 1);
726 CPPUNIT_ASSERT(m_grid
->IsCurrentCellReadOnly());
728 m_grid
->ShowCellEditControl();
733 sim
.Char(WXK_RETURN
);
736 CPPUNIT_ASSERT_EQUAL(0, created
.GetCount());