-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test running QAbstractItemModelTester on the model. Pick-to: 6.6 Change-Id: I40c141c7e754ca05234da611534bd65e456be2fb Reviewed-by: Kai Köhne <[email protected]>
- Loading branch information
1 parent
d50b56b
commit 283cdcd
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2023 The Qt Company Ltd. | ||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause | ||
|
||
#include "treemodel.h" | ||
|
||
#include <QAbstractItemModelTester> | ||
#include <QObject> | ||
#include <QTest> | ||
|
||
using namespace Qt::StringLiterals; | ||
|
||
//! [1] | ||
class TestEditableTreeModel : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
void testTreeModel(); | ||
}; | ||
|
||
void TestEditableTreeModel::testTreeModel() | ||
{ | ||
constexpr auto fileName = ":/default.txt"_L1; | ||
QFile file(fileName); | ||
QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), | ||
qPrintable(fileName + " cannot be opened: "_L1 + file.errorString())); | ||
|
||
const QStringList headers{"column1"_L1, "column2"_L1}; | ||
TreeModel model(headers, QString::fromUtf8(file.readAll())); | ||
|
||
QAbstractItemModelTester tester(&model); | ||
} | ||
|
||
QTEST_APPLESS_MAIN(TestEditableTreeModel) | ||
|
||
#include "test.moc" | ||
//! [1] |