diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fb9427a..6493819f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,121 +1,122 @@ project(kirigami2) cmake_minimum_required(VERSION 2.8.12) set(KF5_MIN_VERSION "5.18.0") set(QT_MIN_VERSION "5.5.0") ################# Disallow in-source build ################# if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message(FATAL_ERROR "kirigami requires an out of source build. Please create a separate build directory and run 'cmake path_to_kirigami [options]' there.") endif() option(PLASMA_ENABLED "Build and install The Plasma style" ON) option(DESKTOP_ENABLED "Build and install The Desktop style" ON) option(STATIC_LIBRARY "Build as a static library" OFF) option(BUILD_EXAMPLES "Build and install examples" OFF) # Make CPack available to easy generate binary packages include(CPack) include(FeatureSummary) IF(STATIC_LIBRARY) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) ADD_DEFINITIONS(-DKIRIGAMI_BUILD_TYPE_STATIC) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg) set (QT_MIN_VERSION "5.5.0") if(UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x") endif() add_subdirectory(src) ELSE(STATIC_LIBRARY) ################# set KDE specific information ################# find_package(ECM 0.0.8 REQUIRED NO_MODULE) # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMPackageConfigHelpers) include(ECMPoQmTools) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Kirigami2") ecm_configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5Kirigami2Config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5Kirigami2Config.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} PATH_VARS KF5_INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5Kirigami2Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5Kirigami2ConfigVersion.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/KF5Kirigami2Macros.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(KF5_VERSION "5.22.0") ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KIRIGAMI VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kirigami_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5Kirigami2ConfigVersion.cmake" SOVERSION 5) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2) if(PLASMA_ENABLED) # treat plasma as an optinal dep: full functionality is expected with only Qt find_package(KF5Plasma ${KF5_MIN_VERSION}) set_package_properties(KF5Plasma PROPERTIES DESCRIPTION "Plasma framework" TYPE OPTIONAL PURPOSE "Optional Look and feel integration with Plasma Mobile." ) endif() if(KF5Plasma_FOUND AND THEME STREQUAL "Plasma") set(PLASMA_ENABLED 1) endif() if(KF5Declarative_FOUND AND THEME STREQUAL "System") set(DESKTOP_ENABLED 1) endif() ################# Enable C++11 features for clang and gcc ################# if(UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x") endif() ################# now find all used packages ################# set (QT_MIN_VERSION "5.5.0") find_package(PkgConfig) ######################################################################### +add_subdirectory(autotests) add_subdirectory(src) #TODO: conditional if (BUILD_EXAMPLES) add_subdirectory(examples) endif() ENDIF(STATIC_LIBRARY) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ecm_install_po_files_as_qm(po) endif() feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt new file mode 100644 index 00000000..c9b0c659 --- /dev/null +++ b/autotests/CMakeLists.txt @@ -0,0 +1 @@ +add_test(qmltests COMMAND qmltestrunner WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/autotests/tst_pagerow.qml b/autotests/tst_pagerow.qml new file mode 100644 index 00000000..2c6764c2 --- /dev/null +++ b/autotests/tst_pagerow.qml @@ -0,0 +1,105 @@ +/* + * Copyright 2016 Aleix Pol Gonzalez + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details + * + * You should have received a copy of the GNU Library 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. + */ + +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Window 2.1 +import org.kde.kirigami 2.0 as Kirigami +import QtTest 1.0 + +TestCase { + id: testCase +// when: mainWindow.visible + width: 400 + height: 400 +// visible: true + when: mainWindow.visible + name: "GoBack" + + Kirigami.ApplicationWindow { + id: mainWindow + width: 480 + height: 360 + visible: true + pageStack.initialPage: Kirigami.Page { + Rectangle { + anchors.fill: parent + color: "green" + } + } + } + + Component { + id: randomPage + Kirigami.Page { + Rectangle { + anchors.fill: parent + color: "red" + } + } + } + + SignalSpy { + id: spyCurrentIndex + target: mainWindow.pageStack + signalName: "currentIndexChanged" + } + + SignalSpy { + id: spyActive + target: mainWindow + signalName: "activeChanged" + } + + function initTestCase() { + spyActive.clear() + spyCurrentIndex.clear() + } + + function test_pop() { + compare(mainWindow.pageStack.depth, 1) + mainWindow.pageStack.push(randomPage) + compare(mainWindow.pageStack.depth, 2) + mainWindow.pageStack.pop() + compare(mainWindow.pageStack.depth, 1) + } + + function test_goBack() { + compare(spyCurrentIndex.count, 0) + compare(mainWindow.pageStack.depth, 1) + mainWindow.pageStack.push(randomPage) + compare(mainWindow.pageStack.depth, 2) + compare(spyCurrentIndex.count, 1) + mainWindow.requestActivate() + spyActive.clear() + spyCurrentIndex.clear() + var sa = spyActive.wait(12321313) + verify(mainWindow.active || sa) + console.log("lalala", mainWindow.active) + keyClick(Qt.Key_Left, Qt.AltModifier) + + spyCurrentIndex.wait(5000) + + compare(mainWindow.pageStack.depth, 2) + compare(mainWindow.pageStack.currentIndex, 0) + compare(spyCurrentIndex.count, 1) + mainWindow.pageStack.pop() + compare(mainWindow.pageStack.depth, 1) + } +}