Skip to content

Commit

Permalink
fix TestSyncConflictsModel by using locale aware test data
Browse files Browse the repository at this point in the history
should ensure comparisons of locale aware text is compared against
locale aware test data

will remove portability issues especially on Windows

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Nov 29, 2024
1 parent f38c2b7 commit 60b1091
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/testsyncconflictsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QTest>
#include <QAbstractItemModelTester>
#include <QSignalSpy>
#include <QLocale>

namespace {

Expand All @@ -47,6 +48,7 @@ class TestSyncConflictsModel : public QObject
Q_OBJECT

private:
QLocale _locale;

private slots:
void initTestCase()
Expand Down Expand Up @@ -104,8 +106,8 @@ private slots:

QCOMPARE(model.rowCount(), 1);
QCOMPARE(model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ExistingFileName)), QString{"a2"});
QCOMPARE(model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ExistingSize)), QString{"6 bytes"});
QCOMPARE(model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ConflictSize)), QString{"5 bytes"});
QCOMPARE(model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ExistingSize)), _locale.formattedDataSize(6));
QCOMPARE(model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ConflictSize)), _locale.formattedDataSize(5));
QVERIFY(!model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ExistingDate)).toString().isEmpty());
QVERIFY(!model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ConflictDate)).toString().isEmpty());
QCOMPARE(model.data(model.index(0), static_cast<int>(SyncConflictsModel::SyncConflictRoles::ExistingPreviewUrl)), QVariant::fromValue(QUrl{QStringLiteral("image://tray-image-provider/:/fileicon%1A/a2").arg(fakeFolder.localPath())}));
Expand Down

0 comments on commit 60b1091

Please sign in to comment.