Skip to content

Commit

Permalink
break up test suites, fix index mapping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ahigerd committed Jul 2, 2022
1 parent f2eabf5 commit cfd523c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 59 deletions.
33 changes: 21 additions & 12 deletions src/platform/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ set(GB_SRC
GBOverride.cpp
PrinterView.cpp)

set(TEST_QT_spanset_SRC
test/spanset.cpp
utils.cpp)

set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libqt5widgets5")

set(AUDIO_SRC)
Expand Down Expand Up @@ -241,6 +245,12 @@ if(USE_SQLITE3)
library/LibraryController.cpp
library/LibraryEntry.cpp
library/LibraryModel.cpp)

set(TEST_QT_library_SRC
library/LibraryEntry.cpp
library/LibraryModel.cpp
test/library.cpp
utils.cpp)
endif()

if(USE_DISCORD_RPC)
Expand Down Expand Up @@ -486,18 +496,17 @@ if(BUILD_SUITE)
enable_testing()
find_package(${QT}Test)
if(${QT}Test_FOUND)
set(TEST_SRC
library/LibraryEntry.cpp
library/LibraryModel.cpp
test/library.cpp
test/main.cpp
test/spanset.cpp
utils.cpp
)
add_executable(test-platform-qt WIN32 ${TEST_SRC})
target_link_libraries(test-platform-qt ${PLATFORM_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES} ${QT}::Test)
set_target_properties(test-platform-qt PROPERTIES COMPILE_DEFINITIONS "${FEATURE_DEFINES};${FUNCTION_DEFINES};${OS_DEFINES};${QT_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}")
add_test(platform-qt test-platform-qt)
get_property(ALL_TESTS DIRECTORY PROPERTY VARIABLES)
list(FILTER ALL_TESTS INCLUDE REGEX "^TEST_QT_.*_SRC$")
foreach(TEST_SRC ${ALL_TESTS})
string(REGEX REPLACE "^TEST_QT_(.*)_SRC$" "\\1" TEST_NAME ${TEST_SRC})
message("TEST_NAME=${TEST_NAME}")
message("TEST_SRC=${${TEST_SRC}}")
add_executable(test-qt-${TEST_NAME} WIN32 ${${TEST_SRC}})
target_link_libraries(test-qt-${TEST_NAME} ${PLATFORM_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES} ${QT}::Test)
set_target_properties(test-qt-${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS "${FEATURE_DEFINES};${FUNCTION_DEFINES};${OS_DEFINES};${QT_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}")
add_test(platform-qt-${TEST_NAME} test-qt-${TEST_NAME})
endforeach()
else()
message("${QT}Test not found")
endif()
Expand Down
7 changes: 7 additions & 0 deletions src/platform/qt/library/LibraryController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ void LibraryController::selectEntry(const QString& fullpath) {
return;
}
QModelIndex index = m_libraryModel->index(fullpath);

// If the model is proxied in the current view, map the index to the proxy
QAbstractProxyModel* proxy = qobject_cast<QAbstractProxyModel*>(m_currentView->model());
if (proxy) {
index = proxy->mapFromSource(index);
}

if (index.isValid()) {
m_currentView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current);
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/qt/test/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "suite.h"
#include "platform/qt/library/LibraryModel.h"

#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#include <QAbstractItemModelTester>
#endif

#include <QSignalSpy>
#include <QTest>

#define FIND_GBA_ROW(gba, gb) \
int gba = findGBARow(); \
Expand Down Expand Up @@ -196,5 +196,5 @@ private slots:
}
};

M_REGISTER_QT_TEST(LibraryModelTest)
QTEST_MAIN(LibraryModelTest)
#include "library.moc"
19 changes: 0 additions & 19 deletions src/platform/qt/test/main.cpp

This file was deleted.

5 changes: 2 additions & 3 deletions src/platform/qt/test/spanset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "suite.h"
#include "platform/qt/utils.h"

#include <QtDebug>
#include <QTest>

using namespace QGBA;

Expand Down Expand Up @@ -58,5 +57,5 @@ private slots:
}
};

M_REGISTER_QT_TEST(SpanSetTest)
QTEST_APPLESS_MAIN(SpanSetTest)
#include "spanset.moc"
23 changes: 0 additions & 23 deletions src/platform/qt/test/suite.h

This file was deleted.

0 comments on commit cfd523c

Please sign in to comment.