Remove call to string-to-multibyte from nndoc.el
[emacs.git] / test / lisp / mouse-tests.el
blob909ba64a724813d94c620134f65ca1b47df5c680
1 ;;; mouse-tests.el --- unit tests for mouse.el -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
5 ;; Author: Philipp Stephani <phst@google.com>
7 ;; This file is part of GNU Emacs.
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.
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.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; Unit tests for lisp/mouse.el.
26 ;;; Code:
28 (ert-deftest bug23288-use-return-value ()
29 "If `mouse-on-link-p' returns a string, its first character is used."
30 (cl-letf ((unread-command-events '((down-mouse-1 nil 1) (mouse-1 nil 1)))
31 (mouse-1-click-follows-link t)
32 (mouse-1-click-in-non-selected-windows t)
33 ((symbol-function 'mouse-on-link-p) (lambda (_pos) "abc")))
34 (should (eq 'down-mouse-1 (car-safe (aref (read-key-sequence "") 0))))
35 (should (eq ?a (aref (read-key-sequence "") 0)))))
37 (ert-deftest bug23288-translate-to-mouse-2 ()
38 "If `mouse-on-link-p' doesn't return a string or vector,
39 translate `mouse-1' events into `mouse-2' events."
40 (cl-letf ((unread-command-events '((down-mouse-1 nil 1) (mouse-1 nil 1)))
41 (mouse-1-click-follows-link t)
42 (mouse-1-click-in-non-selected-windows t)
43 ((symbol-function 'mouse-on-link-p) (lambda (_pos) t)))
44 (should (eq 'down-mouse-1 (car-safe (aref (read-key-sequence "") 0))))
45 (should (eq 'mouse-2 (car-safe (aref (read-key-sequence "") 0))))))
47 (ert-deftest bug26816-mouse-frame-movement ()
48 "Mouse moves relative to frame."
49 (skip-unless (display-graphic-p))
50 (let ((frame (selected-frame)))
51 (set-mouse-position frame 0 0)
52 (should (equal (mouse-position)
53 (cons frame (cons 0 0))))))
56 ;;; mouse-tests.el ends here