Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ut_deviceinfo: initial commit
  • Loading branch information
martyone committed Apr 10, 2013
1 parent 046248a commit 08f9289
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/tests.pro
Expand Up @@ -4,6 +4,7 @@ SUBDIRS = \
testutils \
testutils/sandboxhook.pro \
ut_coreconfig \
ut_deviceinfo \
ut_rndssucli \
ut_sandbox \
ut_settings \
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.xml
Expand Up @@ -8,6 +8,11 @@
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_coreconfig</step>
</case>
</set>
<set name="deviceinfo" description="Test to determine if device info can be retrieved properly" feature="deviceinfo">
<case name="ut_deviceinfo" type="Functional" description="Device info processing test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_deviceinfo</step>
</case>
</set>
<set name="rndssucli" description="Test to determine if ssu command line tool works properly" feature="rndssucli">
<case name="ut_rndssucli" type="Functional" description="SSU command line utility test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_rndssucli</step>
Expand Down
71 changes: 71 additions & 0 deletions tests/ut_deviceinfo/deviceinfotest.cpp
@@ -0,0 +1,71 @@
/**
* @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"

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"));
}

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

void DeviceInfoTest::testVariableSection(){
SsuDeviceInfo deviceInfo;

QHash<QString, QString> fooVars;
QHash<QString, QString> fooVarsExpected;
fooVarsExpected["foo1"] = "foo1Val";
fooVarsExpected["foo2"] = "foo2Val";

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

QCOMPARE(fooVars, fooVarsExpected);

QHash<QString, QString> barVars;
QHash<QString, QString> barVarsExpected;
barVarsExpected["bar1"] = "bar1Val";
barVarsExpected["bar2"] = "bar2Val";

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

QCOMPARE(barVars, barVarsExpected);

QHash<QString, QString> bazVars;
QHash<QString, QString> bazVarsExpected;
bazVarsExpected["foo1"] = "foo1Val";
bazVarsExpected["foo2"] = "foo2Val";
bazVarsExpected["bar1"] = "bar1Val";
bazVarsExpected["bar2"] = "bar2Val";

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

QCOMPARE(bazVars, bazVarsExpected);
}

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"));
}
23 changes: 23 additions & 0 deletions tests/ut_deviceinfo/deviceinfotest.h
@@ -0,0 +1,23 @@
/**
* @file deviceinfotest.h
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/

#ifndef _DEVICEINFOTEST_H
#define _DEVICEINFOTEST_H

#include <QObject>

class DeviceInfoTest: public QObject {
Q_OBJECT

private slots:
void testAdaptationVariables();
void testDeviceUid();
void testVariableSection();
void testValue();
};

#endif
26 changes: 26 additions & 0 deletions tests/ut_deviceinfo/main.cpp
@@ -0,0 +1,26 @@
/**
* @file main.cpp
* @copyright 2012 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2012
*/

#include <QtTest/QtTest>

#include "libssu/sandbox_p.h"
#include "deviceinfotest.h"

int main(int argc, char **argv){
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}

DeviceInfoTest deviceinfoTest;

if (QTest::qExec(&deviceinfoTest, argc, argv))
return 1;

return 0;
}
53 changes: 53 additions & 0 deletions tests/ut_deviceinfo/testdata/board-mappings.ini
@@ -0,0 +1,53 @@
[file.exists]
SDK=/mer-sdk-chroot

[systeminfo.equals]

[cpuinfo.contains]
N900=Nokia RX-51 board
N950=Nokia RM-680 board
N9=Nokia RM-696 board

[arch.equals]
generic-x86=i586

[variants]
N950=N9

[N9]
family=n950-n9
adaptation-repos=n9xx-common,n950-n9
variables = n9

[var-n9]
foo-n9 = foo-n9-val

[var-n950-n9]
foo-n950-n9 = foo-n950-n9-val

[N900]
family=n900
adaptation-repos=n9xx-common,n900

[N950]
foo = n950-foo

[SDK]

[generic-x86]
family=x86
adaptation-repos=x86

[UNKNOWN]
family=UNKNOWN

[var-foo]
foo1 = foo1Val
foo2 = foo2Val

[var-bar]
bar1 = bar1Val
bar2 = bar2Val

[var-baz]
variables = foo, bar
32 changes: 32 additions & 0 deletions tests/ut_deviceinfo/testdata/repos.ini
@@ -0,0 +1,32 @@
[all]
credentials=jolla
credentials-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/credentials.xml
register-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/register.xml

[release]
mer-core=https://%(packagesDomain)/%(release)/mer/%(arch)/%(debugSplit)/

[rnd]
mer-core=https://%(packagesDomain)/mer/%(release)/builds/%(arch)/%(debugSplit)/

[devel-flavour]
flavour-pattern=

[release-flavour]
flavour-pattern=:/release

[testing-flavour]
flavour-pattern=:/testing

[example-domain]
dumpDomain=dump.example.com
packagesDomain=packages.example.com
ssuRegDomain=ssu.example.com
ssuRegPath=ssu/device

# fallback if domain is not matched or not set
[default-domain]
dumpDomain=dump.testing.com
packagesDomain=packages.testing.com
ssuRegDomain=ssu.testing.com
ssuRegPath=ssu/device
1 change: 1 addition & 0 deletions tests/ut_deviceinfo/testdata/ssu-defaults.ini
@@ -0,0 +1 @@
# empty
18 changes: 18 additions & 0 deletions tests/ut_deviceinfo/testdata/ssu.ini
@@ -0,0 +1,18 @@
[General]
initialized=true
flavour=testing
registered=false
rndRelease=next
release=latest
adaptation=
ca-certificate=
credentials-scope=example
credentials-url-example = http://creden.tia.ls/

[credentials-example]
username = example_username
password = example_password

[repository-urls]

[repository-url-variables]
18 changes: 18 additions & 0 deletions tests/ut_deviceinfo/ut_deviceinfo.pro
@@ -0,0 +1,18 @@
TARGET = ut_deviceinfo
include(../testapplication.pri)
include(ut_deviceinfo_dependencies.pri)

HEADERS = \
deviceinfotest.h \

SOURCES = \
main.cpp \
deviceinfotest.cpp \

test_data_etc.files = \
testdata/ssu.ini \

test_data_usr_share.files = \
testdata/ssu-defaults.ini \
testdata/board-mappings.ini \
testdata/repos.ini \
1 change: 1 addition & 0 deletions tests/ut_deviceinfo/ut_deviceinfo_dependencies.pri
@@ -0,0 +1 @@
include(../../libssu/libssu.pri)

0 comments on commit 08f9289

Please sign in to comment.