]> code.delx.au - gnu-emacs/blob - test/lisp/mouse-tests.el
Do not hard-code port for package test server. (Bug#23708)
[gnu-emacs] / test / lisp / mouse-tests.el
1 ;;; mouse-tests.el --- unit tests for mouse.el -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc.
4
5 ;; Author: Philipp Stephani <phst@google.com>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;; Unit tests for lisp/mouse.el.
25
26 ;;; Code:
27
28 (ert-deftest bug23288-use-return-value ()
29 "If ‘mouse-on-link-p’ returns a string, its first character is
30 used."
31 (cl-letf ((last-input-event '(down-mouse-1 nil 1))
32 (unread-command-events '((mouse-1 nil 1)))
33 (mouse-1-click-follows-link t)
34 (mouse-1-click-in-non-selected-windows t)
35 ((symbol-function 'mouse-on-link-p) (lambda (_pos) "abc")))
36 (should-not (mouse--down-1-maybe-follows-link))
37 (should (equal unread-command-events '(?a)))))
38
39 (ert-deftest bug23288-translate-to-mouse-2 ()
40 "If ‘mouse-on-link-p’ doesn’t return a string or vector,
41 translate ‘mouse-1’ events into ‘mouse-2’ events."
42 (cl-letf ((last-input-event '(down-mouse-1 nil 1))
43 (unread-command-events '((mouse-1 nil 1)))
44 (mouse-1-click-follows-link t)
45 (mouse-1-click-in-non-selected-windows t)
46 ((symbol-function 'mouse-on-link-p) (lambda (_pos) t)))
47 (should-not (mouse--down-1-maybe-follows-link))
48 (should (equal unread-command-events '((mouse-2 nil 1))))))
49
50 ;;; mouse-tests.el ends here