]> code.delx.au - gnu-emacs-elpa/blobdiff - company-tests.el
ERT window should occupy the whole frame
[gnu-emacs-elpa] / company-tests.el
index 657486b096a88dc2573801c2a5960e05d544b2f2..9b8e914b26b2effbdc731b73b3598f0c1ebc51b3 100644 (file)
       (should (null company-candidates))
       (should (null (company-explicit-action-p))))))
 
-(ert-deftest company-multi-backend-adapter-uses-respective-prefixes ()
-  ;; And ignores the second argument.
-  (let ((company-backend
-         (list (lambda (command &optional arg)
-                 (case command
-                   (prefix "bar")
-                   (candidates (mapcar (lambda (tail) (concat arg "-" tail))
-                                       '("a" "b" "c")))))
-               (lambda (command &optional arg)
-                 (case command
-                   (prefix "foo-bar")
-                   (candidates (mapcar (lambda (tail) (concat arg "-" tail))
-                                       '("d" "e"))))))))
-    (should (equal (sort '("bar-a" "bar-b" "bar-c" "foo-bar-d" "foo-bar-e")
-                         'string<)
-                   (company-call-backend 'candidates "hubba-hubba")))))
-
-;; Pseudo-Tooltip
-
 (ert-deftest company-pseudo-tooltip-does-not-get-displaced ()
+  :tags '(interactive)
   (with-temp-buffer
     (save-window-excursion
       (set-window-buffer nil (current-buffer))
         (company-call 'open-line 1)
         (should (eq 2 (overlay-start company-pseudo-tooltip-overlay)))))))
 
+(defun company-test-pseudo-tooltip-overlay-show ()
+  (save-window-excursion
+    (set-window-buffer nil (current-buffer))
+    (insert "aaaa\n bb\nccccc\nddd")
+    (search-backward "bb")
+    (let ((col-row (company--col-row))
+          (company-candidates-length 2)
+          (company-candidates '("123" "45")))
+      (company-pseudo-tooltip-show (cdr col-row) (car col-row) 0)
+      (let ((ov company-pseudo-tooltip-overlay))
+        (should (eq (overlay-get ov 'company-width) 3))
+        ;; FIXME: Make it 2?
+        (should (eq (overlay-get ov 'company-height) 10))
+        (should (eq (overlay-get ov 'company-column) (car col-row)))
+        (should (string= (overlay-get ov 'company-before)
+                         " 123\nc45 c\nddd\n"))))))
+
+(ert-deftest company-pseudo-tooltip-overlay-show ()
+  :tags '(interactive)
+  (with-temp-buffer
+    (company-test-pseudo-tooltip-overlay-show)))
+
+(ert-deftest company-pseudo-tooltip-overlay-show-with-header-line ()
+  :tags '(interactive)
+  (with-temp-buffer
+    (setq header-line-format "foo bar")
+    (company-test-pseudo-tooltip-overlay-show)))
+
 ;;; Template
 
 (ert-deftest company-template-removed-after-the-last-jump ()