test: remove outdated keyboard_bridge_test.go
The test referenced removed routing table variables that no longer exist in the refactored keyboard bridge implementation.
- commit
- 1d9c4ceca025537065076354ef8504036fad0544
- author
- bamen · · 2025-10-14 19:09 UTC
- parent
- bea0cdf
- signature
- unsigned
1 file · +0 -205
D pkg/webkit/keyboard_bridge_test.go +0 -205
| @@ -1,205 +0,0 @@ | |||
| 1 | - | package webkit | |
| 2 | - | ||
| 3 | - | import ( | |
| 4 | - | "testing" | |
| 5 | - | ) | |
| 6 | - | ||
| 7 | - | // TestShortcutRoutingTable verifies the routing table configuration | |
| 8 | - | func TestShortcutRoutingTable(t *testing.T) { | |
| 9 | - | tests := []struct { | |
| 10 | - | shortcut string | |
| 11 | - | expectEntry bool | |
| 12 | - | forwardToJS bool | |
| 13 | - | blockWebKit bool | |
| 14 | - | description string | |
| 15 | - | }{ | |
| 16 | - | { | |
| 17 | - | shortcut: "alt+arrowup", | |
| 18 | - | expectEntry: true, | |
| 19 | - | forwardToJS: false, | |
| 20 | - | blockWebKit: true, | |
| 21 | - | description: "Navigate to upper pane (callback handler)", | |
| 22 | - | }, | |
| 23 | - | { | |
| 24 | - | shortcut: "alt+arrowdown", | |
| 25 | - | expectEntry: true, | |
| 26 | - | forwardToJS: false, | |
| 27 | - | blockWebKit: true, | |
| 28 | - | description: "Navigate to lower pane (callback handler)", | |
| 29 | - | }, | |
| 30 | - | { | |
| 31 | - | shortcut: "alt+arrowleft", | |
| 32 | - | expectEntry: true, | |
| 33 | - | forwardToJS: false, | |
| 34 | - | blockWebKit: true, | |
| 35 | - | description: "Navigate to left pane (callback handler)", | |
| 36 | - | }, | |
| 37 | - | { | |
| 38 | - | shortcut: "alt+arrowright", | |
| 39 | - | expectEntry: true, | |
| 40 | - | forwardToJS: false, | |
| 41 | - | blockWebKit: true, | |
| 42 | - | description: "Navigate to right pane (callback handler)", | |
| 43 | - | }, | |
| 44 | - | { | |
| 45 | - | shortcut: "cmdorctrl+p", | |
| 46 | - | expectEntry: true, | |
| 47 | - | forwardToJS: true, | |
| 48 | - | blockWebKit: true, | |
| 49 | - | description: "Enter pane mode (JS handler + block print dialog)", | |
| 50 | - | }, | |
| 51 | - | { | |
| 52 | - | shortcut: "cmdorctrl+l", | |
| 53 | - | expectEntry: false, // Not in table, should use default | |
| 54 | - | forwardToJS: true, | |
| 55 | - | blockWebKit: false, | |
| 56 | - | description: "Default routing", | |
| 57 | - | }, | |
| 58 | - | } | |
| 59 | - | ||
| 60 | - | for _, tt := range tests { | |
| 61 | - | t.Run(tt.shortcut, func(t *testing.T) { | |
| 62 | - | routing, exists := shortcutRoutingTable[tt.shortcut] | |
| 63 | - | ||
| 64 | - | if tt.expectEntry { | |
| 65 | - | if !exists { | |
| 66 | - | t.Errorf("Expected routing entry for %s but not found", tt.shortcut) | |
| 67 | - | return | |
| 68 | - | } | |
| 69 | - | ||
| 70 | - | if routing.forwardToJS != tt.forwardToJS { | |
| 71 | - | t.Errorf("forwardToJS: got %v, want %v", routing.forwardToJS, tt.forwardToJS) | |
| 72 | - | } | |
| 73 | - | ||
| 74 | - | if routing.blockWebKit != tt.blockWebKit { | |
| 75 | - | t.Errorf("blockWebKit: got %v, want %v", routing.blockWebKit, tt.blockWebKit) | |
| 76 | - | } | |
| 77 | - | ||
| 78 | - | if routing.description != tt.description { | |
| 79 | - | t.Errorf("description: got %q, want %q", routing.description, tt.description) | |
| 80 | - | } | |
| 81 | - | } else { | |
| 82 | - | if exists { | |
| 83 | - | t.Errorf("Expected no routing entry for %s but found one", tt.shortcut) | |
| 84 | - | } | |
| 85 | - | } | |
| 86 | - | }) | |
| 87 | - | } | |
| 88 | - | } | |
| 89 | - | ||
| 90 | - | // TestDefaultRouting verifies the default routing behavior | |
| 91 | - | func TestDefaultRouting(t *testing.T) { | |
| 92 | - | if defaultRouting.forwardToJS != true { | |
| 93 | - | t.Errorf("defaultRouting.forwardToJS: got %v, want true", defaultRouting.forwardToJS) | |
| 94 | - | } | |
| 95 | - | ||
| 96 | - | if defaultRouting.blockWebKit != false { | |
| 97 | - | t.Errorf("defaultRouting.blockWebKit: got %v, want false", defaultRouting.blockWebKit) | |
| 98 | - | } | |
| 99 | - | } | |
| 100 | - | ||
| 101 | - | // TestWorkspaceNavigationShortcuts verifies workspace navigation shortcuts block WebKit | |
| 102 | - | func TestWorkspaceNavigationShortcuts(t *testing.T) { | |
| 103 | - | workspaceShortcuts := []string{ | |
| 104 | - | "alt+arrowup", | |
| 105 | - | "alt+arrowdown", | |
| 106 | - | "alt+arrowleft", | |
| 107 | - | "alt+arrowright", | |
| 108 | - | } | |
| 109 | - | ||
| 110 | - | for _, shortcut := range workspaceShortcuts { | |
| 111 | - | t.Run(shortcut, func(t *testing.T) { | |
| 112 | - | routing, exists := shortcutRoutingTable[shortcut] | |
| 113 | - | ||
| 114 | - | if !exists { | |
| 115 | - | t.Fatalf("Workspace navigation shortcut %s not found in routing table", shortcut) | |
| 116 | - | } | |
| 117 | - | ||
| 118 | - | // These shortcuts must block WebKit to prevent page scrolling | |
| 119 | - | if !routing.blockWebKit { | |
| 120 | - | t.Errorf("Workspace navigation shortcut %s must block WebKit (got blockWebKit=%v)", | |
| 121 | - | shortcut, routing.blockWebKit) | |
| 122 | - | } | |
| 123 | - | ||
| 124 | - | // These shortcuts should NOT forward to JS (handled by callback) | |
| 125 | - | if routing.forwardToJS { | |
| 126 | - | t.Errorf("Workspace navigation shortcut %s should not forward to JS (got forwardToJS=%v)", | |
| 127 | - | shortcut, routing.forwardToJS) | |
| 128 | - | } | |
| 129 | - | }) | |
| 130 | - | } | |
| 131 | - | } | |
| 132 | - | ||
| 133 | - | // TestConvertToGtkFormat tests the key format conversion | |
| 134 | - | func TestConvertToGtkFormat(t *testing.T) { | |
| 135 | - | tests := []struct { | |
| 136 | - | input string | |
| 137 | - | expected string | |
| 138 | - | }{ | |
| 139 | - | {"ctrl+l", "<Control>l"}, | |
| 140 | - | {"ctrl+plus", "<Control>plus"}, | |
| 141 | - | {"ctrl+shift+c", "<Control><Shift>c"}, | |
| 142 | - | {"alt+arrowleft", "<Alt>Left"}, | |
| 143 | - | {"alt+arrowright", "<Alt>Right"}, | |
| 144 | - | {"alt+arrowup", "<Alt>Up"}, | |
| 145 | - | {"alt+arrowdown", "<Alt>Down"}, | |
| 146 | - | {"cmdorctrl+p", "<Control>p"}, | |
| 147 | - | {"F12", "F12"}, | |
| 148 | - | {"ctrl+0", "<Control>0"}, | |
| 149 | - | } | |
| 150 | - | ||
| 151 | - | for _, tt := range tests { | |
| 152 | - | t.Run(tt.input, func(t *testing.T) { | |
| 153 | - | result := convertToGtkFormat(tt.input) | |
| 154 | - | if result != tt.expected { | |
| 155 | - | t.Errorf("convertToGtkFormat(%q) = %q, want %q", tt.input, result, tt.expected) | |
| 156 | - | } | |
| 157 | - | }) | |
| 158 | - | } | |
| 159 | - | } | |
| 160 | - | ||
| 161 | - | // TestKeyNameConstants verifies key name constants are properly defined | |
| 162 | - | func TestKeyNameConstants(t *testing.T) { | |
| 163 | - | expectedKeys := map[string]string{ | |
| 164 | - | "keyP": "p", | |
| 165 | - | "keyL": "l", | |
| 166 | - | "keyF": "f", | |
| 167 | - | "keyC": "c", | |
| 168 | - | "keyW": "w", | |
| 169 | - | "keyR": "r", | |
| 170 | - | "keyArrowLeft": "arrowleft", | |
| 171 | - | "keyArrowRight": "arrowright", | |
| 172 | - | "keyArrowUp": "arrowup", | |
| 173 | - | "keyArrowDown": "arrowdown", | |
| 174 | - | "keyF12": "F12", | |
| 175 | - | "keyPlus": "plus", | |
| 176 | - | "keyMinus": "minus", | |
| 177 | - | "keyZero": "0", | |
| 178 | - | } | |
| 179 | - | ||
| 180 | - | // Verify constants exist and have expected values | |
| 181 | - | keys := map[string]string{ | |
| 182 | - | "keyP": keyP, | |
| 183 | - | "keyL": keyL, | |
| 184 | - | "keyF": keyF, | |
| 185 | - | "keyC": keyC, | |
| 186 | - | "keyW": keyW, | |
| 187 | - | "keyR": keyR, | |
| 188 | - | "keyArrowLeft": keyArrowLeft, | |
| 189 | - | "keyArrowRight": keyArrowRight, | |
| 190 | - | "keyArrowUp": keyArrowUp, | |
| 191 | - | "keyArrowDown": keyArrowDown, | |
| 192 | - | "keyF12": keyF12, | |
| 193 | - | "keyPlus": keyPlus, | |
| 194 | - | "keyMinus": keyMinus, | |
| 195 | - | "keyZero": keyZero, | |
| 196 | - | } | |
| 197 | - | ||
| 198 | - | for name, expected := range expectedKeys { | |
| 199 | - | if actual, ok := keys[name]; !ok { | |
| 200 | - | t.Errorf("Constant %s not found", name) | |
| 201 | - | } else if actual != expected { | |
| 202 | - | t.Errorf("Constant %s: got %q, want %q", name, actual, expected) | |
| 203 | - | } | |
| 204 | - | } | |
| 205 | - | } | |
| @@ -1,205 +0,0 @@ | |||||
| 1 | - | package webkit | |||
| 2 | - | ||||
| 3 | - | import ( | |||
| 4 | - | "testing" | |||
| 5 | - | ) | |||
| 6 | - | ||||
| 7 | - | // TestShortcutRoutingTable verifies the routing table configuration | |||
| 8 | - | func TestShortcutRoutingTable(t *testing.T) { | |||
| 9 | - | tests := []struct { | |||
| 10 | - | shortcut string | |||
| 11 | - | expectEntry bool | |||
| 12 | - | forwardToJS bool | |||
| 13 | - | blockWebKit bool | |||
| 14 | - | description string | |||
| 15 | - | }{ | |||
| 16 | - | { | |||
| 17 | - | shortcut: "alt+arrowup", | |||
| 18 | - | expectEntry: true, | |||
| 19 | - | forwardToJS: false, | |||
| 20 | - | blockWebKit: true, | |||
| 21 | - | description: "Navigate to upper pane (callback handler)", | |||
| 22 | - | }, | |||
| 23 | - | { | |||
| 24 | - | shortcut: "alt+arrowdown", | |||
| 25 | - | expectEntry: true, | |||
| 26 | - | forwardToJS: false, | |||
| 27 | - | blockWebKit: true, | |||
| 28 | - | description: "Navigate to lower pane (callback handler)", | |||
| 29 | - | }, | |||
| 30 | - | { | |||
| 31 | - | shortcut: "alt+arrowleft", | |||
| 32 | - | expectEntry: true, | |||
| 33 | - | forwardToJS: false, | |||
| 34 | - | blockWebKit: true, | |||
| 35 | - | description: "Navigate to left pane (callback handler)", | |||
| 36 | - | }, | |||
| 37 | - | { | |||
| 38 | - | shortcut: "alt+arrowright", | |||
| 39 | - | expectEntry: true, | |||
| 40 | - | forwardToJS: false, | |||
| 41 | - | blockWebKit: true, | |||
| 42 | - | description: "Navigate to right pane (callback handler)", | |||
| 43 | - | }, | |||
| 44 | - | { | |||
| 45 | - | shortcut: "cmdorctrl+p", | |||
| 46 | - | expectEntry: true, | |||
| 47 | - | forwardToJS: true, | |||
| 48 | - | blockWebKit: true, | |||
| 49 | - | description: "Enter pane mode (JS handler + block print dialog)", | |||
| 50 | - | }, | |||
| 51 | - | { | |||
| 52 | - | shortcut: "cmdorctrl+l", | |||
| 53 | - | expectEntry: false, // Not in table, should use default | |||
| 54 | - | forwardToJS: true, | |||
| 55 | - | blockWebKit: false, | |||
| 56 | - | description: "Default routing", | |||
| 57 | - | }, | |||
| 58 | - | } | |||
| 59 | - | ||||
| 60 | - | for _, tt := range tests { | |||
| 61 | - | t.Run(tt.shortcut, func(t *testing.T) { | |||
| 62 | - | routing, exists := shortcutRoutingTable[tt.shortcut] | |||
| 63 | - | ||||
| 64 | - | if tt.expectEntry { | |||
| 65 | - | if !exists { | |||
| 66 | - | t.Errorf("Expected routing entry for %s but not found", tt.shortcut) | |||
| 67 | - | return | |||
| 68 | - | } | |||
| 69 | - | ||||
| 70 | - | if routing.forwardToJS != tt.forwardToJS { | |||
| 71 | - | t.Errorf("forwardToJS: got %v, want %v", routing.forwardToJS, tt.forwardToJS) | |||
| 72 | - | } | |||
| 73 | - | ||||
| 74 | - | if routing.blockWebKit != tt.blockWebKit { | |||
| 75 | - | t.Errorf("blockWebKit: got %v, want %v", routing.blockWebKit, tt.blockWebKit) | |||
| 76 | - | } | |||
| 77 | - | ||||
| 78 | - | if routing.description != tt.description { | |||
| 79 | - | t.Errorf("description: got %q, want %q", routing.description, tt.description) | |||
| 80 | - | } | |||
| 81 | - | } else { | |||
| 82 | - | if exists { | |||
| 83 | - | t.Errorf("Expected no routing entry for %s but found one", tt.shortcut) | |||
| 84 | - | } | |||
| 85 | - | } | |||
| 86 | - | }) | |||
| 87 | - | } | |||
| 88 | - | } | |||
| 89 | - | ||||
| 90 | - | // TestDefaultRouting verifies the default routing behavior | |||
| 91 | - | func TestDefaultRouting(t *testing.T) { | |||
| 92 | - | if defaultRouting.forwardToJS != true { | |||
| 93 | - | t.Errorf("defaultRouting.forwardToJS: got %v, want true", defaultRouting.forwardToJS) | |||
| 94 | - | } | |||
| 95 | - | ||||
| 96 | - | if defaultRouting.blockWebKit != false { | |||
| 97 | - | t.Errorf("defaultRouting.blockWebKit: got %v, want false", defaultRouting.blockWebKit) | |||
| 98 | - | } | |||
| 99 | - | } | |||
| 100 | - | ||||
| 101 | - | // TestWorkspaceNavigationShortcuts verifies workspace navigation shortcuts block WebKit | |||
| 102 | - | func TestWorkspaceNavigationShortcuts(t *testing.T) { | |||
| 103 | - | workspaceShortcuts := []string{ | |||
| 104 | - | "alt+arrowup", | |||
| 105 | - | "alt+arrowdown", | |||
| 106 | - | "alt+arrowleft", | |||
| 107 | - | "alt+arrowright", | |||
| 108 | - | } | |||
| 109 | - | ||||
| 110 | - | for _, shortcut := range workspaceShortcuts { | |||
| 111 | - | t.Run(shortcut, func(t *testing.T) { | |||
| 112 | - | routing, exists := shortcutRoutingTable[shortcut] | |||
| 113 | - | ||||
| 114 | - | if !exists { | |||
| 115 | - | t.Fatalf("Workspace navigation shortcut %s not found in routing table", shortcut) | |||
| 116 | - | } | |||
| 117 | - | ||||
| 118 | - | // These shortcuts must block WebKit to prevent page scrolling | |||
| 119 | - | if !routing.blockWebKit { | |||
| 120 | - | t.Errorf("Workspace navigation shortcut %s must block WebKit (got blockWebKit=%v)", | |||
| 121 | - | shortcut, routing.blockWebKit) | |||
| 122 | - | } | |||
| 123 | - | ||||
| 124 | - | // These shortcuts should NOT forward to JS (handled by callback) | |||
| 125 | - | if routing.forwardToJS { | |||
| 126 | - | t.Errorf("Workspace navigation shortcut %s should not forward to JS (got forwardToJS=%v)", | |||
| 127 | - | shortcut, routing.forwardToJS) | |||
| 128 | - | } | |||
| 129 | - | }) | |||
| 130 | - | } | |||
| 131 | - | } | |||
| 132 | - | ||||
| 133 | - | // TestConvertToGtkFormat tests the key format conversion | |||
| 134 | - | func TestConvertToGtkFormat(t *testing.T) { | |||
| 135 | - | tests := []struct { | |||
| 136 | - | input string | |||
| 137 | - | expected string | |||
| 138 | - | }{ | |||
| 139 | - | {"ctrl+l", "<Control>l"}, | |||
| 140 | - | {"ctrl+plus", "<Control>plus"}, | |||
| 141 | - | {"ctrl+shift+c", "<Control><Shift>c"}, | |||
| 142 | - | {"alt+arrowleft", "<Alt>Left"}, | |||
| 143 | - | {"alt+arrowright", "<Alt>Right"}, | |||
| 144 | - | {"alt+arrowup", "<Alt>Up"}, | |||
| 145 | - | {"alt+arrowdown", "<Alt>Down"}, | |||
| 146 | - | {"cmdorctrl+p", "<Control>p"}, | |||
| 147 | - | {"F12", "F12"}, | |||
| 148 | - | {"ctrl+0", "<Control>0"}, | |||
| 149 | - | } | |||
| 150 | - | ||||
| 151 | - | for _, tt := range tests { | |||
| 152 | - | t.Run(tt.input, func(t *testing.T) { | |||
| 153 | - | result := convertToGtkFormat(tt.input) | |||
| 154 | - | if result != tt.expected { | |||
| 155 | - | t.Errorf("convertToGtkFormat(%q) = %q, want %q", tt.input, result, tt.expected) | |||
| 156 | - | } | |||
| 157 | - | }) | |||
| 158 | - | } | |||
| 159 | - | } | |||
| 160 | - | ||||
| 161 | - | // TestKeyNameConstants verifies key name constants are properly defined | |||
| 162 | - | func TestKeyNameConstants(t *testing.T) { | |||
| 163 | - | expectedKeys := map[string]string{ | |||
| 164 | - | "keyP": "p", | |||
| 165 | - | "keyL": "l", | |||
| 166 | - | "keyF": "f", | |||
| 167 | - | "keyC": "c", | |||
| 168 | - | "keyW": "w", | |||
| 169 | - | "keyR": "r", | |||
| 170 | - | "keyArrowLeft": "arrowleft", | |||
| 171 | - | "keyArrowRight": "arrowright", | |||
| 172 | - | "keyArrowUp": "arrowup", | |||
| 173 | - | "keyArrowDown": "arrowdown", | |||
| 174 | - | "keyF12": "F12", | |||
| 175 | - | "keyPlus": "plus", | |||
| 176 | - | "keyMinus": "minus", | |||
| 177 | - | "keyZero": "0", | |||
| 178 | - | } | |||
| 179 | - | ||||
| 180 | - | // Verify constants exist and have expected values | |||
| 181 | - | keys := map[string]string{ | |||
| 182 | - | "keyP": keyP, | |||
| 183 | - | "keyL": keyL, | |||
| 184 | - | "keyF": keyF, | |||
| 185 | - | "keyC": keyC, | |||
| 186 | - | "keyW": keyW, | |||
| 187 | - | "keyR": keyR, | |||
| 188 | - | "keyArrowLeft": keyArrowLeft, | |||
| 189 | - | "keyArrowRight": keyArrowRight, | |||
| 190 | - | "keyArrowUp": keyArrowUp, | |||
| 191 | - | "keyArrowDown": keyArrowDown, | |||
| 192 | - | "keyF12": keyF12, | |||
| 193 | - | "keyPlus": keyPlus, | |||
| 194 | - | "keyMinus": keyMinus, | |||
| 195 | - | "keyZero": keyZero, | |||
| 196 | - | } | |||
| 197 | - | ||||
| 198 | - | for name, expected := range expectedKeys { | |||
| 199 | - | if actual, ok := keys[name]; !ok { | |||
| 200 | - | t.Errorf("Constant %s not found", name) | |||
| 201 | - | } else if actual != expected { | |||
| 202 | - | t.Errorf("Constant %s: got %q, want %q", name, actual, expected) | |||
| 203 | - | } | |||
| 204 | - | } | |||
| 205 | - | } | |||