diff --git a/tests/e2e/select-input-source.swift b/tests/e2e/select-input-source.swift new file mode 100644 index 00000000000..fe8ecf52258 --- /dev/null +++ b/tests/e2e/select-input-source.swift @@ -0,0 +1,14 @@ +import Carbon + +guard CommandLine.arguments.count == 2 else { + exit(2) +} + +let properties = [kTISPropertyInputSourceID: CommandLine.arguments[1] as CFString] as CFDictionary +let sources = TISCreateInputSourceList(properties, true).takeRetainedValue() as! [TISInputSource] +guard let source = sources.first else { + exit(3) +} + +TISEnableInputSource(source) +exit(TISSelectInputSource(source) == noErr ? 0 : 4) diff --git a/tests/e2e/terminal-macos-automatic-period-native.spec.ts b/tests/e2e/terminal-macos-automatic-period-native.spec.ts index 18b1d0d369f..be0e735b18d 100644 --- a/tests/e2e/terminal-macos-automatic-period-native.spec.ts +++ b/tests/e2e/terminal-macos-automatic-period-native.spec.ts @@ -71,7 +71,7 @@ test.describe('Native macOS automatic period substitution @headful', () => { await startTerminalImeByteReader(orcaPage, ptyId, hangulReader) await focusActiveTerminalInput(orcaPage) await installTerminalImeBoundaryProbe(orcaPage) - execFileSync('swift', ['.tmp/select-input-source.swift', KOREAN_ID]) + execFileSync('swift', ['tests/e2e/select-input-source.swift', KOREAN_ID]) await waitForInputSource(orcaPage, KOREAN_ID) typePhysicalKeys(electronApp.process().pid!, [2, 40, 49]) @@ -84,7 +84,7 @@ test.describe('Native macOS automatic period substitution @headful', () => { await startTerminalImeByteReader(orcaPage, ptyId, abcReader) await focusActiveTerminalInput(orcaPage) - execFileSync('swift', ['.tmp/select-input-source.swift', ABC_ID]) + execFileSync('swift', ['tests/e2e/select-input-source.swift', ABC_ID]) await waitForInputSource(orcaPage, ABC_ID) typePhysicalKeys(electronApp.process().pid!, [47, 49, 36]) @@ -102,7 +102,7 @@ test.describe('Native macOS automatic period substitution @headful', () => { { abcPty, automaticPeriodPreference: true, hangulBeforeEnter, hangulPty } ) } finally { - execFileSync('swift', ['.tmp/select-input-source.swift', ABC_ID]) + execFileSync('swift', ['tests/e2e/select-input-source.swift', ABC_ID]) await disposeTerminalImeBoundaryProbe(orcaPage).catch(() => undefined) removeTerminalImeByteReader(hangulReader) removeTerminalImeByteReader(abcReader) diff --git a/tests/e2e/terminal-macos-cangjie-native.spec.ts b/tests/e2e/terminal-macos-cangjie-native.spec.ts index 50b5533475e..8356a8b85b6 100644 --- a/tests/e2e/terminal-macos-cangjie-native.spec.ts +++ b/tests/e2e/terminal-macos-cangjie-native.spec.ts @@ -69,7 +69,7 @@ function typeKeyCodes(processId: number, keyCodes: readonly number[]): void { } function selectInputSource(inputSourceId: string): void { - execFileSync('swift', ['.tmp/select-input-source.swift', inputSourceId]) + execFileSync('swift', ['tests/e2e/select-input-source.swift', inputSourceId]) } async function readActiveComposition(page: Page): Promise { diff --git a/tests/e2e/terminal-macos-korean-chord-commit-native.spec.ts b/tests/e2e/terminal-macos-korean-chord-commit-native.spec.ts index 349b4c53bcf..ba2080938ba 100644 --- a/tests/e2e/terminal-macos-korean-chord-commit-native.spec.ts +++ b/tests/e2e/terminal-macos-korean-chord-commit-native.spec.ts @@ -33,7 +33,7 @@ import { */ const TWO_SET_KOREAN_ID = 'com.apple.inputmethod.Korean.2SetKorean' -const SELECT_INPUT_SOURCE = path.resolve(__dirname, '../../.tmp/select-input-source.swift') +const SELECT_INPUT_SOURCE = path.resolve(__dirname, 'select-input-source.swift') // 2-Set Korean: ㅎ = key code 5, ㅏ = key code 40, Space = 49. Three `하` separated by spaces, // matching the byte expectations preserved below. diff --git a/tests/e2e/terminal-macos-pinyin-native.spec.ts b/tests/e2e/terminal-macos-pinyin-native.spec.ts index e3514d81c3f..30f79c47d5b 100644 --- a/tests/e2e/terminal-macos-pinyin-native.spec.ts +++ b/tests/e2e/terminal-macos-pinyin-native.spec.ts @@ -59,7 +59,7 @@ function typeKeyCodes(processId: number, keyCodes: readonly number[]): void { } function selectInputSource(inputSourceId: string): void { - execFileSync('swift', ['.tmp/select-input-source.swift', inputSourceId]) + execFileSync('swift', ['tests/e2e/select-input-source.swift', inputSourceId]) } async function readActiveComposition(page: Page): Promise { diff --git a/tests/e2e/terminal-macos-vietnamese-native.spec.ts b/tests/e2e/terminal-macos-vietnamese-native.spec.ts index 55d04fd4d46..53080070a6e 100644 --- a/tests/e2e/terminal-macos-vietnamese-native.spec.ts +++ b/tests/e2e/terminal-macos-vietnamese-native.spec.ts @@ -57,7 +57,7 @@ function typeKeyCodes(processId: number, keyCodes: readonly number[]): void { } function selectInputSource(inputSourceId: string): void { - execFileSync('swift', ['.tmp/select-input-source.swift', inputSourceId]) + execFileSync('swift', ['tests/e2e/select-input-source.swift', inputSourceId]) } test.describe('Native macOS Vietnamese terminal input @headful', () => {