|  | 
| 1071 | 1071 |   (should (eq (alist-get 'window-system (frame-parameters)) | 
| 1072 | 1072 |               (turtles-pop-to-buffer-other-frame :check nil nil)))) | 
| 1073 | 1073 | 
 | 
|  | 1074 | +(ert-deftest turtles-pop-to-buffer-interactive () | 
|  | 1075 | +  (turtles-ert-test) | 
|  | 1076 | + | 
|  | 1077 | +  (let ((inst (turtles-start-instance 'default)) | 
|  | 1078 | +        (buf (turtles-instance-eval | 
|  | 1079 | +              'default | 
|  | 1080 | +              '(with-current-buffer | 
|  | 1081 | +                   (generate-new-buffer "*pop-to-buffer-test*") | 
|  | 1082 | +                 (insert "foo bar") | 
|  | 1083 | +                 (current-buffer)))) | 
|  | 1084 | +        (turtles-pop-to-buffer-actions | 
|  | 1085 | +         (list #'turtles-pop-to-buffer-embedded | 
|  | 1086 | +               #'turtles-pop-to-buffer-copy)) | 
|  | 1087 | +        (inhibit-message t)) | 
|  | 1088 | + | 
|  | 1089 | +    (turtles-with-minibuffer | 
|  | 1090 | +        (let ((completion-cycle-threshold 0)) | 
|  | 1091 | +          (turtles-pop-to-buffer buf)) | 
|  | 1092 | + | 
|  | 1093 | +      (turtles-with-grab-buffer (:name "initial") | 
|  | 1094 | +          (should (equal "Display buffer:" (buffer-string)))) | 
|  | 1095 | + | 
|  | 1096 | +      (minibuffer-complete) | 
|  | 1097 | +      (minibuffer-complete) | 
|  | 1098 | +      (turtles-with-grab-buffer (:buf "*Completions*") | 
|  | 1099 | +        (goto-char (point-min)) | 
|  | 1100 | +        (search-forward "possible completions:\n") | 
|  | 1101 | +        (should (equal (concat "copy Display a copy of the instance buffer.\n" | 
|  | 1102 | +                               "embedded Display buffer in the terminal buffer.") | 
|  | 1103 | +                       (buffer-substring (point) (point-max)))) | 
|  | 1104 | + | 
|  | 1105 | +        (execute-kbd-macro (kbd "copy")))) | 
|  | 1106 | + | 
|  | 1107 | +    ;; pop-to-buffer should have made a copy. Let's check it. | 
|  | 1108 | +    (with-current-buffer (window-buffer (selected-window)) | 
|  | 1109 | +      (should (string-prefix-p "[default] *pop-to-buffer-test*" (buffer-name))) | 
|  | 1110 | +      (should (equal "foo bar" (buffer-string))) | 
|  | 1111 | +      (kill-buffer (current-buffer))))) | 
|  | 1112 | + | 
|  | 1113 | +(ert-deftest turtles-pop-to-buffer-interactive-lambdas () | 
|  | 1114 | +  (turtles-ert-test) | 
|  | 1115 | + | 
|  | 1116 | +  (let* ((inst (turtles-start-instance 'default)) | 
|  | 1117 | +         (buf (turtles-instance-eval | 
|  | 1118 | +               'default | 
|  | 1119 | +               '(with-current-buffer | 
|  | 1120 | +                    (generate-new-buffer "*pop-to-buffer-test*") | 
|  | 1121 | +                  (insert "foo bar") | 
|  | 1122 | +                  (current-buffer)))) | 
|  | 1123 | +         (calls nil) | 
|  | 1124 | +         (turtles-pop-to-buffer-actions | 
|  | 1125 | +          (list | 
|  | 1126 | +           (lambda (action &rest _args) | 
|  | 1127 | +             "My Lambda 1." | 
|  | 1128 | +             (when (eq :display action) | 
|  | 1129 | +               (push 'lambda-1 calls)) | 
|  | 1130 | +             t) | 
|  | 1131 | +           (lambda (action &rest _args) | 
|  | 1132 | +             "My Lambda 2." | 
|  | 1133 | +             (when (eq :display action) | 
|  | 1134 | +               (push 'lambda-2 calls)) | 
|  | 1135 | +             t))) | 
|  | 1136 | +         (inhibit-message t)) | 
|  | 1137 | + | 
|  | 1138 | +    (turtles-with-minibuffer | 
|  | 1139 | +        (let ((completion-cycle-threshold 0)) | 
|  | 1140 | +          (turtles-pop-to-buffer buf)) | 
|  | 1141 | +       | 
|  | 1142 | +      (turtles-with-grab-buffer (:name "initial") | 
|  | 1143 | +        (should (equal "Display buffer:" (buffer-string)))) | 
|  | 1144 | + | 
|  | 1145 | +      (minibuffer-complete) | 
|  | 1146 | +      (minibuffer-complete) | 
|  | 1147 | +      (turtles-with-grab-buffer (:buf "*Completions*") | 
|  | 1148 | +        (goto-char (point-min)) | 
|  | 1149 | +        (search-forward "possible completions:\n") | 
|  | 1150 | +        (should (equal (concat "lambda-1 My Lambda 1.\n" | 
|  | 1151 | +                               "lambda-2 My Lambda 2.") | 
|  | 1152 | +                       (buffer-substring (point) (point-max))))) | 
|  | 1153 | +       | 
|  | 1154 | +      (execute-kbd-macro (kbd "1")) | 
|  | 1155 | +      (turtles-with-grab-buffer (:name "choice") | 
|  | 1156 | +        (should (equal "Display buffer: lambda-1" (buffer-string))))) | 
|  | 1157 | + | 
|  | 1158 | +    (should (equal '(lambda-1) calls)))) | 
|  | 1159 | + | 
| 1074 | 1160 | (ert-deftest turtles--split-minibuffer-body () | 
| 1075 | 1161 |   (should | 
| 1076 | 1162 |    (equal | 
|  | 
| 1264 | 1350 |       (goto-char (match-beginning 0)) | 
| 1265 | 1351 |       (should (string-equal-ignore-case "#276ce2" (foreground-color-at-point))) | 
| 1266 | 1352 |       (should (string-equal-ignore-case "#0c1526" (background-color-at-point)))))) | 
|  | 1353 | + | 
0 commit comments