mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add unit tests for get autocomplete result
This commit is contained in:
parent
f64ebdca95
commit
3f2b741dcc
2 changed files with 65 additions and 1 deletions
|
|
@ -329,5 +329,69 @@ namespace Flow.Launcher.Test.Plugins
|
||||||
// Then
|
// Then
|
||||||
Assert.AreEqual(result, expectedResult);
|
Assert.AreEqual(result, expectedResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "q", false, false, "q somefolder")]
|
||||||
|
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "i", true, false, "p c:\\somefolder\\")]
|
||||||
|
[TestCase("somefolder", "c:\\somefolder\\", ResultType.Folder, "irrelevant", true, true, "c:\\somefolder\\")]
|
||||||
|
public void GivenQueryWithFolderTypeResult_WhenGetAutoComplete_ThenResultShouldBeExpectedString(
|
||||||
|
string title,
|
||||||
|
string path,
|
||||||
|
ResultType resultType,
|
||||||
|
string actionKeyword,
|
||||||
|
bool pathSearchKeywordEnabled,
|
||||||
|
bool searchActionKeywordEnabled,
|
||||||
|
string expectedResult)
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var query = new Query() { ActionKeyword = actionKeyword };
|
||||||
|
var settings = new Settings()
|
||||||
|
{
|
||||||
|
PathSearchKeywordEnabled = pathSearchKeywordEnabled,
|
||||||
|
PathSearchActionKeyword = "p",
|
||||||
|
SearchActionKeywordEnabled = searchActionKeywordEnabled,
|
||||||
|
SearchActionKeyword = Query.GlobalPluginWildcardSign,
|
||||||
|
QuickAccessActionKeyword = "q",
|
||||||
|
IndexSearchActionKeyword = "i"
|
||||||
|
};
|
||||||
|
ResultManager.Init(new PluginInitContext(), settings);
|
||||||
|
|
||||||
|
// When
|
||||||
|
var result = ResultManager.GetAutoCompleteText(title, query, path, resultType);
|
||||||
|
|
||||||
|
// Then
|
||||||
|
Assert.AreEqual(result, expectedResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "q", false, false, "q somefile")]
|
||||||
|
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "i", true, false, "p c:\\somefolder\\somefile")]
|
||||||
|
[TestCase("somefile", "c:\\somefolder\\somefile", ResultType.File, "irrelevant", true, true, "c:\\somefolder\\somefile")]
|
||||||
|
public void GivenQueryWithFileTypeResult_WhenGetAutoComplete_ThenResultShouldBeExpectedString(
|
||||||
|
string title,
|
||||||
|
string path,
|
||||||
|
ResultType resultType,
|
||||||
|
string actionKeyword,
|
||||||
|
bool pathSearchKeywordEnabled,
|
||||||
|
bool searchActionKeywordEnabled,
|
||||||
|
string expectedResult)
|
||||||
|
{
|
||||||
|
// Given
|
||||||
|
var query = new Query() { ActionKeyword = actionKeyword };
|
||||||
|
var settings = new Settings()
|
||||||
|
{
|
||||||
|
QuickAccessActionKeyword = "q",
|
||||||
|
IndexSearchActionKeyword = "i",
|
||||||
|
PathSearchActionKeyword = "p",
|
||||||
|
PathSearchKeywordEnabled = pathSearchKeywordEnabled,
|
||||||
|
SearchActionKeywordEnabled = searchActionKeywordEnabled,
|
||||||
|
SearchActionKeyword = Query.GlobalPluginWildcardSign
|
||||||
|
};
|
||||||
|
ResultManager.Init(new PluginInitContext(), settings);
|
||||||
|
|
||||||
|
// When
|
||||||
|
var result = ResultManager.GetAutoCompleteText(title, query, path, resultType);
|
||||||
|
|
||||||
|
// Then
|
||||||
|
Assert.AreEqual(result, expectedResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
||||||
return $"{keyword}{formatted_path}";
|
return $"{keyword}{formatted_path}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetAutoCompleteText(string title, Query query, string path, ResultType resultType)
|
public static string GetAutoCompleteText(string title, Query query, string path, ResultType resultType)
|
||||||
{
|
{
|
||||||
return !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
|
return !Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled
|
||||||
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
|
? $"{query.ActionKeyword} {title}" // Only Quick Access action keyword is used in this scenario
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue