Skip to content

Commit

Permalink
Run code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Jun 18, 2019
1 parent 09181fa commit 1e915ee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
14 changes: 7 additions & 7 deletions src/browser/BrowserAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,13 @@ QString BrowserAction::getErrorMessage(const int errorCode) const

QString BrowserAction::getReturnValue(const BrowserService::ReturnValue returnValue) const
{
switch(returnValue) {
case BrowserService::ReturnValue::Success:
return QString("success");
case BrowserService::ReturnValue::Error:
return QString("error");
case BrowserService::ReturnValue::Canceled:
return QString("canceled");
switch (returnValue) {
case BrowserService::ReturnValue::Success:
return QString("success");
case BrowserService::ReturnValue::Error:
return QString("error");
case BrowserService::ReturnValue::Canceled:
return QString("canceled");
}
return QString("error");
}
Expand Down
18 changes: 8 additions & 10 deletions src/browser/BrowserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void BrowserService::addEntry(const QString& id,

auto db = selectedDb ? selectedDb : selectedDatabase();
if (!db) {
return;
return;
}

auto* entry = new Entry();
Expand Down Expand Up @@ -489,13 +489,12 @@ void BrowserService::addEntry(const QString& id,
config.save(entry);
}

BrowserService::ReturnValue
BrowserService::updateEntry(const QString& id,
const QString& uuid,
const QString& login,
const QString& password,
const QString& url,
const QString& submitUrl)
BrowserService::ReturnValue BrowserService::updateEntry(const QString& id,
const QString& uuid,
const QString& login,
const QString& password,
const QString& url,
const QString& submitUrl)
{
ReturnValue result = ReturnValue::Error;
if (thread() != QThread::currentThread()) {
Expand Down Expand Up @@ -877,8 +876,7 @@ Group* BrowserService::getDefaultEntryGroup(const QSharedPointer<Database>& sele
return nullptr;
}

const QString groupName =
QLatin1String(KEEPASSXCBROWSER_GROUP_NAME);
const QString groupName = QLatin1String(KEEPASSXCBROWSER_GROUP_NAME);

for (auto* g : rootGroup->groupsRecursive(true)) {
if (g->name() == groupName && !g->isRecycled()) {
Expand Down
20 changes: 10 additions & 10 deletions tests/TestBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

#include "TestBrowser.h"
#include "TestGlobal.h"
#include "browser/BrowserSettings.h"
#include "crypto/Crypto.h"
#include "sodium/crypto_box.h"
#include "browser/BrowserSettings.h"
#include <QString>

QTEST_GUILESS_MAIN(TestBrowser)
Expand All @@ -40,7 +40,6 @@ void TestBrowser::initTestCase()

void TestBrowser::cleanupTestCase()
{

}

/**
Expand Down Expand Up @@ -87,7 +86,7 @@ void TestBrowser::testDecryptMessage()
void TestBrowser::testGetBase64FromKey()
{
unsigned char pk[crypto_box_PUBLICKEYBYTES];

for (unsigned int i = 0; i < crypto_box_PUBLICKEYBYTES; ++i) {
pk[i] = i;
}
Expand Down Expand Up @@ -202,19 +201,19 @@ void TestBrowser::testSearchEntries()
}

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[0]->url(), QString("https://github.com/login_page"));
QCOMPARE(result[1]->url(), QString("https://github.com/login"));
QCOMPARE(result[2]->url(), QString("https://github.com/"));
QCOMPARE(result[3]->url(), QString("http://github.com"));
QCOMPARE(result[4]->url(), QString("https://github.com/login"));
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
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[0]->url(), QString("https://github.com/login_page"));
QCOMPARE(result[1]->url(), QString("https://github.com/login"));
Expand All @@ -241,7 +240,7 @@ void TestBrowser::testSearchEntriesWithPort()
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[0]->url(), QString("http://127.0.0.1:443"));
}
Expand Down Expand Up @@ -275,7 +274,8 @@ void TestBrowser::testSortEntries()
}

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[0]->username(), QString("User 2"));
QCOMPARE(result[0]->url(), QString("https://github.com/"));
Expand Down Expand Up @@ -318,7 +318,7 @@ void TestBrowser::testGetDatabaseGroups()

auto result = m_browserService->getDatabaseGroups(db);
QCOMPARE(result.length(), 1);

auto groups = result["groups"].toArray();
auto first = groups.at(0);
auto children = first.toObject()["children"].toArray();
Expand All @@ -341,4 +341,4 @@ void TestBrowser::testGetDatabaseGroups()
auto lastChildren = firstOfCOS.toObject()["children"].toArray();
auto lastChild = lastChildren.at(0);
QCOMPARE(lastChild.toObject()["name"].toString(), QString("group2_1_1"));
}
}

0 comments on commit 1e915ee

Please sign in to comment.