1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
;;; erc-scenarios-scrolltobottom-relaxed.el --- erc-scrolltobottom-all relaxed -*- lexical-binding: t -*-
;; Copyright (C) 2023-2025 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;; TODO assert behavior of prompt input spanning multiple lines, with
;; and without line endings.
;;; Code:
(require 'ert-x)
(eval-and-compile
(let ((load-path (cons (ert-resource-directory) load-path)))
(require 'erc-scenarios-common)))
(require 'erc-goodies)
(ert-deftest erc-scenarios-scrolltobottom--relaxed ()
:tags `(:expensive-test
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
(when (version< emacs-version "29") (ert-skip "Times out"))
(should-not erc-scrolltobottom-all)
(erc-scenarios-common-with-noninteractive-in-term
((erc-scenarios-common-dialog "scrolltobottom")
(dumb-server (erc-d-run "localhost" t 'help))
(port (process-contact dumb-server :service))
(erc-modules `(scrolltobottom fill-wrap ,@erc-modules))
(erc-scrolltobottom-all 'relaxed)
(erc-server-flood-penalty 0.1)
(expect (erc-d-t-make-expecter))
lower upper)
(ert-info ("Connect")
(with-current-buffer (erc :server "127.0.0.1"
:port port
:full-name "tester"
:nick "tester")
(funcall expect 10 "debug mode")))
(with-current-buffer "foonet"
(should (looking-at " and"))
(set-window-buffer nil (current-buffer))
(delete-other-windows)
(split-window-below 15)
(recenter 0)
(ert-info ("Moving into prompt does not trigger scroll")
(with-selected-window (next-window)
(should-not (erc-scenarios-common--at-win-end-p))
(recenter 0)
(goto-char (1- erc-insert-marker))
(execute-kbd-macro "\C-n")
(should-not (erc-scenarios-common--at-win-end-p))
(should (= (point) (point-max)))
(setq lower (count-screen-lines (window-start) (window-point)))))
(ert-info ("Module `move-to-prompt' still works")
;; Prompt is somewhere in the middle of the window.
(should (erc-scenarios-common--above-win-end-p))
(should-not (= (point-max) (point)))
;; Hitting a self-insert key triggers `move-to-prompt' but not
;; a scroll (to bottom).
(execute-kbd-macro "hi")
;; Prompt and input appear on same line.
(should (= (point-max) (point)))
(setq upper (count-screen-lines (window-start) (window-point)))
(should-not (= upper (window-body-height))))
(ert-info ("Command `recenter-top-bottom' allowed at prompt")
;; Hitting C-l recenters the window.
(should (= upper (count-screen-lines (window-start) (window-point))))
(let ((lines (list upper)))
(erc-scenarios-common--recenter-top-bottom)
(push (count-screen-lines (window-start) (window-point)) lines)
(erc-scenarios-common--recenter-top-bottom)
(push (count-screen-lines (window-start) (window-point)) lines)
(erc-scenarios-common--recenter-top-bottom)
(push (count-screen-lines (window-start) (window-point)) lines)
(setq lines (delete-dups lines))
(should (= (length lines) 4))))
(ert-info ("Command `beginning-of-buffer' allowed at prompt")
;; Hitting C-< goes to beginning of buffer.
(execute-kbd-macro "\M-<")
(should (= 1 (point)))
(redisplay)
(should (zerop (count-screen-lines (window-start) (window-point))))
(should (erc-scenarios-common--prompt-past-win-end-p)))
(ert-info ("New message doesn't trigger scroll when away from prompt")
;; Arriving insertions don't trigger a scroll when away from the
;; prompt. New output not seen.
(erc-cmd-MSG "NickServ help register")
(save-excursion (erc-d-t-search-for 10 "End of NickServ"))
(should (= 1 (point)))
(should (zerop (count-screen-lines (window-start) (window-point))))
(should (erc-scenarios-common--prompt-past-win-end-p)))
(ert-info ("New insertion keeps prompt stationary in other window")
(let ((w (next-window)))
;; We're at prompt and completely stationary.
(should (>= (window-point w) erc-input-marker))
(erc-d-t-wait-for 10
(= lower (count-screen-lines (window-start w) (window-point w))))
(erc-d-t-ensure-for 0.5
(= lower (count-screen-lines (window-start w)
(window-point w))))))
(should (= 2 (length (window-list))))
(ert-info ("New message does not trigger a scroll when at prompt")
;; Recenter so prompt is above rather than at window's end.
(funcall expect 10 "End of NickServ HELP")
(recenter 0)
(set-window-point nil (point-max))
(setq upper (count-screen-lines (window-start) (window-point)))
;; Prompt is somewhere in the middle of the window.
(erc-d-t-wait-for 10 (erc-scenarios-common--above-win-end-p))
(erc-scenarios-common-say "/msg NickServ help identify")
;; New arriving messages don't move prompt.
(erc-d-t-ensure-for 1
(= upper (count-screen-lines (window-start) (window-point))))
(funcall expect 10 "IDENTIFY lets you login")))))
;;; erc-scenarios-scrolltobottom-relaxed.el ends here
|