deviceinfotest.cpp 2.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/**
 * @file deviceinfotest.cpp
 * @copyright 2013 Jolla Ltd.
 * @author Martin Kampas <martin.kampas@tieto.com>
 * @date 2013
 */

#include "deviceinfotest.h"

#include <QtTest/QtTest>

#include "libssu/ssudeviceinfo.h"

14 15 16 17 18 19 20 21 22 23 24 25 26
void DeviceInfoTest::testAdaptationVariables()
{
    SsuDeviceInfo deviceInfo("N950");
    QHash<QString, QString> variables;
    QHash<QString, QString> variablesExpected;
    variablesExpected["adaptation"] = "n950-n9";
    variablesExpected["foo-n9"] = "foo-n9-val";
    variablesExpected["foo-n950-n9"] = "foo-n950-n9-val";

    QString repoName = deviceInfo.adaptationVariables("adaptation1", &variables);

    QCOMPARE(variables, variablesExpected);
    QCOMPARE(repoName, QString("adaptation"));
27 28
}

29 30 31
void DeviceInfoTest::testDeviceUid()
{
    QVERIFY2(!SsuDeviceInfo().deviceUid().isEmpty(), "No method to get device UID on this platform");
32 33
}

34 35 36
void DeviceInfoTest::testVariableSection()
{
    SsuDeviceInfo deviceInfo;
37

38 39 40 41
    QHash<QString, QString> fooVars;
    QHash<QString, QString> fooVarsExpected;
    fooVarsExpected["foo1"] = "foo1Val";
    fooVarsExpected["foo2"] = "foo2Val";
42

43
    deviceInfo.variableSection("foo", &fooVars);
44

45
    QCOMPARE(fooVars, fooVarsExpected);
46

47 48 49 50
    QHash<QString, QString> barVars;
    QHash<QString, QString> barVarsExpected;
    barVarsExpected["bar1"] = "bar1Val";
    barVarsExpected["bar2"] = "bar2Val";
51

52
    deviceInfo.variableSection("bar", &barVars);
53

54
    QCOMPARE(barVars, barVarsExpected);
55

56 57 58 59 60 61
    QHash<QString, QString> bazVars;
    QHash<QString, QString> bazVarsExpected;
    bazVarsExpected["foo1"] = "foo1Val";
    bazVarsExpected["foo2"] = "foo2Val";
    bazVarsExpected["bar1"] = "bar1Val";
    bazVarsExpected["bar2"] = "bar2Val";
62

63
    deviceInfo.variableSection("baz", &bazVars);
64

65
    QCOMPARE(bazVars, bazVarsExpected);
66 67
}

68 69 70 71 72 73 74
void DeviceInfoTest::testValue()
{
    SsuDeviceInfo deviceInfo("N950");
    QCOMPARE(deviceInfo.value("family").toString(), QString("n950-n9"));
    QCOMPARE(deviceInfo.value("adaptation-repos").toStringList(),
             QString("n9xx-common,n950-n9").split(','));
    QCOMPARE(deviceInfo.value("foo").toString(), QString("n950-foo"));
75
}