Skip to content

Commit

Permalink
tests: No need to use after-startup-hook anymore.
Browse files Browse the repository at this point in the history
`start' is now synchronous.
  • Loading branch information
Ambrevar committed Jan 23, 2023
1 parent e664766 commit 806d7b8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 45 deletions.
25 changes: 12 additions & 13 deletions tests/renderer-offline/execute-command-eval.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
:headless t
:socket "/tmp/nyxt-test.socket"
:profile "test")
(hooks:once-on (nyxt:after-startup-hook nyxt:*browser*) (browser)
(hooks:once-on (nyxt:prompt-buffer-ready-hook nyxt:*browser*)
(prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(nyxt:set-prompt-buffer-input "1+ 3" prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(nyxt/prompt-buffer-mode:last-suggestion prompt-buffer)
(nyxt/prompt-buffer-mode:previous-suggestion prompt-buffer)
(calispel:! channel (nyxt:current-suggestion-value prompt-buffer))
(nyxt/prompt-buffer-mode:quit-prompt-buffer prompt-buffer))
(nyxt:run-thread "run execute-command"
(let ((nyxt::*interactive-p* t))
(nyxt:execute-command))))
(hooks:once-on (nyxt:prompt-buffer-ready-hook nyxt:*browser*)
(prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(nyxt:set-prompt-buffer-input "1+ 3" prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(nyxt/prompt-buffer-mode:last-suggestion prompt-buffer)
(nyxt/prompt-buffer-mode:previous-suggestion prompt-buffer)
(calispel:! channel (nyxt:current-suggestion-value prompt-buffer))
(nyxt/prompt-buffer-mode:quit-prompt-buffer prompt-buffer))
(nyxt:run-thread "run execute-command"
(let ((nyxt::*interactive-p* t))
(nyxt:execute-command)))
(let ((result (calispel:? channel)))
(assert-eq '1+ (first result))
(assert-eq 3 (second result))))
Expand Down
20 changes: 1 addition & 19 deletions tests/renderer-offline/remembrance.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,11 @@
(quri:make-uri-file :path
(asdf:system-relative-pathname :nyxt "tests/test-data/lorem.html")))

(defmacro wait-on-handler (hook args &body body) ; TODO: Move to Nhooks?
"Like `nhooks:once-on' but block until the handler returns.."
(alex:with-gensyms (promise)
(let ((handler-name (gensym "once-on-hook-handler"))
(args (alexandria:ensure-list args)))
(alexandria:once-only (hook)
`(let ((,promise (lpara:promise)))
(nhooks:add-hook
,hook (make-instance 'nhooks:handler
:fn (lambda ,args
(declare (ignorable ,@args))
(nhooks:remove-hook ,hook (quote ,handler-name))
(lpara:fulfill ,promise
(progn ,@body)))
:name (quote ,handler-name)))
(lpara:force ,promise))))))

(define-test remembrance ()
(nyxt:start :no-config t :no-auto-config t
:socket "/tmp/nyxt-test.socket"
:profile "test")
(wait-on-handler (nyxt:after-startup-hook nyxt:*browser*) (browser)
(nyxt:enable-modes* 'nyxt/remembrance-mode:remembrance-mode (nyxt:current-buffer)))
(nyxt:enable-modes* 'nyxt/remembrance-mode:remembrance-mode (nyxt:current-buffer))
(let ((mode (nyxt:find-submode 'nyxt/remembrance-mode:remembrance-mode)))
(assert-equality 'uiop:pathname-equal
(nfiles:join +test-root+
Expand Down
25 changes: 12 additions & 13 deletions tests/renderer-package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@
:headless t
:socket "/tmp/nyxt-test.socket"
:profile "test")
(hooks:once-on (nyxt:after-startup-hook *browser*) (browser)
(hooks:once-on (nyxt:prompt-buffer-ready-hook browser)
(prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(nyxt:set-prompt-buffer-input url prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(hooks:once-on (nyxt:buffer-loaded-hook (nyxt:current-buffer)) buffer
(calispel:! url-channel (nyxt:render-url (nyxt:url buffer))))
(nyxt/prompt-buffer-mode:run-action-on-return prompt-buffer))
(nyxt:run-thread "run set-url"
;; TODO: Test if thread returns.
(let ((nyxt::*interactive-p* t))
(nyxt:set-url))))
(hooks:once-on (nyxt:prompt-buffer-ready-hook browser)
(prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(nyxt:set-prompt-buffer-input url prompt-buffer)
(prompter:all-ready-p prompt-buffer)
(hooks:once-on (nyxt:buffer-loaded-hook (nyxt:current-buffer)) buffer
(calispel:! url-channel (nyxt:render-url (nyxt:url buffer))))
(nyxt/prompt-buffer-mode:run-action-on-return prompt-buffer))
(nyxt:run-thread "run set-url"
;; TODO: Test if thread returns.
(let ((nyxt::*interactive-p* t))
(nyxt:set-url)))
(assert-string= url (calispel:? url-channel 5))
(nyxt:quit)))

0 comments on commit 806d7b8

Please sign in to comment.