unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/2] test: Add tests for advance/rewind.
Date: Thu, 29 Dec 2011 12:08:10 +0000	[thread overview]
Message-ID: <1325160490-23472-2-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1325160490-23472-1-git-send-email-dme@dme.org>

---

These tests pass when run interactively (via dtach/run_emacs and in a
normal session) with both emacs23 and emacs24. They pass when run via
the test suite with emacs24, but emacs23 behaves differently (the
result of scrolling is different). I've yet to figure out why.

 emacs/notmuch-test.el |  128 +++++++++++++++++++++++++++++++++++++++++++++++++
 test/emacs            |   13 +++++
 2 files changed, 141 insertions(+), 0 deletions(-)
 create mode 100644 emacs/notmuch-test.el

diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el
new file mode 100644
index 0000000..307adfa
--- /dev/null
+++ b/emacs/notmuch-test.el
@@ -0,0 +1,128 @@
+;; notmuch-test.el --- testing the emacs interface
+;;
+;; Copyright © David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch 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.
+;;
+;; Notmuch 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 Notmuch.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;; Authors: David Edmondson <dme@dme.org>
+
+(defvar notmuch-test-tests '(notmuch-test-show-advance-simple
+			     notmuch-test-show-advance-twice
+			     notmuch-test-show-advance-rewind
+			     notmuch-test-show-advance-twice-rewind
+			     notmuch-test-show-advance-not-eobp
+			     notmuch-test-show-advance-eobp)
+  "A list of tests.")
+
+(defun notmuch-test-all ()
+  "Wrapper for ease of test development."
+  (let ((result (get-buffer-create "*notmuch-test*")))
+    (set-buffer result)
+    (erase-buffer)
+    (dolist (test notmuch-test-tests)
+      (insert (format "%40S: %S\n"
+		      test
+		      (save-excursion
+			(funcall test)))))
+    (switch-to-buffer result)))
+
+;;
+
+(defun notmuch-test-show-advance-simple ()
+  ;; Find a particular thread.
+  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")
+  ;; Ensure that all messages are open.
+  (notmuch-show-open-or-close-all)
+  (redisplay t)
+  ;; Advance.
+  (notmuch-show-advance)
+  (redisplay t)
+  ;; The first message in the thread is longer than a screen, so we
+  ;; should just have scrolled normally.
+  (if (= (line-number-at-pos) 19)
+      t
+    (cons (line-number-at-pos) 19)))
+
+(defun notmuch-test-show-advance-twice ()
+  ;; Find a particular thread.
+  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")
+  ;; Ensure that all messages are open.
+  (notmuch-show-open-or-close-all)
+  (redisplay t)
+  ;; Advance twice.
+  (notmuch-show-advance)
+  (redisplay t)
+  (notmuch-show-advance)
+  (redisplay t)
+  ;; The first message in the thread is shorter than two screens, so
+  ;; we should be at the start of the second message.
+  (if (= (line-number-at-pos) 41)
+      t
+    (cons (line-number-at-pos) 41)))
+
+(defun notmuch-test-show-advance-rewind ()
+  ;; Find a particular thread.
+  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")
+  ;; Ensure that all messages are open.
+  (notmuch-show-open-or-close-all)
+  (redisplay t)
+  ;; Advance.
+  (notmuch-show-advance)
+  (redisplay t)
+  ;; Rewind.
+  (notmuch-show-rewind)
+  (redisplay t)
+  ;; Should be back at the start.
+  (if (= (line-number-at-pos) 1)
+      t
+    (cons (line-number-at-pos) 1)))
+
+(defun notmuch-test-show-advance-twice-rewind ()
+  ;; Find a particular thread.
+  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")
+  ;; Ensure that all messages are open.
+  (notmuch-show-open-or-close-all)
+  (redisplay t)
+  ;; Advance twice.
+  (notmuch-show-advance)
+  (redisplay t)
+  (notmuch-show-advance)
+  (redisplay t)
+  ;; Rewind.
+  (notmuch-show-rewind)
+  (redisplay t)
+  ;; The first message in the thread is shorter than two screens, so
+  ;; we should be in the middle of it.
+  (if (= (line-number-at-pos) 17)
+      t
+    (cons (line-number-at-pos) 17)))
+
+(defun notmuch-test-show-advance-not-eobp ()
+  ;; Find a particular thread.
+  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")
+  ;; From here `advance' should never cause us to leave the buffer.
+  (not (notmuch-show-advance)))
+
+(defun notmuch-test-show-advance-eobp ()
+  ;; Find a particular thread.
+  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")
+  (goto-char (point-max))
+  ;; From here `advance' should always cause us to leave the buffer.
+  (notmuch-show-advance))
+
+;;
+
+(provide 'notmuch-test)
diff --git a/test/emacs b/test/emacs
index ca82445..a1f1abc 100755
--- a/test/emacs
+++ b/test/emacs
@@ -514,4 +514,17 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 2
 
+for i in \
+    show-advance-simple \
+    show-advance-twice \
+    show-advance-rewind \
+    show-advance-twice-rewind \
+    show-advance-not-eobp \
+    show-advance-eobp
+do
+    test_begin_subtest "notmuch $i"
+    result=$(test_emacs '(require (quote notmuch-test)) (notmuch-test-'$i')')
+    test_expect_equal "$result" t
+done
+
 test_done
-- 
1.7.7.3

  reply	other threads:[~2011-12-29 12:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <id:"1324553312-10972-1-git-send-email-dme@dme.org">
2011-12-23 18:41 ` [RFC][PATCH v4] emacs: Re-implement advance/rewind functions of notmuch-show-mode David Edmondson
2011-12-23 19:01   ` Dmitry Kurochkin
2011-12-26 10:46     ` David Edmondson
2011-12-26 11:09       ` Dmitry Kurochkin
2011-12-26 22:00         ` David Edmondson
2011-12-26 22:24           ` Jameson Graef Rollins
2011-12-27  7:56             ` David Edmondson
2011-12-25  1:06   ` Austin Clements
2011-12-26  4:11     ` Aaron Ecay
2011-12-26 10:54       ` David Edmondson
2011-12-26 10:49     ` David Edmondson
2011-12-28 15:22       ` David Edmondson
2011-12-28 18:04         ` Aaron Ecay
2011-12-28 20:21           ` Jameson Graef Rollins
2011-12-29  8:42           ` David Edmondson
2011-12-29 12:08   ` [PATCH 1/2] " David Edmondson
2011-12-29 12:08     ` David Edmondson [this message]
2011-12-29 16:05       ` [PATCH 2/2] test: Add tests for advance/rewind David Edmondson
2012-01-06 17:10         ` Jameson Graef Rollins
2012-01-06 17:31           ` David Edmondson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325160490-23472-2-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).