Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2017-10-03 20:11:00 +0300
committerJonathan White <droidmonkey@users.noreply.github.com>2017-10-04 01:40:32 +0300
commit5098866413ea27378482a83b4247d5395a3faa98 (patch)
tree85eb3607bbe640c2f40e1bb768dde6a88b6b75cc /tests/TestEntry.cpp
parent91d746c5c096baeaf93a1a071cb4f7d9e0cbfaaf (diff)
Rewrote resolveUrl function to conform to various test cases
Diffstat (limited to 'tests/TestEntry.cpp')
-rw-r--r--tests/TestEntry.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/TestEntry.cpp b/tests/TestEntry.cpp
index 4d34cf31b..84ad03181 100644
--- a/tests/TestEntry.cpp
+++ b/tests/TestEntry.cpp
@@ -16,6 +16,7 @@
*/
#include "TestEntry.h"
+#include "config-keepassx-tests.h"
#include <QTest>
@@ -130,3 +131,30 @@ void TestEntry::testClone()
delete entryOrg;
}
+
+void TestEntry::testResolveUrl()
+{
+ Entry* entry = new Entry();
+ QString testUrl("www.google.com");
+ QString testCmd("cmd://firefox " + testUrl);
+ QString testComplexCmd("cmd://firefox --start-now --url 'http://" + testUrl + "' --quit");
+ QString nonHttpUrl("ftp://google.com");
+ QString noUrl("random text inserted here");
+
+ // Test standard URL's
+ QCOMPARE(entry->resolveUrl(""), QString(""));
+ QCOMPARE(entry->resolveUrl(testUrl), "https://" + testUrl);
+ QCOMPARE(entry->resolveUrl("http://" + testUrl), "http://" + testUrl);
+ // Test cmd:// with no URL
+ QCOMPARE(entry->resolveUrl("cmd://firefox"), QString(""));
+ QCOMPARE(entry->resolveUrl("cmd://firefox --no-url"), QString(""));
+ // Test cmd:// with URL's
+ QCOMPARE(entry->resolveUrl(testCmd), "https://" + testUrl);
+ QCOMPARE(entry->resolveUrl(testComplexCmd), "http://" + testUrl);
+ // Test non-http URL
+ QCOMPARE(entry->resolveUrl(nonHttpUrl), QString(""));
+ // Test no URL
+ QCOMPARE(entry->resolveUrl(noUrl), QString(""));
+
+ delete entry;
+}