mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
ExclusivePluginQueryIgnoreDisabledTest now sets the ">" plugin's Disabled property to true in PluginMetadata. This verifies that QueryBuilder correctly ignores disabled exclusive plugins.
65 lines
2.9 KiB
C#
65 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using NUnit.Framework.Legacy;
|
|
using Flow.Launcher.Core.Plugin;
|
|
using Flow.Launcher.Plugin;
|
|
|
|
namespace Flow.Launcher.Test
|
|
{
|
|
public class QueryBuilderTest
|
|
{
|
|
[Test]
|
|
public void ExclusivePluginQueryTest()
|
|
{
|
|
var nonGlobalPlugins = new Dictionary<string, List<PluginPair>>
|
|
{
|
|
{ ">", new List<PluginPair>(){ new() { Metadata = new PluginMetadata { ActionKeywords = [">"] } } } }
|
|
};
|
|
|
|
Query q = QueryBuilder.Build("> ping google.com -n 20 -6", "> ping google.com -n 20 -6", nonGlobalPlugins);
|
|
|
|
ClassicAssert.AreEqual("> ping google.com -n 20 -6", q.TrimmedQuery);
|
|
ClassicAssert.AreEqual("ping google.com -n 20 -6", q.Search, "Search should not start with the ActionKeyword.");
|
|
ClassicAssert.AreEqual(">", q.ActionKeyword);
|
|
|
|
ClassicAssert.AreEqual(5, q.SearchTerms.Length, "The length of SearchTerms should match.");
|
|
|
|
ClassicAssert.AreEqual("ping", q.FirstSearch);
|
|
ClassicAssert.AreEqual("google.com", q.SecondSearch);
|
|
ClassicAssert.AreEqual("-n", q.ThirdSearch);
|
|
|
|
ClassicAssert.AreEqual("google.com -n 20 -6", q.SecondToEndSearch, "SecondToEndSearch should be trimmed of multiple whitespace characters");
|
|
}
|
|
|
|
[Test]
|
|
public void ExclusivePluginQueryIgnoreDisabledTest()
|
|
{
|
|
var nonGlobalPlugins = new Dictionary<string, List<PluginPair>>
|
|
{
|
|
{ ">", new List<PluginPair>(){ new() { Metadata = new PluginMetadata { ActionKeywords = [">"], Disabled = true } } } }
|
|
};
|
|
|
|
Query q = QueryBuilder.Build("> ping google.com -n 20 -6", "> ping google.com -n 20 -6", nonGlobalPlugins);
|
|
|
|
ClassicAssert.AreEqual("> ping google.com -n 20 -6", q.Search);
|
|
ClassicAssert.AreEqual(q.Search, q.TrimmedQuery, "TrimmedQuery should be equal to Search.");
|
|
ClassicAssert.AreEqual(6, q.SearchTerms.Length, "The length of SearchTerms should match.");
|
|
ClassicAssert.AreNotEqual(">", q.ActionKeyword, "ActionKeyword should not match that of a disabled plugin.");
|
|
ClassicAssert.AreEqual("ping google.com -n 20 -6", q.SecondToEndSearch, "SecondToEndSearch should be trimmed of multiple whitespace characters");
|
|
}
|
|
|
|
[Test]
|
|
public void GenericPluginQueryTest()
|
|
{
|
|
Query q = QueryBuilder.Build("file.txt file2 file3", "file.txt file2 file3", []);
|
|
|
|
ClassicAssert.AreEqual("file.txt file2 file3", q.Search);
|
|
ClassicAssert.AreEqual("", q.ActionKeyword);
|
|
|
|
ClassicAssert.AreEqual("file.txt", q.FirstSearch);
|
|
ClassicAssert.AreEqual("file2", q.SecondSearch);
|
|
ClassicAssert.AreEqual("file3", q.ThirdSearch);
|
|
ClassicAssert.AreEqual("file2 file3", q.SecondToEndSearch);
|
|
}
|
|
}
|
|
}
|