From dff46376bf319127f9c02163373098582957e4af Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 30 Mar 2018 00:12:20 +0200 Subject: [PATCH] Unit tests update --- .travis.yml | 2 +- src/fwidget.cpp | 8 ++++++-- src/test/foptimove-test.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 299362dc..0d0eb1ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -76,7 +76,7 @@ matrix: script: - ./build.sh coverage after_success: - - coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts + - coveralls --gcov-options '\-lp' -e debian -e doc -e icon -e logo -e m4 -e scripts -e examples # # macOS diff --git a/src/fwidget.cpp b/src/fwidget.cpp index d435dddb..49d4368e 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1766,7 +1766,9 @@ bool FWidget::focusNextChild() FWidget* parent = getParentWidget(); - if ( ! parent->hasChildren() || parent->numOfFocusableChildren() <= 1 ) + if ( ! parent + || ! parent->hasChildren() + || parent->numOfFocusableChildren() <= 1 ) return false; FObjectIterator iter, last; @@ -1829,7 +1831,9 @@ bool FWidget::focusPrevChild() FWidget* parent = getParentWidget(); - if ( ! parent->hasChildren() || parent->numOfFocusableChildren() <= 1 ) + if ( ! parent + || ! parent->hasChildren() + || parent->numOfFocusableChildren() <= 1 ) return false; FObjectIterator iter, first; diff --git a/src/test/foptimove-test.cpp b/src/test/foptimove-test.cpp index a1d4ce8e..9d10b587 100644 --- a/src/test/foptimove-test.cpp +++ b/src/test/foptimove-test.cpp @@ -66,6 +66,7 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture protected: void classNameTest(); void noArgumentTest(); + void homeTest(); void ansiTest(); void vt100Test(); @@ -78,6 +79,7 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture // Add a methods to the test suite CPPUNIT_TEST (classNameTest); CPPUNIT_TEST (noArgumentTest); + CPPUNIT_TEST (homeTest); CPPUNIT_TEST (ansiTest); CPPUNIT_TEST (vt100Test); @@ -122,6 +124,30 @@ void FOptiMoveTest::noArgumentTest() CPPUNIT_ASSERT (om.moveCursor (1, 1, 5, 5) == 0); } +//---------------------------------------------------------------------- +void FOptiMoveTest::homeTest() +{ + int baud = 4800; + FOptiMove om(baud); + om.setTermSize (80, 24); + om.set_cursor_home (C_STR(CSI "H")); + om.set_cursor_to_ll (C_STR(CSI "X")); + om.set_carriage_return (C_STR("\r")); + om.set_cursor_up (C_STR(CSI "A")); + om.set_cursor_down (C_STR(CSI "B")); + om.set_cursor_left (C_STR(CSI "D")); + om.set_cursor_right (C_STR(CSI "C")); + om.set_parm_up_cursor (C_STR(CSI "%p1%dA")); + om.set_parm_down_cursor (C_STR(CSI "%p1%dB")); + om.set_parm_left_cursor (C_STR(CSI "%p1%dD")); + om.set_parm_right_cursor (C_STR(CSI "%p1%dC")); + + // Upper home (first line, first column) + CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 10, 0, 0), C_STR(CSI "H")); + // Lower home (last line, first column) + CPPUNIT_ASSERT_CSTRING (om.moveCursor (10, 10, 0, 23), C_STR(CSI "X")); +} + //---------------------------------------------------------------------- void FOptiMoveTest::ansiTest() { @@ -201,7 +227,9 @@ void FOptiMoveTest::vt100Test() om.set_parm_left_cursor (C_STR(CSI "%p1%dD")); om.set_parm_right_cursor (C_STR(CSI "%p1%dC")); - //std::cout << "\nSequence: " << printSequence(om.moveCursor (53, 2, 53, -3)) << "\n"; + //std::cout << "\nSequence: " + // << printSequence(om.moveCursor (53, 2, 53, -3)) + // << "\n"; CPPUNIT_ASSERT_CSTRING (om.moveCursor (0, 0, 5, 5), C_STR(CSI "6;6H$<5>")); CPPUNIT_ASSERT_CSTRING (om.moveCursor (5, 5, 0, 0), C_STR(CSI "H"));