emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/topspace 7d384d0568 120/181: Add mouse-scrolling test


From: ELPA Syncer
Subject: [elpa] externals/topspace 7d384d0568 120/181: Add mouse-scrolling test
Date: Tue, 23 Aug 2022 12:58:40 -0400 (EDT)

branch: externals/topspace
commit 7d384d056804f0df183a046d85e5ec2284436a61
Author: Trevor Pogue <poguete@mcmaster.ca>
Commit: Trevor Pogue <poguete@mcmaster.ca>

    Add mouse-scrolling test
---
 .gitignore                  |  3 ++-
 tests/director-bootstrap.el |  4 +---
 tests/director.el           |  7 ++++++-
 tests/run                   | 28 ++++++++++++++++++++++------
 tests/tests.el              | 43 +++++++++++++++++++++++++++++++------------
 5 files changed, 62 insertions(+), 23 deletions(-)

diff --git a/.gitignore b/.gitignore
index 54450dd53a..dea17d56b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-*.~undo-tree~
\ No newline at end of file
+*.~undo-tree~
+.projectile
\ No newline at end of file
diff --git a/tests/director-bootstrap.el b/tests/director-bootstrap.el
index 32b9c0fd5e..546663c093 100644
--- a/tests/director-bootstrap.el
+++ b/tests/director-bootstrap.el
@@ -12,7 +12,7 @@
   "Setup the environment for a simulated user session."
 
   (require 'package)
-  
+
   (setq byte-compile-warnings nil)
   (when (boundp 'comp-async-report-warnings-errors)
     (setq comp-async-report-warnings-errors nil))
@@ -30,7 +30,6 @@
 
     ;; attempt requiring director here; if error, add director to list of 
required
     ;; packages, and retry after initializing packages
-    
     (package-initialize)
     (when packages
       (add-to-list 'package-archives '("melpa" . 
"https://melpa.org/packages/";) t)
@@ -39,4 +38,3 @@
           (package-install package))))
 
     (require 'director)))
-
diff --git a/tests/director.el b/tests/director.el
index aeb1fe0d5c..a7bc633efc 100644
--- a/tests/director.el
+++ b/tests/director.el
@@ -80,6 +80,7 @@ A step can be one of:
   using `listify-key-sequence' and can contain special
   characters, e.g. `(:type \"\\M-xsetenv\\r\")'
 - `:call': shortcut to invoke an interactive command, e.g. `(:call setenv)'
+- `:run': Lisp form; it will be evaluated
 - `:log': Lisp form; it will be evaluated and its result will be
   written to log; e.g. `(:log (buffer-file-name (current-buffer)))'
 - `:wait': number; seconds to wait before next step; overrides
@@ -198,6 +199,10 @@ If DELAY-OVERRIDE is non-nil, the next step is delayed by 
that value rather than
            (director--schedule-next)
            (call-interactively command))
 
+          (`(:run ,form)
+           (eval form)
+           (director--schedule-next))
+
           (`(:log ,form)
            (director--schedule-next)
            (director--log (format "LOG %S" (eval form))))
@@ -216,7 +221,7 @@ If DELAY-OVERRIDE is non-nil, the next step is delayed by 
that value rather than
 
           (`(:suspend)
            nil)
-          
+
           (`(:assert ,condition)
            (or (eval condition)
                (setq director--failure condition))
diff --git a/tests/run b/tests/run
index 6b68ce9c0d..11df816c40 100755
--- a/tests/run
+++ b/tests/run
@@ -1,15 +1,31 @@
 #!/usr/bin/env bash
 
-# set -e
+check-result() {
+    if [ $? -eq 0 ]; then
+        echo PASSED $1
+    else
+        echo FAILED $1
+        [ -z "$total_fails" ] && total_fails=0
+        ((total_fails++))
+    fi
+}
+
 this_scripts_dir="$(cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
 cd $this_scripts_dir
+
 emacs -Q \
       -l ../topspace.el \
       -l ./director.el \
       -l ./director-bootstrap.el \
       -l ./tests.el
-if [ $? -eq 0 ]; then
-    echo PASS
-else
-    echo FAIL
-fi
+check-result 'in GUI emacs'
+
+emacs -Q -nw \
+      -l ../topspace.el \
+      -l ./director.el \
+      -l ./director-bootstrap.el \
+      -l ./tests.el
+check-result 'in terminal emacs'
+
+[ -n "$total_fails" ] && echo FAILED $total_fails tests && exit 1
+echo PASSED all tests
diff --git a/tests/tests.el b/tests/tests.el
index 65e74e84ae..52267c61b5 100644
--- a/tests/tests.el
+++ b/tests/tests.el
@@ -1,14 +1,11 @@
 ;; Run with:
 ;;
 ;;   emacs -Q -nw -l ../../util/director-bootstrap.el -l demo.el
-;; (require 'topspace)
 
 (director-bootstrap
  :user-dir "/tmp/director-demo"
  :packages '()
- :load-path '("./"))
-
-(defun t-t () (kill-emacs 1))
+ :load-path '("../.."))
 
 (director-run
  :version 1
@@ -20,21 +17,43 @@
                  (global-topspace-mode)
                  )
  :steps '(
-          (:type "\M-v")
-          (:type "\C-\M-n")
+          ;; Test scrolling using key commands
+          (:type "\M-v")     ;; page down
+          (:type "\C-\M-n")  ;; scroll down line
+          (:assert (setq topspace--tests-prev-height (topspace--height)))
+          (:type "\C-n")     ;; next-line
+          (:assert (= (topspace--height) (1- topspace--tests-prev-height)))
+          (:type "\C-u2\C-n");; next-line x2
+          (:assert (= (topspace--height) (- topspace--tests-prev-height 3)))
+          (:type "\C-\M-n")  ;; scroll down line
+          (:assert (= (topspace--height) (- topspace--tests-prev-height 2)))
+          (:type "\C-u2\C-\M-n")  ;; scroll down line x2
+          (:assert (= (topspace--height) topspace--tests-prev-height))
+          ;; reset top line to top of window:
+          (:type "\C-v")     ;; page up
+          (:assert (= (topspace--height) 1))
+          (:type "\C-\M-p")  ;; scroll up line
+          (:assert (= (topspace--height) 0))
+          (:assert (= (window-start) 1))
+
+          ;; Test mouse scrolling
+          (:type "\M-v")     ;; page down
+          (:run (mwheel-scroll mouse-wheel-down-event)) ;; scroll down line
           (:assert (setq topspace--tests-prev-height (topspace--height)))
-          (:type "\C-n")
+          (:type "\C-n")     ;; next-line
           (:assert (= (topspace--height) (1- topspace--tests-prev-height)))
-          (:type "\C-u2\C-n")
+          (:type "\C-u2\C-n");; next-line x2
           (:assert (= (topspace--height) (- topspace--tests-prev-height 3)))
-          (:type "\C-\M-n")
+          (:run (mwheel-scroll mouse-wheel-down-event)) ;; scroll down line
+          (:run (mwheel-scroll mouse-wheel-up-event))   ;; scroll up line
+          (:run (mwheel-scroll mouse-wheel-down-event)) ;; scroll down line
           (:assert (= (topspace--height) (- topspace--tests-prev-height 2)))
-          (:type "\C-u2\C-\M-n")
+          (:run (mwheel-scroll mouse-wheel-down-event)) ;; scroll down line
+          (:run (mwheel-scroll mouse-wheel-down-event)) ;; scroll down line
           (:assert (= (topspace--height) topspace--tests-prev-height))
           )
  :typing-style 'human
  :delay-between-steps 0.1
  :after-end (lambda () (kill-emacs 0))
  :on-failure (lambda () (kill-emacs 1))
- :on-error (lambda () (kill-emacs 1))
- )
+ :on-error (lambda () (kill-emacs 1)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]