fix: enable browser executable selection
This commit is contained in:
@@ -428,6 +428,81 @@ func TestShellAppliesLatestPathSearchResult(t *testing.T) {
|
||||
if got := shell.chromePath.Text(); got != `C:\Browser\chrome.exe` {
|
||||
t.Fatalf("chrome path = %q", got)
|
||||
}
|
||||
if got := shell.pathFieldFeedback[PathChromeExecutable]; !strings.Contains(got, "已找到") {
|
||||
t.Fatalf("chrome path feedback = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellConfirmsMatchingPathSearchResultNearItsField(t *testing.T) {
|
||||
shell := NewShell(material.NewTheme())
|
||||
shell.chromePath.SetText(`C:\Browser\chrome.exe`)
|
||||
shell.OnPathSearch(func(context.Context, PathField, string) (string, error) {
|
||||
return `C:\Browser\chrome.exe`, nil
|
||||
}, nil)
|
||||
shell.togglePathSearch(PathChromeExecutable)
|
||||
var result pathSearchResult
|
||||
select {
|
||||
case result = <-shell.searchResults:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("search did not produce a result")
|
||||
}
|
||||
shell.searchResults <- result
|
||||
shell.consumeSearchResults()
|
||||
if got := shell.pathFieldFeedback[PathChromeExecutable]; !strings.Contains(got, "已确认") || !strings.Contains(got, "当前路径可用") {
|
||||
t.Fatalf("chrome path feedback = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellAppliesSelectedExecutableToOnlyRequestedField(t *testing.T) {
|
||||
shell := NewShell(material.NewTheme())
|
||||
oldEdge := shell.edgePath.Text()
|
||||
shell.OnChooseExecutable(func(context.Context) (string, error) {
|
||||
return `C:\Browser\chrome.exe`, nil
|
||||
}, nil)
|
||||
shell.chooseExecutable(PathChromeExecutable)
|
||||
if got := shell.pathPickButtonLabel(PathChromeExecutable); got != "选择中…" {
|
||||
t.Fatalf("chrome picker label = %q", got)
|
||||
}
|
||||
var result executablePickResult
|
||||
select {
|
||||
case result = <-shell.executableResults:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("executable picker did not produce a result")
|
||||
}
|
||||
shell.executableResults <- result
|
||||
shell.consumeExecutableResults()
|
||||
if got := shell.chromePath.Text(); got != `C:\Browser\chrome.exe` {
|
||||
t.Fatalf("chrome path = %q", got)
|
||||
}
|
||||
if got := shell.edgePath.Text(); got != oldEdge {
|
||||
t.Fatalf("edge path was unexpectedly changed to %q", got)
|
||||
}
|
||||
if got := shell.pathFieldFeedback[PathChromeExecutable]; !strings.Contains(got, "已选择") {
|
||||
t.Fatalf("chrome picker feedback = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellKeepsExecutableInputWhenSelectionIsCanceled(t *testing.T) {
|
||||
shell := NewShell(material.NewTheme())
|
||||
shell.chromePath.SetText(`C:\Browser\keep.exe`)
|
||||
shell.OnChooseExecutable(func(context.Context) (string, error) {
|
||||
return "", context.Canceled
|
||||
}, nil)
|
||||
shell.chooseExecutable(PathChromeExecutable)
|
||||
var result executablePickResult
|
||||
select {
|
||||
case result = <-shell.executableResults:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("executable picker did not produce a result")
|
||||
}
|
||||
shell.executableResults <- result
|
||||
shell.consumeExecutableResults()
|
||||
if got := shell.chromePath.Text(); got != `C:\Browser\keep.exe` {
|
||||
t.Fatalf("canceled picker changed chrome path to %q", got)
|
||||
}
|
||||
if got := shell.pathFieldFeedback[PathChromeExecutable]; !strings.Contains(got, "已取消") {
|
||||
t.Fatalf("chrome picker feedback = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellSettingsCanBeRestored(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user