Skip to content

test: ロジックを切り出し、画面操作まで含めたテストを追加する - #32

Merged
dominion525 merged 20 commits into
masterfrom
tests-keyevent
Sep 13, 2026
Merged

dominion525 merged 20 commits into
masterfrom
tests-keyevent

Conversation

@dominion525

@dominion525 dominion525 commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • 最前面アプリの切り替え、起動時の設定読み込み、除外アプリ画面の一覧操作を、グローバル状態や UI に依存しない関数に切り出してテストを追加
  • KeyEvent の設定表の参照と OS へのキー送信を差し替え可能にし、タップを通さずにキーの変換・修飾キー単体押し・除外アプリ・メディアキーの処理を検証
  • 設定の保存先を差し替え可能にし、キーリマップ一覧・除外アプリ・設定画面・メニューバーの操作を、実設定を書き換えずに検証
  • KeyMappingListEditor.save のテストを追加
  • 行カバレッジは 48.0% から 81.0% に(ヘルパーを含むアプリ全体)

🤖 Generated with Claude Code

dominion525 and others added 11 commits September 14, 2026 00:34
- 除外判定と「最近使ったアプリ」一覧の更新を ActiveAppTracker.update に移し、KeyEvent はその結果をグローバル変数へ書くだけにする
- 一覧の上限 10 件を定数 recentAppsLimit にする
- ActiveAppTrackerTests を追加(12 件)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- set(_:forKey:) を記録するだけの UserDefaults のサブクラスを使い、"mappings" キーに serialized の結果が書かれることを確かめる

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 除外アプリ一覧の復元と、キー設定の復元・v2.0.x からの移行・初期設定の選択を StartupSettings に移す
- AppDelegate は読み込み結果の出どころに応じて oneShotModifiers の削除と保存を行うだけにする
- StartupSettingsTests を追加(17 本)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 設定表の参照と OS へのキー送信を KeyEvent のプロパティにし、テストでは記録するだけの関数に差し替えられるようにする
- タップのコールバック本体を handle(type:event:) に分ける
- KeyEventTests を追加(20 本)。キーの変換、修飾キー単体押し、除外アプリ、メディアキー、タップ無効化の通知を検証する

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 除外一覧と「最近使ったアプリ」一覧の行の解決、チェック切り替えによる項目の移動、保存形式への変換を ExclusionListEditor に移す
- ID から名前を引く辞書の作成は StartupSettings.exclusionAppsDict を使う
- ExclusionListEditorTests を追加(14 本)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 「ログイン後にこのアプリを起動」の保存値の解釈と、旧設定「起動時にアップデートを確認」の引き継ぎ値を StartupSettings に移す
- StartupSettingsTests に 7 本追加

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- KeyMappingListEditorTests の中にあった RecordingDefaults を独立したファイルに移す
- 最後に書かれた値を引く lastValue(forKey:) を追加

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 設定の保存先をグローバルの settingsDefaults に集め、テストでは記録するだけの UserDefaults に差し替える
- 設定ウィンドウの各画面を取り出すテスト用ヘルパー PreferenceScreens を追加
- 行の追加・削除・並べ替え・有効切り替え、セルの生成、行数のテストを追加(10 本)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 文字列の解決、表示と一覧への反映、保存を commitEditedText に分け、textDidEndEditing はそれを呼ぶ
- 既知の文字列の反映、未知の文字列の扱い 2 種、フォーカスの解除のテストを追加(4 本)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 行数、各列の表示、チェック切り替えによる一覧の移動と保存、他の列への書き込みの無視のテストを追加(6 本)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- ViewController の保存先を差し替え可能にし、テストでは記録するだけの UserDefaults を使う
- アイコン表示の切り替えと保存、チェックボックスの初期状態、メニューの項目と動作の対応のテストを追加(4 本)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dominion525 dominion525 changed the title test: 中核の処理を切り出し、画面の操作まで含めて動作保証を広げる test: キーイベント処理と設定画面のテストを追加する Sep 13, 2026
dominion525 and others added 9 commits September 14, 2026 03:02
- 直列実行の親スイート GlobalStateTests を作り、キーリマップ一覧・除外アプリ・設定画面のスイートをその下に入れる
- スイート内だけの直列指定では、別スイート同士が同じ保存先や一覧を同時に書き換えて戻し損なう余地があった

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- storyboard からもコードからも呼ばれていない AppDelegate.launch(_:) と ViewController.test(_:) を削除
- Xcode の雛形のまま中身が空だった ViewController.representedObject の didSet を削除

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 通常キーは欄に記録して OS に渡さない、修飾キーは入力欄なら記録し出力欄なら記録しない、単体押しの変換結果を送らない、メディアキーは入力欄なら記録して捨て出力欄ならそのまま通す、の 4 つの振る舞いを固定する
- 設定画面で編集中にキーが変換されてしまう退行を検出するため

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- ウィンドウでフォーカスを取ると activeKeyTextField になり、blur で外れることを確かめる
- 一覧画面と設定ウィンドウの mouseDown でフォーカスが外れることを確かめる

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 通知で渡されたアプリが一覧の先頭に入ること、除外アプリなら除外フラグが立ち一覧には入らないことを確かめる

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Shift・Control・Option・fn・CapsLock のそれぞれについて、相手が持っていて自分が持たない場合に false になることを確かめる
- これまでのテストは Command の欠落しか通しておらず、他の修飾キーの判定は実行されていなかった

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- subtype 8 の NX_SYSDEFINED イベントからキー種別と押下が取り出せること、他の subtype と通常のキーイベントは対象外になることを確かめる
- これまで MediaKeyEvent の init は、対象外を弾く経路がテストされていなかった

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- 配列を保存値として渡すと、初回起動ではなくオフと解釈されることを確かめる
- integer(forKey:) と同じ解釈になる経路のうち、この分岐だけがテストされていなかった

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- ViewController のメニューバー項目の表示切り替えを差し替え可能にし、テストでは記録するだけの関数を使う
- AppKit は NSStatusItem の表示状態をアプリの設定に保存するため、テストホストが本物と同じ設定ファイルへ書き込んでいた

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@dominion525 dominion525 changed the title test: キーイベント処理と設定画面のテストを追加する test: ロジックを切り出し、画面操作まで含めたテストを追加する Sep 13, 2026
@dominion525
dominion525 merged commit b0c27fd into master Sep 13, 2026
2 checks passed
@dominion525
dominion525 deleted the tests-keyevent branch September 13, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant