Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 79B4E429E25 for ; Thu, 29 Dec 2011 04:08:19 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NUt1L9W1wKse for ; Thu, 29 Dec 2011 04:08:18 -0800 (PST) Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com [209.85.216.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 42064431FD0 for ; Thu, 29 Dec 2011 04:08:18 -0800 (PST) Received: by qadc12 with SMTP id c12so9026835qad.5 for ; Thu, 29 Dec 2011 04:08:16 -0800 (PST) Received: by 10.224.175.2 with SMTP id v2mr42145296qaz.69.1325160496585; Thu, 29 Dec 2011 04:08:16 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id q14sm64844229qap.4.2011.12.29.04.08.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Dec 2011 04:08:15 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 26834A0B3C; Thu, 29 Dec 2011 12:08:13 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 2/2] test: Add tests for advance/rewind. Date: Thu, 29 Dec 2011 12:08:10 +0000 Message-Id: <1325160490-23472-2-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1325160490-23472-1-git-send-email-dme@dme.org> References: <1324665712-2419-1-git-send-email-dme@dme.org> <1325160490-23472-1-git-send-email-dme@dme.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2011 12:08:19 -0000 --- 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 . +;; +;; Authors: David Edmondson + +(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