diff options
author | Jonathan White <support@dmapps.us> | 2017-10-03 20:11:00 +0300 |
---|---|---|
committer | Jonathan White <droidmonkey@users.noreply.github.com> | 2017-10-04 01:40:32 +0300 |
commit | 5098866413ea27378482a83b4247d5395a3faa98 (patch) | |
tree | 85eb3607bbe640c2f40e1bb768dde6a88b6b75cc /tests/TestEntry.cpp | |
parent | 91d746c5c096baeaf93a1a071cb4f7d9e0cbfaaf (diff) |
Rewrote resolveUrl function to conform to various test cases
Diffstat (limited to 'tests/TestEntry.cpp')
-rw-r--r-- | tests/TestEntry.cpp | 28 |
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; +} |