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:
@@ -4,6 +4,7 @@ option(CHATTERINO_TEST_USE_PUBLIC_HTTPBIN "Use public httpbin for testing networ
|
||||
|
||||
set(test_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/resources/test-resources.qrc
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/ChannelChatters.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/AccessGuard.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/NetworkCommon.cpp
|
||||
@@ -31,6 +32,8 @@ set(test_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/LinkParser.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/InputCompletion.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/Literals.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/XDGDesktopFile.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/XDGHelper.cpp
|
||||
# Add your new file above this line!
|
||||
)
|
||||
|
||||
@@ -62,4 +65,9 @@ if(CHATTERINO_TEST_USE_PUBLIC_HTTPBIN)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE CHATTERINO_TEST_USE_PUBLIC_HTTPBIN)
|
||||
endif()
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
AUTORCC ON
|
||||
)
|
||||
|
||||
gtest_discover_tests(${PROJECT_NAME})
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
thisshould=beignored
|
||||
# this is a comment
|
||||
|
||||
[test]
|
||||
foo=bar
|
||||
# cool comment 😂
|
||||
zoo=zar
|
||||
|
||||
[Default Applications]
|
||||
lol=
|
||||
x-scheme-handler/http=firefox.desktop
|
||||
x-scheme-handler/https=firefox.desktop
|
||||
x-scheme-handler/chrome=firefox.desktop
|
||||
text/html=firefox.desktop
|
||||
application/x-extension-htm=firefox.desktop
|
||||
application/x-extension-html=firefox.desktop
|
||||
application/x-extension-shtml=firefox.desktop
|
||||
application/xhtml+xml=firefox.desktop
|
||||
application/x-extension-xhtml=firefox.desktop
|
||||
application/x-extension-xht=firefox.desktop
|
||||
|
||||
[Added Associations]
|
||||
x-scheme-handler/http=firefox.desktop;
|
||||
x-scheme-handler/https=firefox.desktop;
|
||||
x-scheme-handler/chrome=firefox.desktop;
|
||||
text/html=firefox.desktop;
|
||||
application/x-extension-htm=firefox.desktop;
|
||||
application/x-extension-html=firefox.desktop;
|
||||
application/x-extension-shtml=firefox.desktop;
|
||||
application/xhtml+xml=firefox.desktop;
|
||||
application/x-extension-xhtml=firefox.desktop;
|
||||
application/x-extension-xht=firefox.desktop;
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>001-mimeapps.list</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "util/XDGDesktopFile.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace chatterino;
|
||||
|
||||
TEST(XDGDesktopFile, String)
|
||||
{
|
||||
auto desktopFile = XDGDesktopFile(":/001-mimeapps.list");
|
||||
auto entries = desktopFile.getEntries("Default Applications");
|
||||
|
||||
ASSERT_EQ(entries["thisshould"], "");
|
||||
|
||||
ASSERT_EQ(entries["lol"], "");
|
||||
ASSERT_EQ(entries["x-scheme-handler/http"], QString("firefox.desktop"));
|
||||
|
||||
ASSERT_EQ(desktopFile.getEntries("test").size(), 2);
|
||||
}
|
||||
@@ -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() << "'";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user