Ref T203, unit test for icon index

This commit is contained in:
Klaus Basan
2017-12-10 02:23:28 +01:00
parent 103e55554e
commit c2149f00ac
3 changed files with 95 additions and 2 deletions

View File

@@ -14,7 +14,10 @@
#include "testaviation.h" #include "testaviation.h"
#include "testblackmiscmain.h" #include "testblackmiscmain.h"
#include "testcontainers.h" #include "testcontainers.h"
#include "testdbus.h"
#include "testflightplan.h"
#include "testgeo.h" #include "testgeo.h"
#include "testicon.h"
#include "testidentifier.h" #include "testidentifier.h"
#include "testinput.h" #include "testinput.h"
#include "testinterpolator.h" #include "testinterpolator.h"
@@ -28,8 +31,6 @@
#include "testvaluecache.h" #include "testvaluecache.h"
#include "testvariantandmap.h" #include "testvariantandmap.h"
#include "testweather.h" #include "testweather.h"
#include "testdbus.h"
#include "testflightplan.h"
#include "blackmisc/test/test.h" #include "blackmisc/test/test.h"
#include <QStringList> #include <QStringList>
@@ -117,6 +118,10 @@ namespace BlackMiscTest
CTestDBus testDBus; CTestDBus testDBus;
status |= test.exec(&testDBus, "blackmisc_dbus"); status |= test.exec(&testDBus, "blackmisc_dbus");
} }
{
CTestIcon testIcon;
status |= test.exec(&testIcon, "blackmisc_icon");
}
return status; return status;
} }
} // namespace } // namespace

View File

@@ -0,0 +1,47 @@
/* Copyright (C) 2017
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \cond PRIVATE_TESTS
/*!
* \file
* \ingroup testblackmisc
*/
#include "testicon.h"
#include "blackmisc/iconlist.h"
#include <QString>
#include <QTest>
using namespace BlackMisc;
namespace BlackMiscTest
{
void CTestIcon::iconIndex()
{
const int max = static_cast<int>(CIcons::IconIsGenerated);
QVERIFY2(CIconList::allIcons().size() == max, "Icon list size");
int c = 0;
for (const CIcon &icon : CIconList::allIcons())
{
CIcons::IconIndex ii = icon.getIndex();
const int i = static_cast<int>(ii);
if (i != c)
{
static const QString verifyMsg("Wrong index %1/%2 for icon %3");
qDebug() << verifyMsg.arg(i).arg(c).arg(icon.getDescriptiveText());
QVERIFY2(i == c, "Wrong icon index");
}
c++;
}
}
} //namespace
//! \endcond

View File

@@ -0,0 +1,41 @@
/* Copyright (C) 2017
* swift project community / contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#ifndef BLACKMISCTEST_TESTICON_H
#define BLACKMISCTEST_TESTICON_H
//! \cond PRIVATE_TESTS
/*!
* \file
* \ingroup testblackmisc
*/
#include <QObject>
namespace BlackMiscTest
{
//! Testing icons
class CTestIcon : public QObject
{
Q_OBJECT
public:
//! Constructor
explicit CTestIcon(QObject *parent = nullptr) : QObject(parent) {}
private slots:
//! Icon order/index
void iconIndex();
};
} // namespace
//! \endcond
#endif // guard