Add support for opening links in incognito mode on Linux & BSD (#4745)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Sam Heybey
2023-08-06 09:57:01 -04:00
committed by GitHub
parent 168f346c81
commit 69c983e0d9
18 changed files with 741 additions and 61 deletions
+62
View File
@@ -0,0 +1,62 @@
#include "util/XDGHelper.hpp"
#include <gtest/gtest.h>
#include <QDebug>
using namespace chatterino;
TEST(XDGHelper, ParseDesktopExecProgram)
{
struct TestCase {
QString input;
QString expectedOutput;
};
std::vector<TestCase> testCases{
{
// Sanity check: Ensure simple Exec lines aren't made messed with
"firefox",
"firefox",
},
{
// Simple trim after the first space
"/usr/lib/firefox/firefox %u",
"/usr/lib/firefox/firefox",
},
{
// Simple unquote
"\"/usr/lib/firefox/firefox\"",
"/usr/lib/firefox/firefox",
},
{
// Unquote + trim
"\"/usr/lib/firefox/firefox\" %u",
"/usr/lib/firefox/firefox",
},
{
// Test malformed exec key (only one quote)
"\"/usr/lib/firefox/firefox",
"/usr/lib/firefox/firefox",
},
{
// Quoted executable name with space
"\"/usr/bin/my cool browser\"",
"/usr/bin/my cool browser",
},
{
// Executable name with reserved character
"/usr/bin/\\$hadowwizardmoneybrowser",
"/usr/bin/$hadowwizardmoneybrowser",
},
};
for (const auto &test : testCases)
{
auto output = parseDesktopExecProgram(test.input);
EXPECT_EQ(output, test.expectedOutput)
<< "Input '" << test.input.toStdString() << "' failed. Expected '"
<< test.expectedOutput.toStdString() << "' but got '"
<< output.toStdString() << "'";
}
}