Move global shortcut handling into OSUtils (#5566)

Move global shortcut handling into OSUtils
This commit is contained in:
Jonathan White 2020-12-13 23:23:25 -05:00 committed by GitHub
parent a6f01349e8
commit 404fd941e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1124 additions and 1136 deletions

View file

@ -70,13 +70,13 @@ void TestCli::initTestCase()
Config::createTempFileInstance();
Bootstrap::bootstrap();
auto fd = new QFile();
m_devNull.reset(new QFile());
#ifdef Q_OS_WIN
fd->open(fopen("nul", "w"), QIODevice::WriteOnly);
m_devNull->open(fopen("nul", "w"), QIODevice::WriteOnly);
#else
fd->open(fopen("/dev/null", "w"), QIODevice::WriteOnly);
m_devNull->open(fopen("/dev/null", "w"), QIODevice::WriteOnly);
#endif
Utils::DEVNULL.setDevice(fd);
Utils::DEVNULL.setDevice(m_devNull.data());
}
void TestCli::init()
@ -131,6 +131,11 @@ void TestCli::cleanup()
Utils::STDIN.setDevice(nullptr);
}
void TestCli::cleanupTestCase()
{
m_devNull.reset();
}
QSharedPointer<Database> TestCli::readDatabase(const QString& filename, const QString& pw, const QString& keyfile)
{
auto db = QSharedPointer<Database>::create();
@ -520,8 +525,7 @@ void TestCli::testClip()
setInput("a");
execCmd(clipCmd, {"clip", m_dbFile->fileName(), "-a", "TESTAttribute1", "/Sample Entry"});
QVERIFY(m_stderr->readAll().contains(
"ERROR: attribute TESTAttribute1 is ambiguous, it matches TestAttribute1 and testattribute1.\n"));
QVERIFY(m_stderr->readAll().contains("ERROR: attribute TESTAttribute1 is ambiguous"));
setInput("a");
execCmd(clipCmd, {"clip", m_dbFile2->fileName(), "--attribute", "Username", "--totp", "/Sample Entry"});
@ -1776,8 +1780,7 @@ void TestCli::testShow()
setInput("a");
execCmd(showCmd, {"show", m_dbFile->fileName(), "-a", "Testattribute1", "/Sample Entry"});
QCOMPARE(m_stdout->readAll(), QByteArray());
QVERIFY(m_stderr->readAll().contains(
"ERROR: attribute Testattribute1 is ambiguous, it matches TestAttribute1 and testattribute1.\n"));
QVERIFY(m_stderr->readAll().contains("ERROR: attribute Testattribute1 is ambiguous"));
}
void TestCli::testInvalidDbFiles()