Files
pilotclient/tests/blackmisc/testhardware.cpp
Roland Winklmeier 5cac09f625 Fixed issues arised after merge
- wrong namespace in newly created headers
- wrong includes
- Fixed members in CKeyboardKey
- Fixed CKeyboardKey unit test
2014-03-11 22:24:25 +01:00

60 lines
2.5 KiB
C++

/* 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);
key2.setNativeVirtualKey('5');
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