Commit 08f9289f authored by Martin Kampas's avatar Martin Kampas

ut_deviceinfo: initial commit

parent 046248a9
......@@ -4,6 +4,7 @@ SUBDIRS = \
testutils \
testutils/sandboxhook.pro \
ut_coreconfig \
ut_deviceinfo \
ut_rndssucli \
ut_sandbox \
ut_settings \
......
......@@ -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>
......
/**
* @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"));
}
/**
* @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
/**
* @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;
}
[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
[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
[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]
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 \
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment