Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.56 KB

featuremodeltest.cpp

File metadata and controls

51 lines (38 loc) · 1.56 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* @file featuremodeltest.cpp
* @copyright 2015 Jolla Ltd.
* @author Joona Petrell <joona.petrell@jolla.com>
* @date 2015
*/
#include "featuremodeltest.h"
#include <QtTest/QtTest>
#include <QtTest/QSignalSpy>
#include "libssu/ssufeaturemodel.h"
Oct 10, 2016
Oct 10, 2016
14
15
void FeatureModelTest::initTestCase()
{
16
17
18
}
Oct 10, 2016
Oct 10, 2016
19
20
void FeatureModelTest::cleanupTestCase()
{
21
22
23
}
Oct 10, 2016
Oct 10, 2016
24
25
void FeatureModelTest::testFeatures()
{
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SsuFeatureModel featureModel(0, ":/testdata");
// Features with no name are skipped (feature-noname.ini)
QCOMPARE(featureModel.count(), 3);
// First feature is "Feature A" in version 0.1
// Explicit getter
const QHash<QByteArray, QString> featureA = featureModel.featureAt(0);
QCOMPARE(featureA.value("name"), QString("Feature A"));
QCOMPARE(featureA.value("version"), QString("0.1"));
// Through QAbstractListModel API
QCOMPARE(featureModel.data(featureModel.index(0), SsuFeatureModel::Name).toString(), QString("Feature A"));
QCOMPARE(featureModel.data(featureModel.index(0), SsuFeatureModel::Version).toString(), QString("0.1"));
// Second feature is "Feature B" in version 0.2
const QHash<QByteArray, QString> featureB = featureModel.featureAt(1);
QCOMPARE(featureB.value("name"), QString("Feature B"));
QCOMPARE(featureB.value("version"), QString("0.2"));
// Third feature lacks version number
const QHash<QByteArray, QString> featureWithoutVersion = featureModel.featureAt(2);
QCOMPARE(featureWithoutVersion.value("name"), QString("Feature without version"));
QCOMPARE(featureWithoutVersion.value("version"), QString(""));
}