|
783 | 783 | (should-not (string-match-p "new prompt>" content))))) ; mid-BSU: no prompt |
784 | 784 | (kill-buffer buf)))) |
785 | 785 |
|
| 786 | +;; ----------------------------------------------------------------------- |
| 787 | +;; Test: theme synchronization |
| 788 | +;; ----------------------------------------------------------------------- |
| 789 | + |
| 790 | +(ert-deftest ghostel-test-sync-theme () |
| 791 | + "Test that ghostel-sync-theme applies palette and redraws ghostel buffers." |
| 792 | + (let ((palette-calls nil) |
| 793 | + (redraw-calls nil)) |
| 794 | + (cl-letf (((symbol-function 'ghostel--apply-palette) |
| 795 | + (lambda (term) (push term palette-calls))) |
| 796 | + ((symbol-function 'ghostel--redraw) |
| 797 | + (lambda (term) (push term redraw-calls)))) |
| 798 | + (let ((buf (generate-new-buffer " *ghostel-test-theme*")) |
| 799 | + (other (generate-new-buffer " *ghostel-test-other*"))) |
| 800 | + (unwind-protect |
| 801 | + (progn |
| 802 | + ;; Set up a ghostel-mode buffer with a fake terminal |
| 803 | + (with-current-buffer buf |
| 804 | + (ghostel-mode) |
| 805 | + (setq ghostel--term 'fake-term) |
| 806 | + (setq ghostel--copy-mode-active nil)) |
| 807 | + ;; other buffer is not ghostel-mode |
| 808 | + (ghostel-sync-theme) |
| 809 | + (should (memq 'fake-term palette-calls)) ; palette applied to ghostel buffer |
| 810 | + (should (memq 'fake-term redraw-calls)) ; redraw called for ghostel buffer |
| 811 | + |
| 812 | + ;; Verify copy-mode skips redraw |
| 813 | + (setq palette-calls nil redraw-calls nil) |
| 814 | + (with-current-buffer buf |
| 815 | + (setq ghostel--copy-mode-active t)) |
| 816 | + (ghostel-sync-theme) |
| 817 | + (should (memq 'fake-term palette-calls)) ; palette still applied in copy mode |
| 818 | + (should-not (memq 'fake-term redraw-calls))) ; redraw skipped in copy mode |
| 819 | + (kill-buffer buf) |
| 820 | + (kill-buffer other)))))) |
| 821 | + |
786 | 822 | ;; ----------------------------------------------------------------------- |
787 | 823 | ;; Runner |
788 | 824 | ;; ----------------------------------------------------------------------- |
|
794 | 830 | ghostel-test-raw-key-modified-specials |
795 | 831 | ghostel-test-update-directory |
796 | 832 | ghostel-test-filter-soft-wraps |
797 | | - ghostel-test-prompt-navigation) |
| 833 | + ghostel-test-prompt-navigation |
| 834 | + ghostel-test-sync-theme) |
798 | 835 | "Tests that require only Elisp (no native module).") |
799 | 836 |
|
800 | 837 | (defun ghostel-test-run-elisp () |
|
0 commit comments