Complete refactor of Browser Integration classes
* Removed option to attach KeePassXC to the browser extension. Users must use the proxy application to communicate with KeePassXC. * Significantly streamlined proxy code. Used same implementation of stdin/stdout interface across all platforms. * Moved browser service entry point to BrowserService class instead of NativeMessagingHost. BrowserService now coordinates the communication to/from clients. * Moved settings page definition out of MainWindow * Decoupled BrowserService from DatabaseTabWidget * Reduced complexity of various functions and cleaned the ABI (public vs private). * Eliminated BrowserClients class, moved functionality into the BrowserService * Renamed HostInstaller to NativeMessageInstaller and renamed NativeMessageHost to BrowserHost. * Recognize XDG_CONFIG_HOME when installing native message file on Linux. Fix #4121 and fix #4123.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <QTableView>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "browser/BrowserService.h"
|
||||
#include "config-keepassx-tests.h"
|
||||
#include "core/Bootstrap.h"
|
||||
#include "core/Config.h"
|
||||
@@ -82,30 +83,19 @@ void TestGuiBrowser::initTestCase()
|
||||
Bootstrap::restoreMainWindowState(*m_mainWindow);
|
||||
m_tabWidget = m_mainWindow->findChild<DatabaseTabWidget*>("tabWidget");
|
||||
m_mainWindow->show();
|
||||
|
||||
// Load the NewDatabase.kdbx file into temporary storage
|
||||
QFile sourceDbFile(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabaseBrowser.kdbx"));
|
||||
QVERIFY(sourceDbFile.open(QIODevice::ReadOnly));
|
||||
QVERIFY(Tools::readAllFromDevice(&sourceDbFile, m_dbData));
|
||||
sourceDbFile.close();
|
||||
}
|
||||
|
||||
// Every test starts with opening the temp database
|
||||
void TestGuiBrowser::init()
|
||||
{
|
||||
m_dbFile.reset(new TemporaryFile());
|
||||
// Write the temp storage to a temp database file for use in our tests
|
||||
QVERIFY(m_dbFile->open());
|
||||
QCOMPARE(m_dbFile->write(m_dbData), static_cast<qint64>((m_dbData.size())));
|
||||
m_dbFileName = QFileInfo(m_dbFile->fileName()).fileName();
|
||||
m_dbFilePath = m_dbFile->fileName();
|
||||
m_dbFile->close();
|
||||
m_dbFile->copyFromFile(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabaseBrowser.kdbx"));
|
||||
|
||||
// make sure window is activated or focus tests may fail
|
||||
m_mainWindow->activateWindow();
|
||||
QApplication::processEvents();
|
||||
|
||||
fileDialog()->setNextFileName(m_dbFilePath);
|
||||
fileDialog()->setNextFileName(m_dbFile->fileName());
|
||||
triggerAction("actionDatabaseOpen");
|
||||
|
||||
auto* databaseOpenWidget = m_tabWidget->currentDatabaseWidget()->findChild<QWidget*>("databaseOpenWidget");
|
||||
@@ -241,6 +231,28 @@ void TestGuiBrowser::testAdditionalURLs()
|
||||
}
|
||||
}
|
||||
|
||||
void TestGuiBrowser::testGetDatabaseGroups()
|
||||
{
|
||||
auto result = browserService()->getDatabaseGroups();
|
||||
QCOMPARE(result.length(), 1);
|
||||
|
||||
auto groups = result["groups"].toArray();
|
||||
auto first = groups.at(0);
|
||||
auto children = first.toObject()["children"].toArray();
|
||||
QCOMPARE(first.toObject()["name"].toString(), QString("NewDatabase"));
|
||||
QCOMPARE(children.size(), 6);
|
||||
|
||||
auto firstChild = children.at(0).toObject();
|
||||
auto secondChild = children.at(1).toObject();
|
||||
QCOMPARE(firstChild["name"].toString(), QString("General"));
|
||||
QCOMPARE(secondChild["name"].toString(), QString("Windows"));
|
||||
|
||||
auto subGroups = firstChild["children"].toArray();
|
||||
QCOMPARE(subGroups.count(), 1);
|
||||
auto subGroupObj = subGroups.at(0).toObject();
|
||||
QCOMPARE(subGroupObj["name"].toString(), QString("SubGroup"));
|
||||
}
|
||||
|
||||
void TestGuiBrowser::triggerAction(const QString& name)
|
||||
{
|
||||
auto* action = m_mainWindow->findChild<QAction*>(name);
|
||||
|
||||
Reference in New Issue
Block a user