mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
@@ -195,15 +195,10 @@ namespace BlackMisc
|
|||||||
return this->m_modifier1 != ModifierNone || this->m_modifier2 != ModifierNone;
|
return this->m_modifier1 != ModifierNone || this->m_modifier2 != ModifierNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Modifier?
|
|
||||||
bool hasModifier() const
|
|
||||||
{
|
|
||||||
return this->m_modifier1 != ModifierNone || this->m_modifier2 != ModifierNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Do we have this Modifier?
|
* \brief Do we have this modifier?
|
||||||
* \param modifier
|
* \param modifier
|
||||||
|
* \return
|
||||||
*/
|
*/
|
||||||
bool hasModifier(Modifier modifier) const
|
bool hasModifier(Modifier modifier) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "testgeo.h"
|
#include "testgeo.h"
|
||||||
#include "testcontainers.h"
|
#include "testcontainers.h"
|
||||||
#include "testvariantandmap.h"
|
#include "testvariantandmap.h"
|
||||||
|
#include "testhardware.h"
|
||||||
#include "testblackmiscmain.h"
|
#include "testblackmiscmain.h"
|
||||||
|
|
||||||
namespace BlackMiscTest
|
namespace BlackMiscTest
|
||||||
@@ -26,13 +27,14 @@ namespace BlackMiscTest
|
|||||||
CTestGeo geoTests;
|
CTestGeo geoTests;
|
||||||
CTestContainers containerTests;
|
CTestContainers containerTests;
|
||||||
CTestVariantAndValueMap variantAndValueMap;
|
CTestVariantAndValueMap variantAndValueMap;
|
||||||
|
CTestHardware hardwareTests;
|
||||||
status |= QTest::qExec(&pqBaseTests, argc, argv);
|
status |= QTest::qExec(&pqBaseTests, argc, argv);
|
||||||
status |= QTest::qExec(&avBaseTests, argc, argv);
|
status |= QTest::qExec(&avBaseTests, argc, argv);
|
||||||
status |= QTest::qExec(&vmTests, argc, argv);
|
status |= QTest::qExec(&vmTests, argc, argv);
|
||||||
status |= QTest::qExec(&geoTests, argc, argv);
|
status |= QTest::qExec(&geoTests, argc, argv);
|
||||||
status |= QTest::qExec(&containerTests, argc, argv);
|
status |= QTest::qExec(&containerTests, argc, argv);
|
||||||
status |= QTest::qExec(&variantAndValueMap, argc, argv);
|
status |= QTest::qExec(&variantAndValueMap, argc, argv);
|
||||||
|
status |= QTest::qExec(&hardwareTests, argc, argv);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
58
tests/blackmisc/testhardware.cpp
Normal file
58
tests/blackmisc/testhardware.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / authors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "testhardware.h"
|
||||||
|
#include "blackmisc/hwkeyboardkey.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc::Hardware;
|
||||||
|
|
||||||
|
namespace BlackMiscTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
CTestHardware::CTestHardware(QObject *parent): QObject(parent)
|
||||||
|
{
|
||||||
|
// void
|
||||||
|
}
|
||||||
|
|
||||||
|
// CKeyboardKey tests
|
||||||
|
void CTestHardware::keyboardKey()
|
||||||
|
{
|
||||||
|
// Test equal operator
|
||||||
|
CKeyboardKey key = CKeyboardKey(Qt::Key_5, '5', CKeyboardKey::ModifierAltLeft, CKeyboardKey::ModifierCtrlLeft, CKeyboardKey::HotkeyPtt);
|
||||||
|
CKeyboardKey key2;
|
||||||
|
key2.setKey(Qt::Key_5);
|
||||||
|
key2.setModifier1(CKeyboardKey::ModifierAltLeft);
|
||||||
|
key2.setModifier2(CKeyboardKey::ModifierCtrlLeft);
|
||||||
|
key2.setFunction(CKeyboardKey::HotkeyPtt);
|
||||||
|
QVERIFY2(key == key2, "CKeyboardKey::operator== failed!");
|
||||||
|
|
||||||
|
key = CKeyboardKey();
|
||||||
|
key.setKey(QString("A"));
|
||||||
|
QVERIFY2(key.getKey() == Qt::Key_A, "CKeyboardKey::setKey(const QString &key) failed");
|
||||||
|
|
||||||
|
key.setKey(QChar('B'));
|
||||||
|
QVERIFY2(key.getKey() == Qt::Key_B, "CKeyboardKey::setKey(const QChar key) failed");
|
||||||
|
|
||||||
|
key.setKey(Qt::Key_C);
|
||||||
|
QVERIFY2(key.getKey() == Qt::Key_C, "CKeyboardKey::setKey(const QChar &key) failed");
|
||||||
|
|
||||||
|
key.setKey('D');
|
||||||
|
QVERIFY2(key.getKey() == Qt::Key_D, "CKeyboardKey::setKey(const int key) failed");
|
||||||
|
|
||||||
|
key = CKeyboardKey();
|
||||||
|
QVERIFY2(key.addModifier(CKeyboardKey::ModifierAltLeft), "CKeyboardKey::addModifier() returned wrong result");
|
||||||
|
QVERIFY2(key.numberOfModifiers() == 1, "Expected number of modifiers to be equal to 1");
|
||||||
|
QVERIFY2(key.getModifier1() == CKeyboardKey::ModifierAltLeft, "Expected modifier to be ModifierAltLeft");
|
||||||
|
// Add same modifier again. This should not change the status
|
||||||
|
QVERIFY2(!key.addModifier(CKeyboardKey::ModifierAltLeft), "CKeyboardKey::addModifier() returned wrong result");
|
||||||
|
QVERIFY2(key.numberOfModifiers() == 1, "Expected number of modifiers to be equal to 1");
|
||||||
|
QVERIFY2(key.getModifier1() == CKeyboardKey::ModifierAltLeft, "Expected modifier to be ModifierAltLeft");
|
||||||
|
QVERIFY2(key.getModifier2() == CKeyboardKey::ModifierNone, "Expected modifier to be ModifierAltLeft");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
37
tests/blackmisc/testhardware.h
Normal file
37
tests/blackmisc/testhardware.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKMISCTEST_TESTHARDWARE_H
|
||||||
|
#define BLACKMISCTEST_TESTHARDWARE_H
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BlackMiscTest
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* \brief Hardware classes basic tests
|
||||||
|
*/
|
||||||
|
class CTestHardware : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* \brief Standard test case constructor
|
||||||
|
* \param parent
|
||||||
|
*/
|
||||||
|
explicit CTestHardware(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
//! \brief CKeyboardKey basic tests
|
||||||
|
void keyboardKey();
|
||||||
|
|
||||||
|
};
|
||||||
|
} // namespace BlackMiscTest
|
||||||
|
|
||||||
|
#endif // BLACKMISCTEST_TESTHARDWARE_H
|
||||||
Reference in New Issue
Block a user