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 class GridTestCase
: public CppUnit::TestCase
33 virtual void tearDown();
36 CPPUNIT_TEST_SUITE( GridTestCase
);
37 WXUISIM_TEST( CellEdit
);
38 WXUISIM_TEST( CellClick
);
39 WXUISIM_TEST( CellSelect
);
40 WXUISIM_TEST( LabelClick
);
41 WXUISIM_TEST( SortClick
);
43 WXUISIM_TEST( RangeSelect
);
44 CPPUNIT_TEST( Cursor
);
45 CPPUNIT_TEST( Selection
);
46 CPPUNIT_TEST( AddRowCol
);
47 CPPUNIT_TEST( ColumnOrder
);
48 CPPUNIT_TEST( LineFormatting
);
49 CPPUNIT_TEST( SortSupport
);
50 CPPUNIT_TEST( Labels
);
51 CPPUNIT_TEST( SelectionMode
);
52 CPPUNIT_TEST( CellFormatting
);
53 WXUISIM_TEST( Editable
);
54 WXUISIM_TEST( ReadOnly
);
55 CPPUNIT_TEST( PseudoTest_NativeHeader
);
56 WXUISIM_TEST( LabelClick
);
57 WXUISIM_TEST( SortClick
);
58 CPPUNIT_TEST( ColumnOrder
);
59 CPPUNIT_TEST( PseudoTest_NativeLabels
);
60 WXUISIM_TEST( LabelClick
);
61 WXUISIM_TEST( SortClick
);
62 CPPUNIT_TEST( ColumnOrder
);
63 CPPUNIT_TEST_SUITE_END();
76 void LineFormatting();
80 void CellFormatting();
83 void PseudoTest_NativeHeader() { ms_nativeheader
= true; }
84 void PseudoTest_NativeLabels() { ms_nativeheader
= false;
85 ms_nativelabels
= true; }
87 static bool ms_nativeheader
;
88 static bool ms_nativelabels
;
92 DECLARE_NO_COPY_CLASS(GridTestCase
)
95 // register in the unnamed registry so that these tests are run by default
96 CPPUNIT_TEST_SUITE_REGISTRATION( GridTestCase
);
98 // also include in it's own registry so that these tests can be run alone
99 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GridTestCase
, "GridTestCase" );
101 //initialise the static variable
102 bool GridTestCase::ms_nativeheader
= false;
103 bool GridTestCase::ms_nativelabels
= false;
105 void GridTestCase::setUp()
107 m_grid
= new wxGrid(wxTheApp
->GetTopWindow(), wxID_ANY
);
108 m_grid
->CreateGrid(10, 2);
109 m_grid
->SetSize(400, 200);
111 if( ms_nativeheader
)
112 m_grid
->UseNativeColHeader();
114 if( ms_nativelabels
)
115 m_grid
->SetUseNativeColLabels();
121 void GridTestCase::tearDown()
126 void GridTestCase::CellEdit()
128 #if wxUSE_UIACTIONSIMULATOR
129 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
132 EventCounter
count(m_grid
, wxEVT_GRID_CELL_CHANGING
);
133 EventCounter
count1(m_grid
, wxEVT_GRID_CELL_CHANGED
);
134 EventCounter
count2(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
136 wxUIActionSimulator sim
;
139 m_grid
->SetGridCursor(1, 1);
140 m_grid
->ShowCellEditControl();
143 sim
.Char(WXK_RETURN
);
147 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_EDITOR_CREATED
));
148 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_CHANGING
));
149 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_CHANGED
));
153 void GridTestCase::CellClick()
155 #if wxUSE_UIACTIONSIMULATOR
156 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
159 EventCounter
count(m_grid
, wxEVT_GRID_CELL_LEFT_CLICK
);
160 EventCounter
count1(m_grid
, wxEVT_GRID_CELL_LEFT_DCLICK
);
161 EventCounter
count2(m_grid
, wxEVT_GRID_CELL_RIGHT_CLICK
);
162 EventCounter
count3(m_grid
, wxEVT_GRID_CELL_RIGHT_DCLICK
);
165 wxUIActionSimulator sim
;
167 wxRect rect
= m_grid
->CellToRect(0, 0);
168 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
169 point
= frame
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
170 m_grid
->GetColLabelSize())
173 sim
.MouseMove(point
);
179 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_LEFT_CLICK
));
184 //A double click event sends a single click event first
185 //test to ensure this still happens in the future
186 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_LEFT_CLICK
));
187 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_LEFT_DCLICK
));
189 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
192 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_RIGHT_CLICK
));
194 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
197 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_RIGHT_CLICK
));
198 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_CELL_RIGHT_DCLICK
));
202 void GridTestCase::CellSelect()
204 #if wxUSE_UIACTIONSIMULATOR
205 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
208 EventCounter
count(m_grid
, wxEVT_GRID_SELECT_CELL
);
210 wxUIActionSimulator sim
;
212 wxRect rect
= m_grid
->CellToRect(0, 0);
213 wxPoint point
= m_grid
->CalcScrolledPosition(rect
.GetPosition());
214 point
= frame
->ClientToScreen(point
+ wxPoint(m_grid
->GetRowLabelSize(),
215 m_grid
->GetColLabelSize())
218 sim
.MouseMove(point
);
224 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_SELECT_CELL
));
226 m_grid
->SetGridCursor(1, 1);
227 m_grid
->GoToCell(1, 0);
229 sim
.MouseMove(point
);
235 CPPUNIT_ASSERT_EQUAL(3, frame
->GetEventCount(wxEVT_GRID_SELECT_CELL
));
239 void GridTestCase::LabelClick()
241 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
242 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
245 EventCounter
count(m_grid
, wxEVT_GRID_LABEL_LEFT_CLICK
);
246 EventCounter
count1(m_grid
, wxEVT_GRID_LABEL_LEFT_DCLICK
);
247 EventCounter
count2(m_grid
, wxEVT_GRID_LABEL_RIGHT_CLICK
);
248 EventCounter
count3(m_grid
, wxEVT_GRID_LABEL_RIGHT_DCLICK
);
250 wxUIActionSimulator sim
;
252 wxPoint
pos(m_grid
->GetRowLabelSize() + 2, 2);
253 pos
= m_grid
->ClientToScreen(pos
);
261 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_LEFT_CLICK
));
266 //A double click event sends a single click event first
267 //test to ensure this still happens in the future
268 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_LEFT_CLICK
));
269 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_LEFT_DCLICK
));
271 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
274 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK
));
276 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
279 if( ms_nativeheader
)
281 //Right double click not supported with native headers so we get two
283 CPPUNIT_ASSERT_EQUAL(2, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK
));
287 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK
));
288 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_DCLICK
));
293 void GridTestCase::SortClick()
295 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
296 m_grid
->SetSortingColumn(0);
298 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
301 EventCounter
count(m_grid
, wxEVT_GRID_COL_SORT
);
303 wxUIActionSimulator sim
;
305 wxPoint
pos(m_grid
->GetRowLabelSize() + 4, 4);
306 pos
= m_grid
->ClientToScreen(pos
);
314 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount());
316 m_grid
->SetSortingColumn(wxNOT_FOUND
);
320 void GridTestCase::Size()
322 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
323 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
326 EventCounter
count(m_grid
, wxEVT_GRID_COL_SIZE
);
327 EventCounter
count1(m_grid
, wxEVT_GRID_ROW_SIZE
);
329 wxUIActionSimulator sim
;
331 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() +
332 m_grid
->GetColSize(0), 5));
340 sim
.MouseMove(pt
.x
+ 50, pt
.y
);
346 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_COL_SIZE
));
348 pt
= m_grid
->ClientToScreen(wxPoint(5, m_grid
->GetColLabelSize() +
349 m_grid
->GetRowSize(0)));
351 sim
.MouseDragDrop(pt
.x
, pt
.y
, pt
.x
, pt
.y
+ 50);
354 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_ROW_SIZE
));
358 void GridTestCase::RangeSelect()
360 #if wxUSE_UIACTIONSIMULATOR
361 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
364 EventCounter
count(m_grid
, wxEVT_GRID_RANGE_SELECT
);
366 wxUIActionSimulator sim
;
368 //We add the extra 10 to ensure that we are inside the cell
369 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() + 10,
370 m_grid
->GetColLabelSize() + 10)
379 sim
.MouseMove(pt
.x
+ 50, pt
.y
+ 50);
385 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_RANGE_SELECT
));
389 void GridTestCase::Cursor()
391 m_grid
->SetGridCursor(1, 1);
393 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
394 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorRow());
396 m_grid
->MoveCursorDown(false);
397 m_grid
->MoveCursorLeft(false);
398 m_grid
->MoveCursorUp(false);
399 m_grid
->MoveCursorUp(false);
400 m_grid
->MoveCursorRight(false);
402 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
403 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
405 m_grid
->SetCellValue(0, 0, "some text");
406 m_grid
->SetCellValue(3, 0, "other text");
407 m_grid
->SetCellValue(0, 1, "more text");
408 m_grid
->SetCellValue(3, 1, "extra text");
413 m_grid
->MoveCursorLeftBlock(false);
415 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
416 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
418 m_grid
->MoveCursorDownBlock(false);
420 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
421 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
423 m_grid
->MoveCursorRightBlock(false);
425 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
426 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
428 m_grid
->MoveCursorUpBlock(false);
430 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
431 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
434 void GridTestCase::Selection()
438 CPPUNIT_ASSERT(m_grid
->IsSelection());
439 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 0));
440 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
442 m_grid
->SelectBlock(1, 0, 3, 1);
444 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
445 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
447 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
448 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
450 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
451 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetRow());
452 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
453 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
455 m_grid
->SelectCol(1);
457 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 1));
458 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
459 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
461 m_grid
->SelectRow(4);
463 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 0));
464 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 1));
465 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
468 void GridTestCase::AddRowCol()
470 CPPUNIT_ASSERT_EQUAL(10, m_grid
->GetNumberRows());
471 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetNumberCols());
473 m_grid
->AppendCols();
474 m_grid
->AppendRows();
476 CPPUNIT_ASSERT_EQUAL(11, m_grid
->GetNumberRows());
477 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetNumberCols());
479 m_grid
->AppendCols(2);
480 m_grid
->AppendRows(2);
482 CPPUNIT_ASSERT_EQUAL(13, m_grid
->GetNumberRows());
483 CPPUNIT_ASSERT_EQUAL(5, m_grid
->GetNumberCols());
485 m_grid
->InsertCols(1, 2);
486 m_grid
->InsertRows(2, 3);
488 CPPUNIT_ASSERT_EQUAL(16, m_grid
->GetNumberRows());
489 CPPUNIT_ASSERT_EQUAL(7, m_grid
->GetNumberCols());
492 void GridTestCase::ColumnOrder()
494 m_grid
->AppendCols(2);
496 CPPUNIT_ASSERT_EQUAL(4, m_grid
->GetNumberCols());
499 neworder
.push_back(1);
500 neworder
.push_back(3);
501 neworder
.push_back(2);
502 neworder
.push_back(0);
504 m_grid
->SetColumnsOrder(neworder
);
506 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(1));
507 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(3));
508 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
509 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(0));
511 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColAt(0));
512 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColAt(1));
513 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColAt(2));
514 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColAt(3));
516 m_grid
->ResetColPos();
518 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(0));
519 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(1));
520 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
521 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(3));
524 void GridTestCase::LineFormatting()
526 CPPUNIT_ASSERT(m_grid
->GridLinesEnabled());
528 m_grid
->EnableGridLines(false);
530 CPPUNIT_ASSERT(!m_grid
->GridLinesEnabled());
532 m_grid
->EnableGridLines();
534 m_grid
->SetGridLineColour(*wxRED
);
536 CPPUNIT_ASSERT_EQUAL(m_grid
->GetGridLineColour(), *wxRED
);
539 void GridTestCase::SortSupport()
541 CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND
, m_grid
->GetSortingColumn());
543 m_grid
->SetSortingColumn(1);
545 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
546 CPPUNIT_ASSERT(m_grid
->IsSortingBy(1));
547 CPPUNIT_ASSERT(m_grid
->IsSortOrderAscending());
549 m_grid
->SetSortingColumn(0, false);
551 CPPUNIT_ASSERT(m_grid
->IsSortingBy(0));
552 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
553 CPPUNIT_ASSERT(!m_grid
->IsSortOrderAscending());
555 m_grid
->UnsetSortingColumn();
557 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
558 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
561 void GridTestCase::Labels()
563 CPPUNIT_ASSERT_EQUAL("A", m_grid
->GetColLabelValue(0));
564 CPPUNIT_ASSERT_EQUAL("1", m_grid
->GetRowLabelValue(0));
566 m_grid
->SetColLabelValue(0, "Column 1");
567 m_grid
->SetRowLabelValue(0, "Row 1");
569 CPPUNIT_ASSERT_EQUAL("Column 1", m_grid
->GetColLabelValue(0));
570 CPPUNIT_ASSERT_EQUAL("Row 1", m_grid
->GetRowLabelValue(0));
572 m_grid
->SetLabelTextColour(*wxGREEN
);
573 m_grid
->SetLabelBackgroundColour(*wxRED
);
575 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetLabelTextColour());
576 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetLabelBackgroundColour());
578 m_grid
->SetColLabelTextOrientation(wxVERTICAL
);
580 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxVERTICAL
),
581 static_cast<int>(m_grid
->GetColLabelTextOrientation()));
584 void GridTestCase::SelectionMode()
586 //We already test this mode in Select
587 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectCells
,
588 m_grid
->GetSelectionMode());
590 //Test row selection be selecting a single cell and checking the whole
592 m_grid
->SetSelectionMode(wxGrid::wxGridSelectRows
);
593 m_grid
->SelectBlock(3, 1, 3, 1);
595 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
596 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
598 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
599 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
601 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
602 CPPUNIT_ASSERT_EQUAL(3, topleft
.Item(0).GetRow());
603 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
604 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
606 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectRows
,
607 m_grid
->GetSelectionMode());
610 //Test column selection be selecting a single cell and checking the whole
612 m_grid
->SetSelectionMode(wxGrid::wxGridSelectColumns
);
613 m_grid
->SelectBlock(3, 1, 3, 1);
615 topleft
= m_grid
->GetSelectionBlockTopLeft();
616 bottomright
= m_grid
->GetSelectionBlockBottomRight();
618 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
619 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
621 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetCol());
622 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetRow());
623 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
624 CPPUNIT_ASSERT_EQUAL(9, bottomright
.Item(0).GetRow());
626 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectColumns
,
627 m_grid
->GetSelectionMode());
630 void GridTestCase::CellFormatting()
632 //Check that initial alignment is default
633 int horiz
, cellhoriz
, vert
, cellvert
;
635 m_grid
->GetDefaultCellAlignment(&horiz
, &vert
);
636 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
638 CPPUNIT_ASSERT_EQUAL(cellhoriz
, horiz
);
639 CPPUNIT_ASSERT_EQUAL(cellvert
, vert
);
641 //Check initial text colour and background colour are default
644 back
= m_grid
->GetDefaultCellBackgroundColour();
646 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellBackgroundColour(0, 0));
648 back
= m_grid
->GetDefaultCellTextColour();
650 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellTextColour(0, 0));
652 m_grid
->SetCellAlignment(wxALIGN_CENTRE
, 0, 0);
653 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
655 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellhoriz
);
656 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellvert
);
658 m_grid
->SetCellAlignment(0, 0, wxALIGN_LEFT
, wxALIGN_BOTTOM
);
659 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
661 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_LEFT
), cellhoriz
);
662 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_BOTTOM
), cellvert
);
664 m_grid
->SetCellTextColour(*wxRED
, 0, 0);
666 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetCellTextColour(0, 0));
668 m_grid
->SetCellTextColour(0, 0, *wxGREEN
);
670 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetCellTextColour(0, 0));
673 void GridTestCase::Editable()
675 #if wxUSE_UIACTIONSIMULATOR
676 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
679 //As the grid is not editable we shouldn't create an editor
680 EventCounter
count(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
682 wxUIActionSimulator sim
;
684 CPPUNIT_ASSERT(m_grid
->IsEditable());
686 m_grid
->EnableEditing(false);
688 CPPUNIT_ASSERT(!m_grid
->IsEditable());
691 m_grid
->SetGridCursor(1, 1);
692 m_grid
->ShowCellEditControl();
697 sim
.Char(WXK_RETURN
);
700 CPPUNIT_ASSERT_EQUAL(0, frame
->GetEventCount());
704 void GridTestCase::ReadOnly()
706 #if wxUSE_UIACTIONSIMULATOR
707 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
710 //As the cell is readonly we shouldn't create an editor
711 EventCounter
count(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
713 wxUIActionSimulator sim
;
715 CPPUNIT_ASSERT(!m_grid
->IsReadOnly(1, 1));
717 m_grid
->SetReadOnly(1, 1);
719 CPPUNIT_ASSERT(m_grid
->IsReadOnly(1, 1));
722 m_grid
->SetGridCursor(1, 1);
724 CPPUNIT_ASSERT(m_grid
->IsCurrentCellReadOnly());
726 m_grid
->ShowCellEditControl();
731 sim
.Char(WXK_RETURN
);
734 CPPUNIT_ASSERT_EQUAL(0, frame
->GetEventCount());