diff --git a/libs/widgets/tests/CMakeLists.txt b/libs/widgets/tests/CMakeLists.txt index 7cb62d2545..41113c668a 100644 --- a/libs/widgets/tests/CMakeLists.txt +++ b/libs/widgets/tests/CMakeLists.txt @@ -1,17 +1,18 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) add_definitions(-DFILES_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/") add_definitions(-DFILES_OUTPUT_DIR="${CMAKE_CURRENT_BINARY_DIR}") #add_subdirectory(filedialogtester) include(ECMAddTests) include(KritaAddBrokenUnitTest) ecm_add_tests( zoomhandler_test.cpp zoomcontroller_test.cpp KoResourceTaggingTest.cpp KoAnchorSelectionWidgetTest.cpp + TestKoZoomAction.cpp NAME_PREFIX "libs-widgets-" LINK_LIBRARIES kritawidgets Qt5::Test) diff --git a/libs/widgets/tests/TestKoZoomAction.cpp b/libs/widgets/tests/TestKoZoomAction.cpp new file mode 100644 index 0000000000..4ef109e32c --- /dev/null +++ b/libs/widgets/tests/TestKoZoomAction.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020 Agata Cacko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "TestKoZoomAction.h" + +#include +#include + +#include + +#include "kis_debug.h" +#include "KoZoomMode.h" + +void TestKoZoomAction::test() +{ + KoZoomAction* action = new KoZoomAction(KoZoomMode::ZOOM_CONSTANT, "zoom", 0); + qreal prev, after; + do { + prev = action->effectiveZoom(); + action->zoomIn(); + after = action->effectiveZoom(); + //qDebug() << prev << after; + } while (after != prev); + //qDebug() << action->maximumZoom(); + //qDebug() << action->effectiveZoom(); + //qDebug() << action->nextZoomLevel(); + + QVERIFY(action->nextZoomLevel() == action->effectiveZoom()); + delete action; +} + + +QTEST_MAIN(TestKoZoomAction) diff --git a/libs/widgets/tests/TestKoZoomAction.h b/libs/widgets/tests/TestKoZoomAction.h new file mode 100644 index 0000000000..6d714747f5 --- /dev/null +++ b/libs/widgets/tests/TestKoZoomAction.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Agata Cacko + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __TEST_KO_ZOOM_ACTION_H +#define __TEST_KO_ZOOM_ACTION_H + +#include + +#include + +class TestKoZoomAction : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void test(); + +private Q_SLOTS: + //void slotValueChanged(KoFlake::AnchorPosition id); +}; + +#endif /* __TEST_KO_ZOOM_ACTION_H */