返回 DeepSeek-Reasonix
external_opener_darwin_test.go
根目录 / desktop / external_opener_darwin_test.go
1 //go:build darwin
2
3 package main
4
5 import (
6 "reflect"
7 "strings"
8 "testing"
9 )
10
11 func TestDarwinExternalOpenersUseNativeApplicationMetadata(t *testing.T) {
12 specs := platformExternalOpenerSpecs()
13 finder, ok := externalOpenerByID(specs, "finder")
14 if !ok {
15 t.Fatal("Finder must always be present on macOS")
16 }
17 if !strings.HasSuffix(finder.IconSource, "Finder.app") {
18 t.Fatalf("Finder icon source = %q, want native application bundle", finder.IconSource)
19 }
20 if icon := externalOpenerIconDataURL(finder); !strings.HasPrefix(icon, "data:image/png;base64,") {
21 t.Fatalf("Finder native icon = %q, want PNG data URL", icon)
22 }
23 if iterm, installed := externalOpenerByID(specs, "iterm"); installed && iterm.View.Name != "iTerm2" {
24 t.Fatalf("iTerm label = %q, want official iTerm2 name", iterm.View.Name)
25 }
26 if ghostty, installed := externalOpenerByID(specs, "ghostty"); installed && ghostty.LaunchMode != "ghostty" {
27 t.Fatalf("Ghostty launch mode = %q, want working-directory aware mode", ghostty.LaunchMode)
28 } else if installed {
29 path := "/tmp/reasonix workspace"
30 want := []string{"/usr/bin/open", "-na", ghostty.Target, "--args", "--working-directory=" + path}
31 if got := darwinExternalOpenerCommand(ghostty, path).Args; !reflect.DeepEqual(got, want) {
32 t.Fatalf("Ghostty command = %#v, want %#v", got, want)
33 }
34 }
35 }
36
37 func TestDarwinCatalogIncludesInstalledCodexApplications(t *testing.T) {
38 installed := darwinInstalledApplicationIndex()
39 specs := platformExternalOpenerSpecs()
40 for appName, id := range map[string]string{
41 "xcode": "xcode",
42 "android studio": "android-studio",
43 "pycharm": "pycharm",
44 } {
45 if installed[appName] == "" {
46 continue
47 }
48 if _, ok := externalOpenerByID(specs, id); !ok {
49 t.Errorf("installed %s is missing from external opener catalog", appName)
50 }
51 }
52 }
53
54 func TestDarwinInstalledOpenersExposeNativeIcons(t *testing.T) {
55 for _, spec := range platformExternalOpenerSpecs() {
56 if spec.IconSource == "" {
57 t.Errorf("%s has no native icon source", spec.View.Name)
58 continue
59 }
60 if icon := externalOpenerIconDataURL(spec); !strings.HasPrefix(icon, "data:image/png;base64,") {
61 t.Errorf("%s native icon could not be extracted", spec.View.Name)
62 }
63 }
64 }
65
65 lines GO