mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-22 21:54:39 -04:00
Run code formatter
This commit is contained in:
parent
09181fab13
commit
1e915eef89
3 changed files with 25 additions and 27 deletions
|
@ -516,13 +516,13 @@ QString BrowserAction::getErrorMessage(const int errorCode) const
|
||||||
|
|
||||||
QString BrowserAction::getReturnValue(const BrowserService::ReturnValue returnValue) const
|
QString BrowserAction::getReturnValue(const BrowserService::ReturnValue returnValue) const
|
||||||
{
|
{
|
||||||
switch(returnValue) {
|
switch (returnValue) {
|
||||||
case BrowserService::ReturnValue::Success:
|
case BrowserService::ReturnValue::Success:
|
||||||
return QString("success");
|
return QString("success");
|
||||||
case BrowserService::ReturnValue::Error:
|
case BrowserService::ReturnValue::Error:
|
||||||
return QString("error");
|
return QString("error");
|
||||||
case BrowserService::ReturnValue::Canceled:
|
case BrowserService::ReturnValue::Canceled:
|
||||||
return QString("canceled");
|
return QString("canceled");
|
||||||
}
|
}
|
||||||
return QString("error");
|
return QString("error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,7 +450,7 @@ void BrowserService::addEntry(const QString& id,
|
||||||
|
|
||||||
auto db = selectedDb ? selectedDb : selectedDatabase();
|
auto db = selectedDb ? selectedDb : selectedDatabase();
|
||||||
if (!db) {
|
if (!db) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* entry = new Entry();
|
auto* entry = new Entry();
|
||||||
|
@ -489,13 +489,12 @@ void BrowserService::addEntry(const QString& id,
|
||||||
config.save(entry);
|
config.save(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserService::ReturnValue
|
BrowserService::ReturnValue BrowserService::updateEntry(const QString& id,
|
||||||
BrowserService::updateEntry(const QString& id,
|
const QString& uuid,
|
||||||
const QString& uuid,
|
const QString& login,
|
||||||
const QString& login,
|
const QString& password,
|
||||||
const QString& password,
|
const QString& url,
|
||||||
const QString& url,
|
const QString& submitUrl)
|
||||||
const QString& submitUrl)
|
|
||||||
{
|
{
|
||||||
ReturnValue result = ReturnValue::Error;
|
ReturnValue result = ReturnValue::Error;
|
||||||
if (thread() != QThread::currentThread()) {
|
if (thread() != QThread::currentThread()) {
|
||||||
|
@ -877,8 +876,7 @@ Group* BrowserService::getDefaultEntryGroup(const QSharedPointer<Database>& sele
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString groupName =
|
const QString groupName = QLatin1String(KEEPASSXCBROWSER_GROUP_NAME);
|
||||||
QLatin1String(KEEPASSXCBROWSER_GROUP_NAME);
|
|
||||||
|
|
||||||
for (auto* g : rootGroup->groupsRecursive(true)) {
|
for (auto* g : rootGroup->groupsRecursive(true)) {
|
||||||
if (g->name() == groupName && !g->isRecycled()) {
|
if (g->name() == groupName && !g->isRecycled()) {
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
#include "TestBrowser.h"
|
#include "TestBrowser.h"
|
||||||
#include "TestGlobal.h"
|
#include "TestGlobal.h"
|
||||||
|
#include "browser/BrowserSettings.h"
|
||||||
#include "crypto/Crypto.h"
|
#include "crypto/Crypto.h"
|
||||||
#include "sodium/crypto_box.h"
|
#include "sodium/crypto_box.h"
|
||||||
#include "browser/BrowserSettings.h"
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(TestBrowser)
|
QTEST_GUILESS_MAIN(TestBrowser)
|
||||||
|
@ -40,7 +40,6 @@ void TestBrowser::initTestCase()
|
||||||
|
|
||||||
void TestBrowser::cleanupTestCase()
|
void TestBrowser::cleanupTestCase()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +86,7 @@ void TestBrowser::testDecryptMessage()
|
||||||
void TestBrowser::testGetBase64FromKey()
|
void TestBrowser::testGetBase64FromKey()
|
||||||
{
|
{
|
||||||
unsigned char pk[crypto_box_PUBLICKEYBYTES];
|
unsigned char pk[crypto_box_PUBLICKEYBYTES];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
|
for (unsigned int i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
|
||||||
pk[i] = i;
|
pk[i] = i;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +201,7 @@ void TestBrowser::testSearchEntries()
|
||||||
}
|
}
|
||||||
|
|
||||||
browserSettings()->setMatchUrlScheme(false);
|
browserSettings()->setMatchUrlScheme(false);
|
||||||
auto result = m_browserService->searchEntries(db, "github.com", "https://github.com"); // db, hostname, url
|
auto result = m_browserService->searchEntries(db, "github.com", "https://github.com"); // db, hostname, url
|
||||||
QCOMPARE(result.length(), 7);
|
QCOMPARE(result.length(), 7);
|
||||||
QCOMPARE(result[0]->url(), QString("https://github.com/login_page"));
|
QCOMPARE(result[0]->url(), QString("https://github.com/login_page"));
|
||||||
QCOMPARE(result[1]->url(), QString("https://github.com/login"));
|
QCOMPARE(result[1]->url(), QString("https://github.com/login"));
|
||||||
|
@ -210,11 +209,11 @@ void TestBrowser::testSearchEntries()
|
||||||
QCOMPARE(result[3]->url(), QString("http://github.com"));
|
QCOMPARE(result[3]->url(), QString("http://github.com"));
|
||||||
QCOMPARE(result[4]->url(), QString("http://github.com/login"));
|
QCOMPARE(result[4]->url(), QString("http://github.com/login"));
|
||||||
QCOMPARE(result[5]->url(), QString("github.com"));
|
QCOMPARE(result[5]->url(), QString("github.com"));
|
||||||
QCOMPARE(result[6]->url(), QString("github.com")) ;
|
QCOMPARE(result[6]->url(), QString("github.com"));
|
||||||
|
|
||||||
// With matching there should be only 5 results
|
// With matching there should be only 5 results
|
||||||
browserSettings()->setMatchUrlScheme(true);
|
browserSettings()->setMatchUrlScheme(true);
|
||||||
result = m_browserService->searchEntries(db, "github.com", "https://github.com"); // db, hostname, url
|
result = m_browserService->searchEntries(db, "github.com", "https://github.com"); // db, hostname, url
|
||||||
QCOMPARE(result.length(), 5);
|
QCOMPARE(result.length(), 5);
|
||||||
QCOMPARE(result[0]->url(), QString("https://github.com/login_page"));
|
QCOMPARE(result[0]->url(), QString("https://github.com/login_page"));
|
||||||
QCOMPARE(result[1]->url(), QString("https://github.com/login"));
|
QCOMPARE(result[1]->url(), QString("https://github.com/login"));
|
||||||
|
@ -241,7 +240,7 @@ void TestBrowser::testSearchEntriesWithPort()
|
||||||
entry->endUpdate();
|
entry->endUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = m_browserService->searchEntries(db, "127.0.0.1", "http://127.0.0.1:443"); // db, hostname, url
|
auto result = m_browserService->searchEntries(db, "127.0.0.1", "http://127.0.0.1:443"); // db, hostname, url
|
||||||
QCOMPARE(result.length(), 1);
|
QCOMPARE(result.length(), 1);
|
||||||
QCOMPARE(result[0]->url(), QString("http://127.0.0.1:443"));
|
QCOMPARE(result[0]->url(), QString("http://127.0.0.1:443"));
|
||||||
}
|
}
|
||||||
|
@ -275,7 +274,8 @@ void TestBrowser::testSortEntries()
|
||||||
}
|
}
|
||||||
|
|
||||||
browserSettings()->setBestMatchOnly(false);
|
browserSettings()->setBestMatchOnly(false);
|
||||||
auto result = m_browserService->sortEntries(entries, "github.com", "https://github.com/session"); // entries, host, submitUrl
|
auto result =
|
||||||
|
m_browserService->sortEntries(entries, "github.com", "https://github.com/session"); // entries, host, submitUrl
|
||||||
QCOMPARE(result.size(), 10);
|
QCOMPARE(result.size(), 10);
|
||||||
QCOMPARE(result[0]->username(), QString("User 2"));
|
QCOMPARE(result[0]->username(), QString("User 2"));
|
||||||
QCOMPARE(result[0]->url(), QString("https://github.com/"));
|
QCOMPARE(result[0]->url(), QString("https://github.com/"));
|
||||||
|
@ -318,7 +318,7 @@ void TestBrowser::testGetDatabaseGroups()
|
||||||
|
|
||||||
auto result = m_browserService->getDatabaseGroups(db);
|
auto result = m_browserService->getDatabaseGroups(db);
|
||||||
QCOMPARE(result.length(), 1);
|
QCOMPARE(result.length(), 1);
|
||||||
|
|
||||||
auto groups = result["groups"].toArray();
|
auto groups = result["groups"].toArray();
|
||||||
auto first = groups.at(0);
|
auto first = groups.at(0);
|
||||||
auto children = first.toObject()["children"].toArray();
|
auto children = first.toObject()["children"].toArray();
|
||||||
|
@ -341,4 +341,4 @@ void TestBrowser::testGetDatabaseGroups()
|
||||||
auto lastChildren = firstOfCOS.toObject()["children"].toArray();
|
auto lastChildren = firstOfCOS.toObject()["children"].toArray();
|
||||||
auto lastChild = lastChildren.at(0);
|
auto lastChild = lastChildren.at(0);
|
||||||
QCOMPARE(lastChild.toObject()["name"].toString(), QString("group2_1_1"));
|
QCOMPARE(lastChild.toObject()["name"].toString(), QString("group2_1_1"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue