Improve Auto-Type Select Dialog

Significant improvements to the Auto-Type select dialog. Reduce stale and unnecessary code paths.

* Close select dialog when databases are locked.
* Close open modal dialogs prior to showing the Auto-Type select dialog to prevent interference.
* Never perform Auto-Type on the KeePassXC window.
* Only filter match list based on Group, Title, and Username column data (ie, ignore sequence column)
* Always show the sequence column (revert feature)
* Show selection dialog if there are no matches to allow for a database search

* Close #3630 - Allow typing {USERNAME} and {PASSWORD} from selection dialog (right-click menu).
* Close #429 - Ability to search open databases for an entry from the Auto-Type selection dialog.
* Fix #5361 - Default size of selection dialog doesn't cut off matches
This commit is contained in:
Jonathan White
2021-02-15 17:28:16 -05:00
parent 7ce35f81de
commit d9ae449f04
38 changed files with 830 additions and 1047 deletions

View File

@@ -149,9 +149,6 @@ add_unit_test(NAME testkeepass1reader SOURCES TestKeePass1Reader.cpp
add_unit_test(NAME testopvaultreader SOURCES TestOpVaultReader.cpp
LIBS ${TEST_LIBRARIES})
add_unit_test(NAME testwildcardmatcher SOURCES TestWildcardMatcher.cpp
LIBS ${TEST_LIBRARIES})
if(WITH_XC_NETWORKING)
add_unit_test(NAME testupdatecheck SOURCES TestUpdateCheck.cpp
LIBS ${TEST_LIBRARIES})

View File

@@ -1,88 +0,0 @@
/*
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TestWildcardMatcher.h"
#include "TestGlobal.h"
#include "autotype/WildcardMatcher.h"
QTEST_GUILESS_MAIN(TestWildcardMatcher)
const QString TestWildcardMatcher::DefaultText = QString("some text");
const QString TestWildcardMatcher::AlternativeText = QString("some other text");
void TestWildcardMatcher::testMatcher_data()
{
QTest::addColumn<QString>("text");
QTest::addColumn<QString>("pattern");
QTest::addColumn<bool>("match");
QTest::newRow("MatchWithoutWildcard") << DefaultText << DefaultText << true;
QTest::newRow("NoMatchWithoutWildcard") << DefaultText << QString("no match text") << false;
QTest::newRow("MatchWithOneWildcardInTheMiddle") << AlternativeText << QString("some*text") << true;
QTest::newRow("NoMatchWithOneWildcardInTheMiddle") << AlternativeText << QString("differen*text") << false;
QTest::newRow("MatchWithOneWildcardAtBegin") << DefaultText << QString("*text") << true;
QTest::newRow("NoMatchWithOneWildcardAtBegin") << DefaultText << QString("*text something else") << false;
QTest::newRow("NatchWithOneWildcardAtEnd") << DefaultText << QString("some*") << true;
QTest::newRow("NoMatchWithOneWildcardAtEnd") << DefaultText << QString("some other*") << false;
QTest::newRow("MatchWithMultipleWildcards") << AlternativeText << QString("some*th*text") << true;
QTest::newRow("NoMatchWithMultipleWildcards") << AlternativeText << QString("some*abc*text") << false;
QTest::newRow("MatchJustWildcard") << DefaultText << QString("*") << true;
QTest::newRow("MatchFollowingWildcards") << DefaultText << QString("some t**t") << true;
QTest::newRow("CaseSensitivity") << DefaultText.toUpper() << QString("some t**t") << true;
}
void TestWildcardMatcher::testMatcher()
{
QFETCH(QString, text);
QFETCH(QString, pattern);
QFETCH(bool, match);
initMatcher(text);
verifyMatchResult(pattern, match);
cleanupMatcher();
}
void TestWildcardMatcher::initMatcher(QString text)
{
m_matcher = new WildcardMatcher(text);
}
void TestWildcardMatcher::cleanupMatcher()
{
delete m_matcher;
}
void TestWildcardMatcher::verifyMatchResult(QString pattern, bool expected)
{
if (expected) {
verifyMatch(pattern);
} else {
verifyNoMatch(pattern);
}
}
void TestWildcardMatcher::verifyMatch(QString pattern)
{
bool matchResult = m_matcher->match(pattern);
QVERIFY(matchResult);
}
void TestWildcardMatcher::verifyNoMatch(QString pattern)
{
bool matchResult = m_matcher->match(pattern);
QVERIFY(!matchResult);
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_TESTWILDCARDMATCHER_H
#define KEEPASSX_TESTWILDCARDMATCHER_H
#include <QObject>
class WildcardMatcher;
class TestWildcardMatcher : public QObject
{
Q_OBJECT
private slots:
void testMatcher();
void testMatcher_data();
private:
static const QString DefaultText;
static const QString AlternativeText;
void initMatcher(QString text);
void cleanupMatcher();
void verifyMatchResult(QString pattern, bool expected);
void verifyMatch(QString pattern);
void verifyNoMatch(QString pattern);
WildcardMatcher* m_matcher;
};
#endif // KEEPASSX_TESTWILDCARDMATCHER_H