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 its 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
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 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_LEFT_DCLICK
));
268 sim
.MouseClick(wxMOUSE_BTN_RIGHT
);
271 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK
));
273 sim
.MouseDblClick(wxMOUSE_BTN_RIGHT
);
276 if( ms_nativeheader
)
278 //Right double click not supported with native headers so we get two
280 CPPUNIT_ASSERT_EQUAL(2, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK
));
284 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_CLICK
));
285 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_LABEL_RIGHT_DCLICK
));
290 void GridTestCase::SortClick()
292 #if wxUSE_UIACTIONSIMULATOR
293 m_grid
->SetSortingColumn(0);
295 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
298 EventCounter
count(m_grid
, wxEVT_GRID_COL_SORT
);
300 wxUIActionSimulator sim
;
302 wxPoint
pos(m_grid
->GetRowLabelSize() + 4, 4);
303 pos
= m_grid
->ClientToScreen(pos
);
311 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount());
315 void GridTestCase::Size()
317 #if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)
318 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
321 EventCounter
count(m_grid
, wxEVT_GRID_COL_SIZE
);
322 EventCounter
count1(m_grid
, wxEVT_GRID_ROW_SIZE
);
324 wxUIActionSimulator sim
;
326 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() +
327 m_grid
->GetColSize(0), 5));
335 sim
.MouseMove(pt
.x
+ 50, pt
.y
);
341 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_COL_SIZE
));
343 pt
= m_grid
->ClientToScreen(wxPoint(5, m_grid
->GetColLabelSize() +
344 m_grid
->GetRowSize(0)));
346 sim
.MouseDragDrop(pt
.x
, pt
.y
, pt
.x
, pt
.y
+ 50);
349 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_ROW_SIZE
));
353 void GridTestCase::RangeSelect()
355 #if wxUSE_UIACTIONSIMULATOR
356 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
359 EventCounter
count(m_grid
, wxEVT_GRID_RANGE_SELECT
);
361 wxUIActionSimulator sim
;
363 //We add the extra 10 to ensure that we are inside the cell
364 wxPoint pt
= m_grid
->ClientToScreen(wxPoint(m_grid
->GetRowLabelSize() + 10,
365 m_grid
->GetColLabelSize() + 10)
374 sim
.MouseMove(pt
.x
+ 50, pt
.y
+ 50);
380 CPPUNIT_ASSERT_EQUAL(1, frame
->GetEventCount(wxEVT_GRID_RANGE_SELECT
));
384 void GridTestCase::Cursor()
386 m_grid
->SetGridCursor(1, 1);
388 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
389 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorRow());
391 m_grid
->MoveCursorDown(false);
392 m_grid
->MoveCursorLeft(false);
393 m_grid
->MoveCursorUp(false);
394 m_grid
->MoveCursorUp(false);
395 m_grid
->MoveCursorRight(false);
397 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
398 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
400 m_grid
->SetCellValue(0, 0, "some text");
401 m_grid
->SetCellValue(3, 0, "other text");
402 m_grid
->SetCellValue(0, 1, "more text");
403 m_grid
->SetCellValue(3, 1, "extra text");
408 m_grid
->MoveCursorLeftBlock(false);
410 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
411 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
413 m_grid
->MoveCursorDownBlock(false);
415 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorCol());
416 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
418 m_grid
->MoveCursorRightBlock(false);
420 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
421 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetGridCursorRow());
423 m_grid
->MoveCursorUpBlock(false);
425 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetGridCursorCol());
426 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetGridCursorRow());
429 void GridTestCase::Selection()
433 CPPUNIT_ASSERT(m_grid
->IsSelection());
434 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 0));
435 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
437 m_grid
->SelectBlock(1, 0, 3, 1);
439 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
440 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
442 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
443 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
445 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
446 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetRow());
447 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
448 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
450 m_grid
->SelectCol(1);
452 CPPUNIT_ASSERT(m_grid
->IsInSelection(0, 1));
453 CPPUNIT_ASSERT(m_grid
->IsInSelection(9, 1));
454 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
456 m_grid
->SelectRow(4);
458 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 0));
459 CPPUNIT_ASSERT(m_grid
->IsInSelection(4, 1));
460 CPPUNIT_ASSERT(!m_grid
->IsInSelection(3, 0));
463 void GridTestCase::AddRowCol()
465 CPPUNIT_ASSERT_EQUAL(10, m_grid
->GetNumberRows());
466 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetNumberCols());
468 m_grid
->AppendCols();
469 m_grid
->AppendRows();
471 CPPUNIT_ASSERT_EQUAL(11, m_grid
->GetNumberRows());
472 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetNumberCols());
474 m_grid
->AppendCols(2);
475 m_grid
->AppendRows(2);
477 CPPUNIT_ASSERT_EQUAL(13, m_grid
->GetNumberRows());
478 CPPUNIT_ASSERT_EQUAL(5, m_grid
->GetNumberCols());
480 m_grid
->InsertCols(1, 2);
481 m_grid
->InsertRows(2, 3);
483 CPPUNIT_ASSERT_EQUAL(16, m_grid
->GetNumberRows());
484 CPPUNIT_ASSERT_EQUAL(7, m_grid
->GetNumberCols());
487 void GridTestCase::ColumnOrder()
489 m_grid
->AppendCols(2);
491 CPPUNIT_ASSERT_EQUAL(4, m_grid
->GetNumberCols());
494 neworder
.push_back(1);
495 neworder
.push_back(3);
496 neworder
.push_back(2);
497 neworder
.push_back(0);
499 m_grid
->SetColumnsOrder(neworder
);
501 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(1));
502 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(3));
503 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
504 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(0));
506 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColAt(0));
507 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColAt(1));
508 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColAt(2));
509 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColAt(3));
511 m_grid
->ResetColPos();
513 CPPUNIT_ASSERT_EQUAL(0, m_grid
->GetColPos(0));
514 CPPUNIT_ASSERT_EQUAL(1, m_grid
->GetColPos(1));
515 CPPUNIT_ASSERT_EQUAL(2, m_grid
->GetColPos(2));
516 CPPUNIT_ASSERT_EQUAL(3, m_grid
->GetColPos(3));
519 void GridTestCase::LineFormatting()
521 CPPUNIT_ASSERT(m_grid
->GridLinesEnabled());
523 m_grid
->EnableGridLines(false);
525 CPPUNIT_ASSERT(!m_grid
->GridLinesEnabled());
527 m_grid
->EnableGridLines();
529 m_grid
->SetGridLineColour(*wxRED
);
531 CPPUNIT_ASSERT_EQUAL(m_grid
->GetGridLineColour(), *wxRED
);
534 void GridTestCase::SortSupport()
536 CPPUNIT_ASSERT_EQUAL(wxNOT_FOUND
, m_grid
->GetSortingColumn());
538 m_grid
->SetSortingColumn(1);
540 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
541 CPPUNIT_ASSERT(m_grid
->IsSortingBy(1));
542 CPPUNIT_ASSERT(m_grid
->IsSortOrderAscending());
544 m_grid
->SetSortingColumn(0, false);
546 CPPUNIT_ASSERT(m_grid
->IsSortingBy(0));
547 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
548 CPPUNIT_ASSERT(!m_grid
->IsSortOrderAscending());
550 m_grid
->UnsetSortingColumn();
552 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(0));
553 CPPUNIT_ASSERT(!m_grid
->IsSortingBy(1));
556 void GridTestCase::Labels()
558 CPPUNIT_ASSERT_EQUAL("A", m_grid
->GetColLabelValue(0));
559 CPPUNIT_ASSERT_EQUAL("1", m_grid
->GetRowLabelValue(0));
561 m_grid
->SetColLabelValue(0, "Column 1");
562 m_grid
->SetRowLabelValue(0, "Row 1");
564 CPPUNIT_ASSERT_EQUAL("Column 1", m_grid
->GetColLabelValue(0));
565 CPPUNIT_ASSERT_EQUAL("Row 1", m_grid
->GetRowLabelValue(0));
567 m_grid
->SetLabelTextColour(*wxGREEN
);
568 m_grid
->SetLabelBackgroundColour(*wxRED
);
570 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetLabelTextColour());
571 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetLabelBackgroundColour());
573 m_grid
->SetColLabelTextOrientation(wxVERTICAL
);
575 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxVERTICAL
),
576 static_cast<int>(m_grid
->GetColLabelTextOrientation()));
579 void GridTestCase::SelectionMode()
581 //We already test this mode in Select
582 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectCells
,
583 m_grid
->GetSelectionMode());
585 //Test row selection be selecting a single cell and checking the whole
587 m_grid
->SetSelectionMode(wxGrid::wxGridSelectRows
);
588 m_grid
->SelectBlock(3, 1, 3, 1);
590 wxGridCellCoordsArray topleft
= m_grid
->GetSelectionBlockTopLeft();
591 wxGridCellCoordsArray bottomright
= m_grid
->GetSelectionBlockBottomRight();
593 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
594 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
596 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetCol());
597 CPPUNIT_ASSERT_EQUAL(3, topleft
.Item(0).GetRow());
598 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
599 CPPUNIT_ASSERT_EQUAL(3, bottomright
.Item(0).GetRow());
601 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectRows
,
602 m_grid
->GetSelectionMode());
605 //Test column selection be selecting a single cell and checking the whole
607 m_grid
->SetSelectionMode(wxGrid::wxGridSelectColumns
);
608 m_grid
->SelectBlock(3, 1, 3, 1);
610 topleft
= m_grid
->GetSelectionBlockTopLeft();
611 bottomright
= m_grid
->GetSelectionBlockBottomRight();
613 CPPUNIT_ASSERT_EQUAL(1, topleft
.Count());
614 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Count());
616 CPPUNIT_ASSERT_EQUAL(1, topleft
.Item(0).GetCol());
617 CPPUNIT_ASSERT_EQUAL(0, topleft
.Item(0).GetRow());
618 CPPUNIT_ASSERT_EQUAL(1, bottomright
.Item(0).GetCol());
619 CPPUNIT_ASSERT_EQUAL(9, bottomright
.Item(0).GetRow());
621 CPPUNIT_ASSERT_EQUAL(wxGrid::wxGridSelectColumns
,
622 m_grid
->GetSelectionMode());
625 void GridTestCase::CellFormatting()
627 //Check that initial alignment is default
628 int horiz
, cellhoriz
, vert
, cellvert
;
630 m_grid
->GetDefaultCellAlignment(&horiz
, &vert
);
631 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
633 CPPUNIT_ASSERT_EQUAL(cellhoriz
, horiz
);
634 CPPUNIT_ASSERT_EQUAL(cellvert
, vert
);
636 //Check initial text colour and background colour are default
639 back
= m_grid
->GetDefaultCellBackgroundColour();
641 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellBackgroundColour(0, 0));
643 back
= m_grid
->GetDefaultCellTextColour();
645 CPPUNIT_ASSERT_EQUAL(back
, m_grid
->GetCellTextColour(0, 0));
647 m_grid
->SetCellAlignment(wxALIGN_CENTRE
, 0, 0);
648 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
650 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellhoriz
);
651 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_CENTRE
), cellvert
);
653 m_grid
->SetCellAlignment(0, 0, wxALIGN_LEFT
, wxALIGN_BOTTOM
);
654 m_grid
->GetCellAlignment(0, 0, &cellhoriz
, &cellvert
);
656 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_LEFT
), cellhoriz
);
657 CPPUNIT_ASSERT_EQUAL(static_cast<int>(wxALIGN_BOTTOM
), cellvert
);
659 m_grid
->SetCellTextColour(*wxRED
, 0, 0);
661 CPPUNIT_ASSERT_EQUAL(*wxRED
, m_grid
->GetCellTextColour(0, 0));
663 m_grid
->SetCellTextColour(0, 0, *wxGREEN
);
665 CPPUNIT_ASSERT_EQUAL(*wxGREEN
, m_grid
->GetCellTextColour(0, 0));
668 void GridTestCase::Editable()
670 #if wxUSE_UIACTIONSIMULATOR
671 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
674 //As the grid is not editable we shouldn't create an editor
675 EventCounter
count(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
677 wxUIActionSimulator sim
;
679 CPPUNIT_ASSERT(m_grid
->IsEditable());
681 m_grid
->EnableEditing(false);
683 CPPUNIT_ASSERT(!m_grid
->IsEditable());
686 m_grid
->SetGridCursor(1, 1);
687 m_grid
->ShowCellEditControl();
692 sim
.Char(WXK_RETURN
);
695 CPPUNIT_ASSERT_EQUAL(0, frame
->GetEventCount());
699 void GridTestCase::ReadOnly()
701 #if wxUSE_UIACTIONSIMULATOR
702 wxTestableFrame
* frame
= wxStaticCast(wxTheApp
->GetTopWindow(),
705 //As the cell is readonly we shouldn't create an editor
706 EventCounter
count(m_grid
, wxEVT_GRID_EDITOR_CREATED
);
708 wxUIActionSimulator sim
;
710 CPPUNIT_ASSERT(!m_grid
->IsReadOnly(1, 1));
712 m_grid
->SetReadOnly(1, 1);
714 CPPUNIT_ASSERT(m_grid
->IsReadOnly(1, 1));
717 m_grid
->SetGridCursor(1, 1);
719 CPPUNIT_ASSERT(m_grid
->IsCurrentCellReadOnly());
721 m_grid
->ShowCellEditControl();
726 sim
.Char(WXK_RETURN
);
729 CPPUNIT_ASSERT_EQUAL(0, frame
->GetEventCount());