mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-09 11:06:01 +08:00
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
|
||||
Reference in New Issue
Block a user