| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/gui/text_edit.h" |
| 34 |
|
| 35 |
#include "tests/test_macros.h" |
| 36 |
|
| 37 |
namespace TestTextEdit { |
| 38 |
static inline Array reverse_nested(Array array) { |
| 39 |
Array reversed_array = array.duplicate(true); |
| 40 |
reversed_array.reverse(); |
| 41 |
for (int i = 0; i < reversed_array.size(); i++) { |
| 42 |
((Array)reversed_array[i]).reverse(); |
| 43 |
} |
| 44 |
return reversed_array; |
| 45 |
} |
| 46 |
|
| 47 |
TEST_CASE("[SceneTree][TextEdit] text entry") { |
| 48 |
#if !defined(PHYSICS_2D_DISABLED) || !defined(PHYSICS_3D_DISABLED) |
| 49 |
SceneTree::get_singleton()->get_root()->set_physics_object_picking(false); |
| 50 |
#endif |
| 51 |
TextEdit *text_edit = memnew(TextEdit); |
| 52 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 53 |
text_edit->grab_focus(); |
| 54 |
|
| 55 |
Array empty_signal_args = { {} }; |
| 56 |
|
| 57 |
SUBCASE("[TextEdit] text entry") { |
| 58 |
SIGNAL_WATCH(text_edit, "text_set"); |
| 59 |
SIGNAL_WATCH(text_edit, "text_changed"); |
| 60 |
SIGNAL_WATCH(text_edit, "lines_edited_from"); |
| 61 |
SIGNAL_WATCH(text_edit, "caret_changed"); |
| 62 |
|
| 63 |
Array lines_edited_args = { { 0, 0 }, { 0, 0 } }; |
| 64 |
|
| 65 |
SUBCASE("[TextEdit] clear and set text") { |
| 66 |
|
| 67 |
text_edit->clear(); |
| 68 |
MessageQueue::get_singleton()->flush(); |
| 69 |
CHECK(text_edit->get_text() == ""); |
| 70 |
CHECK(text_edit->get_caret_column() == 0); |
| 71 |
CHECK(text_edit->get_line_count() == 1); |
| 72 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 73 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 74 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 75 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 76 |
|
| 77 |
text_edit->set_text("test text"); |
| 78 |
MessageQueue::get_singleton()->flush(); |
| 79 |
CHECK(text_edit->get_text() == "test text"); |
| 80 |
CHECK(text_edit->get_caret_column() == 0); |
| 81 |
CHECK(text_edit->get_line_count() == 1); |
| 82 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 83 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 84 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 85 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 86 |
|
| 87 |
text_edit->clear(); |
| 88 |
MessageQueue::get_singleton()->flush(); |
| 89 |
CHECK(text_edit->get_text() == ""); |
| 90 |
CHECK(text_edit->get_caret_column() == 0); |
| 91 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 92 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 93 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 94 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 95 |
|
| 96 |
|
| 97 |
text_edit->undo(); |
| 98 |
MessageQueue::get_singleton()->flush(); |
| 99 |
CHECK(text_edit->get_text() == "test text"); |
| 100 |
CHECK(text_edit->get_caret_column() == 0); |
| 101 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 102 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 103 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 104 |
SIGNAL_CHECK_FALSE("text_set"); |
| 105 |
|
| 106 |
text_edit->redo(); |
| 107 |
MessageQueue::get_singleton()->flush(); |
| 108 |
CHECK(text_edit->get_text() == ""); |
| 109 |
CHECK(text_edit->get_caret_column() == 0); |
| 110 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 111 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 112 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 113 |
SIGNAL_CHECK_FALSE("text_set"); |
| 114 |
|
| 115 |
|
| 116 |
text_edit->undo(); |
| 117 |
MessageQueue::get_singleton()->flush(); |
| 118 |
CHECK(text_edit->get_text() == "test text"); |
| 119 |
CHECK(text_edit->get_caret_column() == 0); |
| 120 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 121 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 122 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 123 |
SIGNAL_CHECK_FALSE("text_set"); |
| 124 |
|
| 125 |
|
| 126 |
text_edit->set_editable(false); |
| 127 |
|
| 128 |
Array lines_edited_clear_args = { { 1, 0 } }; |
| 129 |
|
| 130 |
text_edit->clear(); |
| 131 |
MessageQueue::get_singleton()->flush(); |
| 132 |
CHECK(text_edit->get_text() == ""); |
| 133 |
CHECK(text_edit->get_caret_column() == 0); |
| 134 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 135 |
SIGNAL_CHECK("lines_edited_from", lines_edited_clear_args); |
| 136 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 137 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 138 |
|
| 139 |
text_edit->set_editable(true); |
| 140 |
|
| 141 |
text_edit->undo(); |
| 142 |
MessageQueue::get_singleton()->flush(); |
| 143 |
CHECK(text_edit->get_text() == ""); |
| 144 |
CHECK(text_edit->get_caret_column() == 0); |
| 145 |
SIGNAL_CHECK_FALSE("text_set"); |
| 146 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 147 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 148 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 149 |
|
| 150 |
|
| 151 |
text_edit->set_editable(false); |
| 152 |
|
| 153 |
text_edit->set_text("test text"); |
| 154 |
MessageQueue::get_singleton()->flush(); |
| 155 |
CHECK(text_edit->get_text() == "test text"); |
| 156 |
CHECK(text_edit->get_caret_column() == 0); |
| 157 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 158 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 159 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 160 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 161 |
|
| 162 |
text_edit->set_editable(true); |
| 163 |
|
| 164 |
text_edit->undo(); |
| 165 |
MessageQueue::get_singleton()->flush(); |
| 166 |
CHECK(text_edit->get_text() == ""); |
| 167 |
CHECK(text_edit->get_caret_column() == 0); |
| 168 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 169 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 170 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 171 |
SIGNAL_CHECK_FALSE("text_set"); |
| 172 |
|
| 173 |
|
| 174 |
text_edit->set_text("test text"); |
| 175 |
MessageQueue::get_singleton()->flush(); |
| 176 |
text_edit->select_all(); |
| 177 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 178 |
MessageQueue::get_singleton()->flush(); |
| 179 |
CHECK(text_edit->get_text() == "test text"); |
| 180 |
CHECK(text_edit->get_caret_column() == 9); |
| 181 |
CHECK(text_edit->has_selection()); |
| 182 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 183 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 184 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 185 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 186 |
|
| 187 |
text_edit->set_text("test"); |
| 188 |
MessageQueue::get_singleton()->flush(); |
| 189 |
CHECK(text_edit->get_text() == "test"); |
| 190 |
CHECK(text_edit->get_caret_column() == 0); |
| 191 |
CHECK_FALSE(text_edit->has_selection()); |
| 192 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 193 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 194 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 195 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 196 |
|
| 197 |
text_edit->select_all(); |
| 198 |
MessageQueue::get_singleton()->flush(); |
| 199 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 200 |
CHECK(text_edit->has_selection()); |
| 201 |
|
| 202 |
text_edit->clear(); |
| 203 |
MessageQueue::get_singleton()->flush(); |
| 204 |
CHECK(text_edit->get_text() == ""); |
| 205 |
CHECK(text_edit->get_caret_column() == 0); |
| 206 |
CHECK_FALSE(text_edit->has_selection()); |
| 207 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 208 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 209 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 210 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 211 |
} |
| 212 |
|
| 213 |
SUBCASE("[TextEdit] insert text") { |
| 214 |
|
| 215 |
ERR_PRINT_OFF; |
| 216 |
text_edit->insert_text("test", 1, 0); |
| 217 |
ERR_PRINT_ON; |
| 218 |
MessageQueue::get_singleton()->flush(); |
| 219 |
CHECK(text_edit->get_text() == ""); |
| 220 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 221 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 222 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 223 |
SIGNAL_CHECK_FALSE("text_set"); |
| 224 |
|
| 225 |
|
| 226 |
lines_edited_args = { { 0, 0 } }; |
| 227 |
|
| 228 |
text_edit->insert_text("tes", 0, 0); |
| 229 |
MessageQueue::get_singleton()->flush(); |
| 230 |
CHECK(text_edit->get_text() == "tes"); |
| 231 |
CHECK(text_edit->get_caret_line() == 0); |
| 232 |
CHECK(text_edit->get_caret_column() == 3); |
| 233 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 234 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 235 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 236 |
SIGNAL_CHECK_FALSE("text_set"); |
| 237 |
|
| 238 |
|
| 239 |
lines_edited_args = { { 0, 1 } }; |
| 240 |
|
| 241 |
text_edit->insert_text("t\ninserting text", 0, 3); |
| 242 |
MessageQueue::get_singleton()->flush(); |
| 243 |
CHECK(text_edit->get_text() == "test\ninserting text"); |
| 244 |
CHECK(text_edit->get_caret_line() == 1); |
| 245 |
CHECK(text_edit->get_caret_column() == 14); |
| 246 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 247 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 248 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 249 |
SIGNAL_CHECK_FALSE("text_set"); |
| 250 |
|
| 251 |
|
| 252 |
lines_edited_args = { { 1, 1 } }; |
| 253 |
|
| 254 |
text_edit->set_editable(false); |
| 255 |
text_edit->insert_text("mid", 1, 2); |
| 256 |
MessageQueue::get_singleton()->flush(); |
| 257 |
CHECK(text_edit->get_text() == "test\ninmidserting text"); |
| 258 |
CHECK(text_edit->get_caret_line() == 1); |
| 259 |
CHECK(text_edit->get_caret_column() == 17); |
| 260 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 261 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 262 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 263 |
SIGNAL_CHECK_FALSE("text_set"); |
| 264 |
text_edit->set_editable(true); |
| 265 |
|
| 266 |
|
| 267 |
text_edit->undo(); |
| 268 |
MessageQueue::get_singleton()->flush(); |
| 269 |
CHECK(text_edit->get_text() == "test\ninserting text"); |
| 270 |
CHECK(text_edit->get_caret_line() == 1); |
| 271 |
CHECK(text_edit->get_caret_column() == 14); |
| 272 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 273 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 274 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 275 |
SIGNAL_CHECK_FALSE("text_set"); |
| 276 |
|
| 277 |
|
| 278 |
text_edit->redo(); |
| 279 |
MessageQueue::get_singleton()->flush(); |
| 280 |
CHECK(text_edit->get_text() == "test\ninmidserting text"); |
| 281 |
CHECK(text_edit->get_caret_line() == 1); |
| 282 |
CHECK(text_edit->get_caret_column() == 17); |
| 283 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 284 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 285 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 286 |
SIGNAL_CHECK_FALSE("text_set"); |
| 287 |
|
| 288 |
|
| 289 |
text_edit->add_caret(1, 1); |
| 290 |
text_edit->add_caret(1, 4); |
| 291 |
text_edit->select(1, 4, 1, 6, 2); |
| 292 |
MessageQueue::get_singleton()->flush(); |
| 293 |
SIGNAL_DISCARD("caret_changed"); |
| 294 |
lines_edited_args = { { 1, 2 } }; |
| 295 |
|
| 296 |
text_edit->insert_text("\n ", 1, 2); |
| 297 |
MessageQueue::get_singleton()->flush(); |
| 298 |
CHECK(text_edit->get_text() == "test\nin\n midserting text"); |
| 299 |
CHECK(text_edit->get_caret_count() == 3); |
| 300 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 301 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 302 |
CHECK(text_edit->get_caret_column(0) == 16); |
| 303 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 304 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 305 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 306 |
CHECK(text_edit->has_selection(2)); |
| 307 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 308 |
CHECK(text_edit->get_caret_column(2) == 5); |
| 309 |
CHECK(text_edit->get_selection_origin_line(2) == 2); |
| 310 |
CHECK(text_edit->get_selection_origin_column(2) == 3); |
| 311 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 312 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 313 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 314 |
SIGNAL_CHECK_FALSE("text_set"); |
| 315 |
text_edit->remove_secondary_carets(); |
| 316 |
text_edit->deselect(); |
| 317 |
|
| 318 |
|
| 319 |
text_edit->set_text("test text"); |
| 320 |
text_edit->add_caret(0, 8); |
| 321 |
text_edit->select(0, 1, 0, 4, 0); |
| 322 |
text_edit->select(0, 4, 0, 8, 1); |
| 323 |
MessageQueue::get_singleton()->flush(); |
| 324 |
SIGNAL_DISCARD("text_set"); |
| 325 |
SIGNAL_DISCARD("lines_edited_from"); |
| 326 |
SIGNAL_DISCARD("text_changed"); |
| 327 |
SIGNAL_DISCARD("caret_changed"); |
| 328 |
lines_edited_args = { { 0, 0 } }; |
| 329 |
|
| 330 |
text_edit->insert_text("a", 0, 4, true, false); |
| 331 |
MessageQueue::get_singleton()->flush(); |
| 332 |
CHECK(text_edit->get_text() == "testa text"); |
| 333 |
CHECK(text_edit->get_caret_count() == 2); |
| 334 |
CHECK(text_edit->has_selection(0)); |
| 335 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 336 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 337 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 338 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 339 |
CHECK(text_edit->has_selection(1)); |
| 340 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 341 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 342 |
CHECK(text_edit->get_selection_origin_line(1) == 0); |
| 343 |
CHECK(text_edit->get_selection_origin_column(1) == 5); |
| 344 |
|
| 345 |
|
| 346 |
text_edit->set_text("test text"); |
| 347 |
text_edit->add_caret(0, 8); |
| 348 |
text_edit->select(0, 1, 0, 4, 0); |
| 349 |
text_edit->select(0, 4, 0, 8, 1); |
| 350 |
MessageQueue::get_singleton()->flush(); |
| 351 |
SIGNAL_DISCARD("text_set"); |
| 352 |
SIGNAL_DISCARD("lines_edited_from"); |
| 353 |
SIGNAL_DISCARD("text_changed"); |
| 354 |
SIGNAL_DISCARD("caret_changed"); |
| 355 |
lines_edited_args = { { 0, 0 } }; |
| 356 |
|
| 357 |
text_edit->insert_text("a", 0, 4, false, false); |
| 358 |
MessageQueue::get_singleton()->flush(); |
| 359 |
CHECK(text_edit->get_text() == "testa text"); |
| 360 |
CHECK(text_edit->get_caret_count() == 2); |
| 361 |
CHECK(text_edit->has_selection(0)); |
| 362 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 363 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 364 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 365 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 366 |
CHECK(text_edit->has_selection(1)); |
| 367 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 368 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 369 |
CHECK(text_edit->get_selection_origin_line(1) == 0); |
| 370 |
CHECK(text_edit->get_selection_origin_column(1) == 4); |
| 371 |
|
| 372 |
|
| 373 |
text_edit->set_text("test text"); |
| 374 |
text_edit->add_caret(0, 8); |
| 375 |
text_edit->select(0, 1, 0, 4, 0); |
| 376 |
text_edit->select(0, 4, 0, 8, 1); |
| 377 |
MessageQueue::get_singleton()->flush(); |
| 378 |
SIGNAL_DISCARD("text_set"); |
| 379 |
SIGNAL_DISCARD("lines_edited_from"); |
| 380 |
SIGNAL_DISCARD("text_changed"); |
| 381 |
SIGNAL_DISCARD("caret_changed"); |
| 382 |
lines_edited_args = { { 0, 0 } }; |
| 383 |
|
| 384 |
text_edit->insert_text("a", 0, 4, true, true); |
| 385 |
MessageQueue::get_singleton()->flush(); |
| 386 |
CHECK(text_edit->get_text() == "testa text"); |
| 387 |
CHECK(text_edit->get_caret_count() == 2); |
| 388 |
CHECK(text_edit->has_selection(0)); |
| 389 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 390 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 391 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 392 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 393 |
CHECK(text_edit->has_selection(1)); |
| 394 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 395 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 396 |
CHECK(text_edit->get_selection_origin_line(1) == 0); |
| 397 |
CHECK(text_edit->get_selection_origin_column(1) == 5); |
| 398 |
|
| 399 |
|
| 400 |
text_edit->set_text("test text"); |
| 401 |
text_edit->add_caret(0, 8); |
| 402 |
text_edit->select(0, 1, 0, 4, 0); |
| 403 |
text_edit->select(0, 4, 0, 8, 1); |
| 404 |
MessageQueue::get_singleton()->flush(); |
| 405 |
SIGNAL_DISCARD("text_set"); |
| 406 |
SIGNAL_DISCARD("lines_edited_from"); |
| 407 |
SIGNAL_DISCARD("text_changed"); |
| 408 |
SIGNAL_DISCARD("caret_changed"); |
| 409 |
lines_edited_args = { { 0, 0 } }; |
| 410 |
|
| 411 |
text_edit->insert_text("a", 0, 4, false, true); |
| 412 |
MessageQueue::get_singleton()->flush(); |
| 413 |
CHECK(text_edit->get_text() == "testa text"); |
| 414 |
CHECK(text_edit->get_caret_count() == 1); |
| 415 |
CHECK(text_edit->has_selection(0)); |
| 416 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 417 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 418 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 419 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 420 |
} |
| 421 |
|
| 422 |
SUBCASE("[TextEdit] remove text") { |
| 423 |
lines_edited_args = { { 0, 0 }, { 0, 2 } }; |
| 424 |
|
| 425 |
text_edit->set_text("test\nremoveing text\nthird line"); |
| 426 |
MessageQueue::get_singleton()->flush(); |
| 427 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 428 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 429 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 430 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 431 |
|
| 432 |
|
| 433 |
ERR_PRINT_OFF; |
| 434 |
text_edit->remove_text(3, 0, 3, 4); |
| 435 |
ERR_PRINT_ON; |
| 436 |
MessageQueue::get_singleton()->flush(); |
| 437 |
CHECK(text_edit->get_text() == "test\nremoveing text\nthird line"); |
| 438 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 439 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 440 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 441 |
SIGNAL_CHECK_FALSE("text_set"); |
| 442 |
|
| 443 |
|
| 444 |
text_edit->set_caret_line(2); |
| 445 |
text_edit->set_caret_column(10); |
| 446 |
MessageQueue::get_singleton()->flush(); |
| 447 |
SIGNAL_DISCARD("caret_changed"); |
| 448 |
lines_edited_args = { { 2, 1 } }; |
| 449 |
|
| 450 |
text_edit->remove_text(1, 9, 2, 2); |
| 451 |
MessageQueue::get_singleton()->flush(); |
| 452 |
CHECK(text_edit->get_text() == "test\nremoveingird line"); |
| 453 |
CHECK(text_edit->get_caret_line() == 1); |
| 454 |
CHECK(text_edit->get_caret_column() == 17); |
| 455 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 456 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 457 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 458 |
SIGNAL_CHECK_FALSE("text_set"); |
| 459 |
|
| 460 |
|
| 461 |
lines_edited_args = { { 1, 1 } }; |
| 462 |
|
| 463 |
text_edit->set_editable(false); |
| 464 |
text_edit->remove_text(1, 5, 1, 6); |
| 465 |
MessageQueue::get_singleton()->flush(); |
| 466 |
CHECK(text_edit->get_text() == "test\nremovingird line"); |
| 467 |
CHECK(text_edit->get_caret_line() == 1); |
| 468 |
CHECK(text_edit->get_caret_column() == 16); |
| 469 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 470 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 471 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 472 |
SIGNAL_CHECK_FALSE("text_set"); |
| 473 |
text_edit->set_editable(true); |
| 474 |
|
| 475 |
|
| 476 |
text_edit->undo(); |
| 477 |
MessageQueue::get_singleton()->flush(); |
| 478 |
CHECK(text_edit->get_text() == "test\nremoveingird line"); |
| 479 |
CHECK(text_edit->get_caret_line() == 1); |
| 480 |
CHECK(text_edit->get_caret_column() == 17); |
| 481 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 482 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 483 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 484 |
SIGNAL_CHECK_FALSE("text_set"); |
| 485 |
|
| 486 |
|
| 487 |
text_edit->redo(); |
| 488 |
MessageQueue::get_singleton()->flush(); |
| 489 |
CHECK(text_edit->get_text() == "test\nremovingird line"); |
| 490 |
CHECK(text_edit->get_caret_line() == 1); |
| 491 |
CHECK(text_edit->get_caret_column() == 16); |
| 492 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 493 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 494 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 495 |
SIGNAL_CHECK_FALSE("text_set"); |
| 496 |
|
| 497 |
|
| 498 |
text_edit->set_caret_line(1); |
| 499 |
text_edit->set_caret_column(9); |
| 500 |
text_edit->add_caret(1, 10); |
| 501 |
text_edit->select(1, 10, 1, 13, 1); |
| 502 |
text_edit->add_caret(1, 14); |
| 503 |
text_edit->add_caret(1, 2); |
| 504 |
MessageQueue::get_singleton()->flush(); |
| 505 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 506 |
|
| 507 |
text_edit->remove_text(1, 8, 1, 11); |
| 508 |
MessageQueue::get_singleton()->flush(); |
| 509 |
CHECK(text_edit->get_text() == "test\nremoving line"); |
| 510 |
|
| 511 |
CHECK(text_edit->get_caret_count() == 3); |
| 512 |
CHECK(text_edit->has_selection(0)); |
| 513 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 514 |
CHECK(text_edit->get_caret_column(0) == 10); |
| 515 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 516 |
CHECK(text_edit->get_selection_origin_column(0) == 8); |
| 517 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 518 |
CHECK(text_edit->get_caret_column(1) == 11); |
| 519 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 520 |
CHECK(text_edit->get_caret_column(2) == 2); |
| 521 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 522 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 523 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 524 |
SIGNAL_CHECK_FALSE("text_set"); |
| 525 |
text_edit->remove_secondary_carets(); |
| 526 |
} |
| 527 |
|
| 528 |
SUBCASE("[TextEdit] set and get line") { |
| 529 |
|
| 530 |
text_edit->set_line(1, "test"); |
| 531 |
MessageQueue::get_singleton()->flush(); |
| 532 |
CHECK(text_edit->get_text() == ""); |
| 533 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 534 |
SIGNAL_CHECK_FALSE("text_set"); |
| 535 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 536 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 537 |
|
| 538 |
text_edit->set_line(0, "test"); |
| 539 |
MessageQueue::get_singleton()->flush(); |
| 540 |
CHECK(text_edit->get_text() == "test"); |
| 541 |
CHECK(text_edit->get_line(0) == "test"); |
| 542 |
CHECK(text_edit->get_line(1) == ""); |
| 543 |
CHECK(text_edit->get_line_count() == 1); |
| 544 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 545 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 546 |
SIGNAL_CHECK_FALSE("text_set"); |
| 547 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 548 |
|
| 549 |
|
| 550 |
text_edit->select_all(); |
| 551 |
MessageQueue::get_singleton()->flush(); |
| 552 |
SIGNAL_DISCARD("caret_changed"); |
| 553 |
|
| 554 |
text_edit->set_line(0, "test text"); |
| 555 |
MessageQueue::get_singleton()->flush(); |
| 556 |
CHECK(text_edit->get_line(0) == "test text"); |
| 557 |
CHECK(text_edit->has_selection()); |
| 558 |
CHECK(text_edit->get_selected_text() == "test"); |
| 559 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 560 |
CHECK(text_edit->get_caret_column() == 4); |
| 561 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 562 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 563 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 564 |
SIGNAL_CHECK_FALSE("text_set"); |
| 565 |
|
| 566 |
|
| 567 |
text_edit->set_editable(false); |
| 568 |
text_edit->set_line(0, "te"); |
| 569 |
MessageQueue::get_singleton()->flush(); |
| 570 |
CHECK(text_edit->get_line(0) == "te"); |
| 571 |
CHECK(text_edit->has_selection()); |
| 572 |
CHECK(text_edit->get_selected_text() == "te"); |
| 573 |
CHECK(text_edit->get_caret_column() == 2); |
| 574 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 575 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 576 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 577 |
SIGNAL_CHECK_FALSE("text_set"); |
| 578 |
text_edit->set_editable(true); |
| 579 |
|
| 580 |
|
| 581 |
text_edit->undo(); |
| 582 |
MessageQueue::get_singleton()->flush(); |
| 583 |
CHECK(text_edit->get_line(0) == "test text"); |
| 584 |
CHECK(text_edit->has_selection()); |
| 585 |
CHECK(text_edit->get_selected_text() == "test"); |
| 586 |
CHECK(text_edit->get_caret_column() == 4); |
| 587 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 588 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 589 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 590 |
SIGNAL_CHECK_FALSE("text_set"); |
| 591 |
|
| 592 |
text_edit->redo(); |
| 593 |
MessageQueue::get_singleton()->flush(); |
| 594 |
CHECK(text_edit->get_line(0) == "te"); |
| 595 |
CHECK(text_edit->has_selection()); |
| 596 |
CHECK(text_edit->get_caret_column() == 2); |
| 597 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 598 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 599 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 600 |
SIGNAL_CHECK_FALSE("text_set"); |
| 601 |
|
| 602 |
|
| 603 |
ERR_PRINT_OFF; |
| 604 |
text_edit->set_line(-1, "test"); |
| 605 |
MessageQueue::get_singleton()->flush(); |
| 606 |
CHECK(text_edit->get_line(0) == "te"); |
| 607 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 608 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 609 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 610 |
SIGNAL_CHECK_FALSE("text_set"); |
| 611 |
|
| 612 |
text_edit->set_line(1, "test"); |
| 613 |
MessageQueue::get_singleton()->flush(); |
| 614 |
CHECK(text_edit->get_line(0) == "te"); |
| 615 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 616 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 617 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 618 |
SIGNAL_CHECK_FALSE("text_set"); |
| 619 |
ERR_PRINT_ON; |
| 620 |
|
| 621 |
|
| 622 |
text_edit->set_text("test text"); |
| 623 |
text_edit->select(0, 8, 0, 6); |
| 624 |
MessageQueue::get_singleton()->flush(); |
| 625 |
SIGNAL_DISCARD("lines_edited_from"); |
| 626 |
SIGNAL_DISCARD("text_set"); |
| 627 |
SIGNAL_DISCARD("text_changed"); |
| 628 |
SIGNAL_DISCARD("caret_changed"); |
| 629 |
|
| 630 |
text_edit->set_line(0, "test"); |
| 631 |
MessageQueue::get_singleton()->flush(); |
| 632 |
CHECK(text_edit->get_line(0) == "test"); |
| 633 |
CHECK_FALSE(text_edit->has_selection()); |
| 634 |
CHECK(text_edit->get_caret_column() == 4); |
| 635 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 636 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 637 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 638 |
SIGNAL_CHECK_FALSE("text_set"); |
| 639 |
|
| 640 |
|
| 641 |
text_edit->set_text("test text"); |
| 642 |
text_edit->set_caret_column(2); |
| 643 |
text_edit->add_caret(0, 0); |
| 644 |
text_edit->add_caret(0, 1); |
| 645 |
text_edit->add_caret(0, 6); |
| 646 |
MessageQueue::get_singleton()->flush(); |
| 647 |
SIGNAL_DISCARD("lines_edited_from"); |
| 648 |
SIGNAL_DISCARD("text_set"); |
| 649 |
SIGNAL_DISCARD("text_changed"); |
| 650 |
SIGNAL_DISCARD("caret_changed"); |
| 651 |
|
| 652 |
text_edit->set_line(0, "\tset line"); |
| 653 |
MessageQueue::get_singleton()->flush(); |
| 654 |
CHECK(text_edit->get_line(0) == "\tset line"); |
| 655 |
CHECK(text_edit->get_caret_count() == 3); |
| 656 |
CHECK_FALSE(text_edit->has_selection()); |
| 657 |
|
| 658 |
CHECK(text_edit->get_caret_column(0) == 1); |
| 659 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 660 |
|
| 661 |
CHECK(text_edit->get_caret_column(2) == 4); |
| 662 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 663 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 664 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 665 |
SIGNAL_CHECK_FALSE("text_set"); |
| 666 |
text_edit->remove_secondary_carets(); |
| 667 |
|
| 668 |
|
| 669 |
text_edit->set_text("test text\nsecond line"); |
| 670 |
text_edit->set_caret_column(5); |
| 671 |
text_edit->add_caret(1, 6); |
| 672 |
MessageQueue::get_singleton()->flush(); |
| 673 |
SIGNAL_DISCARD("lines_edited_from"); |
| 674 |
SIGNAL_DISCARD("text_set"); |
| 675 |
SIGNAL_DISCARD("text_changed"); |
| 676 |
SIGNAL_DISCARD("caret_changed"); |
| 677 |
lines_edited_args = { { 0, 0 }, { 0, 1 } }; |
| 678 |
|
| 679 |
text_edit->set_line(0, "multiple\nlines"); |
| 680 |
MessageQueue::get_singleton()->flush(); |
| 681 |
CHECK(text_edit->get_text() == "multiple\nlines\nsecond line"); |
| 682 |
CHECK(text_edit->get_caret_count() == 2); |
| 683 |
CHECK_FALSE(text_edit->has_selection()); |
| 684 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 685 |
CHECK(text_edit->get_caret_column(0) == 3); |
| 686 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 687 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 688 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 689 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 690 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 691 |
SIGNAL_CHECK_FALSE("text_set"); |
| 692 |
text_edit->remove_secondary_carets(); |
| 693 |
} |
| 694 |
|
| 695 |
SUBCASE("[TextEdit] swap lines") { |
| 696 |
lines_edited_args = { { 0, 0 }, { 0, 1 } }; |
| 697 |
|
| 698 |
text_edit->set_text("testing\nswap"); |
| 699 |
MessageQueue::get_singleton()->flush(); |
| 700 |
CHECK(text_edit->get_text() == "testing\nswap"); |
| 701 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 702 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 703 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 704 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 705 |
|
| 706 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 707 |
MessageQueue::get_singleton()->flush(); |
| 708 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 709 |
|
| 710 |
lines_edited_args = { { 0, 0 }, { 0, 0 }, { 1, 1 }, { 1, 1 } }; |
| 711 |
|
| 712 |
|
| 713 |
text_edit->set_editable(false); |
| 714 |
text_edit->swap_lines(1, 0); |
| 715 |
MessageQueue::get_singleton()->flush(); |
| 716 |
CHECK(text_edit->get_text() == "swap\ntesting"); |
| 717 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 718 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 719 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 720 |
SIGNAL_CHECK_FALSE("text_set"); |
| 721 |
text_edit->set_editable(true); |
| 722 |
|
| 723 |
|
| 724 |
text_edit->undo(); |
| 725 |
MessageQueue::get_singleton()->flush(); |
| 726 |
CHECK(text_edit->get_text() == "testing\nswap"); |
| 727 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 728 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 729 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 730 |
SIGNAL_CHECK_FALSE("text_set"); |
| 731 |
|
| 732 |
text_edit->redo(); |
| 733 |
MessageQueue::get_singleton()->flush(); |
| 734 |
CHECK(text_edit->get_text() == "swap\ntesting"); |
| 735 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 736 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 737 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 738 |
SIGNAL_CHECK_FALSE("text_set"); |
| 739 |
|
| 740 |
|
| 741 |
ERR_PRINT_OFF; |
| 742 |
text_edit->swap_lines(-1, 0); |
| 743 |
CHECK(text_edit->get_text() == "swap\ntesting"); |
| 744 |
text_edit->swap_lines(0, -1); |
| 745 |
CHECK(text_edit->get_text() == "swap\ntesting"); |
| 746 |
text_edit->swap_lines(2, 0); |
| 747 |
CHECK(text_edit->get_text() == "swap\ntesting"); |
| 748 |
text_edit->swap_lines(0, 2); |
| 749 |
CHECK(text_edit->get_text() == "swap\ntesting"); |
| 750 |
MessageQueue::get_singleton()->flush(); |
| 751 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 752 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 753 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 754 |
SIGNAL_CHECK_FALSE("text_set"); |
| 755 |
ERR_PRINT_ON; |
| 756 |
|
| 757 |
|
| 758 |
text_edit->set_caret_line(0); |
| 759 |
text_edit->set_caret_column(2); |
| 760 |
text_edit->select(0, 0, 0, 2); |
| 761 |
text_edit->add_caret(1, 6); |
| 762 |
MessageQueue::get_singleton()->flush(); |
| 763 |
SIGNAL_DISCARD("caret_changed"); |
| 764 |
lines_edited_args = { { 1, 1 }, { 1, 1 }, { 0, 0 }, { 0, 0 } }; |
| 765 |
|
| 766 |
text_edit->swap_lines(0, 1); |
| 767 |
MessageQueue::get_singleton()->flush(); |
| 768 |
CHECK(text_edit->get_text() == "testing\nswap"); |
| 769 |
CHECK(text_edit->get_caret_count() == 2); |
| 770 |
CHECK(text_edit->has_selection(0)); |
| 771 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 772 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 773 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 774 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 775 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 776 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 777 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 778 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 779 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 780 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 781 |
SIGNAL_CHECK_FALSE("text_set"); |
| 782 |
text_edit->remove_secondary_carets(); |
| 783 |
|
| 784 |
|
| 785 |
text_edit->insert_line_at(1, "new line"); |
| 786 |
text_edit->set_caret_line(1); |
| 787 |
text_edit->set_caret_column(5); |
| 788 |
MessageQueue::get_singleton()->flush(); |
| 789 |
CHECK(text_edit->get_text() == "testing\nnew line\nswap"); |
| 790 |
SIGNAL_DISCARD("caret_changed"); |
| 791 |
SIGNAL_DISCARD("lines_edited_from"); |
| 792 |
SIGNAL_DISCARD("text_changed"); |
| 793 |
lines_edited_args = { { 2, 2 }, { 2, 2 }, { 0, 0 }, { 0, 0 } }; |
| 794 |
|
| 795 |
text_edit->swap_lines(0, 2); |
| 796 |
MessageQueue::get_singleton()->flush(); |
| 797 |
CHECK(text_edit->get_text() == "swap\nnew line\ntesting"); |
| 798 |
CHECK(text_edit->get_caret_line() == 1); |
| 799 |
CHECK(text_edit->get_caret_column() == 5); |
| 800 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 801 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 802 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 803 |
SIGNAL_CHECK_FALSE("text_set"); |
| 804 |
} |
| 805 |
|
| 806 |
SUBCASE("[TextEdit] insert line at") { |
| 807 |
lines_edited_args = { { 0, 0 }, { 0, 1 } }; |
| 808 |
|
| 809 |
text_edit->set_text("testing\nswap"); |
| 810 |
MessageQueue::get_singleton()->flush(); |
| 811 |
CHECK(text_edit->get_text() == "testing\nswap"); |
| 812 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 813 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 814 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 815 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 816 |
|
| 817 |
text_edit->select_all(); |
| 818 |
MessageQueue::get_singleton()->flush(); |
| 819 |
CHECK(text_edit->has_selection()); |
| 820 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 821 |
CHECK(text_edit->get_selection_to_line() == 1); |
| 822 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 823 |
|
| 824 |
|
| 825 |
text_edit->set_editable(false); |
| 826 |
lines_edited_args = { { 0, 1 } }; |
| 827 |
text_edit->insert_line_at(0, "new"); |
| 828 |
MessageQueue::get_singleton()->flush(); |
| 829 |
CHECK(text_edit->get_text() == "new\ntesting\nswap"); |
| 830 |
CHECK(text_edit->get_caret_line() == 2); |
| 831 |
CHECK(text_edit->get_caret_column() == text_edit->get_line(2).size() - 1); |
| 832 |
CHECK(text_edit->has_selection()); |
| 833 |
CHECK(text_edit->get_selection_from_line() == 1); |
| 834 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 835 |
CHECK(text_edit->get_selection_to_line() == 2); |
| 836 |
CHECK(text_edit->get_selection_to_column() == 4); |
| 837 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 838 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 839 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 840 |
SIGNAL_CHECK_FALSE("text_set"); |
| 841 |
text_edit->set_editable(true); |
| 842 |
|
| 843 |
|
| 844 |
text_edit->undo(); |
| 845 |
MessageQueue::get_singleton()->flush(); |
| 846 |
CHECK(text_edit->get_text() == "testing\nswap"); |
| 847 |
CHECK(text_edit->has_selection()); |
| 848 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 849 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 850 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 851 |
SIGNAL_CHECK_FALSE("text_set"); |
| 852 |
|
| 853 |
text_edit->redo(); |
| 854 |
MessageQueue::get_singleton()->flush(); |
| 855 |
CHECK(text_edit->get_text() == "new\ntesting\nswap"); |
| 856 |
CHECK(text_edit->has_selection()); |
| 857 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 858 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 859 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 860 |
SIGNAL_CHECK_FALSE("text_set"); |
| 861 |
|
| 862 |
|
| 863 |
text_edit->select_all(); |
| 864 |
MessageQueue::get_singleton()->flush(); |
| 865 |
CHECK(text_edit->has_selection()); |
| 866 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 867 |
CHECK(text_edit->get_selection_to_line() == 2); |
| 868 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 869 |
lines_edited_args = { { 2, 3 } }; |
| 870 |
|
| 871 |
text_edit->insert_line_at(2, "after"); |
| 872 |
MessageQueue::get_singleton()->flush(); |
| 873 |
CHECK(text_edit->get_text() == "new\ntesting\nafter\nswap"); |
| 874 |
CHECK(text_edit->get_caret_line() == 3); |
| 875 |
CHECK(text_edit->get_caret_column() == text_edit->get_line(3).size() - 1); |
| 876 |
CHECK(text_edit->has_selection()); |
| 877 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 878 |
CHECK(text_edit->get_selection_to_line() == 3); |
| 879 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 880 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 881 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 882 |
SIGNAL_CHECK_FALSE("text_set"); |
| 883 |
|
| 884 |
|
| 885 |
ERR_PRINT_OFF; |
| 886 |
text_edit->insert_line_at(-1, "after"); |
| 887 |
CHECK(text_edit->get_text() == "new\ntesting\nafter\nswap"); |
| 888 |
text_edit->insert_line_at(4, "after"); |
| 889 |
CHECK(text_edit->get_text() == "new\ntesting\nafter\nswap"); |
| 890 |
MessageQueue::get_singleton()->flush(); |
| 891 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 892 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 893 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 894 |
SIGNAL_CHECK_FALSE("text_set"); |
| 895 |
ERR_PRINT_ON; |
| 896 |
|
| 897 |
|
| 898 |
text_edit->select(0, 1, 2, 2); |
| 899 |
MessageQueue::get_singleton()->flush(); |
| 900 |
SIGNAL_DISCARD("caret_changed"); |
| 901 |
lines_edited_args = { { 2, 4 } }; |
| 902 |
|
| 903 |
text_edit->insert_line_at(2, "multiple\nlines"); |
| 904 |
MessageQueue::get_singleton()->flush(); |
| 905 |
CHECK(text_edit->get_text() == "new\ntesting\nmultiple\nlines\nafter\nswap"); |
| 906 |
CHECK(text_edit->has_selection()); |
| 907 |
CHECK(text_edit->get_caret_line() == 4); |
| 908 |
CHECK(text_edit->get_caret_column() == 2); |
| 909 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 910 |
CHECK(text_edit->get_selection_origin_column() == 1); |
| 911 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 912 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 913 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 914 |
SIGNAL_CHECK_FALSE("text_set"); |
| 915 |
} |
| 916 |
|
| 917 |
SUBCASE("[TextEdit] remove line at") { |
| 918 |
lines_edited_args = { { 0, 0 }, { 0, 5 } }; |
| 919 |
text_edit->set_text("testing\nremove line at\n\tremove\nlines\n\ntest"); |
| 920 |
MessageQueue::get_singleton()->flush(); |
| 921 |
CHECK(text_edit->get_text() == "testing\nremove line at\n\tremove\nlines\n\ntest"); |
| 922 |
SIGNAL_CHECK("text_set", empty_signal_args); |
| 923 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 924 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 925 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 926 |
|
| 927 |
|
| 928 |
text_edit->set_caret_line(2); |
| 929 |
text_edit->set_caret_column(0); |
| 930 |
text_edit->add_caret(2, 7); |
| 931 |
text_edit->select(2, 1, 2, 7, 1); |
| 932 |
text_edit->add_caret(3, 1); |
| 933 |
text_edit->add_caret(4, 5); |
| 934 |
text_edit->add_caret(1, 5); |
| 935 |
MessageQueue::get_singleton()->flush(); |
| 936 |
SIGNAL_DISCARD("caret_changed"); |
| 937 |
lines_edited_args = { { 3, 2 } }; |
| 938 |
|
| 939 |
text_edit->remove_line_at(2, true); |
| 940 |
MessageQueue::get_singleton()->flush(); |
| 941 |
CHECK(text_edit->get_text() == "testing\nremove line at\nlines\n\ntest"); |
| 942 |
CHECK(text_edit->get_caret_count() == 5); |
| 943 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 944 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 945 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 946 |
CHECK(text_edit->has_selection(1)); |
| 947 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 948 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 949 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 950 |
CHECK(text_edit->get_selection_origin_column(1) == 3); |
| 951 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 952 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 953 |
CHECK(text_edit->get_caret_column(2) == 1); |
| 954 |
CHECK_FALSE(text_edit->has_selection(3)); |
| 955 |
CHECK(text_edit->get_caret_line(3) == 3); |
| 956 |
CHECK(text_edit->get_caret_column(3) == 0); |
| 957 |
CHECK_FALSE(text_edit->has_selection(4)); |
| 958 |
CHECK(text_edit->get_caret_line(4) == 1); |
| 959 |
CHECK(text_edit->get_caret_column(4) == 5); |
| 960 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 961 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 962 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 963 |
SIGNAL_CHECK_FALSE("text_set"); |
| 964 |
text_edit->remove_secondary_carets(); |
| 965 |
|
| 966 |
|
| 967 |
text_edit->set_caret_line(0); |
| 968 |
text_edit->set_caret_column(5); |
| 969 |
text_edit->add_caret(4, 4); |
| 970 |
MessageQueue::get_singleton()->flush(); |
| 971 |
SIGNAL_DISCARD("caret_changed"); |
| 972 |
lines_edited_args = { { 1, 0 } }; |
| 973 |
|
| 974 |
text_edit->remove_line_at(0, false); |
| 975 |
MessageQueue::get_singleton()->flush(); |
| 976 |
CHECK(text_edit->get_text() == "remove line at\nlines\n\ntest"); |
| 977 |
CHECK(text_edit->get_caret_count() == 2); |
| 978 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 979 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 980 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 981 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 982 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 983 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 984 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 985 |
SIGNAL_CHECK_FALSE("text_set"); |
| 986 |
text_edit->remove_secondary_carets(); |
| 987 |
|
| 988 |
|
| 989 |
text_edit->set_caret_line(2); |
| 990 |
text_edit->set_caret_column(0); |
| 991 |
MessageQueue::get_singleton()->flush(); |
| 992 |
SIGNAL_DISCARD("caret_changed"); |
| 993 |
lines_edited_args = { { 3, 2 } }; |
| 994 |
|
| 995 |
text_edit->remove_line_at(2, false); |
| 996 |
MessageQueue::get_singleton()->flush(); |
| 997 |
CHECK(text_edit->get_text() == "remove line at\nlines\ntest"); |
| 998 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 999 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 1000 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1001 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1002 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1003 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1004 |
|
| 1005 |
|
| 1006 |
text_edit->set_caret_line(2); |
| 1007 |
text_edit->set_caret_column(2); |
| 1008 |
MessageQueue::get_singleton()->flush(); |
| 1009 |
SIGNAL_DISCARD("caret_changed"); |
| 1010 |
lines_edited_args = { { 2, 1 } }; |
| 1011 |
|
| 1012 |
text_edit->remove_line_at(2, true); |
| 1013 |
MessageQueue::get_singleton()->flush(); |
| 1014 |
CHECK(text_edit->get_text() == "remove line at\nlines"); |
| 1015 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1016 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 1017 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1018 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1019 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1020 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1021 |
|
| 1022 |
|
| 1023 |
text_edit->set_caret_line(0); |
| 1024 |
text_edit->set_caret_column(2); |
| 1025 |
MessageQueue::get_singleton()->flush(); |
| 1026 |
SIGNAL_DISCARD("caret_changed"); |
| 1027 |
|
| 1028 |
ERR_PRINT_OFF |
| 1029 |
text_edit->remove_line_at(2, true); |
| 1030 |
ERR_PRINT_ON |
| 1031 |
MessageQueue::get_singleton()->flush(); |
| 1032 |
CHECK(text_edit->get_text() == "remove line at\nlines"); |
| 1033 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 1034 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 1035 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 1036 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 1037 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 1038 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1039 |
|
| 1040 |
|
| 1041 |
text_edit->set_editable(false); |
| 1042 |
text_edit->set_caret_line(1); |
| 1043 |
text_edit->set_caret_column(2); |
| 1044 |
MessageQueue::get_singleton()->flush(); |
| 1045 |
SIGNAL_DISCARD("caret_changed"); |
| 1046 |
lines_edited_args = { { 1, 0 } }; |
| 1047 |
|
| 1048 |
text_edit->remove_line_at(1, false); |
| 1049 |
MessageQueue::get_singleton()->flush(); |
| 1050 |
CHECK(text_edit->get_text() == "remove line at"); |
| 1051 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 1052 |
CHECK(text_edit->get_caret_column(0) == 1); |
| 1053 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1054 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1055 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1056 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1057 |
text_edit->set_editable(true); |
| 1058 |
|
| 1059 |
|
| 1060 |
text_edit->undo(); |
| 1061 |
MessageQueue::get_singleton()->flush(); |
| 1062 |
CHECK(text_edit->get_text() == "remove line at\nlines"); |
| 1063 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1064 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 1065 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 1066 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1067 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1068 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1069 |
|
| 1070 |
|
| 1071 |
text_edit->redo(); |
| 1072 |
MessageQueue::get_singleton()->flush(); |
| 1073 |
CHECK(text_edit->get_text() == "remove line at"); |
| 1074 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 1075 |
CHECK(text_edit->get_caret_column(0) == 1); |
| 1076 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1077 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1078 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1079 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1080 |
|
| 1081 |
|
| 1082 |
text_edit->set_caret_line(0); |
| 1083 |
text_edit->set_caret_column(10); |
| 1084 |
MessageQueue::get_singleton()->flush(); |
| 1085 |
SIGNAL_DISCARD("caret_changed"); |
| 1086 |
lines_edited_args = { { 0, 0 } }; |
| 1087 |
|
| 1088 |
text_edit->remove_line_at(0); |
| 1089 |
MessageQueue::get_singleton()->flush(); |
| 1090 |
CHECK(text_edit->get_text() == ""); |
| 1091 |
CHECK(text_edit->get_line_count() == 1); |
| 1092 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 1093 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 1094 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1095 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1096 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1097 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1098 |
} |
| 1099 |
|
| 1100 |
SUBCASE("[TextEdit] insert text at caret") { |
| 1101 |
lines_edited_args = { { 0, 1 } }; |
| 1102 |
|
| 1103 |
|
| 1104 |
text_edit->insert_text_at_caret("testing\nswap"); |
| 1105 |
MessageQueue::get_singleton()->flush(); |
| 1106 |
CHECK(text_edit->get_text() == "testing\nswap"); |
| 1107 |
CHECK(text_edit->get_caret_line() == 1); |
| 1108 |
CHECK(text_edit->get_caret_column() == text_edit->get_line(1).size() - 1); |
| 1109 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1110 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1111 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1112 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1113 |
|
| 1114 |
|
| 1115 |
text_edit->set_caret_line(0, false); |
| 1116 |
text_edit->set_caret_column(2); |
| 1117 |
MessageQueue::get_singleton()->flush(); |
| 1118 |
SIGNAL_DISCARD("caret_changed"); |
| 1119 |
|
| 1120 |
lines_edited_args = { { 0, 0 } }; |
| 1121 |
text_edit->insert_text_at_caret("mid"); |
| 1122 |
MessageQueue::get_singleton()->flush(); |
| 1123 |
CHECK(text_edit->get_text() == "temidsting\nswap"); |
| 1124 |
CHECK(text_edit->get_caret_line() == 0); |
| 1125 |
CHECK(text_edit->get_caret_column() == 5); |
| 1126 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1127 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1128 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1129 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1130 |
|
| 1131 |
|
| 1132 |
text_edit->select(0, 0, 0, text_edit->get_line(0).length()); |
| 1133 |
CHECK(text_edit->has_selection()); |
| 1134 |
lines_edited_args = { { 0, 0 }, { 0, 0 } }; |
| 1135 |
|
| 1136 |
text_edit->set_editable(false); |
| 1137 |
text_edit->insert_text_at_caret("new line"); |
| 1138 |
MessageQueue::get_singleton()->flush(); |
| 1139 |
CHECK(text_edit->get_text() == "new line\nswap"); |
| 1140 |
CHECK(text_edit->get_caret_line() == 0); |
| 1141 |
CHECK(text_edit->get_caret_column() == text_edit->get_line(0).size() - 1); |
| 1142 |
CHECK_FALSE(text_edit->has_selection()); |
| 1143 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1144 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1145 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1146 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1147 |
text_edit->set_editable(true); |
| 1148 |
|
| 1149 |
|
| 1150 |
text_edit->undo(); |
| 1151 |
MessageQueue::get_singleton()->flush(); |
| 1152 |
CHECK(text_edit->get_text() == "temidsting\nswap"); |
| 1153 |
CHECK(text_edit->get_caret_line() == 0); |
| 1154 |
CHECK(text_edit->get_caret_column() == text_edit->get_line(0).length()); |
| 1155 |
CHECK(text_edit->has_selection()); |
| 1156 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1157 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 1158 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1159 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1160 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1161 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1162 |
|
| 1163 |
text_edit->redo(); |
| 1164 |
MessageQueue::get_singleton()->flush(); |
| 1165 |
CHECK(text_edit->get_text() == "new line\nswap"); |
| 1166 |
CHECK(text_edit->get_caret_line() == 0); |
| 1167 |
CHECK(text_edit->get_caret_column() == 8); |
| 1168 |
CHECK_FALSE(text_edit->has_selection()); |
| 1169 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 1170 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 1171 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1172 |
SIGNAL_CHECK_FALSE("text_set"); |
| 1173 |
} |
| 1174 |
|
| 1175 |
SIGNAL_UNWATCH(text_edit, "text_set"); |
| 1176 |
SIGNAL_UNWATCH(text_edit, "text_changed"); |
| 1177 |
SIGNAL_UNWATCH(text_edit, "lines_edited_from"); |
| 1178 |
SIGNAL_UNWATCH(text_edit, "caret_changed"); |
| 1179 |
} |
| 1180 |
|
| 1181 |
SUBCASE("[TextEdit] indent level") { |
| 1182 |
CHECK(text_edit->get_indent_level(0) == 0); |
| 1183 |
CHECK(text_edit->get_first_non_whitespace_column(0) == 0); |
| 1184 |
|
| 1185 |
text_edit->set_line(0, "a"); |
| 1186 |
CHECK(text_edit->get_indent_level(0) == 0); |
| 1187 |
CHECK(text_edit->get_first_non_whitespace_column(0) == 0); |
| 1188 |
|
| 1189 |
text_edit->set_line(0, "\t"); |
| 1190 |
CHECK(text_edit->get_indent_level(0) == 4); |
| 1191 |
CHECK(text_edit->get_first_non_whitespace_column(0) == 1); |
| 1192 |
|
| 1193 |
text_edit->set_tab_size(8); |
| 1194 |
CHECK(text_edit->get_indent_level(0) == 8); |
| 1195 |
|
| 1196 |
text_edit->set_line(0, "\t a"); |
| 1197 |
CHECK(text_edit->get_first_non_whitespace_column(0) == 2); |
| 1198 |
CHECK(text_edit->get_indent_level(0) == 9); |
| 1199 |
} |
| 1200 |
|
| 1201 |
SUBCASE("[TextEdit] selection") { |
| 1202 |
SIGNAL_WATCH(text_edit, "text_set"); |
| 1203 |
SIGNAL_WATCH(text_edit, "text_changed"); |
| 1204 |
SIGNAL_WATCH(text_edit, "lines_edited_from"); |
| 1205 |
SIGNAL_WATCH(text_edit, "caret_changed"); |
| 1206 |
|
| 1207 |
Array lines_edited_args = { { 0, 0 }, { 0, 0 } }; |
| 1208 |
|
| 1209 |
SUBCASE("[TextEdit] select all") { |
| 1210 |
|
| 1211 |
text_edit->select_all(); |
| 1212 |
CHECK_FALSE(text_edit->has_selection()); |
| 1213 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 1214 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 1215 |
CHECK(text_edit->get_selection_to_line() == 0); |
| 1216 |
CHECK(text_edit->get_selection_to_column() == 0); |
| 1217 |
CHECK(text_edit->get_selected_text() == ""); |
| 1218 |
|
| 1219 |
|
| 1220 |
text_edit->set_text("test\nselection"); |
| 1221 |
SEND_GUI_ACTION("ui_text_select_all"); |
| 1222 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 1223 |
MessageQueue::get_singleton()->flush(); |
| 1224 |
CHECK(text_edit->get_selected_text() == "test\nselection"); |
| 1225 |
CHECK(text_edit->has_selection()); |
| 1226 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 1227 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 1228 |
CHECK(text_edit->get_selection_to_line() == 1); |
| 1229 |
CHECK(text_edit->get_selection_to_column() == 9); |
| 1230 |
CHECK(text_edit->get_selection_mode() == TextEdit::SelectionMode::SELECTION_MODE_SHIFT); |
| 1231 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1232 |
CHECK(text_edit->get_caret_line() == 1); |
| 1233 |
CHECK(text_edit->get_caret_column() == 9); |
| 1234 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1235 |
|
| 1236 |
|
| 1237 |
text_edit->set_caret_line(0); |
| 1238 |
text_edit->set_caret_column(0); |
| 1239 |
text_edit->set_selecting_enabled(false); |
| 1240 |
CHECK_FALSE(text_edit->has_selection()); |
| 1241 |
CHECK(text_edit->get_selected_text() == ""); |
| 1242 |
CHECK(text_edit->get_caret_line() == 0); |
| 1243 |
CHECK(text_edit->get_caret_column() == 0); |
| 1244 |
|
| 1245 |
text_edit->select_all(); |
| 1246 |
CHECK_FALSE(text_edit->has_selection()); |
| 1247 |
CHECK(text_edit->get_selected_text() == ""); |
| 1248 |
CHECK(text_edit->get_caret_line() == 0); |
| 1249 |
CHECK(text_edit->get_caret_column() == 0); |
| 1250 |
} |
| 1251 |
|
| 1252 |
SUBCASE("[TextEdit] select word under caret") { |
| 1253 |
text_edit->set_text("\ntest test\ntest test"); |
| 1254 |
|
| 1255 |
text_edit->set_caret_column(0); |
| 1256 |
text_edit->set_caret_line(1); |
| 1257 |
|
| 1258 |
text_edit->add_caret(2, 0); |
| 1259 |
text_edit->add_caret(2, 2); |
| 1260 |
CHECK(text_edit->get_caret_count() == 3); |
| 1261 |
|
| 1262 |
MessageQueue::get_singleton()->flush(); |
| 1263 |
|
| 1264 |
SIGNAL_DISCARD("text_set"); |
| 1265 |
SIGNAL_DISCARD("text_changed"); |
| 1266 |
SIGNAL_DISCARD("lines_edited_from"); |
| 1267 |
SIGNAL_DISCARD("caret_changed"); |
| 1268 |
|
| 1269 |
|
| 1270 |
text_edit->select_word_under_caret(); |
| 1271 |
CHECK(text_edit->has_selection(0)); |
| 1272 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1273 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1274 |
CHECK(text_edit->get_selection_from_column(0) == 0); |
| 1275 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1276 |
CHECK(text_edit->get_selection_to_column(0) == 4); |
| 1277 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1278 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1279 |
|
| 1280 |
CHECK(text_edit->has_selection(1)); |
| 1281 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1282 |
CHECK(text_edit->get_selection_from_line(1) == 2); |
| 1283 |
CHECK(text_edit->get_selection_from_column(1) == 0); |
| 1284 |
CHECK(text_edit->get_selection_to_line(1) == 2); |
| 1285 |
CHECK(text_edit->get_selection_to_column(1) == 4); |
| 1286 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 1287 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 1288 |
|
| 1289 |
CHECK(text_edit->get_caret_count() == 2); |
| 1290 |
|
| 1291 |
|
| 1292 |
text_edit->select_word_under_caret(); |
| 1293 |
CHECK_FALSE(text_edit->has_selection()); |
| 1294 |
CHECK(text_edit->get_selected_text() == ""); |
| 1295 |
|
| 1296 |
SEND_GUI_ACTION("ui_text_select_word_under_caret"); |
| 1297 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 1298 |
MessageQueue::get_singleton()->flush(); |
| 1299 |
CHECK(text_edit->has_selection(0)); |
| 1300 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1301 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1302 |
CHECK(text_edit->get_selection_from_column(0) == 0); |
| 1303 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1304 |
CHECK(text_edit->get_selection_to_column(0) == 4); |
| 1305 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1306 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1307 |
|
| 1308 |
CHECK(text_edit->has_selection(1)); |
| 1309 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1310 |
CHECK(text_edit->get_selection_from_line(1) == 2); |
| 1311 |
CHECK(text_edit->get_selection_from_column(1) == 0); |
| 1312 |
CHECK(text_edit->get_selection_to_line(1) == 2); |
| 1313 |
CHECK(text_edit->get_selection_to_column(1) == 4); |
| 1314 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 1315 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 1316 |
|
| 1317 |
CHECK(text_edit->get_selected_text() == "test\ntest"); |
| 1318 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1319 |
|
| 1320 |
|
| 1321 |
text_edit->set_selecting_enabled(false); |
| 1322 |
text_edit->select_word_under_caret(); |
| 1323 |
CHECK_FALSE(text_edit->has_selection()); |
| 1324 |
CHECK(text_edit->get_selected_text() == ""); |
| 1325 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1326 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1327 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 1328 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 1329 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 1330 |
text_edit->set_selecting_enabled(true); |
| 1331 |
|
| 1332 |
|
| 1333 |
text_edit->set_caret_line(1, false, true, -1, 0); |
| 1334 |
text_edit->set_caret_column(5, false, 0); |
| 1335 |
text_edit->set_caret_line(2, false, true, -1, 1); |
| 1336 |
text_edit->set_caret_column(5, false, 1); |
| 1337 |
|
| 1338 |
text_edit->select_word_under_caret(); |
| 1339 |
CHECK_FALSE(text_edit->has_selection()); |
| 1340 |
CHECK(text_edit->get_selected_text() == ""); |
| 1341 |
|
| 1342 |
text_edit->select_word_under_caret(); |
| 1343 |
CHECK_FALSE(text_edit->has_selection()); |
| 1344 |
CHECK(text_edit->get_selected_text() == ""); |
| 1345 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1346 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 1347 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 1348 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 1349 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 1350 |
} |
| 1351 |
|
| 1352 |
SUBCASE("[TextEdit] add selection for next occurrence") { |
| 1353 |
text_edit->set_text("\ntest other_test\nrandom test\nword test word nonrandom"); |
| 1354 |
text_edit->set_caret_column(0); |
| 1355 |
text_edit->set_caret_line(1); |
| 1356 |
|
| 1357 |
|
| 1358 |
text_edit->add_selection_for_next_occurrence(); |
| 1359 |
CHECK(text_edit->get_caret_count() == 1); |
| 1360 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1361 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1362 |
CHECK(text_edit->get_selection_from_column(0) == 0); |
| 1363 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1364 |
CHECK(text_edit->get_selection_to_column(0) == 4); |
| 1365 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1366 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1367 |
|
| 1368 |
text_edit->add_selection_for_next_occurrence(); |
| 1369 |
CHECK(text_edit->get_caret_count() == 2); |
| 1370 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1371 |
CHECK(text_edit->get_selection_from_line(1) == 1); |
| 1372 |
CHECK(text_edit->get_selection_from_column(1) == 13); |
| 1373 |
CHECK(text_edit->get_selection_to_line(1) == 1); |
| 1374 |
CHECK(text_edit->get_selection_to_column(1) == 17); |
| 1375 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 1376 |
CHECK(text_edit->get_caret_column(1) == 17); |
| 1377 |
|
| 1378 |
text_edit->add_selection_for_next_occurrence(); |
| 1379 |
CHECK(text_edit->get_caret_count() == 3); |
| 1380 |
CHECK(text_edit->get_selected_text(2) == "test"); |
| 1381 |
CHECK(text_edit->get_selection_from_line(2) == 2); |
| 1382 |
CHECK(text_edit->get_selection_from_column(2) == 9); |
| 1383 |
CHECK(text_edit->get_selection_to_line(2) == 2); |
| 1384 |
CHECK(text_edit->get_selection_to_column(2) == 13); |
| 1385 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 1386 |
CHECK(text_edit->get_caret_column(2) == 13); |
| 1387 |
|
| 1388 |
text_edit->add_selection_for_next_occurrence(); |
| 1389 |
CHECK(text_edit->get_caret_count() == 4); |
| 1390 |
CHECK(text_edit->get_selected_text(3) == "test"); |
| 1391 |
CHECK(text_edit->get_selection_from_line(3) == 3); |
| 1392 |
CHECK(text_edit->get_selection_from_column(3) == 5); |
| 1393 |
CHECK(text_edit->get_selection_to_line(3) == 3); |
| 1394 |
CHECK(text_edit->get_selection_to_column(3) == 9); |
| 1395 |
CHECK(text_edit->get_caret_line(3) == 3); |
| 1396 |
CHECK(text_edit->get_caret_column(3) == 9); |
| 1397 |
|
| 1398 |
|
| 1399 |
text_edit->add_caret(2, 1); |
| 1400 |
text_edit->select(2, 0, 2, 4, 4); |
| 1401 |
CHECK(text_edit->get_selected_text(4) == "rand"); |
| 1402 |
|
| 1403 |
text_edit->add_selection_for_next_occurrence(); |
| 1404 |
CHECK(text_edit->get_caret_count() == 6); |
| 1405 |
CHECK(text_edit->get_selected_text(5) == "rand"); |
| 1406 |
CHECK(text_edit->get_selection_from_line(5) == 3); |
| 1407 |
CHECK(text_edit->get_selection_from_column(5) == 18); |
| 1408 |
CHECK(text_edit->get_selection_to_line(5) == 3); |
| 1409 |
CHECK(text_edit->get_selection_to_column(5) == 22); |
| 1410 |
CHECK(text_edit->get_caret_line(5) == 3); |
| 1411 |
CHECK(text_edit->get_caret_column(5) == 22); |
| 1412 |
|
| 1413 |
|
| 1414 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1415 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1416 |
CHECK(text_edit->get_selected_text(2) == "test"); |
| 1417 |
CHECK(text_edit->get_selected_text(3) == "test"); |
| 1418 |
} |
| 1419 |
|
| 1420 |
SUBCASE("[TextEdit] skip selection for next occurrence") { |
| 1421 |
text_edit->set_text("\ntest other_test\nrandom test\nword test word nonrandom"); |
| 1422 |
text_edit->set_caret_column(0); |
| 1423 |
text_edit->set_caret_line(1); |
| 1424 |
|
| 1425 |
|
| 1426 |
text_edit->skip_selection_for_next_occurrence(); |
| 1427 |
CHECK(text_edit->get_caret_count() == 1); |
| 1428 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 1429 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1430 |
CHECK(text_edit->get_caret_column(0) == 13); |
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
text_edit->skip_selection_for_next_occurrence(); |
| 1437 |
CHECK(text_edit->get_caret_count() == 1); |
| 1438 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 1439 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1440 |
CHECK(text_edit->get_caret_column(0) == 7); |
| 1441 |
|
| 1442 |
|
| 1443 |
text_edit->skip_selection_for_next_occurrence(); |
| 1444 |
CHECK(text_edit->get_caret_count() == 1); |
| 1445 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 1446 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1447 |
CHECK(text_edit->get_caret_column(0) == 7); |
| 1448 |
|
| 1449 |
|
| 1450 |
text_edit->set_caret_column(0); |
| 1451 |
text_edit->set_caret_line(1); |
| 1452 |
|
| 1453 |
|
| 1454 |
text_edit->add_selection_for_next_occurrence(); |
| 1455 |
CHECK(text_edit->get_caret_count() == 1); |
| 1456 |
CHECK(text_edit->has_selection(0)); |
| 1457 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1458 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1459 |
CHECK(text_edit->get_selection_from_column(0) == 0); |
| 1460 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1461 |
CHECK(text_edit->get_selection_to_column(0) == 4); |
| 1462 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1463 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1464 |
|
| 1465 |
|
| 1466 |
text_edit->skip_selection_for_next_occurrence(); |
| 1467 |
CHECK(text_edit->get_caret_count() == 1); |
| 1468 |
CHECK(text_edit->has_selection(0)); |
| 1469 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1470 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1471 |
CHECK(text_edit->get_selection_from_column(0) == 13); |
| 1472 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1473 |
CHECK(text_edit->get_selection_to_column(0) == 17); |
| 1474 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1475 |
CHECK(text_edit->get_caret_column(0) == 17); |
| 1476 |
|
| 1477 |
text_edit->skip_selection_for_next_occurrence(); |
| 1478 |
CHECK(text_edit->get_caret_count() == 1); |
| 1479 |
CHECK(text_edit->has_selection(0)); |
| 1480 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1481 |
CHECK(text_edit->get_selection_from_line(0) == 2); |
| 1482 |
CHECK(text_edit->get_selection_from_column(0) == 9); |
| 1483 |
CHECK(text_edit->get_selection_to_line(0) == 2); |
| 1484 |
CHECK(text_edit->get_selection_to_column(0) == 13); |
| 1485 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 1486 |
CHECK(text_edit->get_caret_column(0) == 13); |
| 1487 |
|
| 1488 |
text_edit->skip_selection_for_next_occurrence(); |
| 1489 |
CHECK(text_edit->get_caret_count() == 1); |
| 1490 |
CHECK(text_edit->has_selection(0)); |
| 1491 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1492 |
CHECK(text_edit->get_selection_from_line(0) == 3); |
| 1493 |
CHECK(text_edit->get_selection_from_column(0) == 5); |
| 1494 |
CHECK(text_edit->get_selection_to_line(0) == 3); |
| 1495 |
CHECK(text_edit->get_selection_to_column(0) == 9); |
| 1496 |
CHECK(text_edit->get_caret_line(0) == 3); |
| 1497 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 1498 |
|
| 1499 |
|
| 1500 |
text_edit->skip_selection_for_next_occurrence(); |
| 1501 |
CHECK(text_edit->has_selection(0)); |
| 1502 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1503 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1504 |
CHECK(text_edit->get_selection_from_column(0) == 0); |
| 1505 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1506 |
CHECK(text_edit->get_selection_to_column(0) == 4); |
| 1507 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1508 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
text_edit->add_selection_for_next_occurrence(); |
| 1513 |
CHECK(text_edit->get_caret_count() == 2); |
| 1514 |
CHECK(text_edit->has_selection(0)); |
| 1515 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1516 |
|
| 1517 |
CHECK(text_edit->has_selection(1)); |
| 1518 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1519 |
CHECK(text_edit->get_selection_from_line(1) == 1); |
| 1520 |
CHECK(text_edit->get_selection_from_column(1) == 13); |
| 1521 |
CHECK(text_edit->get_selection_to_line(1) == 1); |
| 1522 |
CHECK(text_edit->get_selection_to_column(1) == 17); |
| 1523 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 1524 |
CHECK(text_edit->get_caret_column(1) == 17); |
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
text_edit->skip_selection_for_next_occurrence(); |
| 1529 |
CHECK(text_edit->get_caret_count() == 2); |
| 1530 |
CHECK(text_edit->has_selection(0)); |
| 1531 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1532 |
|
| 1533 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1534 |
CHECK(text_edit->get_selection_from_line(1) == 2); |
| 1535 |
CHECK(text_edit->get_selection_from_column(1) == 9); |
| 1536 |
CHECK(text_edit->get_selection_to_line(1) == 2); |
| 1537 |
CHECK(text_edit->get_selection_to_column(1) == 13); |
| 1538 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 1539 |
CHECK(text_edit->get_caret_column(1) == 13); |
| 1540 |
|
| 1541 |
text_edit->skip_selection_for_next_occurrence(); |
| 1542 |
CHECK(text_edit->get_caret_count() == 2); |
| 1543 |
CHECK(text_edit->has_selection(0)); |
| 1544 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1545 |
|
| 1546 |
CHECK(text_edit->get_selected_text(1) == "test"); |
| 1547 |
CHECK(text_edit->get_selection_from_line(1) == 3); |
| 1548 |
CHECK(text_edit->get_selection_from_column(1) == 5); |
| 1549 |
CHECK(text_edit->get_selection_to_line(1) == 3); |
| 1550 |
CHECK(text_edit->get_selection_to_column(1) == 9); |
| 1551 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 1552 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 1553 |
|
| 1554 |
|
| 1555 |
text_edit->skip_selection_for_next_occurrence(); |
| 1556 |
CHECK(text_edit->get_caret_count() == 1); |
| 1557 |
CHECK(text_edit->has_selection(0)); |
| 1558 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 1559 |
CHECK(text_edit->get_selection_from_line(0) == 1); |
| 1560 |
CHECK(text_edit->get_selection_from_column(0) == 0); |
| 1561 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 1562 |
CHECK(text_edit->get_selection_to_column(0) == 4); |
| 1563 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 1564 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1565 |
} |
| 1566 |
|
| 1567 |
SUBCASE("[TextEdit] deselect on focus loss") { |
| 1568 |
text_edit->set_text("test"); |
| 1569 |
|
| 1570 |
text_edit->set_deselect_on_focus_loss_enabled(true); |
| 1571 |
CHECK(text_edit->is_deselect_on_focus_loss_enabled()); |
| 1572 |
|
| 1573 |
text_edit->grab_focus(); |
| 1574 |
text_edit->select_all(); |
| 1575 |
CHECK(text_edit->has_focus()); |
| 1576 |
CHECK(text_edit->has_selection()); |
| 1577 |
|
| 1578 |
text_edit->release_focus(); |
| 1579 |
CHECK_FALSE(text_edit->has_focus()); |
| 1580 |
CHECK_FALSE(text_edit->has_selection()); |
| 1581 |
|
| 1582 |
text_edit->set_deselect_on_focus_loss_enabled(false); |
| 1583 |
CHECK_FALSE(text_edit->is_deselect_on_focus_loss_enabled()); |
| 1584 |
|
| 1585 |
text_edit->grab_focus(); |
| 1586 |
text_edit->select_all(); |
| 1587 |
CHECK(text_edit->has_focus()); |
| 1588 |
CHECK(text_edit->has_selection()); |
| 1589 |
|
| 1590 |
text_edit->release_focus(); |
| 1591 |
CHECK_FALSE(text_edit->has_focus()); |
| 1592 |
CHECK(text_edit->has_selection()); |
| 1593 |
|
| 1594 |
text_edit->set_deselect_on_focus_loss_enabled(true); |
| 1595 |
CHECK_FALSE(text_edit->has_selection()); |
| 1596 |
} |
| 1597 |
|
| 1598 |
SUBCASE("[TextEdit] key select") { |
| 1599 |
text_edit->set_text("test"); |
| 1600 |
|
| 1601 |
text_edit->grab_focus(); |
| 1602 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT) |
| 1603 |
CHECK(text_edit->has_selection()); |
| 1604 |
CHECK(text_edit->get_selected_text() == "t"); |
| 1605 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1606 |
|
| 1607 |
#ifdef MACOS_ENABLED |
| 1608 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT | KeyModifierMask::ALT) |
| 1609 |
#else |
| 1610 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL) |
| 1611 |
#endif |
| 1612 |
CHECK(text_edit->has_selection()); |
| 1613 |
CHECK(text_edit->get_selected_text() == "test"); |
| 1614 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1615 |
|
| 1616 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT) |
| 1617 |
CHECK(text_edit->has_selection()); |
| 1618 |
CHECK(text_edit->get_selected_text() == "tes"); |
| 1619 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1620 |
|
| 1621 |
#ifdef MACOS_ENABLED |
| 1622 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT | KeyModifierMask::ALT) |
| 1623 |
#else |
| 1624 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT | KeyModifierMask::CMD_OR_CTRL) |
| 1625 |
#endif |
| 1626 |
CHECK_FALSE(text_edit->has_selection()); |
| 1627 |
CHECK(text_edit->get_selected_text() == ""); |
| 1628 |
|
| 1629 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT) |
| 1630 |
CHECK(text_edit->has_selection()); |
| 1631 |
CHECK(text_edit->get_selected_text() == "t"); |
| 1632 |
|
| 1633 |
SEND_GUI_KEY_EVENT(Key::RIGHT) |
| 1634 |
CHECK_FALSE(text_edit->has_selection()); |
| 1635 |
CHECK(text_edit->get_selected_text() == ""); |
| 1636 |
|
| 1637 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT) |
| 1638 |
CHECK(text_edit->has_selection()); |
| 1639 |
CHECK(text_edit->get_selected_text() == "t"); |
| 1640 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin()); |
| 1641 |
|
| 1642 |
SEND_GUI_KEY_EVENT(Key::LEFT) |
| 1643 |
CHECK_FALSE(text_edit->has_selection()); |
| 1644 |
CHECK(text_edit->get_selected_text() == ""); |
| 1645 |
|
| 1646 |
|
| 1647 |
text_edit->set_selecting_enabled(false); |
| 1648 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT) |
| 1649 |
CHECK_FALSE(text_edit->has_selection()); |
| 1650 |
CHECK(text_edit->get_selected_text() == ""); |
| 1651 |
text_edit->set_selecting_enabled(true); |
| 1652 |
} |
| 1653 |
|
| 1654 |
SUBCASE("[TextEdit] mouse drag select") { |
| 1655 |
|
| 1656 |
text_edit->set_size(Size2(200, 200)); |
| 1657 |
|
| 1658 |
text_edit->set_text("this is some text\nfor selection"); |
| 1659 |
text_edit->grab_focus(); |
| 1660 |
MessageQueue::get_singleton()->flush(); |
| 1661 |
|
| 1662 |
|
| 1663 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1664 |
|
| 1665 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 1666 |
CHECK(text_edit->has_selection()); |
| 1667 |
CHECK(text_edit->get_selected_text() == "for s"); |
| 1668 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 1669 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 1670 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 1671 |
CHECK(text_edit->get_caret_line() == 1); |
| 1672 |
CHECK(text_edit->get_caret_column() == 5); |
| 1673 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1674 |
CHECK(text_edit->is_dragging_cursor()); |
| 1675 |
|
| 1676 |
|
| 1677 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1678 |
CHECK(text_edit->has_selection()); |
| 1679 |
CHECK(text_edit->get_selected_text() == "for s"); |
| 1680 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 9).get_center() + Point2i(2, 0), MouseButtonMask::NONE, Key::NONE); |
| 1681 |
CHECK(text_edit->has_selection()); |
| 1682 |
CHECK(text_edit->get_selected_text() == "for s"); |
| 1683 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 1684 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 1685 |
CHECK(text_edit->get_caret_line() == 1); |
| 1686 |
CHECK(text_edit->get_caret_column() == 5); |
| 1687 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1688 |
|
| 1689 |
|
| 1690 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1691 |
CHECK_FALSE(text_edit->has_selection()); |
| 1692 |
CHECK(text_edit->get_caret_line() == 0); |
| 1693 |
CHECK(text_edit->get_caret_column() == 7); |
| 1694 |
|
| 1695 |
|
| 1696 |
text_edit->set_selecting_enabled(false); |
| 1697 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1698 |
CHECK(text_edit->get_caret_line() == 1); |
| 1699 |
CHECK(text_edit->get_caret_column() == 0); |
| 1700 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 1701 |
CHECK_FALSE(text_edit->has_selection()); |
| 1702 |
CHECK(text_edit->get_caret_line() == 1); |
| 1703 |
CHECK(text_edit->get_caret_column() == 5); |
| 1704 |
text_edit->set_selecting_enabled(true); |
| 1705 |
|
| 1706 |
|
| 1707 |
text_edit->set_caret_line(0); |
| 1708 |
text_edit->set_caret_column(4); |
| 1709 |
text_edit->add_caret(0, 15); |
| 1710 |
text_edit->select(0, 11, 0, 15, 1); |
| 1711 |
MessageQueue::get_singleton()->flush(); |
| 1712 |
|
| 1713 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::ALT); |
| 1714 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 0).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1715 |
CHECK(text_edit->get_caret_count() == 3); |
| 1716 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 1717 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 1718 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 1719 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 1720 |
|
| 1721 |
CHECK(text_edit->has_selection(1)); |
| 1722 |
CHECK(text_edit->get_selection_origin_line(1) == 0); |
| 1723 |
CHECK(text_edit->get_selection_origin_column(1) == 11); |
| 1724 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 1725 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 1726 |
|
| 1727 |
CHECK(text_edit->has_selection(2)); |
| 1728 |
CHECK(text_edit->get_selected_text(2) == "for s"); |
| 1729 |
CHECK(text_edit->get_selection_origin_line(2) == 1); |
| 1730 |
CHECK(text_edit->get_selection_origin_column(2) == 5); |
| 1731 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 1732 |
CHECK(text_edit->get_caret_column(2) == 0); |
| 1733 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(2)); |
| 1734 |
|
| 1735 |
|
| 1736 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 1737 |
CHECK(text_edit->get_caret_count() == 1); |
| 1738 |
CHECK(text_edit->has_selection()); |
| 1739 |
CHECK(text_edit->get_selected_text() == "s is some text\nfor s"); |
| 1740 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 1741 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 1742 |
CHECK(text_edit->get_selection_origin_column() == 5); |
| 1743 |
CHECK(text_edit->get_caret_line() == 0); |
| 1744 |
CHECK(text_edit->get_caret_column() == 3); |
| 1745 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin()); |
| 1746 |
|
| 1747 |
|
| 1748 |
text_edit->insert_text_at_caret("a"); |
| 1749 |
CHECK_FALSE(text_edit->has_selection()); |
| 1750 |
CHECK(text_edit->get_text() == "thiaelection"); |
| 1751 |
CHECK(text_edit->get_caret_line() == 0); |
| 1752 |
CHECK(text_edit->get_caret_column() == 4); |
| 1753 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 10).get_center() + Point2i(2, 0), MouseButtonMask::NONE, Key::NONE); |
| 1754 |
CHECK_FALSE(text_edit->has_selection()); |
| 1755 |
CHECK(text_edit->get_caret_line() == 0); |
| 1756 |
CHECK(text_edit->get_caret_column() == 4); |
| 1757 |
|
| 1758 |
|
| 1759 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 1760 |
text_edit->set_text("this is some text\nfor selection"); |
| 1761 |
text_edit->set_size(Size2(110, 100)); |
| 1762 |
MessageQueue::get_singleton()->flush(); |
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
CHECK(text_edit->is_line_wrapped(0)); |
| 1767 |
|
| 1768 |
|
| 1769 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 11).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1770 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 8).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1771 |
CHECK(text_edit->has_selection()); |
| 1772 |
CHECK(text_edit->get_selected_text() == "so"); |
| 1773 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 1774 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1775 |
CHECK(text_edit->get_selection_origin_column() == 10); |
| 1776 |
CHECK(text_edit->get_caret_line() == 0); |
| 1777 |
CHECK(text_edit->get_caret_column() == 8); |
| 1778 |
CHECK(text_edit->is_dragging_cursor()); |
| 1779 |
} |
| 1780 |
|
| 1781 |
SUBCASE("[TextEdit] mouse word select") { |
| 1782 |
|
| 1783 |
text_edit->set_size(Size2(200, 200)); |
| 1784 |
|
| 1785 |
text_edit->set_text("this is some text\nfor selection\n"); |
| 1786 |
MessageQueue::get_singleton()->flush(); |
| 1787 |
SIGNAL_DISCARD("caret_changed"); |
| 1788 |
|
| 1789 |
|
| 1790 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(1, 2).get_center() + Point2i(2, 0), Key::NONE); |
| 1791 |
CHECK(text_edit->has_selection()); |
| 1792 |
CHECK(text_edit->get_selected_text() == "for"); |
| 1793 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1794 |
CHECK(text_edit->get_selection_from_line() == 1); |
| 1795 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 1796 |
CHECK(text_edit->get_selection_to_line() == 1); |
| 1797 |
CHECK(text_edit->get_selection_to_column() == 3); |
| 1798 |
CHECK(text_edit->get_caret_line() == 1); |
| 1799 |
CHECK(text_edit->get_caret_column() == 3); |
| 1800 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1801 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1802 |
|
| 1803 |
|
| 1804 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 6).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 1805 |
CHECK(text_edit->has_selection()); |
| 1806 |
CHECK(text_edit->get_selected_text() == "for selection"); |
| 1807 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1808 |
CHECK(text_edit->get_selection_from_line() == 1); |
| 1809 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 1810 |
CHECK(text_edit->get_selection_to_line() == 1); |
| 1811 |
CHECK(text_edit->get_selection_to_column() == 13); |
| 1812 |
CHECK(text_edit->get_caret_line() == 1); |
| 1813 |
CHECK(text_edit->get_caret_column() == 13); |
| 1814 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1815 |
CHECK(text_edit->is_dragging_cursor()); |
| 1816 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1817 |
|
| 1818 |
|
| 1819 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 10).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1820 |
CHECK(text_edit->has_selection()); |
| 1821 |
CHECK(text_edit->get_selected_text() == "some text\nfor"); |
| 1822 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1823 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 1824 |
CHECK(text_edit->get_selection_from_column() == 8); |
| 1825 |
CHECK(text_edit->get_selection_to_line() == 1); |
| 1826 |
CHECK(text_edit->get_selection_to_column() == 3); |
| 1827 |
CHECK(text_edit->get_caret_line() == 0); |
| 1828 |
CHECK(text_edit->get_caret_column() == 8); |
| 1829 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin()); |
| 1830 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 1831 |
|
| 1832 |
|
| 1833 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 10).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1834 |
CHECK(text_edit->has_selection()); |
| 1835 |
CHECK(text_edit->get_selected_text() == "some text\nfor"); |
| 1836 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 2).get_center(), MouseButtonMask::NONE, Key::NONE); |
| 1837 |
CHECK(text_edit->has_selection()); |
| 1838 |
CHECK(text_edit->get_selected_text() == "some text\nfor"); |
| 1839 |
text_edit->deselect(); |
| 1840 |
|
| 1841 |
|
| 1842 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(2, 0).get_center() + Point2i(2, 0), Key::NONE); |
| 1843 |
CHECK_FALSE(text_edit->has_selection()); |
| 1844 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1845 |
CHECK(text_edit->get_caret_line() == 2); |
| 1846 |
CHECK(text_edit->get_caret_column() == 0); |
| 1847 |
|
| 1848 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 9).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1849 |
CHECK(text_edit->has_selection()); |
| 1850 |
CHECK(text_edit->get_selected_text() == "selection\n"); |
| 1851 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1852 |
CHECK(text_edit->get_caret_line() == 1); |
| 1853 |
CHECK(text_edit->get_caret_column() == 4); |
| 1854 |
CHECK(text_edit->get_selection_origin_line() == 2); |
| 1855 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 1856 |
|
| 1857 |
|
| 1858 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1859 |
CHECK_FALSE(text_edit->has_selection()); |
| 1860 |
CHECK(text_edit->get_caret_line() == 0); |
| 1861 |
CHECK(text_edit->get_caret_column() == 0); |
| 1862 |
|
| 1863 |
|
| 1864 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(0, 8).get_center() + Point2i(2, 0), Key::NONE); |
| 1865 |
CHECK(text_edit->has_selection()); |
| 1866 |
CHECK(text_edit->get_selected_text() == "some"); |
| 1867 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1868 |
CHECK(text_edit->get_caret_line() == 0); |
| 1869 |
CHECK(text_edit->get_caret_column() == 12); |
| 1870 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1871 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1872 |
|
| 1873 |
|
| 1874 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(0, 12).get_center() + Point2i(2, 0), Key::NONE); |
| 1875 |
CHECK(text_edit->has_selection()); |
| 1876 |
CHECK(text_edit->get_selected_text() == "some"); |
| 1877 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1878 |
CHECK(text_edit->get_caret_line() == 0); |
| 1879 |
CHECK(text_edit->get_caret_column() == 12); |
| 1880 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1881 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1882 |
|
| 1883 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 9).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1884 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1885 |
CHECK(text_edit->has_selection()); |
| 1886 |
CHECK(text_edit->get_selected_text() == "some text\nfor selection"); |
| 1887 |
CHECK(text_edit->get_caret_line() == 1); |
| 1888 |
CHECK(text_edit->get_caret_column() == 13); |
| 1889 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1890 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1891 |
|
| 1892 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 10).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1893 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1894 |
CHECK(text_edit->has_selection()); |
| 1895 |
CHECK(text_edit->get_selected_text() == "some"); |
| 1896 |
CHECK(text_edit->get_caret_line() == 0); |
| 1897 |
CHECK(text_edit->get_caret_column() == 12); |
| 1898 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1899 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1900 |
|
| 1901 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 15).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1902 |
|
| 1903 |
|
| 1904 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::ALT); |
| 1905 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 8).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::ALT); |
| 1906 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 1907 |
CHECK(text_edit->get_caret_count() == 2); |
| 1908 |
CHECK(text_edit->has_selection(0)); |
| 1909 |
CHECK(text_edit->get_selected_text(0) == "some"); |
| 1910 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 1911 |
CHECK(text_edit->get_caret_column(0) == 12); |
| 1912 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 1913 |
CHECK(text_edit->get_selection_origin_column(0) == 8); |
| 1914 |
|
| 1915 |
CHECK(text_edit->has_selection(1)); |
| 1916 |
CHECK(text_edit->get_selected_text(1) == "ele"); |
| 1917 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 1918 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 1919 |
CHECK(text_edit->get_selection_origin_line(1) == 1); |
| 1920 |
CHECK(text_edit->get_selection_origin_column(1) == 5); |
| 1921 |
|
| 1922 |
|
| 1923 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 8).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1924 |
text_edit->remove_secondary_carets(); |
| 1925 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), Key::NONE | KeyModifierMask::SHIFT); |
| 1926 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1927 |
CHECK(text_edit->has_selection()); |
| 1928 |
CHECK(text_edit->get_selected_text() == "some text\nfor selection"); |
| 1929 |
CHECK(text_edit->get_caret_line() == 1); |
| 1930 |
CHECK(text_edit->get_caret_column() == 13); |
| 1931 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1932 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1933 |
|
| 1934 |
|
| 1935 |
text_edit->set_selecting_enabled(false); |
| 1936 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(1, 1).get_center() + Point2i(2, 0), Key::NONE); |
| 1937 |
CHECK_FALSE(text_edit->has_selection()); |
| 1938 |
CHECK(text_edit->get_caret_line() == 1); |
| 1939 |
CHECK(text_edit->get_caret_column() == 3); |
| 1940 |
text_edit->set_selecting_enabled(true); |
| 1941 |
|
| 1942 |
|
| 1943 |
text_edit->set_text("this is some text\nwith an extra space\n"); |
| 1944 |
MessageQueue::get_singleton()->flush(); |
| 1945 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(0, 8).get_center() + Point2i(2, 0), Key::NONE); |
| 1946 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1947 |
CHECK_FALSE(text_edit->has_selection()); |
| 1948 |
CHECK(text_edit->get_caret_line() == 0); |
| 1949 |
CHECK(text_edit->get_caret_column() == 8); |
| 1950 |
|
| 1951 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 13).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1952 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1953 |
CHECK(text_edit->has_selection()); |
| 1954 |
CHECK(text_edit->get_selected_text() == " some text\nwith an extra"); |
| 1955 |
CHECK(text_edit->get_caret_line() == 1); |
| 1956 |
CHECK(text_edit->get_caret_column() == 13); |
| 1957 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1958 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1959 |
|
| 1960 |
|
| 1961 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 1962 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1963 |
CHECK(text_edit->has_selection()); |
| 1964 |
CHECK(text_edit->get_selected_text() == "this is "); |
| 1965 |
CHECK(text_edit->get_caret_line() == 0); |
| 1966 |
CHECK(text_edit->get_caret_column() == 0); |
| 1967 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 1968 |
CHECK(text_edit->get_selection_origin_column() == 8); |
| 1969 |
|
| 1970 |
|
| 1971 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 8).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 1972 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_WORD); |
| 1973 |
CHECK_FALSE(text_edit->has_selection()); |
| 1974 |
CHECK(text_edit->get_caret_line() == 0); |
| 1975 |
CHECK(text_edit->get_caret_column() == 8); |
| 1976 |
} |
| 1977 |
|
| 1978 |
SUBCASE("[TextEdit] mouse line select") { |
| 1979 |
|
| 1980 |
text_edit->set_size(Size2(200, 200)); |
| 1981 |
|
| 1982 |
text_edit->set_text("this is some text\nfor selection\nwith 3 lines"); |
| 1983 |
MessageQueue::get_singleton()->flush(); |
| 1984 |
|
| 1985 |
|
| 1986 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(1, 2).get_center(), Key::NONE); |
| 1987 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 2).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 1988 |
CHECK(text_edit->has_selection()); |
| 1989 |
CHECK(text_edit->get_selected_text() == "for selection\n"); |
| 1990 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 1991 |
CHECK(text_edit->get_selection_from_line() == 1); |
| 1992 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 1993 |
CHECK(text_edit->get_selection_to_line() == 2); |
| 1994 |
CHECK(text_edit->get_selection_to_column() == 0); |
| 1995 |
CHECK(text_edit->get_caret_line() == 2); |
| 1996 |
CHECK(text_edit->get_caret_column() == 0); |
| 1997 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 1998 |
|
| 1999 |
|
| 2000 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 10).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2001 |
CHECK(text_edit->has_selection()); |
| 2002 |
CHECK(text_edit->get_selected_text() == "this is some text\nfor selection"); |
| 2003 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2004 |
CHECK(text_edit->get_selection_from_line() == 0); |
| 2005 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 2006 |
CHECK(text_edit->get_selection_to_line() == 1); |
| 2007 |
CHECK(text_edit->get_selection_to_column() == 13); |
| 2008 |
CHECK(text_edit->get_caret_line() == 0); |
| 2009 |
CHECK(text_edit->get_caret_column() == 0); |
| 2010 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin()); |
| 2011 |
CHECK(text_edit->is_dragging_cursor()); |
| 2012 |
|
| 2013 |
|
| 2014 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(2, 10).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2015 |
CHECK(text_edit->has_selection()); |
| 2016 |
CHECK(text_edit->get_selected_text() == "for selection\nwith 3 lines"); |
| 2017 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2018 |
CHECK(text_edit->get_selection_from_line() == 1); |
| 2019 |
CHECK(text_edit->get_selection_from_column() == 0); |
| 2020 |
CHECK(text_edit->get_selection_to_line() == 2); |
| 2021 |
CHECK(text_edit->get_selection_to_column() == 12); |
| 2022 |
CHECK(text_edit->get_caret_line() == 2); |
| 2023 |
CHECK(text_edit->get_caret_column() == 12); |
| 2024 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 2025 |
|
| 2026 |
|
| 2027 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(2, 10).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2028 |
CHECK(text_edit->has_selection()); |
| 2029 |
CHECK(text_edit->get_selected_text() == "for selection\nwith 3 lines"); |
| 2030 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 2).get_center(), MouseButtonMask::NONE, Key::NONE); |
| 2031 |
CHECK(text_edit->has_selection()); |
| 2032 |
CHECK(text_edit->get_selected_text() == "for selection\nwith 3 lines"); |
| 2033 |
|
| 2034 |
|
| 2035 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2036 |
CHECK_FALSE(text_edit->has_selection()); |
| 2037 |
CHECK(text_edit->get_caret_line() == 0); |
| 2038 |
CHECK(text_edit->get_caret_column() == 0); |
| 2039 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2040 |
|
| 2041 |
|
| 2042 |
text_edit->set_text("this is some text\n\nfor selection\nwith 4 lines"); |
| 2043 |
MessageQueue::get_singleton()->flush(); |
| 2044 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(1, 0).get_center() + Point2i(2, 0), Key::NONE); |
| 2045 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2046 |
CHECK(text_edit->has_selection()); |
| 2047 |
CHECK(text_edit->get_selected_text() == "\n"); |
| 2048 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2049 |
CHECK(text_edit->get_caret_line() == 2); |
| 2050 |
CHECK(text_edit->get_caret_column() == 0); |
| 2051 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2052 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2053 |
|
| 2054 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(2, 9).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2055 |
CHECK(text_edit->has_selection()); |
| 2056 |
CHECK(text_edit->get_selected_text() == "\nfor selection\n"); |
| 2057 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2058 |
CHECK(text_edit->get_caret_line() == 3); |
| 2059 |
CHECK(text_edit->get_caret_column() == 0); |
| 2060 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2061 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2062 |
|
| 2063 |
|
| 2064 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::ALT); |
| 2065 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 4).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::ALT); |
| 2066 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2067 |
CHECK(text_edit->get_caret_count() == 2); |
| 2068 |
CHECK(text_edit->has_selection(0)); |
| 2069 |
CHECK(text_edit->get_selected_text(0) == "\nfor selection\n"); |
| 2070 |
CHECK(text_edit->get_caret_line(0) == 3); |
| 2071 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 2072 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 2073 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 2074 |
|
| 2075 |
CHECK(text_edit->has_selection(1)); |
| 2076 |
CHECK(text_edit->get_selected_text(1) == "is"); |
| 2077 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 2078 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 2079 |
CHECK(text_edit->get_selection_origin_line(1) == 0); |
| 2080 |
CHECK(text_edit->get_selection_origin_column(1) == 2); |
| 2081 |
text_edit->remove_secondary_carets(); |
| 2082 |
text_edit->deselect(); |
| 2083 |
|
| 2084 |
|
| 2085 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(3, 3).get_center(), Key::NONE); |
| 2086 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(3, 3).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2087 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2088 |
CHECK(text_edit->has_selection()); |
| 2089 |
CHECK(text_edit->get_selected_text() == "with 4 lines"); |
| 2090 |
CHECK(text_edit->get_caret_line() == 3); |
| 2091 |
CHECK(text_edit->get_caret_column() == 12); |
| 2092 |
CHECK(text_edit->get_selection_origin_line() == 3); |
| 2093 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2094 |
|
| 2095 |
|
| 2096 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(2, 10).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2097 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2098 |
CHECK(text_edit->has_selection()); |
| 2099 |
CHECK(text_edit->get_selected_text() == "for selection\nwith 4 lines"); |
| 2100 |
CHECK(text_edit->get_caret_line() == 2); |
| 2101 |
CHECK(text_edit->get_caret_column() == 0); |
| 2102 |
CHECK(text_edit->get_selection_origin_line() == 3); |
| 2103 |
CHECK(text_edit->get_selection_origin_column() == 12); |
| 2104 |
|
| 2105 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(2, 10).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2106 |
|
| 2107 |
|
| 2108 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(0, 9).get_center() + Point2i(2, 0), Key::NONE | KeyModifierMask::SHIFT); |
| 2109 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 9).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2110 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_LINE); |
| 2111 |
CHECK(text_edit->has_selection()); |
| 2112 |
CHECK(text_edit->get_selected_text() == "this is some text\n\nfor selection\nwith 4 lines"); |
| 2113 |
CHECK(text_edit->get_caret_line() == 0); |
| 2114 |
CHECK(text_edit->get_caret_column() == 0); |
| 2115 |
CHECK(text_edit->get_selection_origin_line() == 3); |
| 2116 |
CHECK(text_edit->get_selection_origin_column() == 12); |
| 2117 |
|
| 2118 |
|
| 2119 |
text_edit->set_selecting_enabled(false); |
| 2120 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(0, 2).get_center(), Key::NONE); |
| 2121 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 2).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2122 |
CHECK_FALSE(text_edit->has_selection()); |
| 2123 |
CHECK(text_edit->get_caret_line() == 1); |
| 2124 |
CHECK(text_edit->get_caret_column() == 0); |
| 2125 |
text_edit->set_selecting_enabled(true); |
| 2126 |
} |
| 2127 |
|
| 2128 |
SUBCASE("[TextEdit] mouse shift click select") { |
| 2129 |
|
| 2130 |
text_edit->set_size(Size2(200, 200)); |
| 2131 |
|
| 2132 |
text_edit->set_text("this is some text\nfor selection"); |
| 2133 |
MessageQueue::get_singleton()->flush(); |
| 2134 |
|
| 2135 |
|
| 2136 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 1).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2137 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 1).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2138 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2139 |
CHECK(text_edit->has_selection()); |
| 2140 |
CHECK(text_edit->get_selected_text() == "or s"); |
| 2141 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2142 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2143 |
CHECK(text_edit->get_selection_origin_column() == 1); |
| 2144 |
CHECK(text_edit->get_caret_line() == 1); |
| 2145 |
CHECK(text_edit->get_caret_column() == 5); |
| 2146 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 2147 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2148 |
|
| 2149 |
|
| 2150 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2151 |
CHECK(text_edit->has_selection()); |
| 2152 |
CHECK(text_edit->get_selected_text() == "s some text\nf"); |
| 2153 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2154 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2155 |
CHECK(text_edit->get_selection_origin_column() == 1); |
| 2156 |
CHECK(text_edit->get_caret_line() == 0); |
| 2157 |
CHECK(text_edit->get_caret_column() == 6); |
| 2158 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin()); |
| 2159 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2160 |
|
| 2161 |
|
| 2162 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2163 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2164 |
CHECK_FALSE(text_edit->has_selection()); |
| 2165 |
CHECK(text_edit->get_caret_line() == 1); |
| 2166 |
CHECK(text_edit->get_caret_column() == 7); |
| 2167 |
|
| 2168 |
|
| 2169 |
text_edit->set_selecting_enabled(false); |
| 2170 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2171 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2172 |
CHECK(text_edit->get_caret_line() == 1); |
| 2173 |
CHECK(text_edit->get_caret_column() == 0); |
| 2174 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2175 |
CHECK_FALSE(text_edit->has_selection()); |
| 2176 |
CHECK(text_edit->get_caret_line() == 1); |
| 2177 |
CHECK(text_edit->get_caret_column() == 5); |
| 2178 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2179 |
text_edit->set_selecting_enabled(true); |
| 2180 |
|
| 2181 |
|
| 2182 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2183 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2184 |
text_edit->set_caret_column(5, false); |
| 2185 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 13).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2186 |
CHECK(text_edit->has_selection()); |
| 2187 |
CHECK(text_edit->get_selected_text() == "is some "); |
| 2188 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2189 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2190 |
CHECK(text_edit->get_selection_origin_column() == 5); |
| 2191 |
CHECK(text_edit->get_caret_line() == 0); |
| 2192 |
CHECK(text_edit->get_caret_column() == 13); |
| 2193 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 2194 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 13).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2195 |
text_edit->deselect(); |
| 2196 |
|
| 2197 |
|
| 2198 |
text_edit->select(1, 2, 1, 5); |
| 2199 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 8).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2200 |
CHECK(text_edit->has_selection()); |
| 2201 |
CHECK(text_edit->get_selected_text() == "r sele"); |
| 2202 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2203 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2204 |
CHECK(text_edit->get_selection_origin_column() == 2); |
| 2205 |
CHECK(text_edit->get_caret_line() == 1); |
| 2206 |
CHECK(text_edit->get_caret_column() == 8); |
| 2207 |
CHECK(text_edit->is_caret_after_selection_origin()); |
| 2208 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 8).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2209 |
text_edit->deselect(); |
| 2210 |
|
| 2211 |
|
| 2212 |
SEND_GUI_DOUBLE_CLICK(text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), Key::NONE); |
| 2213 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2214 |
CHECK(text_edit->has_selection()); |
| 2215 |
CHECK(text_edit->get_selected_text() == "is"); |
| 2216 |
CHECK(text_edit->get_caret_line() == 0); |
| 2217 |
CHECK(text_edit->get_caret_column() == 7); |
| 2218 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2219 |
CHECK(text_edit->get_selection_origin_column() == 5); |
| 2220 |
|
| 2221 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 10).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2222 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2223 |
CHECK(text_edit->has_selection()); |
| 2224 |
CHECK(text_edit->get_selected_text() == "is so"); |
| 2225 |
CHECK(text_edit->get_caret_line() == 0); |
| 2226 |
CHECK(text_edit->get_caret_column() == 10); |
| 2227 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2228 |
CHECK(text_edit->get_selection_origin_column() == 5); |
| 2229 |
|
| 2230 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2231 |
CHECK(text_edit->get_selection_mode() == TextEdit::SELECTION_MODE_POINTER); |
| 2232 |
CHECK(text_edit->has_selection()); |
| 2233 |
CHECK(text_edit->get_selected_text() == "is is"); |
| 2234 |
CHECK(text_edit->get_caret_line() == 0); |
| 2235 |
CHECK(text_edit->get_caret_column() == 2); |
| 2236 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2237 |
CHECK(text_edit->get_selection_origin_column() == 7); |
| 2238 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE | KeyModifierMask::SHIFT); |
| 2239 |
} |
| 2240 |
|
| 2241 |
SUBCASE("[TextEdit] select and deselect") { |
| 2242 |
text_edit->set_text("this is some text\nfor selection"); |
| 2243 |
MessageQueue::get_singleton()->flush(); |
| 2244 |
SIGNAL_DISCARD("caret_changed"); |
| 2245 |
|
| 2246 |
|
| 2247 |
text_edit->select(-1, -1, 500, 500); |
| 2248 |
MessageQueue::get_singleton()->flush(); |
| 2249 |
CHECK(text_edit->has_selection()); |
| 2250 |
CHECK(text_edit->get_selected_text() == "this is some text\nfor selection"); |
| 2251 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 2252 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 2253 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 2254 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 2255 |
CHECK(text_edit->get_caret_column(0) == 13); |
| 2256 |
CHECK(text_edit->get_selection_from_line(0) == text_edit->get_selection_origin_line(0)); |
| 2257 |
CHECK(text_edit->get_selection_from_column(0) == text_edit->get_selection_origin_column(0)); |
| 2258 |
CHECK(text_edit->get_selection_to_line(0) == text_edit->get_caret_line(0)); |
| 2259 |
CHECK(text_edit->get_selection_to_column(0) == text_edit->get_caret_column(0)); |
| 2260 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2261 |
|
| 2262 |
text_edit->deselect(); |
| 2263 |
MessageQueue::get_singleton()->flush(); |
| 2264 |
CHECK_FALSE(text_edit->has_selection()); |
| 2265 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 2266 |
|
| 2267 |
|
| 2268 |
text_edit->select(500, 500, -1, -1); |
| 2269 |
MessageQueue::get_singleton()->flush(); |
| 2270 |
CHECK(text_edit->has_selection()); |
| 2271 |
CHECK(text_edit->get_selected_text() == "this is some text\nfor selection"); |
| 2272 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(0)); |
| 2273 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 2274 |
CHECK(text_edit->get_selection_origin_column(0) == 13); |
| 2275 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 2276 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 2277 |
CHECK(text_edit->get_selection_from_line(0) == text_edit->get_caret_line(0)); |
| 2278 |
CHECK(text_edit->get_selection_from_column(0) == text_edit->get_caret_column(0)); |
| 2279 |
CHECK(text_edit->get_selection_to_line(0) == text_edit->get_selection_origin_line(0)); |
| 2280 |
CHECK(text_edit->get_selection_to_column(0) == text_edit->get_selection_origin_column(0)); |
| 2281 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2282 |
|
| 2283 |
text_edit->deselect(); |
| 2284 |
MessageQueue::get_singleton()->flush(); |
| 2285 |
CHECK_FALSE(text_edit->has_selection()); |
| 2286 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 2287 |
|
| 2288 |
|
| 2289 |
text_edit->select(0, 4, 0, 8); |
| 2290 |
MessageQueue::get_singleton()->flush(); |
| 2291 |
CHECK(text_edit->has_selection()); |
| 2292 |
CHECK(text_edit->get_selected_text() == " is "); |
| 2293 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 2294 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 2295 |
CHECK(text_edit->get_selection_origin_column(0) == 4); |
| 2296 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 2297 |
CHECK(text_edit->get_caret_column(0) == 8); |
| 2298 |
CHECK(text_edit->get_selection_from_line(0) == text_edit->get_selection_origin_line(0)); |
| 2299 |
CHECK(text_edit->get_selection_from_column(0) == text_edit->get_selection_origin_column(0)); |
| 2300 |
CHECK(text_edit->get_selection_to_line(0) == text_edit->get_caret_line(0)); |
| 2301 |
CHECK(text_edit->get_selection_to_column(0) == text_edit->get_caret_column(0)); |
| 2302 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2303 |
|
| 2304 |
text_edit->deselect(); |
| 2305 |
MessageQueue::get_singleton()->flush(); |
| 2306 |
CHECK_FALSE(text_edit->has_selection()); |
| 2307 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 2308 |
|
| 2309 |
|
| 2310 |
text_edit->select(0, 8, 0, 4); |
| 2311 |
MessageQueue::get_singleton()->flush(); |
| 2312 |
CHECK(text_edit->has_selection()); |
| 2313 |
CHECK(text_edit->get_selected_text() == " is "); |
| 2314 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(0)); |
| 2315 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 2316 |
CHECK(text_edit->get_selection_origin_column(0) == 8); |
| 2317 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 2318 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 2319 |
CHECK(text_edit->get_selection_from_line(0) == text_edit->get_caret_line(0)); |
| 2320 |
CHECK(text_edit->get_selection_from_column(0) == text_edit->get_caret_column(0)); |
| 2321 |
CHECK(text_edit->get_selection_to_line(0) == text_edit->get_selection_origin_line(0)); |
| 2322 |
CHECK(text_edit->get_selection_to_column(0) == text_edit->get_selection_origin_column(0)); |
| 2323 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2324 |
|
| 2325 |
|
| 2326 |
text_edit->set_selecting_enabled(false); |
| 2327 |
CHECK_FALSE(text_edit->has_selection()); |
| 2328 |
text_edit->select(0, 8, 0, 4); |
| 2329 |
MessageQueue::get_singleton()->flush(); |
| 2330 |
CHECK_FALSE(text_edit->has_selection()); |
| 2331 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 2332 |
text_edit->set_selecting_enabled(true); |
| 2333 |
} |
| 2334 |
|
| 2335 |
SUBCASE("[TextEdit] delete selection") { |
| 2336 |
text_edit->set_text("this is some text\nfor selection"); |
| 2337 |
MessageQueue::get_singleton()->flush(); |
| 2338 |
|
| 2339 |
|
| 2340 |
text_edit->set_caret_line(0); |
| 2341 |
text_edit->set_caret_column(8); |
| 2342 |
CHECK_FALSE(text_edit->has_selection()); |
| 2343 |
|
| 2344 |
text_edit->delete_selection(); |
| 2345 |
CHECK(text_edit->get_text() == "this is some text\nfor selection"); |
| 2346 |
CHECK_FALSE(text_edit->has_selection()); |
| 2347 |
CHECK(text_edit->get_caret_line() == 0); |
| 2348 |
CHECK(text_edit->get_caret_column() == 8); |
| 2349 |
|
| 2350 |
|
| 2351 |
text_edit->select(0, 4, 0, 8); |
| 2352 |
CHECK(text_edit->has_selection()); |
| 2353 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 2354 |
CHECK_FALSE(text_edit->has_selection()); |
| 2355 |
CHECK(text_edit->get_text() == "thissome text\nfor selection"); |
| 2356 |
CHECK(text_edit->get_caret_line() == 0); |
| 2357 |
CHECK(text_edit->get_caret_column() == 4); |
| 2358 |
|
| 2359 |
|
| 2360 |
text_edit->undo(); |
| 2361 |
CHECK(text_edit->get_text() == "this is some text\nfor selection"); |
| 2362 |
CHECK(text_edit->has_selection()); |
| 2363 |
CHECK(text_edit->get_caret_line() == 0); |
| 2364 |
CHECK(text_edit->get_caret_column() == 8); |
| 2365 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2366 |
CHECK(text_edit->get_selection_origin_column() == 4); |
| 2367 |
|
| 2368 |
|
| 2369 |
text_edit->redo(); |
| 2370 |
CHECK(text_edit->get_text() == "thissome text\nfor selection"); |
| 2371 |
CHECK_FALSE(text_edit->has_selection()); |
| 2372 |
CHECK(text_edit->get_caret_line() == 0); |
| 2373 |
CHECK(text_edit->get_caret_column() == 4); |
| 2374 |
|
| 2375 |
text_edit->undo(); |
| 2376 |
CHECK(text_edit->get_text() == "this is some text\nfor selection"); |
| 2377 |
CHECK(text_edit->has_selection()); |
| 2378 |
CHECK(text_edit->get_caret_line() == 0); |
| 2379 |
CHECK(text_edit->get_caret_column() == 8); |
| 2380 |
|
| 2381 |
text_edit->select(0, 4, 0, 8); |
| 2382 |
CHECK(text_edit->has_selection()); |
| 2383 |
|
| 2384 |
|
| 2385 |
text_edit->delete_selection(); |
| 2386 |
CHECK(text_edit->get_text() == "thissome text\nfor selection"); |
| 2387 |
CHECK_FALSE(text_edit->has_selection()); |
| 2388 |
CHECK(text_edit->get_caret_line() == 0); |
| 2389 |
CHECK(text_edit->get_caret_column() == 4); |
| 2390 |
|
| 2391 |
|
| 2392 |
text_edit->undo(); |
| 2393 |
CHECK(text_edit->get_text() == "this is some text\nfor selection"); |
| 2394 |
CHECK(text_edit->has_selection()); |
| 2395 |
CHECK(text_edit->get_caret_line() == 0); |
| 2396 |
CHECK(text_edit->get_caret_column() == 8); |
| 2397 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2398 |
CHECK(text_edit->get_selection_origin_column() == 4); |
| 2399 |
|
| 2400 |
|
| 2401 |
text_edit->redo(); |
| 2402 |
CHECK(text_edit->get_text() == "thissome text\nfor selection"); |
| 2403 |
CHECK_FALSE(text_edit->has_selection()); |
| 2404 |
CHECK(text_edit->get_caret_line() == 0); |
| 2405 |
CHECK(text_edit->get_caret_column() == 4); |
| 2406 |
|
| 2407 |
text_edit->undo(); |
| 2408 |
CHECK(text_edit->has_selection()); |
| 2409 |
CHECK(text_edit->get_text() == "this is some text\nfor selection"); |
| 2410 |
CHECK(text_edit->get_caret_line() == 0); |
| 2411 |
CHECK(text_edit->get_caret_column() == 8); |
| 2412 |
|
| 2413 |
|
| 2414 |
text_edit->set_editable(false); |
| 2415 |
text_edit->delete_selection(); |
| 2416 |
text_edit->set_editable(false); |
| 2417 |
CHECK_FALSE(text_edit->has_selection()); |
| 2418 |
CHECK(text_edit->get_text() == "thissome text\nfor selection"); |
| 2419 |
|
| 2420 |
|
| 2421 |
text_edit->undo(); |
| 2422 |
CHECK_FALSE(text_edit->has_selection()); |
| 2423 |
CHECK(text_edit->get_text() == "thissome text\nfor selection"); |
| 2424 |
|
| 2425 |
|
| 2426 |
text_edit->select(0, 0, 0, 5); |
| 2427 |
text_edit->add_caret(0, 8); |
| 2428 |
text_edit->select(0, 5, 0, 8, 1); |
| 2429 |
CHECK(text_edit->get_caret_count() == 2); |
| 2430 |
text_edit->delete_selection(); |
| 2431 |
CHECK(text_edit->get_text() == " text\nfor selection"); |
| 2432 |
CHECK(text_edit->get_caret_count() == 1); |
| 2433 |
CHECK_FALSE(text_edit->has_selection()); |
| 2434 |
CHECK(text_edit->get_caret_line() == 0); |
| 2435 |
CHECK(text_edit->get_caret_column() == 0); |
| 2436 |
|
| 2437 |
|
| 2438 |
text_edit->remove_secondary_carets(); |
| 2439 |
text_edit->select(1, 3, 0, 2); |
| 2440 |
text_edit->add_caret(1, 7); |
| 2441 |
text_edit->delete_selection(); |
| 2442 |
CHECK(text_edit->get_text() == " t selection"); |
| 2443 |
CHECK(text_edit->get_caret_count() == 2); |
| 2444 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 2445 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 2446 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 2447 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 2448 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 2449 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 2450 |
} |
| 2451 |
|
| 2452 |
SUBCASE("[TextEdit] text drag") { |
| 2453 |
text_edit->set_size(Size2(200, 200)); |
| 2454 |
text_edit->set_text("drag test\ndrop here ''"); |
| 2455 |
text_edit->grab_click_focus(); |
| 2456 |
MessageQueue::get_singleton()->flush(); |
| 2457 |
|
| 2458 |
|
| 2459 |
text_edit->select(0, 0, 0, 4); |
| 2460 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2461 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2462 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2463 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2464 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag"); |
| 2465 |
CHECK(text_edit->has_selection()); |
| 2466 |
CHECK(text_edit->get_caret_line() == 0); |
| 2467 |
CHECK(text_edit->get_caret_column() == 4); |
| 2468 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2469 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2470 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 11).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2471 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 11).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2472 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2473 |
CHECK(text_edit->get_text() == " test\ndrop here 'drag'"); |
| 2474 |
CHECK(text_edit->has_selection()); |
| 2475 |
CHECK(text_edit->get_caret_line() == 1); |
| 2476 |
CHECK(text_edit->get_caret_column() == 15); |
| 2477 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2478 |
CHECK(text_edit->get_selection_origin_column() == 11); |
| 2479 |
|
| 2480 |
|
| 2481 |
text_edit->undo(); |
| 2482 |
CHECK(text_edit->get_text() == "drag test\ndrop here ''"); |
| 2483 |
CHECK(text_edit->has_selection()); |
| 2484 |
CHECK(text_edit->get_caret_line() == 0); |
| 2485 |
CHECK(text_edit->get_caret_column() == 4); |
| 2486 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2487 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2488 |
|
| 2489 |
|
| 2490 |
text_edit->redo(); |
| 2491 |
CHECK(text_edit->get_text() == " test\ndrop here 'drag'"); |
| 2492 |
CHECK(text_edit->has_selection()); |
| 2493 |
CHECK(text_edit->get_caret_line() == 1); |
| 2494 |
CHECK(text_edit->get_caret_column() == 15); |
| 2495 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2496 |
CHECK(text_edit->get_selection_origin_column() == 11); |
| 2497 |
|
| 2498 |
|
| 2499 |
text_edit->select(1, 10, 1, 16); |
| 2500 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 12).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2501 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2502 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2503 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2504 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "'drag'"); |
| 2505 |
CHECK(text_edit->has_selection()); |
| 2506 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2507 |
SEND_GUI_KEY_EVENT(Key::CMD_OR_CTRL); |
| 2508 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2509 |
SEND_GUI_KEY_UP_EVENT(Key::CMD_OR_CTRL); |
| 2510 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2511 |
CHECK(text_edit->get_text() == "'drag' test\ndrop here 'drag'"); |
| 2512 |
CHECK(text_edit->has_selection()); |
| 2513 |
CHECK(text_edit->get_caret_line() == 0); |
| 2514 |
CHECK(text_edit->get_caret_column() == 6); |
| 2515 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2516 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2517 |
|
| 2518 |
|
| 2519 |
text_edit->select(0, 11, 0, 7, 0); |
| 2520 |
text_edit->add_caret(1, 2); |
| 2521 |
text_edit->select(1, 2, 1, 4, 1); |
| 2522 |
text_edit->add_caret(1, 12); |
| 2523 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 3).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2524 |
CHECK(text_edit->is_mouse_over_selection(true, 1)); |
| 2525 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 12).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2526 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2527 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "test\nop"); |
| 2528 |
|
| 2529 |
CHECK(text_edit->get_caret_count() == 3); |
| 2530 |
CHECK(text_edit->has_selection(0)); |
| 2531 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 2532 |
CHECK(text_edit->get_caret_column(0) == 7); |
| 2533 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 2534 |
CHECK(text_edit->get_selection_origin_column(0) == 11); |
| 2535 |
CHECK(text_edit->has_selection(1)); |
| 2536 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 2537 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 2538 |
CHECK(text_edit->get_selection_origin_line(1) == 1); |
| 2539 |
CHECK(text_edit->get_selection_origin_column(1) == 2); |
| 2540 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 2541 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 2542 |
CHECK(text_edit->get_caret_column(2) == 12); |
| 2543 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 9).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2544 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 9).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2545 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2546 |
CHECK(text_edit->get_text() == "'drag' \ndr heretest\nop 'drag'"); |
| 2547 |
CHECK(text_edit->get_caret_count() == 1); |
| 2548 |
CHECK(text_edit->has_selection()); |
| 2549 |
CHECK(text_edit->get_caret_line() == 2); |
| 2550 |
CHECK(text_edit->get_caret_column() == 2); |
| 2551 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2552 |
CHECK(text_edit->get_selection_origin_column() == 7); |
| 2553 |
|
| 2554 |
|
| 2555 |
text_edit->select(1, 3, 1, 7); |
| 2556 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(1, 6).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2557 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2558 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2559 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2560 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "here"); |
| 2561 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2562 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2563 |
CHECK(text_edit->get_text() == "'drag' \ndr heretest\nop 'drag'"); |
| 2564 |
CHECK(text_edit->get_caret_count() == 1); |
| 2565 |
CHECK(text_edit->has_selection()); |
| 2566 |
CHECK(text_edit->get_caret_line() == 1); |
| 2567 |
CHECK(text_edit->get_caret_column() == 7); |
| 2568 |
CHECK(text_edit->get_selection_origin_line() == 1); |
| 2569 |
CHECK(text_edit->get_selection_origin_column() == 3); |
| 2570 |
|
| 2571 |
|
| 2572 |
text_edit->set_drag_and_drop_selection_enabled(false); |
| 2573 |
text_edit->select(0, 1, 0, 5); |
| 2574 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2575 |
CHECK_FALSE(text_edit->is_mouse_over_selection()); |
| 2576 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2577 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2578 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2579 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2580 |
CHECK(text_edit->get_text() == "'drag' \ndr heretest\nop 'drag'"); |
| 2581 |
CHECK(text_edit->has_selection()); |
| 2582 |
CHECK(text_edit->get_caret_line() == 1); |
| 2583 |
CHECK(text_edit->get_caret_column() == 7); |
| 2584 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2585 |
CHECK(text_edit->get_selection_origin_column() == 2); |
| 2586 |
text_edit->set_drag_and_drop_selection_enabled(true); |
| 2587 |
|
| 2588 |
|
| 2589 |
text_edit->select(0, 1, 0, 5); |
| 2590 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2591 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2592 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2593 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2594 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag"); |
| 2595 |
SEND_GUI_KEY_EVENT(Key::ESCAPE); |
| 2596 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2597 |
CHECK(text_edit->get_text() == "'drag' \ndr heretest\nop 'drag'"); |
| 2598 |
CHECK(text_edit->has_selection()); |
| 2599 |
CHECK(text_edit->get_caret_line() == 0); |
| 2600 |
CHECK(text_edit->get_caret_column() == 5); |
| 2601 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2602 |
CHECK(text_edit->get_selection_origin_column() == 1); |
| 2603 |
|
| 2604 |
|
| 2605 |
text_edit->select(0, 1, 0, 5); |
| 2606 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2607 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2608 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2609 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2610 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag"); |
| 2611 |
SEND_GUI_KEY_EVENT(Key::RIGHT); |
| 2612 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2613 |
CHECK(text_edit->get_text() == "'drag' \ndr heretest\nop 'drag'"); |
| 2614 |
CHECK_FALSE(text_edit->has_selection()); |
| 2615 |
CHECK(text_edit->get_caret_line() == 0); |
| 2616 |
CHECK(text_edit->get_caret_column() == 5); |
| 2617 |
|
| 2618 |
|
| 2619 |
text_edit->select(0, 1, 0, 5); |
| 2620 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 3).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2621 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2622 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2623 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2624 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag"); |
| 2625 |
SEND_GUI_KEY_EVENT(Key::A); |
| 2626 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2627 |
CHECK(text_edit->get_text() == "'A' \ndr heretest\nop 'drag'"); |
| 2628 |
CHECK_FALSE(text_edit->has_selection()); |
| 2629 |
CHECK(text_edit->get_caret_line() == 0); |
| 2630 |
CHECK(text_edit->get_caret_column() == 2); |
| 2631 |
} |
| 2632 |
|
| 2633 |
SUBCASE("[TextEdit] text drag to another text edit") { |
| 2634 |
TextEdit *target_text_edit = memnew(TextEdit); |
| 2635 |
SceneTree::get_singleton()->get_root()->add_child(target_text_edit); |
| 2636 |
|
| 2637 |
target_text_edit->set_size(Size2(200, 200)); |
| 2638 |
target_text_edit->set_position(Point2(400, 0)); |
| 2639 |
|
| 2640 |
text_edit->set_size(Size2(200, 200)); |
| 2641 |
|
| 2642 |
CHECK_FALSE(text_edit->is_mouse_over_selection()); |
| 2643 |
text_edit->set_text("drag me"); |
| 2644 |
text_edit->select_all(); |
| 2645 |
text_edit->grab_click_focus(); |
| 2646 |
CHECK(text_edit->has_selection()); |
| 2647 |
CHECK(text_edit->get_caret_line() == 0); |
| 2648 |
CHECK(text_edit->get_caret_column() == 7); |
| 2649 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2650 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2651 |
MessageQueue::get_singleton()->flush(); |
| 2652 |
|
| 2653 |
|
| 2654 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 0).get_center(), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2655 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2656 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 7).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2657 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2658 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag me"); |
| 2659 |
CHECK(text_edit->has_selection()); |
| 2660 |
CHECK(text_edit->get_caret_line() == 0); |
| 2661 |
CHECK(text_edit->get_caret_column() == 7); |
| 2662 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2663 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2664 |
|
| 2665 |
Point2i target_line0 = target_text_edit->get_position() + Point2i(1, target_text_edit->get_line_height() / 2); |
| 2666 |
SEND_GUI_MOUSE_MOTION_EVENT(target_line0, MouseButtonMask::LEFT, Key::NONE); |
| 2667 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2668 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2669 |
CHECK(target_text_edit->get_caret_column() == 0); |
| 2670 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_line0, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2671 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2672 |
CHECK(text_edit->get_text() == ""); |
| 2673 |
CHECK_FALSE(text_edit->has_selection()); |
| 2674 |
CHECK(text_edit->get_caret_line() == 0); |
| 2675 |
CHECK(text_edit->get_caret_column() == 0); |
| 2676 |
CHECK(target_text_edit->get_text() == "drag me"); |
| 2677 |
CHECK(target_text_edit->has_selection()); |
| 2678 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2679 |
CHECK(target_text_edit->get_caret_column() == 7); |
| 2680 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2681 |
CHECK(target_text_edit->get_selection_origin_column() == 0); |
| 2682 |
|
| 2683 |
|
| 2684 |
text_edit->undo(); |
| 2685 |
CHECK(text_edit->get_text() == "drag me"); |
| 2686 |
CHECK(text_edit->has_selection()); |
| 2687 |
CHECK(text_edit->get_caret_line() == 0); |
| 2688 |
CHECK(text_edit->get_caret_column() == 7); |
| 2689 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2690 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2691 |
CHECK(target_text_edit->get_text() == "drag me"); |
| 2692 |
CHECK(target_text_edit->has_selection()); |
| 2693 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2694 |
CHECK(target_text_edit->get_caret_column() == 7); |
| 2695 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2696 |
CHECK(target_text_edit->get_selection_origin_column() == 0); |
| 2697 |
|
| 2698 |
target_text_edit->undo(); |
| 2699 |
CHECK(text_edit->get_text() == "drag me"); |
| 2700 |
CHECK(text_edit->has_selection()); |
| 2701 |
CHECK(text_edit->get_caret_line() == 0); |
| 2702 |
CHECK(text_edit->get_caret_column() == 7); |
| 2703 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 2704 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 2705 |
CHECK(target_text_edit->get_text() == ""); |
| 2706 |
CHECK_FALSE(target_text_edit->has_selection()); |
| 2707 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2708 |
CHECK(target_text_edit->get_caret_column() == 0); |
| 2709 |
|
| 2710 |
|
| 2711 |
text_edit->redo(); |
| 2712 |
CHECK(text_edit->get_text() == ""); |
| 2713 |
CHECK_FALSE(text_edit->has_selection()); |
| 2714 |
CHECK(text_edit->get_caret_line() == 0); |
| 2715 |
CHECK(text_edit->get_caret_column() == 0); |
| 2716 |
CHECK(target_text_edit->get_text() == ""); |
| 2717 |
CHECK_FALSE(target_text_edit->has_selection()); |
| 2718 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2719 |
CHECK(target_text_edit->get_caret_column() == 0); |
| 2720 |
|
| 2721 |
target_text_edit->redo(); |
| 2722 |
CHECK(text_edit->get_text() == ""); |
| 2723 |
CHECK_FALSE(text_edit->has_selection()); |
| 2724 |
CHECK(text_edit->get_caret_line() == 0); |
| 2725 |
CHECK(text_edit->get_caret_column() == 0); |
| 2726 |
CHECK(target_text_edit->get_text() == "drag me"); |
| 2727 |
CHECK(target_text_edit->has_selection()); |
| 2728 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2729 |
CHECK(target_text_edit->get_caret_column() == 7); |
| 2730 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2731 |
CHECK(target_text_edit->get_selection_origin_column() == 0); |
| 2732 |
|
| 2733 |
|
| 2734 |
text_edit->set_text("drag test\ndrop test"); |
| 2735 |
MessageQueue::get_singleton()->flush(); |
| 2736 |
target_text_edit->select(0, 0, 0, 3, 0); |
| 2737 |
target_text_edit->add_caret(0, 5); |
| 2738 |
text_edit->select(0, 5, 0, 7, 0); |
| 2739 |
text_edit->add_caret(0, 1); |
| 2740 |
text_edit->select(0, 1, 0, 0, 1); |
| 2741 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 5).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2742 |
CHECK(text_edit->is_mouse_over_selection(true, 0)); |
| 2743 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 6).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2744 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2745 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "d\nte"); |
| 2746 |
CHECK(text_edit->has_selection()); |
| 2747 |
SEND_GUI_KEY_EVENT(Key::CMD_OR_CTRL); |
| 2748 |
SEND_GUI_MOUSE_MOTION_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2749 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2750 |
SEND_GUI_KEY_UP_EVENT(Key::CMD_OR_CTRL); |
| 2751 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2752 |
CHECK(text_edit->get_text() == "drag test\ndrop test"); |
| 2753 |
CHECK(text_edit->get_caret_count() == 2); |
| 2754 |
CHECK_FALSE(text_edit->has_selection()); |
| 2755 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 2756 |
CHECK(text_edit->get_caret_column(0) == 7); |
| 2757 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 2758 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 2759 |
CHECK(target_text_edit->get_text() == "drag md\ntee"); |
| 2760 |
CHECK(target_text_edit->get_caret_count() == 1); |
| 2761 |
CHECK(target_text_edit->has_selection()); |
| 2762 |
CHECK(target_text_edit->get_caret_line() == 1); |
| 2763 |
CHECK(target_text_edit->get_caret_column() == 2); |
| 2764 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2765 |
CHECK(target_text_edit->get_selection_origin_column() == 6); |
| 2766 |
|
| 2767 |
|
| 2768 |
text_edit->set_deselect_on_focus_loss_enabled(false); |
| 2769 |
target_text_edit->set_deselect_on_focus_loss_enabled(false); |
| 2770 |
text_edit->remove_secondary_carets(); |
| 2771 |
text_edit->select(0, 5, 0, 9); |
| 2772 |
target_text_edit->select(0, 6, 0, 8); |
| 2773 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 6).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2774 |
CHECK(text_edit->is_mouse_over_selection(true, 0)); |
| 2775 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center(), MouseButtonMask::LEFT, Key::NONE); |
| 2776 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2777 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "test"); |
| 2778 |
CHECK(text_edit->has_selection()); |
| 2779 |
SEND_GUI_MOUSE_MOTION_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2780 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2781 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2782 |
CHECK(text_edit->get_text() == "drag \ndrop test"); |
| 2783 |
CHECK(target_text_edit->get_caret_count() == 1); |
| 2784 |
CHECK_FALSE(text_edit->has_selection()); |
| 2785 |
CHECK(text_edit->get_caret_line() == 0); |
| 2786 |
CHECK(text_edit->get_caret_column() == 5); |
| 2787 |
CHECK(target_text_edit->get_text() == "drag mdtest\ntee"); |
| 2788 |
CHECK(target_text_edit->has_selection()); |
| 2789 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2790 |
CHECK(target_text_edit->get_caret_column() == 11); |
| 2791 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2792 |
CHECK(target_text_edit->get_selection_origin_column() == 7); |
| 2793 |
text_edit->set_deselect_on_focus_loss_enabled(true); |
| 2794 |
target_text_edit->set_deselect_on_focus_loss_enabled(true); |
| 2795 |
|
| 2796 |
|
| 2797 |
target_text_edit->set_drag_and_drop_selection_enabled(false); |
| 2798 |
text_edit->select(0, 4, 0, 5); |
| 2799 |
target_text_edit->deselect(); |
| 2800 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 4).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2801 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2802 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2803 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2804 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == " "); |
| 2805 |
CHECK(text_edit->has_selection()); |
| 2806 |
SEND_GUI_MOUSE_MOTION_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2807 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 7).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2808 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2809 |
CHECK(text_edit->get_text() == "drag\ndrop test"); |
| 2810 |
CHECK(target_text_edit->get_text() == "drag md test\ntee"); |
| 2811 |
CHECK_FALSE(text_edit->has_selection()); |
| 2812 |
CHECK(text_edit->get_caret_line() == 0); |
| 2813 |
CHECK(text_edit->get_caret_column() == 4); |
| 2814 |
CHECK(target_text_edit->has_selection()); |
| 2815 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2816 |
CHECK(target_text_edit->get_caret_column() == 8); |
| 2817 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2818 |
CHECK(target_text_edit->get_selection_origin_column() == 7); |
| 2819 |
target_text_edit->set_drag_and_drop_selection_enabled(true); |
| 2820 |
|
| 2821 |
|
| 2822 |
target_text_edit->set_editable(false); |
| 2823 |
text_edit->select(0, 1, 0, 4); |
| 2824 |
target_text_edit->deselect(); |
| 2825 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2826 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2827 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2828 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2829 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "rag"); |
| 2830 |
CHECK(text_edit->has_selection()); |
| 2831 |
SEND_GUI_MOUSE_MOTION_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2832 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2833 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2834 |
CHECK(text_edit->get_text() == "drag\ndrop test"); |
| 2835 |
CHECK(target_text_edit->get_text() == "drag md test\ntee"); |
| 2836 |
CHECK(text_edit->has_selection()); |
| 2837 |
CHECK_FALSE(target_text_edit->has_selection()); |
| 2838 |
target_text_edit->set_editable(true); |
| 2839 |
|
| 2840 |
|
| 2841 |
text_edit->set_editable(false); |
| 2842 |
text_edit->select(0, 0, 0, 4); |
| 2843 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 2844 |
CHECK(text_edit->is_mouse_over_selection()); |
| 2845 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 7).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2846 |
CHECK(text_edit->get_viewport()->gui_is_dragging()); |
| 2847 |
CHECK(text_edit->get_viewport()->gui_get_drag_data() == "drag"); |
| 2848 |
CHECK(text_edit->has_selection()); |
| 2849 |
SEND_GUI_MOUSE_MOTION_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 4).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 2850 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(target_text_edit->get_position() + target_text_edit->get_rect_at_line_column(0, 4).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE); |
| 2851 |
CHECK_FALSE(text_edit->get_viewport()->gui_is_dragging()); |
| 2852 |
CHECK(text_edit->get_text() == "drag\ndrop test"); |
| 2853 |
CHECK(target_text_edit->get_text() == "dragdrag md test\ntee"); |
| 2854 |
CHECK_FALSE(text_edit->has_selection()); |
| 2855 |
CHECK(text_edit->get_caret_line() == 0); |
| 2856 |
CHECK(text_edit->get_caret_column() == 4); |
| 2857 |
CHECK(target_text_edit->has_selection()); |
| 2858 |
CHECK(target_text_edit->get_caret_line() == 0); |
| 2859 |
CHECK(target_text_edit->get_caret_column() == 8); |
| 2860 |
CHECK(target_text_edit->get_selection_origin_line() == 0); |
| 2861 |
CHECK(target_text_edit->get_selection_origin_column() == 4); |
| 2862 |
text_edit->set_editable(true); |
| 2863 |
|
| 2864 |
memdelete(target_text_edit); |
| 2865 |
} |
| 2866 |
|
| 2867 |
SIGNAL_UNWATCH(text_edit, "text_set"); |
| 2868 |
SIGNAL_UNWATCH(text_edit, "text_changed"); |
| 2869 |
SIGNAL_UNWATCH(text_edit, "lines_edited_from"); |
| 2870 |
SIGNAL_UNWATCH(text_edit, "caret_changed"); |
| 2871 |
} |
| 2872 |
|
| 2873 |
SUBCASE("[TextEdit] overridable actions") { |
| 2874 |
DisplayServerMock *DS = (DisplayServerMock *)(DisplayServer::get_singleton()); |
| 2875 |
|
| 2876 |
SIGNAL_WATCH(text_edit, "text_set"); |
| 2877 |
SIGNAL_WATCH(text_edit, "text_changed"); |
| 2878 |
SIGNAL_WATCH(text_edit, "lines_edited_from"); |
| 2879 |
SIGNAL_WATCH(text_edit, "caret_changed"); |
| 2880 |
|
| 2881 |
Array lines_edited_args = { { 0, 0 } }; |
| 2882 |
|
| 2883 |
SUBCASE("[TextEdit] backspace") { |
| 2884 |
text_edit->set_text("this is\nsome\n"); |
| 2885 |
text_edit->set_caret_line(0); |
| 2886 |
text_edit->set_caret_column(0); |
| 2887 |
MessageQueue::get_singleton()->flush(); |
| 2888 |
SIGNAL_DISCARD("text_set"); |
| 2889 |
SIGNAL_DISCARD("text_changed"); |
| 2890 |
SIGNAL_DISCARD("lines_edited_from"); |
| 2891 |
SIGNAL_DISCARD("caret_changed"); |
| 2892 |
|
| 2893 |
|
| 2894 |
text_edit->backspace(); |
| 2895 |
MessageQueue::get_singleton()->flush(); |
| 2896 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 2897 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 2898 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 2899 |
|
| 2900 |
|
| 2901 |
text_edit->set_caret_line(2); |
| 2902 |
text_edit->set_caret_column(0); |
| 2903 |
MessageQueue::get_singleton()->flush(); |
| 2904 |
SIGNAL_DISCARD("caret_changed"); |
| 2905 |
lines_edited_args = { { 2, 1 } }; |
| 2906 |
|
| 2907 |
text_edit->backspace(); |
| 2908 |
MessageQueue::get_singleton()->flush(); |
| 2909 |
CHECK(text_edit->get_text() == "this is\nsome"); |
| 2910 |
CHECK(text_edit->get_caret_line() == 1); |
| 2911 |
CHECK(text_edit->get_caret_column() == 4); |
| 2912 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2913 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 2914 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 2915 |
|
| 2916 |
|
| 2917 |
lines_edited_args = { { 1, 1 } }; |
| 2918 |
text_edit->backspace(); |
| 2919 |
MessageQueue::get_singleton()->flush(); |
| 2920 |
CHECK(text_edit->get_text() == "this is\nsom"); |
| 2921 |
CHECK(text_edit->get_caret_line() == 1); |
| 2922 |
CHECK(text_edit->get_caret_column() == 3); |
| 2923 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2924 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 2925 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 2926 |
|
| 2927 |
|
| 2928 |
text_edit->end_complex_operation(); |
| 2929 |
text_edit->select(1, 0, 1, 3); |
| 2930 |
text_edit->backspace(); |
| 2931 |
MessageQueue::get_singleton()->flush(); |
| 2932 |
CHECK(text_edit->get_text() == "this is\n"); |
| 2933 |
CHECK(text_edit->get_caret_line() == 1); |
| 2934 |
CHECK(text_edit->get_caret_column() == 0); |
| 2935 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2936 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 2937 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 2938 |
|
| 2939 |
|
| 2940 |
text_edit->set_editable(false); |
| 2941 |
text_edit->backspace(); |
| 2942 |
text_edit->set_editable(true); |
| 2943 |
MessageQueue::get_singleton()->flush(); |
| 2944 |
CHECK(text_edit->get_text() == "this is\n"); |
| 2945 |
CHECK(text_edit->get_caret_line() == 1); |
| 2946 |
CHECK(text_edit->get_caret_column() == 0); |
| 2947 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 2948 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 2949 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 2950 |
|
| 2951 |
|
| 2952 |
text_edit->undo(); |
| 2953 |
MessageQueue::get_singleton()->flush(); |
| 2954 |
CHECK(text_edit->get_text() == "this is\nsom"); |
| 2955 |
CHECK(text_edit->get_caret_line() == 1); |
| 2956 |
CHECK(text_edit->get_caret_column() == 3); |
| 2957 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2958 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 2959 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 2960 |
|
| 2961 |
|
| 2962 |
text_edit->redo(); |
| 2963 |
MessageQueue::get_singleton()->flush(); |
| 2964 |
CHECK(text_edit->get_text() == "this is\n"); |
| 2965 |
CHECK(text_edit->get_caret_line() == 1); |
| 2966 |
CHECK(text_edit->get_caret_column() == 0); |
| 2967 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2968 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 2969 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 2970 |
|
| 2971 |
|
| 2972 |
} |
| 2973 |
|
| 2974 |
SUBCASE("[TextEdit] cut") { |
| 2975 |
|
| 2976 |
text_edit->set_text("this is\nsome\n"); |
| 2977 |
text_edit->set_caret_line(0); |
| 2978 |
text_edit->set_caret_column(6); |
| 2979 |
MessageQueue::get_singleton()->flush(); |
| 2980 |
SIGNAL_DISCARD("text_set"); |
| 2981 |
SIGNAL_DISCARD("text_changed"); |
| 2982 |
SIGNAL_DISCARD("lines_edited_from"); |
| 2983 |
SIGNAL_DISCARD("caret_changed"); |
| 2984 |
lines_edited_args = { { 1, 0 } }; |
| 2985 |
|
| 2986 |
text_edit->cut(); |
| 2987 |
MessageQueue::get_singleton()->flush(); |
| 2988 |
CHECK(DS->clipboard_get() == "this is\n"); |
| 2989 |
CHECK(text_edit->get_text() == "some\n"); |
| 2990 |
CHECK(text_edit->get_caret_line() == 0); |
| 2991 |
CHECK(text_edit->get_caret_column() == 3); |
| 2992 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 2993 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 2994 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 2995 |
|
| 2996 |
|
| 2997 |
text_edit->undo(); |
| 2998 |
MessageQueue::get_singleton()->flush(); |
| 2999 |
CHECK(DS->clipboard_get() == "this is\n"); |
| 3000 |
CHECK(text_edit->get_text() == "this is\nsome\n"); |
| 3001 |
CHECK(text_edit->get_caret_line() == 0); |
| 3002 |
CHECK(text_edit->get_caret_column() == 6); |
| 3003 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3004 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3005 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 3006 |
|
| 3007 |
|
| 3008 |
text_edit->redo(); |
| 3009 |
MessageQueue::get_singleton()->flush(); |
| 3010 |
CHECK(DS->clipboard_get() == "this is\n"); |
| 3011 |
CHECK(text_edit->get_text() == "some\n"); |
| 3012 |
CHECK(text_edit->get_caret_line() == 0); |
| 3013 |
CHECK(text_edit->get_caret_column() == 3); |
| 3014 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3015 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3016 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3017 |
|
| 3018 |
|
| 3019 |
text_edit->set_text("this is\nsome\n"); |
| 3020 |
text_edit->select(0, 5, 0, 7); |
| 3021 |
MessageQueue::get_singleton()->flush(); |
| 3022 |
SIGNAL_DISCARD("text_set"); |
| 3023 |
SIGNAL_DISCARD("text_changed"); |
| 3024 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3025 |
SIGNAL_DISCARD("caret_changed"); |
| 3026 |
lines_edited_args = { { 0, 0 } }; |
| 3027 |
|
| 3028 |
SEND_GUI_ACTION("ui_cut"); |
| 3029 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3030 |
MessageQueue::get_singleton()->flush(); |
| 3031 |
CHECK(DS->clipboard_get() == "is"); |
| 3032 |
CHECK(text_edit->get_text() == "this \nsome\n"); |
| 3033 |
CHECK_FALSE(text_edit->get_caret_line()); |
| 3034 |
CHECK(text_edit->get_caret_line() == 0); |
| 3035 |
CHECK(text_edit->get_caret_column() == 5); |
| 3036 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3037 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3038 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3039 |
|
| 3040 |
|
| 3041 |
text_edit->set_text("this is\nsome\n"); |
| 3042 |
text_edit->set_caret_line(0); |
| 3043 |
text_edit->set_caret_column(5); |
| 3044 |
MessageQueue::get_singleton()->flush(); |
| 3045 |
SIGNAL_DISCARD("text_set"); |
| 3046 |
SIGNAL_DISCARD("text_changed"); |
| 3047 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3048 |
SIGNAL_DISCARD("caret_changed"); |
| 3049 |
|
| 3050 |
text_edit->set_editable(false); |
| 3051 |
text_edit->cut(); |
| 3052 |
MessageQueue::get_singleton()->flush(); |
| 3053 |
text_edit->set_editable(true); |
| 3054 |
CHECK(DS->clipboard_get() == "this is\n"); |
| 3055 |
CHECK(text_edit->get_text() == "this is\nsome\n"); |
| 3056 |
CHECK(text_edit->get_caret_line() == 0); |
| 3057 |
CHECK(text_edit->get_caret_column() == 5); |
| 3058 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3059 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3060 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3061 |
|
| 3062 |
|
| 3063 |
text_edit->set_text("this is\nsome\n"); |
| 3064 |
text_edit->set_caret_line(0); |
| 3065 |
text_edit->set_caret_column(3); |
| 3066 |
text_edit->add_caret(0, 2); |
| 3067 |
text_edit->add_caret(0, 4); |
| 3068 |
text_edit->add_caret(2, 0); |
| 3069 |
MessageQueue::get_singleton()->flush(); |
| 3070 |
SIGNAL_DISCARD("text_set"); |
| 3071 |
SIGNAL_DISCARD("text_changed"); |
| 3072 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3073 |
SIGNAL_DISCARD("caret_changed"); |
| 3074 |
lines_edited_args = { { 1, 0 }, { 1, 0 } }; |
| 3075 |
|
| 3076 |
text_edit->cut(); |
| 3077 |
MessageQueue::get_singleton()->flush(); |
| 3078 |
CHECK(DS->clipboard_get() == "this is\n\n"); |
| 3079 |
CHECK(text_edit->get_text() == "some"); |
| 3080 |
CHECK(text_edit->get_caret_count() == 3); |
| 3081 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3082 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3083 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 3084 |
|
| 3085 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3086 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 3087 |
CHECK(text_edit->get_caret_column(1) == 3); |
| 3088 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 3089 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 3090 |
CHECK(text_edit->get_caret_column(2) == 4); |
| 3091 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3092 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3093 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3094 |
text_edit->remove_secondary_carets(); |
| 3095 |
|
| 3096 |
|
| 3097 |
text_edit->set_caret_line(0); |
| 3098 |
text_edit->set_caret_column(2); |
| 3099 |
MessageQueue::get_singleton()->flush(); |
| 3100 |
SIGNAL_DISCARD("caret_changed"); |
| 3101 |
lines_edited_args = { { 0, 0 } }; |
| 3102 |
|
| 3103 |
text_edit->cut(); |
| 3104 |
MessageQueue::get_singleton()->flush(); |
| 3105 |
CHECK(DS->clipboard_get() == "some\n"); |
| 3106 |
CHECK(text_edit->get_text() == ""); |
| 3107 |
CHECK(text_edit->get_line_count() == 1); |
| 3108 |
CHECK(text_edit->get_caret_line() == 0); |
| 3109 |
CHECK(text_edit->get_caret_column() == 0); |
| 3110 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3111 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3112 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3113 |
|
| 3114 |
|
| 3115 |
text_edit->cut(); |
| 3116 |
MessageQueue::get_singleton()->flush(); |
| 3117 |
CHECK(DS->clipboard_get() == "\n"); |
| 3118 |
CHECK(text_edit->get_text() == ""); |
| 3119 |
CHECK(text_edit->get_caret_line() == 0); |
| 3120 |
CHECK(text_edit->get_caret_column() == 0); |
| 3121 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3122 |
|
| 3123 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3124 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3125 |
|
| 3126 |
|
| 3127 |
text_edit->set_text("this is\nsome\ntext to\nbe\n\ncut"); |
| 3128 |
text_edit->set_caret_line(2); |
| 3129 |
text_edit->set_caret_column(7); |
| 3130 |
text_edit->add_caret(3, 0); |
| 3131 |
text_edit->add_caret(0, 2); |
| 3132 |
MessageQueue::get_singleton()->flush(); |
| 3133 |
SIGNAL_DISCARD("text_set"); |
| 3134 |
SIGNAL_DISCARD("text_changed"); |
| 3135 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3136 |
SIGNAL_DISCARD("caret_changed"); |
| 3137 |
lines_edited_args = { { 1, 0 }, { 3, 2 }, { 2, 1 } }; |
| 3138 |
|
| 3139 |
text_edit->cut(); |
| 3140 |
MessageQueue::get_singleton()->flush(); |
| 3141 |
CHECK(DS->clipboard_get() == "this is\ntext to\nbe\n"); |
| 3142 |
CHECK(text_edit->get_text() == "some\n\ncut"); |
| 3143 |
CHECK(text_edit->get_caret_count() == 2); |
| 3144 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3145 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3146 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 3147 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 3148 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3149 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3150 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3151 |
text_edit->remove_secondary_carets(); |
| 3152 |
|
| 3153 |
|
| 3154 |
text_edit->set_text("this is\nsome\ntext to\nbe\n\ncut"); |
| 3155 |
text_edit->add_caret(3, 0); |
| 3156 |
text_edit->add_caret(0, 2); |
| 3157 |
text_edit->add_caret(2, 0); |
| 3158 |
text_edit->select(1, 0, 1, 2, 0); |
| 3159 |
text_edit->select(3, 0, 4, 0, 1); |
| 3160 |
text_edit->select(0, 5, 0, 3, 2); |
| 3161 |
MessageQueue::get_singleton()->flush(); |
| 3162 |
SIGNAL_DISCARD("text_set"); |
| 3163 |
SIGNAL_DISCARD("text_changed"); |
| 3164 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3165 |
SIGNAL_DISCARD("caret_changed"); |
| 3166 |
lines_edited_args = { { 1, 1 }, { 4, 3 }, { 0, 0 } }; |
| 3167 |
|
| 3168 |
text_edit->cut(); |
| 3169 |
MessageQueue::get_singleton()->flush(); |
| 3170 |
CHECK(DS->clipboard_get() == "s \nso\nbe\n"); |
| 3171 |
CHECK(text_edit->get_text() == "thiis\nme\ntext to\n\ncut"); |
| 3172 |
CHECK(text_edit->get_caret_count() == 4); |
| 3173 |
CHECK_FALSE(text_edit->has_selection()); |
| 3174 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3175 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3176 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 3177 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3178 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 3179 |
CHECK(text_edit->get_caret_column(2) == 3); |
| 3180 |
CHECK(text_edit->get_caret_line(3) == 2); |
| 3181 |
CHECK(text_edit->get_caret_column(3) == 0); |
| 3182 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3183 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3184 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3185 |
} |
| 3186 |
|
| 3187 |
SUBCASE("[TextEdit] copy") { |
| 3188 |
text_edit->set_text("this is\nsome\ntest\n\ntext"); |
| 3189 |
MessageQueue::get_singleton()->flush(); |
| 3190 |
SIGNAL_DISCARD("text_set"); |
| 3191 |
SIGNAL_DISCARD("text_changed"); |
| 3192 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3193 |
SIGNAL_DISCARD("caret_changed"); |
| 3194 |
|
| 3195 |
|
| 3196 |
text_edit->select(0, 0, 1, 2, 0); |
| 3197 |
MessageQueue::get_singleton()->flush(); |
| 3198 |
SIGNAL_DISCARD("caret_changed"); |
| 3199 |
DS->clipboard_set_primary(""); |
| 3200 |
|
| 3201 |
text_edit->copy(); |
| 3202 |
MessageQueue::get_singleton()->flush(); |
| 3203 |
CHECK(DS->clipboard_get() == "this is\nso"); |
| 3204 |
CHECK(DS->clipboard_get_primary() == ""); |
| 3205 |
CHECK(text_edit->get_text() == "this is\nsome\ntest\n\ntext"); |
| 3206 |
CHECK(text_edit->has_selection()); |
| 3207 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 3208 |
CHECK(text_edit->get_selection_origin_column() == 0); |
| 3209 |
CHECK(text_edit->get_caret_line() == 1); |
| 3210 |
CHECK(text_edit->get_caret_column() == 2); |
| 3211 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3212 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3213 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3214 |
|
| 3215 |
|
| 3216 |
text_edit->select(0, 0, 0, 2, 0); |
| 3217 |
MessageQueue::get_singleton()->flush(); |
| 3218 |
SIGNAL_DISCARD("caret_changed"); |
| 3219 |
|
| 3220 |
SEND_GUI_ACTION("ui_copy"); |
| 3221 |
MessageQueue::get_singleton()->flush(); |
| 3222 |
CHECK(DS->clipboard_get() == "th"); |
| 3223 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3224 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3225 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3226 |
|
| 3227 |
|
| 3228 |
text_edit->select(2, 4, 1, 2, 0); |
| 3229 |
MessageQueue::get_singleton()->flush(); |
| 3230 |
SIGNAL_DISCARD("caret_changed"); |
| 3231 |
|
| 3232 |
text_edit->set_editable(false); |
| 3233 |
text_edit->copy(); |
| 3234 |
text_edit->set_editable(true); |
| 3235 |
MessageQueue::get_singleton()->flush(); |
| 3236 |
CHECK(DS->clipboard_get() == "me\ntest"); |
| 3237 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3238 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3239 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3240 |
text_edit->deselect(); |
| 3241 |
|
| 3242 |
|
| 3243 |
text_edit->set_caret_line(0); |
| 3244 |
text_edit->set_caret_column(2); |
| 3245 |
MessageQueue::get_singleton()->flush(); |
| 3246 |
SIGNAL_DISCARD("caret_changed"); |
| 3247 |
|
| 3248 |
text_edit->copy(); |
| 3249 |
MessageQueue::get_singleton()->flush(); |
| 3250 |
CHECK(DS->clipboard_get() == "this is\n"); |
| 3251 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3252 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3253 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3254 |
|
| 3255 |
|
| 3256 |
text_edit->set_caret_line(3); |
| 3257 |
text_edit->set_caret_column(0); |
| 3258 |
MessageQueue::get_singleton()->flush(); |
| 3259 |
SIGNAL_DISCARD("caret_changed"); |
| 3260 |
|
| 3261 |
text_edit->copy(); |
| 3262 |
MessageQueue::get_singleton()->flush(); |
| 3263 |
CHECK(DS->clipboard_get() == "\n"); |
| 3264 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3265 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3266 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3267 |
text_edit->deselect(); |
| 3268 |
|
| 3269 |
|
| 3270 |
text_edit->set_caret_line(1); |
| 3271 |
text_edit->set_caret_column(2); |
| 3272 |
text_edit->add_caret(1, 0); |
| 3273 |
text_edit->add_caret(1, 4); |
| 3274 |
MessageQueue::get_singleton()->flush(); |
| 3275 |
SIGNAL_DISCARD("caret_changed"); |
| 3276 |
|
| 3277 |
text_edit->copy(); |
| 3278 |
MessageQueue::get_singleton()->flush(); |
| 3279 |
CHECK(DS->clipboard_get() == "some\n"); |
| 3280 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3281 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3282 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3283 |
text_edit->remove_secondary_carets(); |
| 3284 |
|
| 3285 |
|
| 3286 |
text_edit->set_caret_line(2); |
| 3287 |
text_edit->set_caret_column(4); |
| 3288 |
text_edit->add_caret(4, 0); |
| 3289 |
text_edit->add_caret(0, 4); |
| 3290 |
text_edit->add_caret(1, 0); |
| 3291 |
text_edit->select(1, 3, 2, 4, 0); |
| 3292 |
text_edit->select(4, 4, 4, 0, 1); |
| 3293 |
text_edit->select(0, 5, 0, 4, 2); |
| 3294 |
MessageQueue::get_singleton()->flush(); |
| 3295 |
SIGNAL_DISCARD("caret_changed"); |
| 3296 |
|
| 3297 |
text_edit->copy(); |
| 3298 |
MessageQueue::get_singleton()->flush(); |
| 3299 |
CHECK(DS->clipboard_get() == " \ne\ntest\ntext"); |
| 3300 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3301 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3302 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3303 |
text_edit->remove_secondary_carets(); |
| 3304 |
text_edit->deselect(); |
| 3305 |
|
| 3306 |
|
| 3307 |
text_edit->set_caret_line(3); |
| 3308 |
text_edit->set_caret_column(0); |
| 3309 |
text_edit->add_caret(4, 2); |
| 3310 |
text_edit->add_caret(0, 4); |
| 3311 |
MessageQueue::get_singleton()->flush(); |
| 3312 |
SIGNAL_DISCARD("caret_changed"); |
| 3313 |
|
| 3314 |
text_edit->copy(); |
| 3315 |
MessageQueue::get_singleton()->flush(); |
| 3316 |
CHECK(DS->clipboard_get() == "this is\n\ntext\n"); |
| 3317 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3318 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3319 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3320 |
} |
| 3321 |
|
| 3322 |
SUBCASE("[TextEdit] paste") { |
| 3323 |
|
| 3324 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3325 |
text_edit->set_caret_line(1); |
| 3326 |
text_edit->set_caret_column(2); |
| 3327 |
MessageQueue::get_singleton()->flush(); |
| 3328 |
SIGNAL_DISCARD("text_set"); |
| 3329 |
SIGNAL_DISCARD("text_changed"); |
| 3330 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3331 |
SIGNAL_DISCARD("caret_changed"); |
| 3332 |
lines_edited_args = { { 1, 1 } }; |
| 3333 |
DS->clipboard_set("paste"); |
| 3334 |
|
| 3335 |
text_edit->paste(); |
| 3336 |
MessageQueue::get_singleton()->flush(); |
| 3337 |
CHECK(DS->clipboard_get() == "paste"); |
| 3338 |
CHECK(text_edit->get_text() == "this is\nsopasteme\n\ntext"); |
| 3339 |
CHECK_FALSE(text_edit->has_selection()); |
| 3340 |
CHECK(text_edit->get_caret_line() == 1); |
| 3341 |
CHECK(text_edit->get_caret_column() == 7); |
| 3342 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3343 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3344 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3345 |
|
| 3346 |
|
| 3347 |
text_edit->undo(); |
| 3348 |
MessageQueue::get_singleton()->flush(); |
| 3349 |
CHECK(DS->clipboard_get() == "paste"); |
| 3350 |
CHECK(text_edit->get_text() == "this is\nsome\n\ntext"); |
| 3351 |
CHECK(text_edit->get_caret_line() == 1); |
| 3352 |
CHECK(text_edit->get_caret_column() == 2); |
| 3353 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3354 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3355 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3356 |
|
| 3357 |
|
| 3358 |
text_edit->redo(); |
| 3359 |
MessageQueue::get_singleton()->flush(); |
| 3360 |
CHECK(DS->clipboard_get() == "paste"); |
| 3361 |
CHECK(text_edit->get_text() == "this is\nsopasteme\n\ntext"); |
| 3362 |
CHECK(text_edit->get_caret_line() == 1); |
| 3363 |
CHECK(text_edit->get_caret_column() == 7); |
| 3364 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3365 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3366 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3367 |
|
| 3368 |
|
| 3369 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3370 |
text_edit->set_caret_line(2); |
| 3371 |
text_edit->set_caret_column(0); |
| 3372 |
MessageQueue::get_singleton()->flush(); |
| 3373 |
SIGNAL_DISCARD("text_set"); |
| 3374 |
SIGNAL_DISCARD("text_changed"); |
| 3375 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3376 |
SIGNAL_DISCARD("caret_changed"); |
| 3377 |
lines_edited_args = { { 2, 2 } }; |
| 3378 |
DS->clipboard_set("paste2"); |
| 3379 |
|
| 3380 |
SEND_GUI_ACTION("ui_paste"); |
| 3381 |
MessageQueue::get_singleton()->flush(); |
| 3382 |
CHECK(DS->clipboard_get() == "paste2"); |
| 3383 |
CHECK(text_edit->get_text() == "this is\nsome\npaste2\ntext"); |
| 3384 |
CHECK(text_edit->get_caret_line() == 2); |
| 3385 |
CHECK(text_edit->get_caret_column() == 6); |
| 3386 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3387 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3388 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3389 |
|
| 3390 |
|
| 3391 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3392 |
text_edit->select(0, 5, 1, 3); |
| 3393 |
MessageQueue::get_singleton()->flush(); |
| 3394 |
SIGNAL_DISCARD("text_set"); |
| 3395 |
SIGNAL_DISCARD("text_changed"); |
| 3396 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3397 |
SIGNAL_DISCARD("caret_changed"); |
| 3398 |
lines_edited_args = { { 1, 0 }, { 0, 0 } }; |
| 3399 |
DS->clipboard_set("paste"); |
| 3400 |
|
| 3401 |
text_edit->paste(); |
| 3402 |
MessageQueue::get_singleton()->flush(); |
| 3403 |
CHECK(DS->clipboard_get() == "paste"); |
| 3404 |
CHECK(text_edit->get_text() == "this pastee\n\ntext"); |
| 3405 |
CHECK_FALSE(text_edit->has_selection()); |
| 3406 |
CHECK(text_edit->get_caret_line() == 0); |
| 3407 |
CHECK(text_edit->get_caret_column() == 10); |
| 3408 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3409 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3410 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3411 |
|
| 3412 |
|
| 3413 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3414 |
text_edit->set_caret_line(0); |
| 3415 |
text_edit->set_caret_column(1); |
| 3416 |
MessageQueue::get_singleton()->flush(); |
| 3417 |
SIGNAL_DISCARD("text_set"); |
| 3418 |
SIGNAL_DISCARD("text_changed"); |
| 3419 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3420 |
SIGNAL_DISCARD("caret_changed"); |
| 3421 |
lines_edited_args = { { 0, 3 } }; |
| 3422 |
DS->clipboard_set("multi\n\nline\npaste"); |
| 3423 |
|
| 3424 |
text_edit->paste(); |
| 3425 |
MessageQueue::get_singleton()->flush(); |
| 3426 |
CHECK(DS->clipboard_get() == "multi\n\nline\npaste"); |
| 3427 |
CHECK(text_edit->get_text() == "tmulti\n\nline\npastehis is\nsome\n\ntext"); |
| 3428 |
CHECK(text_edit->get_caret_line() == 3); |
| 3429 |
CHECK(text_edit->get_caret_column() == 5); |
| 3430 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3431 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3432 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3433 |
|
| 3434 |
|
| 3435 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3436 |
text_edit->set_caret_line(1); |
| 3437 |
text_edit->set_caret_column(2); |
| 3438 |
MessageQueue::get_singleton()->flush(); |
| 3439 |
SIGNAL_DISCARD("text_set"); |
| 3440 |
SIGNAL_DISCARD("text_changed"); |
| 3441 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3442 |
SIGNAL_DISCARD("caret_changed"); |
| 3443 |
lines_edited_args = { { 1, 2 } }; |
| 3444 |
DS->clipboard_set(""); |
| 3445 |
text_edit->copy(); |
| 3446 |
text_edit->set_caret_column(3); |
| 3447 |
CHECK(DS->clipboard_get() == "some\n"); |
| 3448 |
MessageQueue::get_singleton()->flush(); |
| 3449 |
SIGNAL_DISCARD("caret_changed"); |
| 3450 |
|
| 3451 |
text_edit->paste(); |
| 3452 |
MessageQueue::get_singleton()->flush(); |
| 3453 |
CHECK(DS->clipboard_get() == "some\n"); |
| 3454 |
CHECK(text_edit->get_text() == "this is\nsome\nsome\n\ntext"); |
| 3455 |
CHECK(text_edit->get_caret_line() == 2); |
| 3456 |
CHECK(text_edit->get_caret_column() == 3); |
| 3457 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3458 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3459 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3460 |
|
| 3461 |
|
| 3462 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3463 |
text_edit->set_caret_line(0); |
| 3464 |
text_edit->set_caret_column(4); |
| 3465 |
MessageQueue::get_singleton()->flush(); |
| 3466 |
SIGNAL_DISCARD("text_set"); |
| 3467 |
SIGNAL_DISCARD("text_changed"); |
| 3468 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3469 |
SIGNAL_DISCARD("caret_changed"); |
| 3470 |
lines_edited_args = { { 0, 1 } }; |
| 3471 |
DS->clipboard_set("paste\n"); |
| 3472 |
|
| 3473 |
text_edit->paste(); |
| 3474 |
MessageQueue::get_singleton()->flush(); |
| 3475 |
CHECK(DS->clipboard_get() == "paste\n"); |
| 3476 |
CHECK(text_edit->get_text() == "thispaste\n is\nsome\n\ntext"); |
| 3477 |
CHECK(text_edit->get_caret_line() == 1); |
| 3478 |
CHECK(text_edit->get_caret_column() == 0); |
| 3479 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3480 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3481 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3482 |
|
| 3483 |
|
| 3484 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3485 |
text_edit->set_caret_line(1); |
| 3486 |
text_edit->set_caret_column(2); |
| 3487 |
text_edit->add_caret(3, 4); |
| 3488 |
text_edit->add_caret(0, 4); |
| 3489 |
MessageQueue::get_singleton()->flush(); |
| 3490 |
SIGNAL_DISCARD("text_set"); |
| 3491 |
SIGNAL_DISCARD("text_changed"); |
| 3492 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3493 |
SIGNAL_DISCARD("caret_changed"); |
| 3494 |
lines_edited_args = { { 0, 1 }, { 2, 3 }, { 5, 6 } }; |
| 3495 |
DS->clipboard_set("paste\ntest"); |
| 3496 |
|
| 3497 |
text_edit->paste(); |
| 3498 |
MessageQueue::get_singleton()->flush(); |
| 3499 |
CHECK(DS->clipboard_get() == "paste\ntest"); |
| 3500 |
CHECK(text_edit->get_text() == "thispaste\ntest is\nsopaste\ntestme\n\ntextpaste\ntest"); |
| 3501 |
CHECK(text_edit->get_caret_count() == 3); |
| 3502 |
CHECK(text_edit->get_caret_line(0) == 3); |
| 3503 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 3504 |
CHECK(text_edit->get_caret_line(1) == 6); |
| 3505 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 3506 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 3507 |
CHECK(text_edit->get_caret_column(2) == 4); |
| 3508 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3509 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3510 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3511 |
text_edit->remove_secondary_carets(); |
| 3512 |
|
| 3513 |
|
| 3514 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3515 |
text_edit->set_caret_line(1); |
| 3516 |
text_edit->set_caret_column(2); |
| 3517 |
text_edit->add_caret(3, 4); |
| 3518 |
text_edit->add_caret(0, 4); |
| 3519 |
MessageQueue::get_singleton()->flush(); |
| 3520 |
SIGNAL_DISCARD("text_set"); |
| 3521 |
SIGNAL_DISCARD("text_changed"); |
| 3522 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3523 |
SIGNAL_DISCARD("caret_changed"); |
| 3524 |
lines_edited_args = { { 0, 0 }, { 1, 1 }, { 3, 3 } }; |
| 3525 |
DS->clipboard_set("paste\ntest\n1"); |
| 3526 |
|
| 3527 |
text_edit->paste(); |
| 3528 |
MessageQueue::get_singleton()->flush(); |
| 3529 |
CHECK(DS->clipboard_get() == "paste\ntest\n1"); |
| 3530 |
CHECK(text_edit->get_text() == "thispaste is\nsotestme\n\ntext1"); |
| 3531 |
CHECK(text_edit->get_caret_count() == 3); |
| 3532 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3533 |
CHECK(text_edit->get_caret_column(0) == 6); |
| 3534 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 3535 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 3536 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 3537 |
CHECK(text_edit->get_caret_column(2) == 9); |
| 3538 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3539 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3540 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3541 |
text_edit->remove_secondary_carets(); |
| 3542 |
|
| 3543 |
|
| 3544 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3545 |
text_edit->set_caret_line(0); |
| 3546 |
text_edit->set_caret_column(4); |
| 3547 |
MessageQueue::get_singleton()->flush(); |
| 3548 |
SIGNAL_DISCARD("text_set"); |
| 3549 |
SIGNAL_DISCARD("text_changed"); |
| 3550 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3551 |
SIGNAL_DISCARD("caret_changed"); |
| 3552 |
DS->clipboard_set("no paste"); |
| 3553 |
|
| 3554 |
text_edit->set_editable(false); |
| 3555 |
text_edit->paste(); |
| 3556 |
text_edit->set_editable(true); |
| 3557 |
MessageQueue::get_singleton()->flush(); |
| 3558 |
CHECK(DS->clipboard_get() == "no paste"); |
| 3559 |
CHECK(text_edit->get_text() == "this is\nsome\n\ntext"); |
| 3560 |
CHECK(text_edit->get_caret_line() == 0); |
| 3561 |
CHECK(text_edit->get_caret_column() == 4); |
| 3562 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3563 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3564 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3565 |
} |
| 3566 |
|
| 3567 |
SUBCASE("[TextEdit] paste primary") { |
| 3568 |
|
| 3569 |
text_edit->set_size(Size2(200, 200)); |
| 3570 |
|
| 3571 |
text_edit->grab_focus(); |
| 3572 |
DS->clipboard_set(""); |
| 3573 |
DS->clipboard_set_primary(""); |
| 3574 |
CHECK(DS->clipboard_get_primary() == ""); |
| 3575 |
|
| 3576 |
|
| 3577 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3578 |
MessageQueue::get_singleton()->flush(); |
| 3579 |
SIGNAL_DISCARD("text_set"); |
| 3580 |
SIGNAL_DISCARD("text_changed"); |
| 3581 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3582 |
SIGNAL_DISCARD("caret_changed"); |
| 3583 |
|
| 3584 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(0, 2).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 3585 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 3).get_center() + Point2i(2, 0), MouseButtonMask::LEFT, Key::NONE); |
| 3586 |
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(text_edit->get_rect_at_line_column(1, 3).get_center() + Point2i(2, 0), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 3587 |
CHECK(DS->clipboard_get() == ""); |
| 3588 |
CHECK(DS->clipboard_get_primary() == "is is\nsom"); |
| 3589 |
CHECK(text_edit->get_text() == "this is\nsome\n\ntext"); |
| 3590 |
CHECK(text_edit->has_selection()); |
| 3591 |
CHECK(text_edit->get_selected_text() == "is is\nsom"); |
| 3592 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 3593 |
CHECK(text_edit->get_selection_origin_column() == 2); |
| 3594 |
CHECK(text_edit->get_caret_line() == 1); |
| 3595 |
CHECK(text_edit->get_caret_column() == 3); |
| 3596 |
SIGNAL_CHECK_FALSE("text_set"); |
| 3597 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3598 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3599 |
|
| 3600 |
|
| 3601 |
SIGNAL_DISCARD("text_set"); |
| 3602 |
SIGNAL_DISCARD("text_changed"); |
| 3603 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3604 |
SIGNAL_DISCARD("caret_changed"); |
| 3605 |
lines_edited_args = { { 3, 4 } }; |
| 3606 |
|
| 3607 |
SEND_GUI_MOUSE_BUTTON_EVENT(text_edit->get_rect_at_line_column(3, 2).get_center() + Point2i(2, 0), MouseButton::MIDDLE, MouseButtonMask::MIDDLE, Key::NONE); |
| 3608 |
CHECK(DS->clipboard_get_primary() == "is is\nsom"); |
| 3609 |
CHECK(text_edit->get_text() == "this is\nsome\n\nteis is\nsomxt"); |
| 3610 |
CHECK_FALSE(text_edit->has_selection()); |
| 3611 |
CHECK(text_edit->get_caret_line() == 4); |
| 3612 |
CHECK(text_edit->get_caret_column() == 3); |
| 3613 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3614 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3615 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3616 |
|
| 3617 |
|
| 3618 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3619 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButtonMask::NONE, Key::NONE); |
| 3620 |
MessageQueue::get_singleton()->flush(); |
| 3621 |
SIGNAL_DISCARD("text_set"); |
| 3622 |
SIGNAL_DISCARD("text_changed"); |
| 3623 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3624 |
SIGNAL_DISCARD("caret_changed"); |
| 3625 |
DS->clipboard_set_primary("paste"); |
| 3626 |
lines_edited_args = { { 0, 0 } }; |
| 3627 |
|
| 3628 |
text_edit->paste_primary_clipboard(); |
| 3629 |
MessageQueue::get_singleton()->flush(); |
| 3630 |
CHECK(DS->clipboard_get_primary() == "paste"); |
| 3631 |
CHECK(text_edit->get_text() == "tpastehis is\nsome\n\ntext"); |
| 3632 |
CHECK_FALSE(text_edit->has_selection()); |
| 3633 |
CHECK(text_edit->get_caret_line() == 0); |
| 3634 |
CHECK(text_edit->get_caret_column() == 6); |
| 3635 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3636 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3637 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3638 |
|
| 3639 |
|
| 3640 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3641 |
text_edit->set_caret_line(1); |
| 3642 |
text_edit->set_caret_column(0); |
| 3643 |
text_edit->add_caret(2, 0); |
| 3644 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(0, 1).get_center() + Point2i(2, 0), MouseButtonMask::NONE, Key::NONE); |
| 3645 |
MessageQueue::get_singleton()->flush(); |
| 3646 |
SIGNAL_DISCARD("text_set"); |
| 3647 |
SIGNAL_DISCARD("text_changed"); |
| 3648 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3649 |
SIGNAL_DISCARD("caret_changed"); |
| 3650 |
DS->clipboard_set_primary("paste"); |
| 3651 |
lines_edited_args = { { 1, 1 }, { 2, 2 } }; |
| 3652 |
|
| 3653 |
text_edit->paste_primary_clipboard(); |
| 3654 |
MessageQueue::get_singleton()->flush(); |
| 3655 |
CHECK(DS->clipboard_get_primary() == "paste"); |
| 3656 |
CHECK(text_edit->get_text() == "this is\npastesome\npaste\ntext"); |
| 3657 |
CHECK_FALSE(text_edit->has_selection()); |
| 3658 |
CHECK(text_edit->get_caret_count() == 2); |
| 3659 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3660 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 3661 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 3662 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 3663 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3664 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3665 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3666 |
|
| 3667 |
|
| 3668 |
text_edit->set_text("this is\nsome\n\ntext"); |
| 3669 |
text_edit->set_caret_line(0); |
| 3670 |
text_edit->set_caret_column(4); |
| 3671 |
SEND_GUI_MOUSE_MOTION_EVENT(text_edit->get_rect_at_line_column(1, 3).get_center() + Point2i(2, 0), MouseButtonMask::NONE, Key::NONE); |
| 3672 |
MessageQueue::get_singleton()->flush(); |
| 3673 |
SIGNAL_DISCARD("text_set"); |
| 3674 |
SIGNAL_DISCARD("text_changed"); |
| 3675 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3676 |
SIGNAL_DISCARD("caret_changed"); |
| 3677 |
DS->clipboard_set("no paste"); |
| 3678 |
|
| 3679 |
text_edit->set_editable(false); |
| 3680 |
text_edit->paste_primary_clipboard(); |
| 3681 |
text_edit->set_editable(true); |
| 3682 |
MessageQueue::get_singleton()->flush(); |
| 3683 |
CHECK(DS->clipboard_get() == "no paste"); |
| 3684 |
CHECK(text_edit->get_text() == "this is\nsome\n\ntext"); |
| 3685 |
CHECK(text_edit->get_caret_line() == 0); |
| 3686 |
CHECK(text_edit->get_caret_column() == 4); |
| 3687 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3688 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3689 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3690 |
} |
| 3691 |
|
| 3692 |
SUBCASE("[TextEdit] cut when empty selection clipboard disabled") { |
| 3693 |
text_edit->set_empty_selection_clipboard_enabled(false); |
| 3694 |
DS->clipboard_set(""); |
| 3695 |
|
| 3696 |
text_edit->set_text("this is\nsome\n"); |
| 3697 |
text_edit->set_caret_line(0); |
| 3698 |
text_edit->set_caret_column(6); |
| 3699 |
MessageQueue::get_singleton()->flush(); |
| 3700 |
SIGNAL_DISCARD("text_set"); |
| 3701 |
SIGNAL_DISCARD("text_changed"); |
| 3702 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3703 |
SIGNAL_DISCARD("caret_changed"); |
| 3704 |
|
| 3705 |
text_edit->cut(); |
| 3706 |
MessageQueue::get_singleton()->flush(); |
| 3707 |
CHECK(DS->clipboard_get() == ""); |
| 3708 |
CHECK(text_edit->get_text() == "this is\nsome\n"); |
| 3709 |
CHECK(text_edit->get_caret_line() == 0); |
| 3710 |
CHECK(text_edit->get_caret_column() == 6); |
| 3711 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3712 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3713 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3714 |
} |
| 3715 |
|
| 3716 |
SUBCASE("[TextEdit] copy when empty selection clipboard disabled") { |
| 3717 |
text_edit->set_empty_selection_clipboard_enabled(false); |
| 3718 |
DS->clipboard_set(""); |
| 3719 |
|
| 3720 |
text_edit->set_text("this is\nsome\n"); |
| 3721 |
text_edit->set_caret_line(0); |
| 3722 |
text_edit->set_caret_column(6); |
| 3723 |
MessageQueue::get_singleton()->flush(); |
| 3724 |
SIGNAL_DISCARD("text_set"); |
| 3725 |
SIGNAL_DISCARD("text_changed"); |
| 3726 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3727 |
SIGNAL_DISCARD("caret_changed"); |
| 3728 |
|
| 3729 |
text_edit->copy(); |
| 3730 |
MessageQueue::get_singleton()->flush(); |
| 3731 |
CHECK(DS->clipboard_get() == ""); |
| 3732 |
CHECK(text_edit->get_text() == "this is\nsome\n"); |
| 3733 |
CHECK(text_edit->get_caret_line() == 0); |
| 3734 |
CHECK(text_edit->get_caret_column() == 6); |
| 3735 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3736 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3737 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3738 |
} |
| 3739 |
|
| 3740 |
SIGNAL_UNWATCH(text_edit, "text_set"); |
| 3741 |
SIGNAL_UNWATCH(text_edit, "text_changed"); |
| 3742 |
SIGNAL_UNWATCH(text_edit, "lines_edited_from"); |
| 3743 |
SIGNAL_UNWATCH(text_edit, "caret_changed"); |
| 3744 |
} |
| 3745 |
|
| 3746 |
SUBCASE("[TextEdit] input") { |
| 3747 |
SIGNAL_WATCH(text_edit, "text_set"); |
| 3748 |
SIGNAL_WATCH(text_edit, "text_changed"); |
| 3749 |
SIGNAL_WATCH(text_edit, "lines_edited_from"); |
| 3750 |
SIGNAL_WATCH(text_edit, "caret_changed"); |
| 3751 |
|
| 3752 |
Array lines_edited_args = { { 0, 0 } }; |
| 3753 |
|
| 3754 |
SUBCASE("[TextEdit] ui_text_newline_above") { |
| 3755 |
text_edit->set_text("this is some test text.\nthis is some test text."); |
| 3756 |
MessageQueue::get_singleton()->flush(); |
| 3757 |
SIGNAL_DISCARD("text_set"); |
| 3758 |
SIGNAL_DISCARD("text_changed"); |
| 3759 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3760 |
SIGNAL_DISCARD("caret_changed"); |
| 3761 |
|
| 3762 |
|
| 3763 |
text_edit->select(0, 0, 0, 4); |
| 3764 |
text_edit->add_caret(1, 4); |
| 3765 |
CHECK(text_edit->get_caret_count() == 2); |
| 3766 |
MessageQueue::get_singleton()->flush(); |
| 3767 |
SIGNAL_DISCARD("caret_changed"); |
| 3768 |
lines_edited_args = { { 0, 1 }, { 2, 3 } }; |
| 3769 |
|
| 3770 |
SEND_GUI_ACTION("ui_text_newline_above"); |
| 3771 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3772 |
CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); |
| 3773 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3774 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3775 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3776 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3777 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 3778 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3779 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3780 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3781 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3782 |
|
| 3783 |
|
| 3784 |
text_edit->undo(); |
| 3785 |
MessageQueue::get_singleton()->flush(); |
| 3786 |
CHECK(text_edit->get_text() == "this is some test text.\nthis is some test text."); |
| 3787 |
CHECK(text_edit->has_selection(0)); |
| 3788 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3789 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 3790 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 3791 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 3792 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3793 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 3794 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 3795 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3796 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3797 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 3798 |
|
| 3799 |
|
| 3800 |
text_edit->redo(); |
| 3801 |
MessageQueue::get_singleton()->flush(); |
| 3802 |
CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); |
| 3803 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3804 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3805 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3806 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3807 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 3808 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3809 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3810 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3811 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3812 |
|
| 3813 |
|
| 3814 |
text_edit->set_caret_line(1); |
| 3815 |
text_edit->set_caret_column(4); |
| 3816 |
text_edit->set_caret_line(3, false, true, -1, 1); |
| 3817 |
text_edit->set_caret_column(4, false, 1); |
| 3818 |
MessageQueue::get_singleton()->flush(); |
| 3819 |
SIGNAL_DISCARD("caret_changed"); |
| 3820 |
|
| 3821 |
text_edit->set_editable(false); |
| 3822 |
SEND_GUI_ACTION("ui_text_newline_above"); |
| 3823 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3824 |
CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); |
| 3825 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3826 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3827 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 3828 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3829 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 3830 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 3831 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3832 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3833 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3834 |
text_edit->set_editable(true); |
| 3835 |
|
| 3836 |
|
| 3837 |
text_edit->select(1, 10, 0, 0); |
| 3838 |
MessageQueue::get_singleton()->flush(); |
| 3839 |
SIGNAL_DISCARD("caret_changed"); |
| 3840 |
lines_edited_args = { { 0, 1 }, { 4, 5 } }; |
| 3841 |
|
| 3842 |
SEND_GUI_ACTION("ui_text_newline_above"); |
| 3843 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3844 |
CHECK(text_edit->get_text() == "\n\nthis is some test text.\n\n\nthis is some test text."); |
| 3845 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3846 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3847 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3848 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3849 |
CHECK(text_edit->get_caret_line(1) == 4); |
| 3850 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3851 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3852 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3853 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3854 |
|
| 3855 |
|
| 3856 |
text_edit->set_text("test"); |
| 3857 |
text_edit->set_caret_line(0); |
| 3858 |
text_edit->set_caret_column(1); |
| 3859 |
text_edit->add_caret(0, 3); |
| 3860 |
MessageQueue::get_singleton()->flush(); |
| 3861 |
SIGNAL_DISCARD("text_set"); |
| 3862 |
SIGNAL_DISCARD("text_changed"); |
| 3863 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3864 |
SIGNAL_DISCARD("caret_changed"); |
| 3865 |
lines_edited_args = { { 0, 1 }, { 1, 2 } }; |
| 3866 |
|
| 3867 |
SEND_GUI_ACTION("ui_text_newline_above"); |
| 3868 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3869 |
CHECK(text_edit->get_text() == "\n\ntest"); |
| 3870 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3871 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3872 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3873 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3874 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 3875 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3876 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3877 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3878 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3879 |
} |
| 3880 |
|
| 3881 |
SUBCASE("[TextEdit] ui_text_newline_blank") { |
| 3882 |
text_edit->set_text("this is some test text.\nthis is some test text."); |
| 3883 |
MessageQueue::get_singleton()->flush(); |
| 3884 |
SIGNAL_DISCARD("text_set"); |
| 3885 |
SIGNAL_DISCARD("text_changed"); |
| 3886 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3887 |
|
| 3888 |
|
| 3889 |
text_edit->select(0, 0, 0, 4); |
| 3890 |
text_edit->add_caret(1, 4); |
| 3891 |
CHECK(text_edit->get_caret_count() == 2); |
| 3892 |
MessageQueue::get_singleton()->flush(); |
| 3893 |
SIGNAL_DISCARD("caret_changed"); |
| 3894 |
lines_edited_args = { { 0, 1 }, { 2, 3 } }; |
| 3895 |
|
| 3896 |
SEND_GUI_ACTION("ui_text_newline_blank"); |
| 3897 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3898 |
CHECK(text_edit->get_text() == "this is some test text.\n\nthis is some test text.\n"); |
| 3899 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3900 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3901 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3902 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3903 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 3904 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3905 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3906 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3907 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3908 |
|
| 3909 |
|
| 3910 |
text_edit->undo(); |
| 3911 |
MessageQueue::get_singleton()->flush(); |
| 3912 |
CHECK(text_edit->get_text() == "this is some test text.\nthis is some test text."); |
| 3913 |
CHECK(text_edit->has_selection(0)); |
| 3914 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 3915 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 3916 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 3917 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 3918 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3919 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 3920 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 3921 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3922 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3923 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 3924 |
|
| 3925 |
|
| 3926 |
text_edit->redo(); |
| 3927 |
MessageQueue::get_singleton()->flush(); |
| 3928 |
CHECK(text_edit->get_text() == "this is some test text.\n\nthis is some test text.\n"); |
| 3929 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3930 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3931 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3932 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 3933 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3934 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3935 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3936 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3937 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3938 |
|
| 3939 |
|
| 3940 |
text_edit->set_editable(false); |
| 3941 |
SEND_GUI_ACTION("ui_text_newline_blank"); |
| 3942 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3943 |
CHECK(text_edit->get_text() == "this is some test text.\n\nthis is some test text.\n"); |
| 3944 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3945 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 3946 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3947 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3948 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 3949 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3950 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 3951 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 3952 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 3953 |
text_edit->set_editable(true); |
| 3954 |
|
| 3955 |
|
| 3956 |
text_edit->set_text("test"); |
| 3957 |
text_edit->set_caret_line(0); |
| 3958 |
text_edit->set_caret_column(1); |
| 3959 |
text_edit->add_caret(0, 3); |
| 3960 |
MessageQueue::get_singleton()->flush(); |
| 3961 |
SIGNAL_DISCARD("text_set"); |
| 3962 |
SIGNAL_DISCARD("text_changed"); |
| 3963 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3964 |
SIGNAL_DISCARD("caret_changed"); |
| 3965 |
lines_edited_args = { { 0, 1 }, { 0, 1 } }; |
| 3966 |
|
| 3967 |
SEND_GUI_ACTION("ui_text_newline_blank"); |
| 3968 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 3969 |
CHECK(text_edit->get_text() == "test\n\n"); |
| 3970 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 3971 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 3972 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 3973 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 3974 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 3975 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 3976 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 3977 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 3978 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 3979 |
} |
| 3980 |
|
| 3981 |
SUBCASE("[TextEdit] ui_text_newline") { |
| 3982 |
text_edit->set_text("this is some test text.\nthis is some test text."); |
| 3983 |
MessageQueue::get_singleton()->flush(); |
| 3984 |
SIGNAL_DISCARD("text_set"); |
| 3985 |
SIGNAL_DISCARD("text_changed"); |
| 3986 |
SIGNAL_DISCARD("lines_edited_from"); |
| 3987 |
SIGNAL_DISCARD("caret_changed"); |
| 3988 |
|
| 3989 |
|
| 3990 |
text_edit->select(0, 0, 0, 4); |
| 3991 |
text_edit->add_caret(1, 4); |
| 3992 |
CHECK(text_edit->get_caret_count() == 2); |
| 3993 |
MessageQueue::get_singleton()->flush(); |
| 3994 |
SIGNAL_DISCARD("caret_changed"); |
| 3995 |
|
| 3996 |
lines_edited_args = { { 0, 0 }, { 0, 1 }, { 2, 3 } }; |
| 3997 |
|
| 3998 |
SEND_GUI_ACTION("ui_text_newline"); |
| 3999 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4000 |
CHECK(text_edit->get_text() == "\n is some test text.\nthis\n is some test text."); |
| 4001 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4002 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4003 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4004 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4005 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4006 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4007 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4008 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4009 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4010 |
|
| 4011 |
|
| 4012 |
text_edit->undo(); |
| 4013 |
MessageQueue::get_singleton()->flush(); |
| 4014 |
CHECK(text_edit->get_text() == "this is some test text.\nthis is some test text."); |
| 4015 |
CHECK(text_edit->has_selection(0)); |
| 4016 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4017 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4018 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 4019 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 4020 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4021 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4022 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 4023 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4024 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4025 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4026 |
|
| 4027 |
|
| 4028 |
text_edit->redo(); |
| 4029 |
MessageQueue::get_singleton()->flush(); |
| 4030 |
CHECK(text_edit->get_text() == "\n is some test text.\nthis\n is some test text."); |
| 4031 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4032 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4033 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4034 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4035 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4036 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4037 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4038 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4039 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4040 |
|
| 4041 |
|
| 4042 |
text_edit->set_editable(false); |
| 4043 |
SEND_GUI_ACTION("ui_text_newline"); |
| 4044 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4045 |
CHECK(text_edit->get_text() == "\n is some test text.\nthis\n is some test text."); |
| 4046 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4047 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4048 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4049 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4050 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4051 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4052 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4053 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4054 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4055 |
text_edit->set_editable(true); |
| 4056 |
} |
| 4057 |
|
| 4058 |
SUBCASE("[TextEdit] ui_text_backspace_all_to_left") { |
| 4059 |
Ref<InputEvent> tmpevent = InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::ALT | KeyModifierMask::CMD_OR_CTRL); |
| 4060 |
InputMap::get_singleton()->action_add_event("ui_text_backspace_all_to_left", tmpevent); |
| 4061 |
|
| 4062 |
text_edit->set_text("\nthis is some test text.\n\nthis is some test text."); |
| 4063 |
MessageQueue::get_singleton()->flush(); |
| 4064 |
SIGNAL_DISCARD("text_set"); |
| 4065 |
SIGNAL_DISCARD("text_changed"); |
| 4066 |
SIGNAL_DISCARD("lines_edited_from"); |
| 4067 |
SIGNAL_DISCARD("caret_changed"); |
| 4068 |
|
| 4069 |
|
| 4070 |
text_edit->set_caret_line(1); |
| 4071 |
text_edit->set_caret_column(5); |
| 4072 |
text_edit->add_caret(1, 2); |
| 4073 |
text_edit->add_caret(1, 8); |
| 4074 |
lines_edited_args = { { 1, 1 } }; |
| 4075 |
MessageQueue::get_singleton()->flush(); |
| 4076 |
SIGNAL_DISCARD("caret_changed"); |
| 4077 |
|
| 4078 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4079 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4080 |
CHECK(text_edit->get_text() == "\nsome test text.\n\nthis is some test text."); |
| 4081 |
CHECK(text_edit->get_caret_count() == 1); |
| 4082 |
CHECK_FALSE(text_edit->has_selection()); |
| 4083 |
CHECK(text_edit->get_caret_line() == 1); |
| 4084 |
CHECK(text_edit->get_caret_column() == 0); |
| 4085 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4086 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4087 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4088 |
|
| 4089 |
|
| 4090 |
text_edit->undo(); |
| 4091 |
MessageQueue::get_singleton()->flush(); |
| 4092 |
CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); |
| 4093 |
CHECK(text_edit->get_caret_count() == 3); |
| 4094 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4095 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4096 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 4097 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4098 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4099 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 4100 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 4101 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 4102 |
CHECK(text_edit->get_caret_column(2) == 8); |
| 4103 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4104 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4105 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4106 |
|
| 4107 |
|
| 4108 |
text_edit->redo(); |
| 4109 |
MessageQueue::get_singleton()->flush(); |
| 4110 |
CHECK(text_edit->get_text() == "\nsome test text.\n\nthis is some test text."); |
| 4111 |
CHECK(text_edit->get_caret_count() == 1); |
| 4112 |
CHECK_FALSE(text_edit->has_selection()); |
| 4113 |
CHECK(text_edit->get_caret_line() == 1); |
| 4114 |
CHECK(text_edit->get_caret_column() == 0); |
| 4115 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4116 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4117 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4118 |
|
| 4119 |
|
| 4120 |
text_edit->select(1, 5, 1, 9, 0); |
| 4121 |
text_edit->add_caret(3, 4); |
| 4122 |
text_edit->select(3, 7, 3, 4, 1); |
| 4123 |
MessageQueue::get_singleton()->flush(); |
| 4124 |
SIGNAL_DISCARD("caret_changed"); |
| 4125 |
lines_edited_args = { { 3, 3 }, { 1, 1 } }; |
| 4126 |
|
| 4127 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4128 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4129 |
CHECK(text_edit->get_text() == "\nsome text.\n\nthis some test text."); |
| 4130 |
CHECK(text_edit->get_caret_count() == 2); |
| 4131 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4132 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4133 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 4134 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4135 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4136 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 4137 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4138 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4139 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4140 |
|
| 4141 |
|
| 4142 |
text_edit->set_caret_column(0); |
| 4143 |
text_edit->set_caret_column(0, false, 1); |
| 4144 |
MessageQueue::get_singleton()->flush(); |
| 4145 |
SIGNAL_DISCARD("caret_changed"); |
| 4146 |
lines_edited_args = { { 3, 2 }, { 1, 0 } }; |
| 4147 |
|
| 4148 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4149 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4150 |
CHECK(text_edit->get_text() == "some text.\nthis some test text."); |
| 4151 |
CHECK(text_edit->get_caret_count() == 2); |
| 4152 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4153 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4154 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4155 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4156 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4157 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4158 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4159 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4160 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4161 |
|
| 4162 |
|
| 4163 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 4164 |
text_edit->set_caret_column(text_edit->get_line(1).length(), false, 1); |
| 4165 |
MessageQueue::get_singleton()->flush(); |
| 4166 |
SIGNAL_DISCARD("caret_changed"); |
| 4167 |
|
| 4168 |
text_edit->set_editable(false); |
| 4169 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4170 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4171 |
CHECK(text_edit->get_text() == "some text.\nthis some test text."); |
| 4172 |
CHECK(text_edit->get_caret_count() == 2); |
| 4173 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4174 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4175 |
CHECK(text_edit->get_caret_column(0) == text_edit->get_line(0).length()); |
| 4176 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4177 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4178 |
CHECK(text_edit->get_caret_column(1) == text_edit->get_line(1).length()); |
| 4179 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4180 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4181 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4182 |
text_edit->set_editable(true); |
| 4183 |
|
| 4184 |
|
| 4185 |
lines_edited_args = { { 1, 1 }, { 0, 0 } }; |
| 4186 |
|
| 4187 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4188 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4189 |
CHECK(text_edit->get_text() == "\n"); |
| 4190 |
CHECK(text_edit->get_caret_count() == 2); |
| 4191 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4192 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4193 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4194 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4195 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4196 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4197 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4198 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4199 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4200 |
text_edit->remove_secondary_carets(); |
| 4201 |
|
| 4202 |
|
| 4203 |
text_edit->set_text("test\nlines"); |
| 4204 |
text_edit->set_caret_line(1); |
| 4205 |
text_edit->set_caret_column(0); |
| 4206 |
text_edit->add_caret(1, 4); |
| 4207 |
|
| 4208 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4209 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4210 |
CHECK_FALSE(text_edit->has_selection()); |
| 4211 |
CHECK(text_edit->get_text() == "tests"); |
| 4212 |
CHECK(text_edit->get_caret_count() == 1); |
| 4213 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4214 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4215 |
text_edit->remove_secondary_carets(); |
| 4216 |
|
| 4217 |
|
| 4218 |
text_edit->set_text("test\nlines"); |
| 4219 |
text_edit->set_caret_line(1); |
| 4220 |
text_edit->set_caret_column(4); |
| 4221 |
text_edit->add_caret(1, 0); |
| 4222 |
|
| 4223 |
SEND_GUI_ACTION("ui_text_backspace_all_to_left"); |
| 4224 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4225 |
CHECK_FALSE(text_edit->has_selection()); |
| 4226 |
CHECK(text_edit->get_text() == "tests"); |
| 4227 |
CHECK(text_edit->get_caret_count() == 1); |
| 4228 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4229 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4230 |
text_edit->remove_secondary_carets(); |
| 4231 |
|
| 4232 |
InputMap::get_singleton()->action_erase_event("ui_text_backspace_all_to_left", tmpevent); |
| 4233 |
} |
| 4234 |
|
| 4235 |
SUBCASE("[TextEdit] ui_text_backspace_word") { |
| 4236 |
text_edit->set_text("\nthis is some test text.\n\nthis is some test text."); |
| 4237 |
MessageQueue::get_singleton()->flush(); |
| 4238 |
SIGNAL_DISCARD("text_set"); |
| 4239 |
SIGNAL_DISCARD("text_changed"); |
| 4240 |
SIGNAL_DISCARD("lines_edited_from"); |
| 4241 |
|
| 4242 |
|
| 4243 |
text_edit->select(1, 8, 1, 15); |
| 4244 |
text_edit->add_caret(3, 6); |
| 4245 |
text_edit->select(3, 10, 3, 6, 1); |
| 4246 |
MessageQueue::get_singleton()->flush(); |
| 4247 |
SIGNAL_DISCARD("caret_changed"); |
| 4248 |
lines_edited_args = { { 3, 3 }, { 1, 1 } }; |
| 4249 |
|
| 4250 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4251 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4252 |
CHECK(text_edit->get_text() == "\nthis is st text.\n\nthis ime test text."); |
| 4253 |
CHECK(text_edit->get_caret_count() == 2); |
| 4254 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4255 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4256 |
CHECK(text_edit->get_caret_column(0) == 8); |
| 4257 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4258 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4259 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 4260 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4261 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4262 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4263 |
text_edit->end_complex_operation(); |
| 4264 |
|
| 4265 |
lines_edited_args = { { 3, 2 }, { 1, 0 } }; |
| 4266 |
|
| 4267 |
|
| 4268 |
text_edit->set_caret_column(0); |
| 4269 |
text_edit->set_caret_column(0, false, 1); |
| 4270 |
MessageQueue::get_singleton()->flush(); |
| 4271 |
SIGNAL_DISCARD("caret_changed"); |
| 4272 |
|
| 4273 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4274 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4275 |
CHECK(text_edit->get_text() == "this is st text.\nthis ime test text."); |
| 4276 |
CHECK(text_edit->get_caret_count() == 2); |
| 4277 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4278 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4279 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4280 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4281 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4282 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4283 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4284 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4285 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4286 |
|
| 4287 |
|
| 4288 |
text_edit->set_editable(false); |
| 4289 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4290 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4291 |
CHECK(text_edit->get_text() == "this is st text.\nthis ime test text."); |
| 4292 |
CHECK(text_edit->get_caret_count() == 2); |
| 4293 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4294 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4295 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4296 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4297 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4298 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4299 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4300 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4301 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4302 |
text_edit->set_editable(true); |
| 4303 |
|
| 4304 |
|
| 4305 |
text_edit->start_action(TextEdit::ACTION_NONE); |
| 4306 |
|
| 4307 |
|
| 4308 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 4309 |
text_edit->set_caret_column(12, false, 1); |
| 4310 |
MessageQueue::get_singleton()->flush(); |
| 4311 |
SIGNAL_DISCARD("caret_changed"); |
| 4312 |
lines_edited_args = { { 1, 1 }, { 0, 0 } }; |
| 4313 |
|
| 4314 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4315 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4316 |
CHECK(text_edit->get_text() == "this is st \nthis ime t text."); |
| 4317 |
CHECK(text_edit->get_caret_count() == 2); |
| 4318 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4319 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4320 |
CHECK(text_edit->get_caret_column(0) == 11); |
| 4321 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4322 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4323 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 4324 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4325 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4326 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4327 |
|
| 4328 |
|
| 4329 |
text_edit->undo(); |
| 4330 |
MessageQueue::get_singleton()->flush(); |
| 4331 |
CHECK(text_edit->get_text() == "this is st text.\nthis ime test text."); |
| 4332 |
CHECK(text_edit->get_caret_count() == 2); |
| 4333 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4334 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4335 |
CHECK(text_edit->get_caret_column(0) == 16); |
| 4336 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4337 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4338 |
CHECK(text_edit->get_caret_column(1) == 12); |
| 4339 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4340 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4341 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4342 |
|
| 4343 |
|
| 4344 |
text_edit->redo(); |
| 4345 |
MessageQueue::get_singleton()->flush(); |
| 4346 |
CHECK(text_edit->get_text() == "this is st \nthis ime t text."); |
| 4347 |
CHECK(text_edit->get_caret_count() == 2); |
| 4348 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4349 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4350 |
CHECK(text_edit->get_caret_column(0) == 11); |
| 4351 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4352 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4353 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 4354 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4355 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4356 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4357 |
|
| 4358 |
|
| 4359 |
text_edit->set_text("test\nlines"); |
| 4360 |
text_edit->set_caret_line(1); |
| 4361 |
text_edit->set_caret_column(0); |
| 4362 |
text_edit->add_caret(1, 4); |
| 4363 |
|
| 4364 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4365 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4366 |
CHECK_FALSE(text_edit->has_selection()); |
| 4367 |
CHECK(text_edit->get_text() == "tests"); |
| 4368 |
CHECK(text_edit->get_caret_count() == 1); |
| 4369 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4370 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4371 |
text_edit->remove_secondary_carets(); |
| 4372 |
|
| 4373 |
|
| 4374 |
text_edit->set_text("test\nlines"); |
| 4375 |
text_edit->set_caret_line(1); |
| 4376 |
text_edit->set_caret_column(4); |
| 4377 |
text_edit->add_caret(1, 0); |
| 4378 |
|
| 4379 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4380 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4381 |
CHECK_FALSE(text_edit->has_selection()); |
| 4382 |
CHECK(text_edit->get_text() == "tests"); |
| 4383 |
CHECK(text_edit->get_caret_count() == 1); |
| 4384 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4385 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4386 |
text_edit->remove_secondary_carets(); |
| 4387 |
|
| 4388 |
|
| 4389 |
text_edit->set_text("#{}"); |
| 4390 |
text_edit->set_caret_line(0); |
| 4391 |
text_edit->set_caret_column(3); |
| 4392 |
|
| 4393 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4394 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4395 |
CHECK_FALSE(text_edit->has_selection()); |
| 4396 |
CHECK(text_edit->get_text() == ""); |
| 4397 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4398 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4399 |
} |
| 4400 |
|
| 4401 |
SUBCASE("[TextEdit] ui_text_backspace_word same line") { |
| 4402 |
text_edit->set_text("test longwordtest test"); |
| 4403 |
MessageQueue::get_singleton()->flush(); |
| 4404 |
SIGNAL_DISCARD("text_set"); |
| 4405 |
SIGNAL_DISCARD("text_changed"); |
| 4406 |
SIGNAL_DISCARD("lines_edited_from"); |
| 4407 |
SIGNAL_DISCARD("caret_changed"); |
| 4408 |
|
| 4409 |
|
| 4410 |
text_edit->set_caret_line(0); |
| 4411 |
text_edit->set_caret_column(4); |
| 4412 |
text_edit->add_caret(0, 11); |
| 4413 |
text_edit->add_caret(0, 15); |
| 4414 |
text_edit->add_caret(0, 9); |
| 4415 |
MessageQueue::get_singleton()->flush(); |
| 4416 |
SIGNAL_DISCARD("caret_changed"); |
| 4417 |
|
| 4418 |
lines_edited_args = { { 0, 0 }, { 0, 0 } }; |
| 4419 |
|
| 4420 |
SEND_GUI_ACTION("ui_text_backspace_word"); |
| 4421 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4422 |
CHECK(text_edit->get_text() == " st test"); |
| 4423 |
CHECK(text_edit->get_caret_count() == 2); |
| 4424 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4425 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4426 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4427 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4428 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 4429 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 4430 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4431 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4432 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4433 |
|
| 4434 |
text_edit->undo(); |
| 4435 |
MessageQueue::get_singleton()->flush(); |
| 4436 |
CHECK(text_edit->get_text() == "test longwordtest test"); |
| 4437 |
CHECK(text_edit->get_caret_count() == 4); |
| 4438 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4439 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4440 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4441 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4442 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 4443 |
CHECK(text_edit->get_caret_column(1) == 11); |
| 4444 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 4445 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 4446 |
CHECK(text_edit->get_caret_column(2) == 15); |
| 4447 |
CHECK_FALSE(text_edit->has_selection(3)); |
| 4448 |
CHECK(text_edit->get_caret_line(3) == 0); |
| 4449 |
CHECK(text_edit->get_caret_column(3) == 9); |
| 4450 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4451 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4452 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4453 |
|
| 4454 |
text_edit->redo(); |
| 4455 |
MessageQueue::get_singleton()->flush(); |
| 4456 |
CHECK(text_edit->get_text() == " st test"); |
| 4457 |
CHECK(text_edit->get_caret_count() == 2); |
| 4458 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4459 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4460 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4461 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4462 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 4463 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 4464 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4465 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4466 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4467 |
} |
| 4468 |
|
| 4469 |
SUBCASE("[TextEdit] ui_text_backspace") { |
| 4470 |
text_edit->set_text("\nthis is some test text.\n\nthis is some test text."); |
| 4471 |
MessageQueue::get_singleton()->flush(); |
| 4472 |
SIGNAL_DISCARD("text_set"); |
| 4473 |
SIGNAL_DISCARD("text_changed"); |
| 4474 |
SIGNAL_DISCARD("lines_edited_from"); |
| 4475 |
|
| 4476 |
|
| 4477 |
text_edit->select(1, 0, 1, 4); |
| 4478 |
text_edit->add_caret(3, 4); |
| 4479 |
text_edit->select(3, 5, 3, 2, 1); |
| 4480 |
MessageQueue::get_singleton()->flush(); |
| 4481 |
SIGNAL_DISCARD("caret_changed"); |
| 4482 |
lines_edited_args = { { 3, 3 }, { 1, 1 } }; |
| 4483 |
|
| 4484 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4485 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4486 |
CHECK(text_edit->get_text() == "\n is some test text.\n\nthis some test text."); |
| 4487 |
CHECK(text_edit->get_caret_count() == 2); |
| 4488 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4489 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4490 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4491 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4492 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4493 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 4494 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4495 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4496 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4497 |
|
| 4498 |
|
| 4499 |
text_edit->undo(); |
| 4500 |
MessageQueue::get_singleton()->flush(); |
| 4501 |
CHECK(text_edit->get_caret_count() == 2); |
| 4502 |
CHECK(text_edit->get_text() == "\nthis is some test text.\n\nthis is some test text."); |
| 4503 |
CHECK(text_edit->get_caret_count() == 2); |
| 4504 |
CHECK(text_edit->has_selection(0)); |
| 4505 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4506 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 4507 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 4508 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 4509 |
CHECK(text_edit->has_selection(1)); |
| 4510 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4511 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 4512 |
CHECK(text_edit->get_selection_origin_line(1) == 3); |
| 4513 |
CHECK(text_edit->get_selection_origin_column(1) == 5); |
| 4514 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4515 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4516 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4517 |
|
| 4518 |
|
| 4519 |
text_edit->redo(); |
| 4520 |
MessageQueue::get_singleton()->flush(); |
| 4521 |
CHECK(text_edit->get_text() == "\n is some test text.\n\nthis some test text."); |
| 4522 |
CHECK(text_edit->get_caret_count() == 2); |
| 4523 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4524 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4525 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4526 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4527 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4528 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 4529 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4530 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4531 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4532 |
|
| 4533 |
|
| 4534 |
text_edit->set_caret_column(0, false, 1); |
| 4535 |
MessageQueue::get_singleton()->flush(); |
| 4536 |
SIGNAL_DISCARD("caret_changed"); |
| 4537 |
lines_edited_args = { { 3, 2 }, { 1, 0 } }; |
| 4538 |
|
| 4539 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4540 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4541 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 4542 |
CHECK(text_edit->get_caret_count() == 2); |
| 4543 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4544 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4545 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4546 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4547 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4548 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4549 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4550 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4551 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4552 |
|
| 4553 |
|
| 4554 |
text_edit->undo(); |
| 4555 |
MessageQueue::get_singleton()->flush(); |
| 4556 |
CHECK(text_edit->get_text() == "\n is some test text.\n\nthis some test text."); |
| 4557 |
CHECK(text_edit->get_caret_count() == 2); |
| 4558 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4559 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 4560 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4561 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4562 |
CHECK(text_edit->get_caret_line(1) == 3); |
| 4563 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4564 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4565 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4566 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4567 |
|
| 4568 |
|
| 4569 |
text_edit->redo(); |
| 4570 |
MessageQueue::get_singleton()->flush(); |
| 4571 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 4572 |
CHECK(text_edit->get_caret_count() == 2); |
| 4573 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4574 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4575 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4576 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4577 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4578 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4579 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4580 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4581 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4582 |
|
| 4583 |
|
| 4584 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 4585 |
text_edit->set_caret_column(15, false, 1); |
| 4586 |
MessageQueue::get_singleton()->flush(); |
| 4587 |
SIGNAL_DISCARD("caret_changed"); |
| 4588 |
|
| 4589 |
text_edit->set_editable(false); |
| 4590 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4591 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4592 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 4593 |
CHECK(text_edit->get_caret_count() == 2); |
| 4594 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4595 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4596 |
CHECK(text_edit->get_caret_column(0) == text_edit->get_line(0).length()); |
| 4597 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4598 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4599 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 4600 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4601 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4602 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4603 |
text_edit->set_editable(true); |
| 4604 |
|
| 4605 |
|
| 4606 |
text_edit->start_action(TextEdit::ACTION_NONE); |
| 4607 |
|
| 4608 |
|
| 4609 |
lines_edited_args = { { 1, 1 }, { 0, 0 } }; |
| 4610 |
|
| 4611 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4612 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4613 |
CHECK(text_edit->get_text() == " is some test text\nthis some testtext."); |
| 4614 |
CHECK(text_edit->get_caret_count() == 2); |
| 4615 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4616 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4617 |
CHECK(text_edit->get_caret_column(0) == 18); |
| 4618 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4619 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4620 |
CHECK(text_edit->get_caret_column(1) == 14); |
| 4621 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4622 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4623 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4624 |
|
| 4625 |
|
| 4626 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4627 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4628 |
CHECK(text_edit->get_text() == " is some test tex\nthis some testext."); |
| 4629 |
CHECK(text_edit->get_caret_count() == 2); |
| 4630 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4631 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4632 |
CHECK(text_edit->get_caret_column(0) == 17); |
| 4633 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4634 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4635 |
CHECK(text_edit->get_caret_column(1) == 13); |
| 4636 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4637 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4638 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4639 |
|
| 4640 |
|
| 4641 |
lines_edited_args = { { 1, 1 }, { 0, 0 }, { 1, 1 }, { 0, 0 } }; |
| 4642 |
|
| 4643 |
text_edit->undo(); |
| 4644 |
MessageQueue::get_singleton()->flush(); |
| 4645 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 4646 |
CHECK(text_edit->get_caret_count() == 2); |
| 4647 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4648 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4649 |
CHECK(text_edit->get_caret_column(0) == 19); |
| 4650 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4651 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4652 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 4653 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4654 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4655 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4656 |
|
| 4657 |
|
| 4658 |
text_edit->redo(); |
| 4659 |
MessageQueue::get_singleton()->flush(); |
| 4660 |
CHECK(text_edit->get_text() == " is some test tex\nthis some testext."); |
| 4661 |
CHECK(text_edit->get_caret_count() == 2); |
| 4662 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4663 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4664 |
CHECK(text_edit->get_caret_column(0) == 17); |
| 4665 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4666 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4667 |
CHECK(text_edit->get_caret_column(1) == 13); |
| 4668 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4669 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4670 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4671 |
|
| 4672 |
|
| 4673 |
text_edit->remove_secondary_carets(); |
| 4674 |
text_edit->set_caret_line(0); |
| 4675 |
text_edit->set_caret_column(8); |
| 4676 |
text_edit->add_caret(0, 7); |
| 4677 |
text_edit->add_caret(0, 9); |
| 4678 |
MessageQueue::get_singleton()->flush(); |
| 4679 |
SIGNAL_DISCARD("caret_changed"); |
| 4680 |
lines_edited_args = { { 0, 0 }, { 0, 0 }, { 0, 0 } }; |
| 4681 |
|
| 4682 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4683 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4684 |
CHECK(text_edit->get_text() == " is sotest tex\nthis some testext."); |
| 4685 |
CHECK(text_edit->get_caret_count() == 1); |
| 4686 |
CHECK_FALSE(text_edit->has_selection()); |
| 4687 |
CHECK(text_edit->get_caret_line() == 0); |
| 4688 |
CHECK(text_edit->get_caret_column() == 6); |
| 4689 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4690 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4691 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4692 |
|
| 4693 |
|
| 4694 |
text_edit->select(0, text_edit->get_line(0).length(), 0, 0); |
| 4695 |
text_edit->add_caret(1, 0); |
| 4696 |
text_edit->select(1, text_edit->get_line(1).length(), 1, 0, 1); |
| 4697 |
MessageQueue::get_singleton()->flush(); |
| 4698 |
SIGNAL_DISCARD("caret_changed"); |
| 4699 |
lines_edited_args = { { 1, 1 }, { 0, 0 } }; |
| 4700 |
|
| 4701 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4702 |
CHECK(text_edit->get_text() == "\n"); |
| 4703 |
CHECK(text_edit->get_caret_count() == 2); |
| 4704 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4705 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4706 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4707 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4708 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4709 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4710 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4711 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4712 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4713 |
|
| 4714 |
|
| 4715 |
text_edit->remove_secondary_carets(); |
| 4716 |
text_edit->deselect(); |
| 4717 |
text_edit->set_caret_line(0); |
| 4718 |
text_edit->set_caret_column(0); |
| 4719 |
MessageQueue::get_singleton()->flush(); |
| 4720 |
SIGNAL_DISCARD("caret_changed"); |
| 4721 |
|
| 4722 |
SEND_GUI_ACTION("ui_text_backspace"); |
| 4723 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4724 |
CHECK(text_edit->get_text() == "\n"); |
| 4725 |
CHECK(text_edit->get_caret_count() == 1); |
| 4726 |
CHECK_FALSE(text_edit->has_selection()); |
| 4727 |
CHECK(text_edit->get_caret_line() == 0); |
| 4728 |
CHECK(text_edit->get_caret_column() == 0); |
| 4729 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4730 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4731 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4732 |
} |
| 4733 |
|
| 4734 |
SUBCASE("[TextEdit] ui_text_delete_all_to_right") { |
| 4735 |
Ref<InputEvent> tmpevent = InputEventKey::create_reference(Key::BACKSPACE | KeyModifierMask::ALT | KeyModifierMask::CMD_OR_CTRL); |
| 4736 |
InputMap::get_singleton()->action_add_event("ui_text_delete_all_to_right", tmpevent); |
| 4737 |
|
| 4738 |
text_edit->set_text("this is some test text.\nthis is some test text.\n"); |
| 4739 |
MessageQueue::get_singleton()->flush(); |
| 4740 |
SIGNAL_DISCARD("text_set"); |
| 4741 |
SIGNAL_DISCARD("text_changed"); |
| 4742 |
SIGNAL_DISCARD("lines_edited_from"); |
| 4743 |
|
| 4744 |
|
| 4745 |
text_edit->set_caret_line(0); |
| 4746 |
text_edit->set_caret_column(18); |
| 4747 |
text_edit->add_caret(0, 16); |
| 4748 |
text_edit->add_caret(0, 20); |
| 4749 |
MessageQueue::get_singleton()->flush(); |
| 4750 |
SIGNAL_DISCARD("caret_changed"); |
| 4751 |
lines_edited_args = { { 0, 0 } }; |
| 4752 |
|
| 4753 |
SEND_GUI_ACTION("ui_text_delete_all_to_right"); |
| 4754 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4755 |
CHECK(text_edit->get_text() == "this is some tes\nthis is some test text.\n"); |
| 4756 |
CHECK(text_edit->get_caret_count() == 1); |
| 4757 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4758 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4759 |
CHECK(text_edit->get_caret_column(0) == 16); |
| 4760 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4761 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4762 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4763 |
|
| 4764 |
|
| 4765 |
lines_edited_args = { { 0, 0 } }; |
| 4766 |
|
| 4767 |
text_edit->undo(); |
| 4768 |
MessageQueue::get_singleton()->flush(); |
| 4769 |
CHECK(text_edit->get_text() == "this is some test text.\nthis is some test text.\n"); |
| 4770 |
CHECK(text_edit->get_caret_count() == 3); |
| 4771 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4772 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4773 |
CHECK(text_edit->get_caret_column(0) == 18); |
| 4774 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4775 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 4776 |
CHECK(text_edit->get_caret_column(1) == 16); |
| 4777 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 4778 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 4779 |
CHECK(text_edit->get_caret_column(2) == 20); |
| 4780 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4781 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4782 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4783 |
|
| 4784 |
|
| 4785 |
text_edit->redo(); |
| 4786 |
MessageQueue::get_singleton()->flush(); |
| 4787 |
CHECK(text_edit->get_text() == "this is some tes\nthis is some test text.\n"); |
| 4788 |
CHECK(text_edit->get_caret_count() == 1); |
| 4789 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4790 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4791 |
CHECK(text_edit->get_caret_column(0) == 16); |
| 4792 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4793 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4794 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4795 |
|
| 4796 |
|
| 4797 |
text_edit->select(0, 0, 0, 4); |
| 4798 |
text_edit->add_caret(1, 4); |
| 4799 |
text_edit->select(1, 8, 1, 4, 1); |
| 4800 |
MessageQueue::get_singleton()->flush(); |
| 4801 |
SIGNAL_DISCARD("caret_changed"); |
| 4802 |
lines_edited_args = { { 0, 0 }, { 1, 1 } }; |
| 4803 |
|
| 4804 |
SEND_GUI_ACTION("ui_text_delete_all_to_right"); |
| 4805 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4806 |
CHECK(text_edit->get_text() == " is some tes\nthissome test text.\n"); |
| 4807 |
CHECK(text_edit->get_caret_count() == 2); |
| 4808 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4809 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4810 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4811 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4812 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4813 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 4814 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4815 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4816 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4817 |
|
| 4818 |
|
| 4819 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 4820 |
text_edit->set_caret_column(text_edit->get_line(1).length(), false, 1); |
| 4821 |
MessageQueue::get_singleton()->flush(); |
| 4822 |
SIGNAL_DISCARD("caret_changed"); |
| 4823 |
|
| 4824 |
SEND_GUI_ACTION("ui_text_delete_all_to_right"); |
| 4825 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4826 |
CHECK(text_edit->get_text() == " is some tes\nthissome test text.\n"); |
| 4827 |
CHECK(text_edit->get_caret_count() == 2); |
| 4828 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4829 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4830 |
CHECK(text_edit->get_caret_column(0) == text_edit->get_line(0).length()); |
| 4831 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4832 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4833 |
CHECK(text_edit->get_caret_column(1) == text_edit->get_line(1).length()); |
| 4834 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4835 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4836 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4837 |
|
| 4838 |
|
| 4839 |
text_edit->set_caret_column(0); |
| 4840 |
text_edit->set_caret_column(0, false, 1); |
| 4841 |
MessageQueue::get_singleton()->flush(); |
| 4842 |
SIGNAL_DISCARD("caret_changed"); |
| 4843 |
|
| 4844 |
text_edit->set_editable(false); |
| 4845 |
SEND_GUI_ACTION("ui_text_delete_all_to_right"); |
| 4846 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4847 |
CHECK(text_edit->get_text() == " is some tes\nthissome test text.\n"); |
| 4848 |
CHECK(text_edit->get_caret_count() == 2); |
| 4849 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4850 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4851 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4852 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4853 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4854 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4855 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4856 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4857 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4858 |
text_edit->set_editable(true); |
| 4859 |
|
| 4860 |
|
| 4861 |
SEND_GUI_ACTION("ui_text_delete_all_to_right"); |
| 4862 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4863 |
CHECK(text_edit->get_text() == "\n\n"); |
| 4864 |
CHECK(text_edit->get_caret_count() == 2); |
| 4865 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4866 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4867 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4868 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4869 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4870 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 4871 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4872 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4873 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4874 |
|
| 4875 |
InputMap::get_singleton()->action_erase_event("ui_text_delete_all_to_right", tmpevent); |
| 4876 |
} |
| 4877 |
|
| 4878 |
SUBCASE("[TextEdit] ui_text_delete_word") { |
| 4879 |
text_edit->set_caret_mid_grapheme_enabled(true); |
| 4880 |
CHECK(text_edit->is_caret_mid_grapheme_enabled()); |
| 4881 |
|
| 4882 |
text_edit->set_text("this is some test text.\n\nthis is some test text.\n"); |
| 4883 |
MessageQueue::get_singleton()->flush(); |
| 4884 |
SIGNAL_DISCARD("text_set"); |
| 4885 |
SIGNAL_DISCARD("text_changed"); |
| 4886 |
SIGNAL_DISCARD("lines_edited_from"); |
| 4887 |
SIGNAL_DISCARD("caret_changed"); |
| 4888 |
|
| 4889 |
|
| 4890 |
text_edit->select(0, 8, 0, 15); |
| 4891 |
text_edit->add_caret(2, 6); |
| 4892 |
text_edit->select(2, 10, 2, 6, 1); |
| 4893 |
MessageQueue::get_singleton()->flush(); |
| 4894 |
SIGNAL_DISCARD("caret_changed"); |
| 4895 |
lines_edited_args = { { 0, 0 }, { 2, 2 } }; |
| 4896 |
|
| 4897 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 4898 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4899 |
CHECK(text_edit->get_text() == "this is st text.\n\nthis ime test text.\n"); |
| 4900 |
CHECK(text_edit->get_caret_count() == 2); |
| 4901 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4902 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4903 |
CHECK(text_edit->get_caret_column(0) == 8); |
| 4904 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4905 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 4906 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 4907 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4908 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4909 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4910 |
|
| 4911 |
|
| 4912 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 4913 |
text_edit->set_caret_column(text_edit->get_line(2).length(), false, 1); |
| 4914 |
MessageQueue::get_singleton()->flush(); |
| 4915 |
SIGNAL_DISCARD("caret_changed"); |
| 4916 |
lines_edited_args = { { 1, 0 }, { 2, 1 } }; |
| 4917 |
|
| 4918 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 4919 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4920 |
CHECK(text_edit->get_text() == "this is st text.\nthis ime test text."); |
| 4921 |
CHECK(text_edit->get_caret_count() == 2); |
| 4922 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4923 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4924 |
CHECK(text_edit->get_caret_column(0) == text_edit->get_line(0).length()); |
| 4925 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4926 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4927 |
CHECK(text_edit->get_caret_column(1) == text_edit->get_line(1).length()); |
| 4928 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 4929 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4930 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4931 |
|
| 4932 |
|
| 4933 |
text_edit->set_caret_column(0); |
| 4934 |
text_edit->set_caret_column(10, false, 1); |
| 4935 |
MessageQueue::get_singleton()->flush(); |
| 4936 |
SIGNAL_DISCARD("caret_changed"); |
| 4937 |
|
| 4938 |
text_edit->set_editable(false); |
| 4939 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 4940 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4941 |
CHECK(text_edit->get_text() == "this is st text.\nthis ime test text."); |
| 4942 |
CHECK(text_edit->get_caret_count() == 2); |
| 4943 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4944 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4945 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4946 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4947 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4948 |
CHECK(text_edit->get_caret_column(1) == 10); |
| 4949 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4950 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 4951 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 4952 |
text_edit->set_editable(true); |
| 4953 |
|
| 4954 |
|
| 4955 |
text_edit->start_action(TextEdit::ACTION_NONE); |
| 4956 |
|
| 4957 |
|
| 4958 |
lines_edited_args = { { 0, 0 }, { 1, 1 } }; |
| 4959 |
|
| 4960 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 4961 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 4962 |
CHECK(text_edit->get_text() == " is st text.\nthis ime t text."); |
| 4963 |
CHECK(text_edit->get_caret_count() == 2); |
| 4964 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4965 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4966 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4967 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4968 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4969 |
CHECK(text_edit->get_caret_column(1) == 10); |
| 4970 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4971 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4972 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 4973 |
|
| 4974 |
|
| 4975 |
text_edit->undo(); |
| 4976 |
MessageQueue::get_singleton()->flush(); |
| 4977 |
CHECK(text_edit->get_text() == "this is st text.\nthis ime test text."); |
| 4978 |
CHECK(text_edit->get_caret_count() == 2); |
| 4979 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4980 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4981 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4982 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4983 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4984 |
CHECK(text_edit->get_caret_column(1) == 10); |
| 4985 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 4986 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 4987 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 4988 |
|
| 4989 |
|
| 4990 |
text_edit->redo(); |
| 4991 |
MessageQueue::get_singleton()->flush(); |
| 4992 |
CHECK(text_edit->get_text() == " is st text.\nthis ime t text."); |
| 4993 |
CHECK(text_edit->get_caret_count() == 2); |
| 4994 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 4995 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 4996 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 4997 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 4998 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 4999 |
CHECK(text_edit->get_caret_column(1) == 10); |
| 5000 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5001 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5002 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5003 |
|
| 5004 |
|
| 5005 |
text_edit->remove_secondary_carets(); |
| 5006 |
text_edit->set_text("onelongword test"); |
| 5007 |
text_edit->set_caret_line(0); |
| 5008 |
text_edit->set_caret_column(6); |
| 5009 |
text_edit->add_caret(0, 9); |
| 5010 |
text_edit->add_caret(0, 3); |
| 5011 |
lines_edited_args = { { 0, 0 } }; |
| 5012 |
MessageQueue::get_singleton()->flush(); |
| 5013 |
SIGNAL_DISCARD("text_set"); |
| 5014 |
SIGNAL_DISCARD("text_changed"); |
| 5015 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5016 |
SIGNAL_DISCARD("caret_changed"); |
| 5017 |
|
| 5018 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 5019 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5020 |
CHECK(text_edit->get_text() == "one test"); |
| 5021 |
CHECK(text_edit->get_caret_count() == 1); |
| 5022 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5023 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5024 |
CHECK(text_edit->get_caret_column(0) == 3); |
| 5025 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5026 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5027 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5028 |
|
| 5029 |
|
| 5030 |
text_edit->set_text("test\nlines"); |
| 5031 |
text_edit->set_caret_line(0); |
| 5032 |
text_edit->set_caret_column(2); |
| 5033 |
text_edit->add_caret(0, 4); |
| 5034 |
|
| 5035 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 5036 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5037 |
CHECK_FALSE(text_edit->has_selection()); |
| 5038 |
CHECK(text_edit->get_text() == "telines"); |
| 5039 |
CHECK(text_edit->get_caret_count() == 1); |
| 5040 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5041 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 5042 |
text_edit->remove_secondary_carets(); |
| 5043 |
|
| 5044 |
|
| 5045 |
text_edit->set_text("test\nlines"); |
| 5046 |
text_edit->set_caret_line(0); |
| 5047 |
text_edit->set_caret_column(4); |
| 5048 |
text_edit->add_caret(0, 2); |
| 5049 |
|
| 5050 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 5051 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5052 |
CHECK_FALSE(text_edit->has_selection()); |
| 5053 |
CHECK(text_edit->get_text() == "telines"); |
| 5054 |
CHECK(text_edit->get_caret_count() == 1); |
| 5055 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5056 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 5057 |
text_edit->remove_secondary_carets(); |
| 5058 |
|
| 5059 |
|
| 5060 |
text_edit->set_text("#{}"); |
| 5061 |
text_edit->set_caret_line(0); |
| 5062 |
text_edit->set_caret_column(0); |
| 5063 |
|
| 5064 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 5065 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5066 |
CHECK_FALSE(text_edit->has_selection()); |
| 5067 |
CHECK(text_edit->get_text() == ""); |
| 5068 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5069 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5070 |
} |
| 5071 |
|
| 5072 |
SUBCASE("[TextEdit] ui_text_delete_word same line") { |
| 5073 |
text_edit->set_text("test longwordtest test"); |
| 5074 |
MessageQueue::get_singleton()->flush(); |
| 5075 |
SIGNAL_DISCARD("text_set"); |
| 5076 |
SIGNAL_DISCARD("text_changed"); |
| 5077 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5078 |
SIGNAL_DISCARD("caret_changed"); |
| 5079 |
|
| 5080 |
|
| 5081 |
text_edit->set_caret_line(0); |
| 5082 |
text_edit->set_caret_column(0); |
| 5083 |
text_edit->add_caret(0, 11); |
| 5084 |
text_edit->add_caret(0, 15); |
| 5085 |
text_edit->add_caret(0, 9); |
| 5086 |
MessageQueue::get_singleton()->flush(); |
| 5087 |
SIGNAL_DISCARD("caret_changed"); |
| 5088 |
|
| 5089 |
lines_edited_args = { { 0, 0 }, { 0, 0 } }; |
| 5090 |
|
| 5091 |
SEND_GUI_ACTION("ui_text_delete_word"); |
| 5092 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5093 |
CHECK(text_edit->get_text() == " long test"); |
| 5094 |
CHECK(text_edit->get_caret_count() == 2); |
| 5095 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5096 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5097 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5098 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5099 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 5100 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 5101 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5102 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5103 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5104 |
|
| 5105 |
lines_edited_args = { { 0, 0 }, { 0, 0 } }; |
| 5106 |
|
| 5107 |
text_edit->undo(); |
| 5108 |
MessageQueue::get_singleton()->flush(); |
| 5109 |
CHECK(text_edit->get_text() == "test longwordtest test"); |
| 5110 |
CHECK(text_edit->get_caret_count() == 4); |
| 5111 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5112 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5113 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5114 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5115 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 5116 |
CHECK(text_edit->get_caret_column(1) == 11); |
| 5117 |
CHECK_FALSE(text_edit->has_selection(2)); |
| 5118 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 5119 |
CHECK(text_edit->get_caret_column(2) == 15); |
| 5120 |
CHECK_FALSE(text_edit->has_selection(3)); |
| 5121 |
CHECK(text_edit->get_caret_line(3) == 0); |
| 5122 |
CHECK(text_edit->get_caret_column(3) == 9); |
| 5123 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5124 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5125 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 5126 |
|
| 5127 |
text_edit->redo(); |
| 5128 |
MessageQueue::get_singleton()->flush(); |
| 5129 |
CHECK(text_edit->get_text() == " long test"); |
| 5130 |
CHECK(text_edit->get_caret_count() == 2); |
| 5131 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5132 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5133 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5134 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5135 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 5136 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 5137 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5138 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5139 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5140 |
} |
| 5141 |
|
| 5142 |
SUBCASE("[TextEdit] ui_text_delete") { |
| 5143 |
text_edit->set_caret_mid_grapheme_enabled(true); |
| 5144 |
CHECK(text_edit->is_caret_mid_grapheme_enabled()); |
| 5145 |
|
| 5146 |
text_edit->set_text("this is some test text.\n\nthis is some test text.\n"); |
| 5147 |
MessageQueue::get_singleton()->flush(); |
| 5148 |
SIGNAL_DISCARD("text_set"); |
| 5149 |
SIGNAL_DISCARD("text_changed"); |
| 5150 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5151 |
SIGNAL_DISCARD("caret_changed"); |
| 5152 |
|
| 5153 |
|
| 5154 |
text_edit->select(0, 0, 0, 4); |
| 5155 |
text_edit->add_caret(2, 2); |
| 5156 |
text_edit->select(2, 5, 2, 2, 1); |
| 5157 |
MessageQueue::get_singleton()->flush(); |
| 5158 |
SIGNAL_DISCARD("caret_changed"); |
| 5159 |
lines_edited_args = { { 0, 0 }, { 2, 2 } }; |
| 5160 |
|
| 5161 |
SEND_GUI_ACTION("ui_text_delete"); |
| 5162 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5163 |
CHECK(text_edit->get_text() == " is some test text.\n\nthis some test text.\n"); |
| 5164 |
CHECK(text_edit->get_caret_count() == 2); |
| 5165 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5166 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5167 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5168 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5169 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5170 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 5171 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5172 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5173 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5174 |
|
| 5175 |
|
| 5176 |
text_edit->undo(); |
| 5177 |
MessageQueue::get_singleton()->flush(); |
| 5178 |
CHECK(text_edit->get_caret_count() == 2); |
| 5179 |
CHECK(text_edit->get_text() == "this is some test text.\n\nthis is some test text.\n"); |
| 5180 |
CHECK(text_edit->get_caret_count() == 2); |
| 5181 |
CHECK(text_edit->has_selection(0)); |
| 5182 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5183 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 5184 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5185 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 5186 |
CHECK(text_edit->has_selection(1)); |
| 5187 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5188 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 5189 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5190 |
CHECK(text_edit->get_selection_origin_column(1) == 5); |
| 5191 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5192 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5193 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 5194 |
|
| 5195 |
|
| 5196 |
text_edit->redo(); |
| 5197 |
MessageQueue::get_singleton()->flush(); |
| 5198 |
CHECK(text_edit->get_text() == " is some test text.\n\nthis some test text.\n"); |
| 5199 |
CHECK(text_edit->get_caret_count() == 2); |
| 5200 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5201 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5202 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5203 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5204 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5205 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 5206 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5207 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5208 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5209 |
|
| 5210 |
|
| 5211 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 5212 |
text_edit->set_caret_column(text_edit->get_line(2).length(), false, 1); |
| 5213 |
MessageQueue::get_singleton()->flush(); |
| 5214 |
SIGNAL_DISCARD("caret_changed"); |
| 5215 |
lines_edited_args = { { 1, 0 }, { 2, 1 } }; |
| 5216 |
|
| 5217 |
SEND_GUI_ACTION("ui_text_delete"); |
| 5218 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5219 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 5220 |
CHECK(text_edit->get_caret_count() == 2); |
| 5221 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5222 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5223 |
CHECK(text_edit->get_caret_column(0) == 19); |
| 5224 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5225 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5226 |
CHECK(text_edit->get_caret_column(1) == 20); |
| 5227 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5228 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5229 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5230 |
|
| 5231 |
|
| 5232 |
text_edit->undo(); |
| 5233 |
MessageQueue::get_singleton()->flush(); |
| 5234 |
CHECK(text_edit->get_text() == " is some test text.\n\nthis some test text.\n"); |
| 5235 |
CHECK(text_edit->get_caret_count() == 2); |
| 5236 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5237 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5238 |
CHECK(text_edit->get_caret_column(0) == 19); |
| 5239 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5240 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5241 |
CHECK(text_edit->get_caret_column(1) == 20); |
| 5242 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5243 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5244 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 5245 |
|
| 5246 |
|
| 5247 |
text_edit->redo(); |
| 5248 |
MessageQueue::get_singleton()->flush(); |
| 5249 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 5250 |
CHECK(text_edit->get_caret_count() == 2); |
| 5251 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5252 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5253 |
CHECK(text_edit->get_caret_column(0) == 19); |
| 5254 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5255 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5256 |
CHECK(text_edit->get_caret_column(1) == 20); |
| 5257 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5258 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5259 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5260 |
|
| 5261 |
|
| 5262 |
text_edit->set_caret_column(0); |
| 5263 |
text_edit->set_caret_column(15, false, 1); |
| 5264 |
MessageQueue::get_singleton()->flush(); |
| 5265 |
SIGNAL_DISCARD("caret_changed"); |
| 5266 |
|
| 5267 |
text_edit->set_editable(false); |
| 5268 |
SEND_GUI_ACTION("ui_text_delete"); |
| 5269 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5270 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 5271 |
CHECK(text_edit->get_caret_count() == 2); |
| 5272 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5273 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5274 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5275 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5276 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5277 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 5278 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5279 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5280 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5281 |
text_edit->set_editable(true); |
| 5282 |
|
| 5283 |
|
| 5284 |
text_edit->start_action(TextEdit::EditAction::ACTION_NONE); |
| 5285 |
|
| 5286 |
|
| 5287 |
lines_edited_args = { { 0, 0 }, { 1, 1 } }; |
| 5288 |
|
| 5289 |
SEND_GUI_ACTION("ui_text_delete"); |
| 5290 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5291 |
CHECK(text_edit->get_text() == "is some test text.\nthis some test ext."); |
| 5292 |
CHECK(text_edit->get_caret_count() == 2); |
| 5293 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5294 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5295 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5296 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5297 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5298 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 5299 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5300 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5301 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5302 |
|
| 5303 |
|
| 5304 |
SEND_GUI_ACTION("ui_text_delete"); |
| 5305 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5306 |
CHECK(text_edit->get_text() == "s some test text.\nthis some test xt."); |
| 5307 |
CHECK(text_edit->get_caret_count() == 2); |
| 5308 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5309 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5310 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5311 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5312 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5313 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 5314 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5315 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5316 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5317 |
|
| 5318 |
|
| 5319 |
lines_edited_args = { { 0, 0 }, { 1, 1 }, { 0, 0 }, { 1, 1 } }; |
| 5320 |
|
| 5321 |
text_edit->undo(); |
| 5322 |
MessageQueue::get_singleton()->flush(); |
| 5323 |
CHECK(text_edit->get_text() == " is some test text.\nthis some test text."); |
| 5324 |
CHECK(text_edit->get_caret_count() == 2); |
| 5325 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5326 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5327 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5328 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5329 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5330 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 5331 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5332 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5333 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 5334 |
|
| 5335 |
|
| 5336 |
text_edit->redo(); |
| 5337 |
MessageQueue::get_singleton()->flush(); |
| 5338 |
CHECK(text_edit->get_text() == "s some test text.\nthis some test xt."); |
| 5339 |
CHECK(text_edit->get_caret_count() == 2); |
| 5340 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5341 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5342 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5343 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5344 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5345 |
CHECK(text_edit->get_caret_column(1) == 15); |
| 5346 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5347 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 5348 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 5349 |
|
| 5350 |
|
| 5351 |
text_edit->remove_secondary_carets(); |
| 5352 |
text_edit->set_caret_line(1); |
| 5353 |
text_edit->set_caret_column(18); |
| 5354 |
MessageQueue::get_singleton()->flush(); |
| 5355 |
SIGNAL_DISCARD("caret_changed"); |
| 5356 |
|
| 5357 |
SEND_GUI_ACTION("ui_text_delete"); |
| 5358 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5359 |
CHECK(text_edit->get_text() == "s some test text.\nthis some test xt."); |
| 5360 |
CHECK(text_edit->get_caret_count() == 1); |
| 5361 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5362 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5363 |
CHECK(text_edit->get_caret_column(0) == 18); |
| 5364 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 5365 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5366 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5367 |
} |
| 5368 |
|
| 5369 |
SUBCASE("[TextEdit] ui_text_caret_word_left") { |
| 5370 |
text_edit->set_text("\nthis is some test text.\nthis is some test text."); |
| 5371 |
text_edit->set_caret_line(1); |
| 5372 |
text_edit->set_caret_column(15); |
| 5373 |
text_edit->add_caret(2, 10); |
| 5374 |
text_edit->select(1, 10, 1, 15); |
| 5375 |
text_edit->select(2, 15, 2, 10, 1); |
| 5376 |
MessageQueue::get_singleton()->flush(); |
| 5377 |
SIGNAL_DISCARD("text_set"); |
| 5378 |
SIGNAL_DISCARD("text_changed"); |
| 5379 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5380 |
SIGNAL_DISCARD("caret_changed"); |
| 5381 |
|
| 5382 |
|
| 5383 |
|
| 5384 |
#ifdef MACOS_ENABLED |
| 5385 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); |
| 5386 |
#else |
| 5387 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 5388 |
#endif |
| 5389 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5390 |
CHECK(text_edit->get_caret_count() == 2); |
| 5391 |
|
| 5392 |
CHECK(text_edit->has_selection(0)); |
| 5393 |
CHECK(text_edit->get_selected_text(0) == "me "); |
| 5394 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5395 |
CHECK(text_edit->get_caret_column(0) == 13); |
| 5396 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 5397 |
CHECK(text_edit->get_selection_origin_column(0) == 10); |
| 5398 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5399 |
|
| 5400 |
CHECK(text_edit->has_selection(1)); |
| 5401 |
CHECK(text_edit->get_selected_text(1) == "some te"); |
| 5402 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5403 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 5404 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5405 |
CHECK(text_edit->get_selection_origin_column(1) == 15); |
| 5406 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(1)); |
| 5407 |
|
| 5408 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5409 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5410 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5411 |
|
| 5412 |
|
| 5413 |
text_edit->deselect(); |
| 5414 |
text_edit->set_caret_column(7); |
| 5415 |
text_edit->set_caret_column(16, false, 1); |
| 5416 |
MessageQueue::get_singleton()->flush(); |
| 5417 |
SIGNAL_DISCARD("caret_changed"); |
| 5418 |
|
| 5419 |
#ifdef MACOS_ENABLED |
| 5420 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); |
| 5421 |
#else |
| 5422 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 5423 |
#endif |
| 5424 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5425 |
CHECK(text_edit->get_caret_count() == 2); |
| 5426 |
|
| 5427 |
CHECK(text_edit->has_selection(0)); |
| 5428 |
CHECK(text_edit->get_selected_text(0) == "is"); |
| 5429 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5430 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 5431 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 5432 |
CHECK(text_edit->get_selection_origin_column(0) == 7); |
| 5433 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(0)); |
| 5434 |
|
| 5435 |
CHECK(text_edit->has_selection(1)); |
| 5436 |
CHECK(text_edit->get_selected_text(1) == "tes"); |
| 5437 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5438 |
CHECK(text_edit->get_caret_column(1) == 13); |
| 5439 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5440 |
CHECK(text_edit->get_selection_origin_column(1) == 16); |
| 5441 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(1)); |
| 5442 |
|
| 5443 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5444 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5445 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5446 |
|
| 5447 |
|
| 5448 |
SEND_GUI_ACTION("ui_text_caret_word_left"); |
| 5449 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5450 |
CHECK(text_edit->get_caret_count() == 2); |
| 5451 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5452 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5453 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5454 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5455 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5456 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 5457 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5458 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5459 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5460 |
|
| 5461 |
|
| 5462 |
text_edit->set_caret_line(0); |
| 5463 |
text_edit->set_caret_column(0); |
| 5464 |
text_edit->set_caret_column(0, false, 1); |
| 5465 |
MessageQueue::get_singleton()->flush(); |
| 5466 |
SIGNAL_DISCARD("caret_changed"); |
| 5467 |
|
| 5468 |
SEND_GUI_ACTION("ui_text_caret_word_left"); |
| 5469 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5470 |
CHECK(text_edit->get_caret_count() == 2); |
| 5471 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5472 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5473 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5474 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5475 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5476 |
CHECK(text_edit->get_caret_column(1) == 23); |
| 5477 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5478 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5479 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5480 |
|
| 5481 |
|
| 5482 |
text_edit->set_text("#{}"); |
| 5483 |
text_edit->set_caret_line(0); |
| 5484 |
text_edit->set_caret_column(3); |
| 5485 |
|
| 5486 |
SEND_GUI_ACTION("ui_text_caret_word_left"); |
| 5487 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5488 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5489 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5490 |
} |
| 5491 |
|
| 5492 |
SUBCASE("[TextEdit] ui_text_caret_left") { |
| 5493 |
text_edit->set_text("\nthis is some test text.\nthis is some test text."); |
| 5494 |
text_edit->set_caret_line(1); |
| 5495 |
text_edit->set_caret_column(7); |
| 5496 |
text_edit->select(1, 3, 1, 7); |
| 5497 |
text_edit->add_caret(2, 3); |
| 5498 |
text_edit->select(2, 7, 2, 3, 1); |
| 5499 |
MessageQueue::get_singleton()->flush(); |
| 5500 |
SIGNAL_DISCARD("text_set"); |
| 5501 |
SIGNAL_DISCARD("text_changed"); |
| 5502 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5503 |
SIGNAL_DISCARD("caret_changed"); |
| 5504 |
|
| 5505 |
|
| 5506 |
|
| 5507 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT); |
| 5508 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5509 |
CHECK(text_edit->get_caret_count() == 2); |
| 5510 |
CHECK(text_edit->has_selection(0)); |
| 5511 |
CHECK(text_edit->get_selected_text(0) == "s i"); |
| 5512 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5513 |
CHECK(text_edit->get_caret_column(0) == 6); |
| 5514 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 5515 |
CHECK(text_edit->get_selection_origin_column(0) == 3); |
| 5516 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5517 |
|
| 5518 |
CHECK(text_edit->has_selection(1)); |
| 5519 |
CHECK(text_edit->get_selected_text(1) == "is is"); |
| 5520 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5521 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 5522 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5523 |
CHECK(text_edit->get_selection_origin_column(1) == 7); |
| 5524 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(1)); |
| 5525 |
|
| 5526 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5527 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5528 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5529 |
|
| 5530 |
|
| 5531 |
SEND_GUI_ACTION("ui_text_caret_left"); |
| 5532 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5533 |
CHECK(text_edit->get_caret_count() == 2); |
| 5534 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5535 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5536 |
CHECK(text_edit->get_caret_column(0) == 3); |
| 5537 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5538 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5539 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 5540 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5541 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5542 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5543 |
|
| 5544 |
|
| 5545 |
SEND_GUI_ACTION("ui_text_caret_left"); |
| 5546 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5547 |
CHECK(text_edit->get_caret_count() == 2); |
| 5548 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5549 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5550 |
CHECK(text_edit->get_caret_column(0) == 2); |
| 5551 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5552 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5553 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 5554 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5555 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5556 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5557 |
|
| 5558 |
|
| 5559 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT); |
| 5560 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5561 |
CHECK(text_edit->get_caret_count() == 2); |
| 5562 |
CHECK(text_edit->has_selection(0)); |
| 5563 |
CHECK(text_edit->get_selected_text(0) == "h"); |
| 5564 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5565 |
CHECK(text_edit->get_caret_column(0) == 1); |
| 5566 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 5567 |
CHECK(text_edit->get_selection_origin_column(0) == 2); |
| 5568 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(0)); |
| 5569 |
|
| 5570 |
CHECK(text_edit->has_selection(1)); |
| 5571 |
CHECK(text_edit->get_selected_text(1) == "t"); |
| 5572 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5573 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 5574 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5575 |
CHECK(text_edit->get_selection_origin_column(1) == 1); |
| 5576 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(1)); |
| 5577 |
|
| 5578 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5579 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5580 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5581 |
|
| 5582 |
|
| 5583 |
text_edit->deselect(); |
| 5584 |
text_edit->set_caret_line(0); |
| 5585 |
text_edit->set_caret_column(0); |
| 5586 |
text_edit->set_caret_column(0, false, 1); |
| 5587 |
MessageQueue::get_singleton()->flush(); |
| 5588 |
SIGNAL_DISCARD("caret_changed"); |
| 5589 |
|
| 5590 |
SEND_GUI_ACTION("ui_text_caret_left"); |
| 5591 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5592 |
CHECK(text_edit->get_caret_count() == 2); |
| 5593 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5594 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5595 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5596 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5597 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 5598 |
CHECK(text_edit->get_caret_column(1) == 23); |
| 5599 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5600 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5601 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5602 |
|
| 5603 |
|
| 5604 |
text_edit->remove_secondary_carets(); |
| 5605 |
text_edit->set_caret_line(1); |
| 5606 |
text_edit->set_caret_column(0); |
| 5607 |
text_edit->select(1, 1, 1, 0); |
| 5608 |
MessageQueue::get_singleton()->flush(); |
| 5609 |
SIGNAL_DISCARD("caret_changed"); |
| 5610 |
|
| 5611 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT); |
| 5612 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5613 |
CHECK(text_edit->get_caret_count() == 1); |
| 5614 |
CHECK(text_edit->has_selection(0)); |
| 5615 |
CHECK(text_edit->get_selected_text(0) == "\nt"); |
| 5616 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5617 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5618 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 5619 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 5620 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(0)); |
| 5621 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5622 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5623 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5624 |
|
| 5625 |
|
| 5626 |
text_edit->set_caret_line(1); |
| 5627 |
text_edit->set_caret_column(4); |
| 5628 |
text_edit->select(1, 6, 1, 4); |
| 5629 |
text_edit->add_caret(1, 8); |
| 5630 |
text_edit->select(1, 8, 1, 6, 1); |
| 5631 |
MessageQueue::get_singleton()->flush(); |
| 5632 |
SIGNAL_DISCARD("caret_changed"); |
| 5633 |
CHECK(text_edit->get_caret_count() == 2); |
| 5634 |
|
| 5635 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::SHIFT); |
| 5636 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5637 |
CHECK(text_edit->get_caret_count() == 1); |
| 5638 |
CHECK(text_edit->has_selection(0)); |
| 5639 |
CHECK(text_edit->get_selected_text(0) == "s is "); |
| 5640 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5641 |
CHECK(text_edit->get_caret_column(0) == 3); |
| 5642 |
CHECK(text_edit->get_selection_origin_line(0) == 1); |
| 5643 |
CHECK(text_edit->get_selection_origin_column(0) == 8); |
| 5644 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(0)); |
| 5645 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5646 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5647 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5648 |
} |
| 5649 |
|
| 5650 |
SUBCASE("[TextEdit] ui_text_caret_word_right") { |
| 5651 |
text_edit->set_text("this is some test text\n\nthis is some test text"); |
| 5652 |
text_edit->set_caret_line(0); |
| 5653 |
text_edit->set_caret_column(15); |
| 5654 |
text_edit->add_caret(2, 10); |
| 5655 |
text_edit->select(0, 10, 0, 15); |
| 5656 |
text_edit->select(2, 15, 2, 10, 1); |
| 5657 |
MessageQueue::get_singleton()->flush(); |
| 5658 |
SIGNAL_DISCARD("text_set"); |
| 5659 |
SIGNAL_DISCARD("text_changed"); |
| 5660 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5661 |
SIGNAL_DISCARD("caret_changed"); |
| 5662 |
|
| 5663 |
|
| 5664 |
|
| 5665 |
#ifdef MACOS_ENABLED |
| 5666 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); |
| 5667 |
#else |
| 5668 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 5669 |
#endif |
| 5670 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5671 |
CHECK(text_edit->get_caret_count() == 2); |
| 5672 |
CHECK(text_edit->has_selection(0)); |
| 5673 |
CHECK(text_edit->get_selected_text(0) == "me test"); |
| 5674 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5675 |
CHECK(text_edit->get_caret_column(0) == 17); |
| 5676 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5677 |
CHECK(text_edit->get_selection_origin_column(0) == 10); |
| 5678 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5679 |
|
| 5680 |
CHECK(text_edit->has_selection(1)); |
| 5681 |
CHECK(text_edit->get_selected_text(1) == " te"); |
| 5682 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5683 |
CHECK(text_edit->get_caret_column(1) == 12); |
| 5684 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5685 |
CHECK(text_edit->get_selection_origin_column(1) == 15); |
| 5686 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(1)); |
| 5687 |
|
| 5688 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5689 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5690 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5691 |
|
| 5692 |
|
| 5693 |
text_edit->deselect(); |
| 5694 |
text_edit->set_caret_column(13); |
| 5695 |
text_edit->set_caret_column(15, false, 1); |
| 5696 |
MessageQueue::get_singleton()->flush(); |
| 5697 |
SIGNAL_DISCARD("caret_changed"); |
| 5698 |
#ifdef MACOS_ENABLED |
| 5699 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::ALT | KeyModifierMask::SHIFT); |
| 5700 |
#else |
| 5701 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 5702 |
#endif |
| 5703 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5704 |
CHECK(text_edit->get_caret_count() == 2); |
| 5705 |
CHECK(text_edit->has_selection(0)); |
| 5706 |
CHECK(text_edit->get_selected_text(0) == "test"); |
| 5707 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5708 |
CHECK(text_edit->get_caret_column(0) == 17); |
| 5709 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5710 |
CHECK(text_edit->get_selection_origin_column(0) == 13); |
| 5711 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5712 |
|
| 5713 |
CHECK(text_edit->has_selection(1)); |
| 5714 |
CHECK(text_edit->get_selected_text(1) == "st"); |
| 5715 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5716 |
CHECK(text_edit->get_caret_column(1) == 17); |
| 5717 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5718 |
CHECK(text_edit->get_selection_origin_column(1) == 15); |
| 5719 |
CHECK(text_edit->is_caret_after_selection_origin(1)); |
| 5720 |
|
| 5721 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5722 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5723 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5724 |
|
| 5725 |
|
| 5726 |
SEND_GUI_ACTION("ui_text_caret_word_right"); |
| 5727 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5728 |
CHECK(text_edit->get_caret_count() == 2); |
| 5729 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5730 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5731 |
CHECK(text_edit->get_caret_column(0) == 22); |
| 5732 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5733 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5734 |
CHECK(text_edit->get_caret_column(1) == 22); |
| 5735 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5736 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5737 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5738 |
|
| 5739 |
|
| 5740 |
SEND_GUI_ACTION("ui_text_caret_word_right"); |
| 5741 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5742 |
CHECK(text_edit->get_caret_count() == 2); |
| 5743 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5744 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5745 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5746 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5747 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5748 |
CHECK(text_edit->get_caret_column(1) == 22); |
| 5749 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5750 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5751 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5752 |
|
| 5753 |
|
| 5754 |
text_edit->set_text("#{}"); |
| 5755 |
text_edit->set_caret_line(0); |
| 5756 |
text_edit->set_caret_column(0); |
| 5757 |
|
| 5758 |
SEND_GUI_ACTION("ui_text_caret_word_right"); |
| 5759 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5760 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5761 |
CHECK(text_edit->get_caret_column(0) == 3); |
| 5762 |
} |
| 5763 |
|
| 5764 |
SUBCASE("[TextEdit] ui_text_caret_right") { |
| 5765 |
text_edit->set_text("this is some test text\n\nthis is some test text"); |
| 5766 |
text_edit->set_caret_line(0); |
| 5767 |
text_edit->set_caret_column(19); |
| 5768 |
text_edit->select(0, 15, 0, 19); |
| 5769 |
text_edit->add_caret(2, 15); |
| 5770 |
text_edit->select(2, 19, 2, 15, 1); |
| 5771 |
MessageQueue::get_singleton()->flush(); |
| 5772 |
SIGNAL_DISCARD("text_set"); |
| 5773 |
SIGNAL_DISCARD("text_changed"); |
| 5774 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5775 |
SIGNAL_DISCARD("caret_changed"); |
| 5776 |
|
| 5777 |
|
| 5778 |
|
| 5779 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT); |
| 5780 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5781 |
CHECK(text_edit->get_caret_count() == 2); |
| 5782 |
CHECK(text_edit->has_selection(0)); |
| 5783 |
CHECK(text_edit->get_selected_text(0) == "st te"); |
| 5784 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5785 |
CHECK(text_edit->get_caret_column(0) == 20); |
| 5786 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5787 |
CHECK(text_edit->get_selection_origin_column(0) == 15); |
| 5788 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5789 |
|
| 5790 |
CHECK(text_edit->has_selection(1)); |
| 5791 |
CHECK(text_edit->get_selected_text(1) == "t t"); |
| 5792 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5793 |
CHECK(text_edit->get_caret_column(1) == 16); |
| 5794 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5795 |
CHECK(text_edit->get_selection_origin_column(1) == 19); |
| 5796 |
CHECK_FALSE(text_edit->is_caret_after_selection_origin(1)); |
| 5797 |
|
| 5798 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5799 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5800 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5801 |
|
| 5802 |
|
| 5803 |
SEND_GUI_ACTION("ui_text_caret_right"); |
| 5804 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5805 |
CHECK(text_edit->get_caret_count() == 2); |
| 5806 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5807 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5808 |
CHECK(text_edit->get_caret_column(0) == 20); |
| 5809 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5810 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5811 |
CHECK(text_edit->get_caret_column(1) == 19); |
| 5812 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5813 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5814 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5815 |
|
| 5816 |
|
| 5817 |
SEND_GUI_ACTION("ui_text_caret_right"); |
| 5818 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5819 |
CHECK(text_edit->get_caret_count() == 2); |
| 5820 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5821 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5822 |
CHECK(text_edit->get_caret_column(0) == 21); |
| 5823 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5824 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5825 |
CHECK(text_edit->get_caret_column(1) == 20); |
| 5826 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5827 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5828 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5829 |
|
| 5830 |
|
| 5831 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT); |
| 5832 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5833 |
CHECK(text_edit->get_caret_count() == 2); |
| 5834 |
CHECK(text_edit->has_selection(0)); |
| 5835 |
CHECK(text_edit->get_selected_text(0) == "t"); |
| 5836 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5837 |
CHECK(text_edit->get_caret_column(0) == 22); |
| 5838 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5839 |
CHECK(text_edit->get_selection_origin_column(0) == 21); |
| 5840 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5841 |
|
| 5842 |
CHECK(text_edit->has_selection(1)); |
| 5843 |
CHECK(text_edit->get_selected_text(1) == "x"); |
| 5844 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5845 |
CHECK(text_edit->get_caret_column(1) == 21); |
| 5846 |
CHECK(text_edit->get_selection_origin_line(1) == 2); |
| 5847 |
CHECK(text_edit->get_selection_origin_column(1) == 20); |
| 5848 |
CHECK(text_edit->is_caret_after_selection_origin(1)); |
| 5849 |
|
| 5850 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5851 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5852 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5853 |
|
| 5854 |
|
| 5855 |
text_edit->deselect(); |
| 5856 |
text_edit->set_caret_line(0); |
| 5857 |
text_edit->set_caret_column(22); |
| 5858 |
text_edit->set_caret_column(22, false, 1); |
| 5859 |
MessageQueue::get_singleton()->flush(); |
| 5860 |
SIGNAL_DISCARD("caret_changed"); |
| 5861 |
|
| 5862 |
SEND_GUI_ACTION("ui_text_caret_right"); |
| 5863 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5864 |
CHECK(text_edit->get_caret_count() == 2); |
| 5865 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5866 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5867 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5868 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5869 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 5870 |
CHECK(text_edit->get_caret_column(1) == 22); |
| 5871 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5872 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5873 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5874 |
|
| 5875 |
|
| 5876 |
text_edit->remove_secondary_carets(); |
| 5877 |
text_edit->set_caret_line(0); |
| 5878 |
text_edit->set_caret_column(22); |
| 5879 |
text_edit->select(0, 21, 0, 22); |
| 5880 |
MessageQueue::get_singleton()->flush(); |
| 5881 |
SIGNAL_DISCARD("caret_changed"); |
| 5882 |
|
| 5883 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT); |
| 5884 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5885 |
CHECK(text_edit->get_caret_count() == 1); |
| 5886 |
CHECK(text_edit->has_selection(0)); |
| 5887 |
CHECK(text_edit->get_selected_text(0) == "t\n"); |
| 5888 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 5889 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 5890 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5891 |
CHECK(text_edit->get_selection_origin_column(0) == 21); |
| 5892 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5893 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5894 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5895 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5896 |
|
| 5897 |
|
| 5898 |
text_edit->set_caret_line(0); |
| 5899 |
text_edit->set_caret_column(4); |
| 5900 |
text_edit->select(0, 4, 0, 6); |
| 5901 |
text_edit->add_caret(0, 8); |
| 5902 |
text_edit->select(0, 6, 0, 8, 1); |
| 5903 |
MessageQueue::get_singleton()->flush(); |
| 5904 |
SIGNAL_DISCARD("caret_changed"); |
| 5905 |
CHECK(text_edit->get_caret_count() == 2); |
| 5906 |
|
| 5907 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::SHIFT); |
| 5908 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5909 |
CHECK(text_edit->get_caret_count() == 1); |
| 5910 |
CHECK(text_edit->has_selection(0)); |
| 5911 |
CHECK(text_edit->get_selected_text(0) == " is s"); |
| 5912 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 5913 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 5914 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 5915 |
CHECK(text_edit->get_selection_origin_column(0) == 4); |
| 5916 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 5917 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5918 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5919 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5920 |
} |
| 5921 |
|
| 5922 |
SUBCASE("[TextEdit] ui_text_caret_up") { |
| 5923 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 5924 |
|
| 5925 |
text_edit->set_size(Size2(110, 100)); |
| 5926 |
text_edit->set_text("this is some\nother test\nlines\ngo here\nthis is some\nother test\nlines\ngo here"); |
| 5927 |
text_edit->set_caret_line(3); |
| 5928 |
text_edit->set_caret_column(7); |
| 5929 |
|
| 5930 |
text_edit->add_caret(7, 7); |
| 5931 |
CHECK(text_edit->get_caret_count() == 2); |
| 5932 |
|
| 5933 |
MessageQueue::get_singleton()->flush(); |
| 5934 |
|
| 5935 |
CHECK(text_edit->is_line_wrapped(0)); |
| 5936 |
SIGNAL_DISCARD("text_set"); |
| 5937 |
SIGNAL_DISCARD("text_changed"); |
| 5938 |
SIGNAL_DISCARD("lines_edited_from"); |
| 5939 |
SIGNAL_DISCARD("caret_changed"); |
| 5940 |
|
| 5941 |
|
| 5942 |
SEND_GUI_KEY_EVENT(Key::UP | KeyModifierMask::SHIFT); |
| 5943 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5944 |
CHECK(text_edit->get_caret_line() == 2); |
| 5945 |
CHECK(text_edit->get_caret_column() == 5); |
| 5946 |
CHECK(text_edit->get_selected_text(0) == "\ngo here"); |
| 5947 |
CHECK(text_edit->has_selection(0)); |
| 5948 |
|
| 5949 |
CHECK(text_edit->get_caret_line(1) == 6); |
| 5950 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 5951 |
CHECK(text_edit->get_selected_text(1) == "\ngo here"); |
| 5952 |
CHECK(text_edit->has_selection(1)); |
| 5953 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5954 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5955 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5956 |
|
| 5957 |
|
| 5958 |
SEND_GUI_ACTION("ui_text_caret_up"); |
| 5959 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5960 |
CHECK(text_edit->get_caret_line() == 1); |
| 5961 |
CHECK(text_edit->get_caret_column() == 8); |
| 5962 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5963 |
|
| 5964 |
CHECK(text_edit->get_caret_line(1) == 5); |
| 5965 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 5966 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5967 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5968 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5969 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5970 |
|
| 5971 |
|
| 5972 |
SEND_GUI_ACTION("ui_text_caret_up"); |
| 5973 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5974 |
CHECK(text_edit->get_caret_line() == 0); |
| 5975 |
CHECK(text_edit->get_caret_column() == 12); |
| 5976 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5977 |
|
| 5978 |
CHECK(text_edit->get_caret_line(1) == 4); |
| 5979 |
CHECK(text_edit->get_caret_column(1) == 12); |
| 5980 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5981 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5982 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5983 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5984 |
|
| 5985 |
|
| 5986 |
text_edit->set_caret_column(12, false); |
| 5987 |
SEND_GUI_ACTION("ui_text_caret_up"); |
| 5988 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 5989 |
CHECK(text_edit->get_caret_line() == 0); |
| 5990 |
CHECK(text_edit->get_caret_column() == 7); |
| 5991 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 5992 |
|
| 5993 |
CHECK(text_edit->get_caret_line(1) == 4); |
| 5994 |
CHECK(text_edit->get_caret_column(1) == 7); |
| 5995 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 5996 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 5997 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 5998 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 5999 |
|
| 6000 |
|
| 6001 |
text_edit->remove_secondary_carets(); |
| 6002 |
text_edit->set_caret_line(5); |
| 6003 |
text_edit->set_caret_column(0); |
| 6004 |
SEND_GUI_ACTION("ui_text_caret_up"); |
| 6005 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6006 |
CHECK(text_edit->get_caret_line() == 4); |
| 6007 |
CHECK(text_edit->get_caret_column() == 8); |
| 6008 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6009 |
|
| 6010 |
|
| 6011 |
SEND_GUI_ACTION("ui_text_caret_up"); |
| 6012 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6013 |
CHECK(text_edit->get_caret_line() == 4); |
| 6014 |
CHECK(text_edit->get_caret_column() == 0); |
| 6015 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6016 |
} |
| 6017 |
|
| 6018 |
SUBCASE("[TextEdit] ui_text_caret_down") { |
| 6019 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 6020 |
|
| 6021 |
text_edit->set_size(Size2(110, 100)); |
| 6022 |
text_edit->set_text("go here\nlines\nother test\nthis is some\ngo here\nlines\nother test\nthis is some"); |
| 6023 |
text_edit->set_caret_line(0); |
| 6024 |
text_edit->set_caret_column(7); |
| 6025 |
|
| 6026 |
text_edit->add_caret(4, 7); |
| 6027 |
CHECK(text_edit->get_caret_count() == 2); |
| 6028 |
|
| 6029 |
MessageQueue::get_singleton()->flush(); |
| 6030 |
|
| 6031 |
|
| 6032 |
CHECK(text_edit->is_line_wrapped(3)); |
| 6033 |
SIGNAL_DISCARD("text_set"); |
| 6034 |
SIGNAL_DISCARD("text_changed"); |
| 6035 |
SIGNAL_DISCARD("lines_edited_from"); |
| 6036 |
SIGNAL_DISCARD("caret_changed"); |
| 6037 |
|
| 6038 |
|
| 6039 |
SEND_GUI_KEY_EVENT(Key::DOWN | KeyModifierMask::SHIFT); |
| 6040 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6041 |
CHECK(text_edit->get_caret_line() == 1); |
| 6042 |
CHECK(text_edit->get_caret_column() == 5); |
| 6043 |
CHECK(text_edit->get_selected_text(0) == "\nlines"); |
| 6044 |
CHECK(text_edit->has_selection(0)); |
| 6045 |
|
| 6046 |
CHECK(text_edit->get_caret_line(1) == 5); |
| 6047 |
CHECK(text_edit->get_caret_column(1) == 5); |
| 6048 |
CHECK(text_edit->get_selected_text(1) == "\nlines"); |
| 6049 |
CHECK(text_edit->has_selection(1)); |
| 6050 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6051 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6052 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6053 |
|
| 6054 |
|
| 6055 |
SEND_GUI_ACTION("ui_text_caret_down"); |
| 6056 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6057 |
CHECK(text_edit->get_caret_line() == 2); |
| 6058 |
CHECK(text_edit->get_caret_column() == 8); |
| 6059 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6060 |
|
| 6061 |
CHECK(text_edit->get_caret_line(1) == 6); |
| 6062 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 6063 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6064 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6065 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6066 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6067 |
|
| 6068 |
|
| 6069 |
SEND_GUI_ACTION("ui_text_caret_down"); |
| 6070 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6071 |
CHECK(text_edit->get_caret_line() == 3); |
| 6072 |
CHECK(text_edit->get_caret_column() == 7); |
| 6073 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6074 |
|
| 6075 |
CHECK(text_edit->get_caret_line(1) == 7); |
| 6076 |
CHECK(text_edit->get_caret_column(1) == 7); |
| 6077 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6078 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6079 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6080 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6081 |
|
| 6082 |
|
| 6083 |
text_edit->set_caret_column(7, false); |
| 6084 |
SEND_GUI_ACTION("ui_text_caret_down"); |
| 6085 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6086 |
CHECK(text_edit->get_caret_line() == 3); |
| 6087 |
CHECK(text_edit->get_caret_column() == 12); |
| 6088 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6089 |
|
| 6090 |
CHECK(text_edit->get_caret_line(1) == 7); |
| 6091 |
CHECK(text_edit->get_caret_column(1) == 12); |
| 6092 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6093 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6094 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6095 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6096 |
|
| 6097 |
|
| 6098 |
text_edit->remove_secondary_carets(); |
| 6099 |
text_edit->set_caret_line(3); |
| 6100 |
text_edit->set_caret_column(0); |
| 6101 |
SEND_GUI_ACTION("ui_text_caret_down"); |
| 6102 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6103 |
CHECK(text_edit->get_caret_line() == 3); |
| 6104 |
CHECK(text_edit->get_caret_column() == 8); |
| 6105 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6106 |
|
| 6107 |
|
| 6108 |
SEND_GUI_ACTION("ui_text_caret_down"); |
| 6109 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6110 |
CHECK(text_edit->get_caret_line() == 4); |
| 6111 |
CHECK(text_edit->get_caret_column() == 0); |
| 6112 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6113 |
} |
| 6114 |
|
| 6115 |
SUBCASE("[TextEdit] ui_text_caret_document_start") { |
| 6116 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 6117 |
|
| 6118 |
text_edit->set_size(Size2(110, 100)); |
| 6119 |
text_edit->set_text("this is some\nother test\nlines\ngo here"); |
| 6120 |
text_edit->set_caret_line(4); |
| 6121 |
text_edit->set_caret_column(7); |
| 6122 |
|
| 6123 |
text_edit->add_caret(3, 2); |
| 6124 |
CHECK(text_edit->get_caret_count() == 2); |
| 6125 |
|
| 6126 |
MessageQueue::get_singleton()->flush(); |
| 6127 |
|
| 6128 |
CHECK(text_edit->is_line_wrapped(0)); |
| 6129 |
SIGNAL_DISCARD("text_set"); |
| 6130 |
SIGNAL_DISCARD("text_changed"); |
| 6131 |
SIGNAL_DISCARD("lines_edited_from"); |
| 6132 |
SIGNAL_DISCARD("caret_changed"); |
| 6133 |
|
| 6134 |
#ifdef MACOS_ENABLED |
| 6135 |
SEND_GUI_KEY_EVENT(Key::UP | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 6136 |
#else |
| 6137 |
SEND_GUI_KEY_EVENT(Key::HOME | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 6138 |
#endif |
| 6139 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6140 |
CHECK(text_edit->get_text() == "this is some\nother test\nlines\ngo here"); |
| 6141 |
CHECK(text_edit->get_caret_line() == 0); |
| 6142 |
CHECK(text_edit->get_caret_column() == 0); |
| 6143 |
CHECK(text_edit->get_selected_text() == "this is some\nother test\nlines\ngo here"); |
| 6144 |
CHECK(text_edit->has_selection()); |
| 6145 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6146 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6147 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6148 |
CHECK(text_edit->get_caret_count() == 1); |
| 6149 |
|
| 6150 |
SEND_GUI_ACTION("ui_text_caret_document_start"); |
| 6151 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6152 |
CHECK(text_edit->get_text() == "this is some\nother test\nlines\ngo here"); |
| 6153 |
CHECK(text_edit->get_caret_line() == 0); |
| 6154 |
CHECK(text_edit->get_caret_column() == 0); |
| 6155 |
CHECK_FALSE(text_edit->has_selection()); |
| 6156 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6157 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6158 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6159 |
} |
| 6160 |
|
| 6161 |
SUBCASE("[TextEdit] ui_text_caret_document_end") { |
| 6162 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 6163 |
|
| 6164 |
text_edit->set_size(Size2(110, 100)); |
| 6165 |
text_edit->set_text("go here\nlines\nother test\nthis is some"); |
| 6166 |
text_edit->set_caret_line(0); |
| 6167 |
text_edit->set_caret_column(0); |
| 6168 |
|
| 6169 |
text_edit->add_caret(1, 0); |
| 6170 |
CHECK(text_edit->get_caret_count() == 2); |
| 6171 |
MessageQueue::get_singleton()->flush(); |
| 6172 |
|
| 6173 |
CHECK(text_edit->is_line_wrapped(3)); |
| 6174 |
SIGNAL_DISCARD("text_set"); |
| 6175 |
SIGNAL_DISCARD("text_changed"); |
| 6176 |
SIGNAL_DISCARD("lines_edited_from"); |
| 6177 |
SIGNAL_DISCARD("caret_changed"); |
| 6178 |
|
| 6179 |
#ifdef MACOS_ENABLED |
| 6180 |
SEND_GUI_KEY_EVENT(Key::DOWN | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 6181 |
#else |
| 6182 |
SEND_GUI_KEY_EVENT(Key::END | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 6183 |
#endif |
| 6184 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6185 |
CHECK(text_edit->get_text() == "go here\nlines\nother test\nthis is some"); |
| 6186 |
CHECK(text_edit->get_caret_line() == 3); |
| 6187 |
CHECK(text_edit->get_caret_column() == 12); |
| 6188 |
CHECK(text_edit->get_selected_text() == "go here\nlines\nother test\nthis is some"); |
| 6189 |
CHECK(text_edit->has_selection()); |
| 6190 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6191 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6192 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6193 |
CHECK(text_edit->get_caret_count() == 1); |
| 6194 |
|
| 6195 |
SEND_GUI_ACTION("ui_text_caret_document_end"); |
| 6196 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6197 |
CHECK(text_edit->get_text() == "go here\nlines\nother test\nthis is some"); |
| 6198 |
CHECK(text_edit->get_caret_line() == 3); |
| 6199 |
CHECK(text_edit->get_caret_column() == 12); |
| 6200 |
CHECK_FALSE(text_edit->has_selection()); |
| 6201 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6202 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6203 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6204 |
} |
| 6205 |
|
| 6206 |
SUBCASE("[TextEdit] ui_text_caret_line_start") { |
| 6207 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 6208 |
|
| 6209 |
text_edit->set_size(Size2(110, 100)); |
| 6210 |
text_edit->set_text(" this is some\n this is some"); |
| 6211 |
text_edit->set_caret_line(0); |
| 6212 |
text_edit->set_caret_column(text_edit->get_line(0).length()); |
| 6213 |
|
| 6214 |
text_edit->add_caret(1, text_edit->get_line(1).length()); |
| 6215 |
CHECK(text_edit->get_caret_count() == 2); |
| 6216 |
MessageQueue::get_singleton()->flush(); |
| 6217 |
|
| 6218 |
CHECK(text_edit->is_line_wrapped(0)); |
| 6219 |
SIGNAL_DISCARD("text_set"); |
| 6220 |
SIGNAL_DISCARD("text_changed"); |
| 6221 |
SIGNAL_DISCARD("lines_edited_from"); |
| 6222 |
SIGNAL_DISCARD("caret_changed"); |
| 6223 |
|
| 6224 |
#ifdef MACOS_ENABLED |
| 6225 |
SEND_GUI_KEY_EVENT(Key::LEFT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 6226 |
#else |
| 6227 |
SEND_GUI_KEY_EVENT(Key::HOME | KeyModifierMask::SHIFT); |
| 6228 |
#endif |
| 6229 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6230 |
CHECK(text_edit->get_caret_line() == 0); |
| 6231 |
CHECK(text_edit->get_caret_column() == 10); |
| 6232 |
CHECK(text_edit->has_selection(0)); |
| 6233 |
CHECK(text_edit->get_selected_text(0) == "some"); |
| 6234 |
|
| 6235 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 6236 |
CHECK(text_edit->get_caret_column(1) == 10); |
| 6237 |
CHECK(text_edit->has_selection(1)); |
| 6238 |
CHECK(text_edit->get_selected_text(1) == "some"); |
| 6239 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6240 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6241 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6242 |
|
| 6243 |
SEND_GUI_ACTION("ui_text_caret_line_start"); |
| 6244 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6245 |
CHECK(text_edit->get_caret_line() == 0); |
| 6246 |
CHECK(text_edit->get_caret_column() == 2); |
| 6247 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6248 |
|
| 6249 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 6250 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 6251 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6252 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6253 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6254 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6255 |
|
| 6256 |
SEND_GUI_ACTION("ui_text_caret_line_start"); |
| 6257 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6258 |
CHECK(text_edit->get_caret_line() == 0); |
| 6259 |
CHECK(text_edit->get_caret_column() == 0); |
| 6260 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6261 |
|
| 6262 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 6263 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 6264 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6265 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6266 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6267 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6268 |
|
| 6269 |
SEND_GUI_ACTION("ui_text_caret_line_start"); |
| 6270 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6271 |
CHECK(text_edit->get_caret_line() == 0); |
| 6272 |
CHECK(text_edit->get_caret_column() == 2); |
| 6273 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6274 |
|
| 6275 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 6276 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 6277 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6278 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6279 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6280 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6281 |
} |
| 6282 |
|
| 6283 |
SUBCASE("[TextEdit] ui_text_caret_line_end") { |
| 6284 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 6285 |
|
| 6286 |
text_edit->set_size(Size2(110, 100)); |
| 6287 |
text_edit->set_text(" this is some\n this is some"); |
| 6288 |
text_edit->set_caret_line(0); |
| 6289 |
text_edit->set_caret_column(0); |
| 6290 |
|
| 6291 |
text_edit->add_caret(1, 0); |
| 6292 |
CHECK(text_edit->get_caret_count() == 2); |
| 6293 |
MessageQueue::get_singleton()->flush(); |
| 6294 |
|
| 6295 |
CHECK(text_edit->is_line_wrapped(0)); |
| 6296 |
SIGNAL_DISCARD("text_set"); |
| 6297 |
SIGNAL_DISCARD("text_changed"); |
| 6298 |
SIGNAL_DISCARD("lines_edited_from"); |
| 6299 |
SIGNAL_DISCARD("caret_changed"); |
| 6300 |
|
| 6301 |
#ifdef MACOS_ENABLED |
| 6302 |
SEND_GUI_KEY_EVENT(Key::RIGHT | KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT); |
| 6303 |
#else |
| 6304 |
SEND_GUI_KEY_EVENT(Key::END | KeyModifierMask::SHIFT); |
| 6305 |
#endif |
| 6306 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6307 |
CHECK(text_edit->get_caret_line() == 0); |
| 6308 |
CHECK(text_edit->get_caret_column() == 9); |
| 6309 |
CHECK(text_edit->has_selection(0)); |
| 6310 |
CHECK(text_edit->get_selected_text(0) == " this is"); |
| 6311 |
|
| 6312 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 6313 |
CHECK(text_edit->get_caret_column(1) == 9); |
| 6314 |
CHECK(text_edit->has_selection(1)); |
| 6315 |
CHECK(text_edit->get_selected_text(1) == " this is"); |
| 6316 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6317 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6318 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6319 |
|
| 6320 |
SEND_GUI_ACTION("ui_text_caret_line_end"); |
| 6321 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6322 |
CHECK(text_edit->get_caret_line() == 0); |
| 6323 |
CHECK(text_edit->get_caret_column() == text_edit->get_line(0).length()); |
| 6324 |
CHECK_FALSE(text_edit->has_selection(0)); |
| 6325 |
|
| 6326 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6327 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 6328 |
CHECK(text_edit->get_caret_column(1) == text_edit->get_line(1).length()); |
| 6329 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 6330 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6331 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6332 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6333 |
} |
| 6334 |
|
| 6335 |
SUBCASE("[TextEdit] unicode") { |
| 6336 |
text_edit->set_text("\n"); |
| 6337 |
text_edit->set_caret_line(0); |
| 6338 |
text_edit->set_caret_column(0); |
| 6339 |
|
| 6340 |
text_edit->add_caret(1, 0); |
| 6341 |
CHECK(text_edit->get_caret_count() == 2); |
| 6342 |
text_edit->insert_text_at_caret("a"); |
| 6343 |
MessageQueue::get_singleton()->flush(); |
| 6344 |
|
| 6345 |
SIGNAL_DISCARD("text_set"); |
| 6346 |
SIGNAL_DISCARD("text_changed"); |
| 6347 |
SIGNAL_DISCARD("lines_edited_from"); |
| 6348 |
SIGNAL_DISCARD("caret_changed"); |
| 6349 |
|
| 6350 |
lines_edited_args = { { 0, 0 }, { 1, 1 } }; |
| 6351 |
|
| 6352 |
SEND_GUI_KEY_EVENT(Key::A); |
| 6353 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6354 |
CHECK(text_edit->get_text() == "aA\naA"); |
| 6355 |
CHECK(text_edit->get_caret_column() == 2); |
| 6356 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 6357 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6358 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6359 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 6360 |
|
| 6361 |
|
| 6362 |
text_edit->undo(); |
| 6363 |
MessageQueue::get_singleton()->flush(); |
| 6364 |
CHECK(text_edit->get_text() == "a\na"); |
| 6365 |
CHECK(text_edit->get_caret_column() == 1); |
| 6366 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 6367 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6368 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6369 |
SIGNAL_CHECK("lines_edited_from", reverse_nested(lines_edited_args)); |
| 6370 |
|
| 6371 |
|
| 6372 |
text_edit->redo(); |
| 6373 |
MessageQueue::get_singleton()->flush(); |
| 6374 |
CHECK(text_edit->get_text() == "aA\naA"); |
| 6375 |
CHECK(text_edit->get_caret_column() == 2); |
| 6376 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 6377 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6378 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6379 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 6380 |
|
| 6381 |
|
| 6382 |
text_edit->set_editable(false); |
| 6383 |
SEND_GUI_KEY_EVENT(Key::A); |
| 6384 |
CHECK_FALSE(text_edit->get_viewport()->is_input_handled()); |
| 6385 |
CHECK(text_edit->get_text() == "aA\naA"); |
| 6386 |
CHECK(text_edit->get_caret_column() == 2); |
| 6387 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 6388 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6389 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 6390 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 6391 |
text_edit->set_editable(true); |
| 6392 |
|
| 6393 |
lines_edited_args = { { 0, 0 }, { 0, 0 }, { 1, 1 }, { 1, 1 } }; |
| 6394 |
|
| 6395 |
text_edit->select(0, 0, 0, 1); |
| 6396 |
text_edit->select(1, 0, 1, 1, 1); |
| 6397 |
SEND_GUI_KEY_EVENT(Key::B); |
| 6398 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6399 |
CHECK(text_edit->get_text() == "BA\nBA"); |
| 6400 |
CHECK(text_edit->get_caret_column() == 1); |
| 6401 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 6402 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6403 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6404 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 6405 |
|
| 6406 |
SEND_GUI_ACTION("ui_text_toggle_insert_mode"); |
| 6407 |
CHECK(text_edit->is_overtype_mode_enabled()); |
| 6408 |
|
| 6409 |
SEND_GUI_KEY_EVENT(Key::B); |
| 6410 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6411 |
CHECK(text_edit->get_text() == "BB\nBB"); |
| 6412 |
CHECK(text_edit->get_caret_column() == 2); |
| 6413 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6414 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6415 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 6416 |
|
| 6417 |
text_edit->select(0, 0, 0, 1); |
| 6418 |
text_edit->select(1, 0, 1, 1, 1); |
| 6419 |
SEND_GUI_KEY_EVENT(Key::A); |
| 6420 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6421 |
CHECK(text_edit->get_text() == "AB\nAB"); |
| 6422 |
CHECK(text_edit->get_caret_column() == 1); |
| 6423 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 6424 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6425 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6426 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 6427 |
text_edit->set_overtype_mode_enabled(false); |
| 6428 |
CHECK_FALSE(text_edit->is_overtype_mode_enabled()); |
| 6429 |
|
| 6430 |
lines_edited_args = { { 0, 0 }, { 1, 1 } }; |
| 6431 |
|
| 6432 |
SEND_GUI_KEY_EVENT(Key::TAB); |
| 6433 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 6434 |
CHECK(text_edit->get_text() == "A\tB\nA\tB"); |
| 6435 |
CHECK(text_edit->get_caret_column() == 2); |
| 6436 |
CHECK(text_edit->get_caret_column(1) == 2); |
| 6437 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6438 |
SIGNAL_CHECK("text_changed", empty_signal_args); |
| 6439 |
SIGNAL_CHECK("lines_edited_from", lines_edited_args); |
| 6440 |
} |
| 6441 |
|
| 6442 |
SIGNAL_UNWATCH(text_edit, "text_set"); |
| 6443 |
SIGNAL_UNWATCH(text_edit, "text_changed"); |
| 6444 |
SIGNAL_UNWATCH(text_edit, "lines_edited_from"); |
| 6445 |
SIGNAL_UNWATCH(text_edit, "caret_changed"); |
| 6446 |
} |
| 6447 |
|
| 6448 |
memdelete(text_edit); |
| 6449 |
} |
| 6450 |
|
| 6451 |
TEST_CASE("[SceneTree][TextEdit] context menu") { |
| 6452 |
TextEdit *text_edit = memnew(TextEdit); |
| 6453 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 6454 |
|
| 6455 |
text_edit->set_size(Size2(800, 200)); |
| 6456 |
text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); |
| 6457 |
MessageQueue::get_singleton()->flush(); |
| 6458 |
|
| 6459 |
text_edit->set_context_menu_enabled(false); |
| 6460 |
CHECK_FALSE(text_edit->is_context_menu_enabled()); |
| 6461 |
|
| 6462 |
CHECK_FALSE(text_edit->is_menu_visible()); |
| 6463 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(600, 10), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); |
| 6464 |
CHECK_FALSE(text_edit->is_menu_visible()); |
| 6465 |
|
| 6466 |
text_edit->set_context_menu_enabled(true); |
| 6467 |
CHECK(text_edit->is_context_menu_enabled()); |
| 6468 |
|
| 6469 |
CHECK_FALSE(text_edit->is_menu_visible()); |
| 6470 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(700, 10), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); |
| 6471 |
CHECK(text_edit->is_menu_visible()); |
| 6472 |
|
| 6473 |
memdelete(text_edit); |
| 6474 |
} |
| 6475 |
|
| 6476 |
TEST_CASE("[SceneTree][TextEdit] versioning") { |
| 6477 |
TextEdit *text_edit = memnew(TextEdit); |
| 6478 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 6479 |
|
| 6480 |
|
| 6481 |
CHECK_FALSE(text_edit->has_undo()); |
| 6482 |
CHECK_FALSE(text_edit->has_redo()); |
| 6483 |
CHECK(text_edit->get_version() == 0); |
| 6484 |
CHECK(text_edit->get_saved_version() == 0); |
| 6485 |
|
| 6486 |
text_edit->begin_complex_operation(); |
| 6487 |
text_edit->begin_complex_operation(); |
| 6488 |
text_edit->begin_complex_operation(); |
| 6489 |
|
| 6490 |
text_edit->insert_text_at_caret("test"); |
| 6491 |
CHECK(text_edit->get_version() == 1); |
| 6492 |
CHECK(text_edit->get_saved_version() == 0); |
| 6493 |
CHECK(text_edit->has_undo()); |
| 6494 |
CHECK_FALSE(text_edit->has_redo()); |
| 6495 |
|
| 6496 |
text_edit->end_complex_operation(); |
| 6497 |
|
| 6498 |
|
| 6499 |
text_edit->insert_text_at_caret(" nested"); |
| 6500 |
CHECK(text_edit->get_version() == 2); |
| 6501 |
CHECK(text_edit->get_saved_version() == 0); |
| 6502 |
CHECK(text_edit->has_undo()); |
| 6503 |
CHECK_FALSE(text_edit->has_redo()); |
| 6504 |
text_edit->undo(); |
| 6505 |
|
| 6506 |
CHECK(text_edit->has_redo()); |
| 6507 |
text_edit->redo(); |
| 6508 |
|
| 6509 |
text_edit->end_complex_operation(); |
| 6510 |
|
| 6511 |
text_edit->insert_text_at_caret(" ops"); |
| 6512 |
CHECK(text_edit->get_version() == 3); |
| 6513 |
CHECK(text_edit->get_saved_version() == 0); |
| 6514 |
CHECK(text_edit->has_undo()); |
| 6515 |
CHECK_FALSE(text_edit->has_redo()); |
| 6516 |
|
| 6517 |
text_edit->end_complex_operation(); |
| 6518 |
|
| 6519 |
text_edit->tag_saved_version(); |
| 6520 |
CHECK(text_edit->get_saved_version() == 3); |
| 6521 |
|
| 6522 |
text_edit->undo(); |
| 6523 |
CHECK(text_edit->get_line(0) == ""); |
| 6524 |
CHECK(text_edit->get_version() == 0); |
| 6525 |
CHECK(text_edit->get_saved_version() == 3); |
| 6526 |
CHECK_FALSE(text_edit->has_undo()); |
| 6527 |
CHECK(text_edit->has_redo()); |
| 6528 |
|
| 6529 |
text_edit->redo(); |
| 6530 |
CHECK(text_edit->get_line(0) == "test ops nested"); |
| 6531 |
CHECK(text_edit->get_version() == 3); |
| 6532 |
CHECK(text_edit->get_saved_version() == 3); |
| 6533 |
CHECK(text_edit->has_undo()); |
| 6534 |
CHECK_FALSE(text_edit->has_redo()); |
| 6535 |
|
| 6536 |
text_edit->clear_undo_history(); |
| 6537 |
CHECK_FALSE(text_edit->has_undo()); |
| 6538 |
CHECK_FALSE(text_edit->has_redo()); |
| 6539 |
CHECK(text_edit->get_version() == 3); |
| 6540 |
CHECK(text_edit->get_saved_version() == 0); |
| 6541 |
|
| 6542 |
SUBCASE("[TextEdit] versioning selection") { |
| 6543 |
text_edit->set_text("Godot Engine\nWaiting for Godot\nTest Text for multi carat\nLine 4 Text"); |
| 6544 |
text_edit->set_multiple_carets_enabled(true); |
| 6545 |
|
| 6546 |
text_edit->remove_secondary_carets(); |
| 6547 |
text_edit->deselect(); |
| 6548 |
text_edit->set_caret_line(0); |
| 6549 |
text_edit->set_caret_column(0); |
| 6550 |
|
| 6551 |
CHECK(text_edit->get_caret_count() == 1); |
| 6552 |
|
| 6553 |
Array caret_index = { 0 }; |
| 6554 |
|
| 6555 |
for (int i = 1; i < 4; i++) { |
| 6556 |
caret_index.push_back(text_edit->add_caret(i, 0)); |
| 6557 |
CHECK((int)caret_index.back() >= 0); |
| 6558 |
} |
| 6559 |
|
| 6560 |
CHECK(text_edit->get_caret_count() == 4); |
| 6561 |
|
| 6562 |
for (int i = 0; i < 4; i++) { |
| 6563 |
text_edit->select(i, 0, i, 5, caret_index[i]); |
| 6564 |
} |
| 6565 |
|
| 6566 |
CHECK(text_edit->get_caret_count() == 4); |
| 6567 |
for (int i = 0; i < 4; i++) { |
| 6568 |
CHECK(text_edit->has_selection(caret_index[i])); |
| 6569 |
CHECK(text_edit->get_selection_from_line(caret_index[i]) == i); |
| 6570 |
CHECK(text_edit->get_selection_from_column(caret_index[i]) == 0); |
| 6571 |
CHECK(text_edit->get_selection_to_line(caret_index[i]) == i); |
| 6572 |
CHECK(text_edit->get_selection_to_column(caret_index[i]) == 5); |
| 6573 |
} |
| 6574 |
text_edit->begin_complex_operation(); |
| 6575 |
text_edit->deselect(); |
| 6576 |
text_edit->set_text("New Line Text"); |
| 6577 |
text_edit->select(0, 0, 0, 7, 0); |
| 6578 |
text_edit->end_complex_operation(); |
| 6579 |
|
| 6580 |
CHECK(text_edit->get_caret_count() == 1); |
| 6581 |
CHECK(text_edit->get_selected_text(0) == "New Lin"); |
| 6582 |
|
| 6583 |
text_edit->undo(); |
| 6584 |
|
| 6585 |
CHECK(text_edit->get_caret_count() == 4); |
| 6586 |
for (int i = 0; i < 4; i++) { |
| 6587 |
CHECK(text_edit->has_selection(caret_index[i])); |
| 6588 |
CHECK(text_edit->get_selection_from_line(caret_index[i]) == i); |
| 6589 |
CHECK(text_edit->get_selection_from_column(caret_index[i]) == 0); |
| 6590 |
CHECK(text_edit->get_selection_to_line(caret_index[i]) == i); |
| 6591 |
CHECK(text_edit->get_selection_to_column(caret_index[i]) == 5); |
| 6592 |
} |
| 6593 |
} |
| 6594 |
|
| 6595 |
memdelete(text_edit); |
| 6596 |
} |
| 6597 |
|
| 6598 |
TEST_CASE("[SceneTree][TextEdit] search") { |
| 6599 |
TextEdit *text_edit = memnew(TextEdit); |
| 6600 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 6601 |
|
| 6602 |
text_edit->set_text("hay needle, hay\nHAY NEEDLE, HAY\nwordword.word.word"); |
| 6603 |
int length = text_edit->get_line(1).length(); |
| 6604 |
|
| 6605 |
CHECK(text_edit->search("test", 0, 0, 0) == Point2i(-1, -1)); |
| 6606 |
CHECK(text_edit->search("test", TextEdit::SEARCH_MATCH_CASE, 0, 0) == Point2i(-1, -1)); |
| 6607 |
CHECK(text_edit->search("test", TextEdit::SEARCH_WHOLE_WORDS, 0, 0) == Point2i(-1, -1)); |
| 6608 |
CHECK(text_edit->search("test", TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(-1, -1)); |
| 6609 |
|
| 6610 |
CHECK(text_edit->search("test", 0, 1, length) == Point2i(-1, -1)); |
| 6611 |
CHECK(text_edit->search("test", TextEdit::SEARCH_MATCH_CASE, 1, length) == Point2i(-1, -1)); |
| 6612 |
CHECK(text_edit->search("test", TextEdit::SEARCH_WHOLE_WORDS, 1, length) == Point2i(-1, -1)); |
| 6613 |
CHECK(text_edit->search("test", TextEdit::SEARCH_BACKWARDS, 1, length) == Point2i(-1, -1)); |
| 6614 |
|
| 6615 |
CHECK(text_edit->search("needle", 0, 0, 0) == Point2i(4, 0)); |
| 6616 |
CHECK(text_edit->search("needle", 0, 1, length) == Point2i(4, 0)); |
| 6617 |
CHECK(text_edit->search("needle", 0, 0, 5) == Point2i(4, 1)); |
| 6618 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(4, 1)); |
| 6619 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_BACKWARDS, 1, 5) == Point2i(4, 1)); |
| 6620 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_BACKWARDS, 1, 3) == Point2i(4, 0)); |
| 6621 |
|
| 6622 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_MATCH_CASE, 0, 0) == Point2i(4, 0)); |
| 6623 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_MATCH_CASE | TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(4, 0)); |
| 6624 |
|
| 6625 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_WHOLE_WORDS | TextEdit::SEARCH_MATCH_CASE, 0, 0) == Point2i(4, 0)); |
| 6626 |
CHECK(text_edit->search("needle", TextEdit::SEARCH_WHOLE_WORDS | TextEdit::SEARCH_MATCH_CASE | TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(4, 0)); |
| 6627 |
|
| 6628 |
CHECK(text_edit->search("need", TextEdit::SEARCH_MATCH_CASE, 0, 0) == Point2i(4, 0)); |
| 6629 |
CHECK(text_edit->search("need", TextEdit::SEARCH_MATCH_CASE | TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(4, 0)); |
| 6630 |
|
| 6631 |
CHECK(text_edit->search("need", TextEdit::SEARCH_WHOLE_WORDS | TextEdit::SEARCH_MATCH_CASE, 0, 0) == Point2i(-1, -1)); |
| 6632 |
CHECK(text_edit->search("need", TextEdit::SEARCH_WHOLE_WORDS | TextEdit::SEARCH_MATCH_CASE | TextEdit::SEARCH_BACKWARDS, 0, 0) == Point2i(-1, -1)); |
| 6633 |
|
| 6634 |
CHECK(text_edit->search("word", TextEdit::SEARCH_WHOLE_WORDS, 2, 0) == Point2i(9, 2)); |
| 6635 |
CHECK(text_edit->search("word", TextEdit::SEARCH_WHOLE_WORDS, 2, 10) == Point2i(14, 2)); |
| 6636 |
CHECK(text_edit->search(".word", TextEdit::SEARCH_WHOLE_WORDS, 2, 0) == Point2i(8, 2)); |
| 6637 |
CHECK(text_edit->search("word.", TextEdit::SEARCH_WHOLE_WORDS, 2, 0) == Point2i(9, 2)); |
| 6638 |
|
| 6639 |
ERR_PRINT_OFF; |
| 6640 |
CHECK(text_edit->search("", 0, 0, 0) == Point2i(-1, -1)); |
| 6641 |
CHECK(text_edit->search("needle", 0, -1, 0) == Point2i(-1, -1)); |
| 6642 |
CHECK(text_edit->search("needle", 0, 0, -1) == Point2i(-1, -1)); |
| 6643 |
CHECK(text_edit->search("needle", 0, 100, 0) == Point2i(-1, -1)); |
| 6644 |
CHECK(text_edit->search("needle", 0, 0, 100) == Point2i(-1, -1)); |
| 6645 |
ERR_PRINT_ON; |
| 6646 |
|
| 6647 |
memdelete(text_edit); |
| 6648 |
} |
| 6649 |
|
| 6650 |
TEST_CASE("[SceneTree][TextEdit] mouse") { |
| 6651 |
TextEdit *text_edit = memnew(TextEdit); |
| 6652 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 6653 |
|
| 6654 |
text_edit->set_size(Size2(800, 200)); |
| 6655 |
|
| 6656 |
CHECK(text_edit->get_rect_at_line_column(0, 0).get_position() == Point2i(0, 0)); |
| 6657 |
|
| 6658 |
text_edit->set_line(0, "A"); |
| 6659 |
MessageQueue::get_singleton()->flush(); |
| 6660 |
CHECK(text_edit->get_rect_at_line_column(0, 1).get_position().x > 0); |
| 6661 |
|
| 6662 |
text_edit->clear(); |
| 6663 |
|
| 6664 |
text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); |
| 6665 |
MessageQueue::get_singleton()->flush(); |
| 6666 |
|
| 6667 |
CHECK(text_edit->get_word_at_pos(text_edit->get_pos_at_line_column(0, 1)) == "Lorem"); |
| 6668 |
CHECK(text_edit->get_word_at_pos(text_edit->get_pos_at_line_column(0, 9)) == "ipsum"); |
| 6669 |
|
| 6670 |
ERR_PRINT_OFF; |
| 6671 |
CHECK(text_edit->get_pos_at_line_column(0, -1) == Point2i(-1, -1)); |
| 6672 |
CHECK(text_edit->get_pos_at_line_column(-1, 0) == Point2i(-1, -1)); |
| 6673 |
CHECK(text_edit->get_pos_at_line_column(-1, -1) == Point2i(-1, -1)); |
| 6674 |
|
| 6675 |
CHECK(text_edit->get_pos_at_line_column(0, 500) == Point2i(-1, -1)); |
| 6676 |
CHECK(text_edit->get_pos_at_line_column(2, 0) == Point2i(-1, -1)); |
| 6677 |
CHECK(text_edit->get_pos_at_line_column(2, 500) == Point2i(-1, -1)); |
| 6678 |
|
| 6679 |
|
| 6680 |
CHECK(text_edit->get_pos_at_line_column(0, text_edit->get_line(0).length() - 1) == Point2i(-1, -1)); |
| 6681 |
ERR_PRINT_ON; |
| 6682 |
|
| 6683 |
|
| 6684 |
Point2i start_pos = text_edit->get_pos_at_line_column(0, 0); |
| 6685 |
Point2i end_pos = text_edit->get_pos_at_line_column(0, 104); |
| 6686 |
|
| 6687 |
CHECK(text_edit->get_line_column_at_pos(Point2i(start_pos.x, start_pos.y)) == Point2i(0, 0)); |
| 6688 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y)) == Point2i(103, 0)); |
| 6689 |
|
| 6690 |
|
| 6691 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y), false) == Point2i(88, 0)); |
| 6692 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y + 100), false) == Point2i(-1, -1)); |
| 6693 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y + 100), false) == Point2i(-1, -1)); |
| 6694 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y - 100), false) == Point2i(103, 0)); |
| 6695 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y - 100), false) == Point2i(88, 0)); |
| 6696 |
|
| 6697 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y)) == Point2i(88, 0)); |
| 6698 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y + 100)) == Point2i(140, 0)); |
| 6699 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y + 100)) == Point2i(140, 0)); |
| 6700 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x, end_pos.y - 100)) == Point2i(103, 0)); |
| 6701 |
CHECK(text_edit->get_line_column_at_pos(Point2i(end_pos.x - 100, end_pos.y - 100)) == Point2i(88, 0)); |
| 6702 |
|
| 6703 |
memdelete(text_edit); |
| 6704 |
} |
| 6705 |
|
| 6706 |
TEST_CASE("[SceneTree][TextEdit] caret") { |
| 6707 |
TextEdit *text_edit = memnew(TextEdit); |
| 6708 |
text_edit->set_context_menu_enabled(false); |
| 6709 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 6710 |
|
| 6711 |
text_edit->set_size(Size2(800, 200)); |
| 6712 |
text_edit->grab_focus(); |
| 6713 |
text_edit->set_line(0, "ffi"); |
| 6714 |
|
| 6715 |
text_edit->set_caret_mid_grapheme_enabled(true); |
| 6716 |
CHECK(text_edit->is_caret_mid_grapheme_enabled()); |
| 6717 |
|
| 6718 |
SEND_GUI_ACTION("ui_text_caret_right"); |
| 6719 |
CHECK(text_edit->get_caret_column() == 1); |
| 6720 |
|
| 6721 |
SEND_GUI_ACTION("ui_text_caret_right"); |
| 6722 |
CHECK(text_edit->get_caret_column() == 2); |
| 6723 |
|
| 6724 |
SEND_GUI_ACTION("ui_text_caret_right"); |
| 6725 |
CHECK(text_edit->get_caret_column() == 3); |
| 6726 |
|
| 6727 |
SEND_GUI_ACTION("ui_text_caret_left"); |
| 6728 |
CHECK(text_edit->get_caret_column() == 2); |
| 6729 |
|
| 6730 |
text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); |
| 6731 |
for (int i = 0; i < 3; i++) { |
| 6732 |
text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); |
| 6733 |
} |
| 6734 |
MessageQueue::get_singleton()->flush(); |
| 6735 |
|
| 6736 |
text_edit->set_caret_blink_enabled(false); |
| 6737 |
CHECK_FALSE(text_edit->is_caret_blink_enabled()); |
| 6738 |
|
| 6739 |
text_edit->set_caret_blink_enabled(true); |
| 6740 |
CHECK(text_edit->is_caret_blink_enabled()); |
| 6741 |
|
| 6742 |
text_edit->set_caret_blink_interval(10); |
| 6743 |
CHECK(text_edit->get_caret_blink_interval() == 10); |
| 6744 |
|
| 6745 |
ERR_PRINT_OFF; |
| 6746 |
text_edit->set_caret_blink_interval(-1); |
| 6747 |
CHECK(text_edit->get_caret_blink_interval() == 10); |
| 6748 |
|
| 6749 |
text_edit->set_caret_blink_interval(0); |
| 6750 |
CHECK(text_edit->get_caret_blink_interval() == 10); |
| 6751 |
ERR_PRINT_ON; |
| 6752 |
|
| 6753 |
text_edit->set_caret_type(TextEdit::CaretType::CARET_TYPE_LINE); |
| 6754 |
CHECK(text_edit->get_caret_type() == TextEdit::CaretType::CARET_TYPE_LINE); |
| 6755 |
|
| 6756 |
text_edit->set_caret_type(TextEdit::CaretType::CARET_TYPE_BLOCK); |
| 6757 |
CHECK(text_edit->get_caret_type() == TextEdit::CaretType::CARET_TYPE_BLOCK); |
| 6758 |
|
| 6759 |
text_edit->set_caret_type(TextEdit::CaretType::CARET_TYPE_LINE); |
| 6760 |
CHECK(text_edit->get_caret_type() == TextEdit::CaretType::CARET_TYPE_LINE); |
| 6761 |
|
| 6762 |
int caret_col = text_edit->get_caret_column(); |
| 6763 |
text_edit->set_move_caret_on_right_click_enabled(false); |
| 6764 |
CHECK_FALSE(text_edit->is_move_caret_on_right_click_enabled()); |
| 6765 |
|
| 6766 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(100, 1), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); |
| 6767 |
CHECK(text_edit->get_caret_column() == caret_col); |
| 6768 |
|
| 6769 |
text_edit->set_move_caret_on_right_click_enabled(true); |
| 6770 |
CHECK(text_edit->is_move_caret_on_right_click_enabled()); |
| 6771 |
|
| 6772 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(100, 1), MouseButton::RIGHT, MouseButtonMask::RIGHT, Key::NONE); |
| 6773 |
CHECK(text_edit->get_caret_column() != caret_col); |
| 6774 |
|
| 6775 |
text_edit->set_move_caret_on_right_click_enabled(false); |
| 6776 |
CHECK_FALSE(text_edit->is_move_caret_on_right_click_enabled()); |
| 6777 |
|
| 6778 |
text_edit->set_caret_column(0); |
| 6779 |
CHECK(text_edit->get_word_under_caret() == "Lorem"); |
| 6780 |
|
| 6781 |
text_edit->set_caret_column(4); |
| 6782 |
CHECK(text_edit->get_word_under_caret() == "Lorem"); |
| 6783 |
|
| 6784 |
text_edit->set_caret_column(1); |
| 6785 |
text_edit->add_caret(0, 15); |
| 6786 |
CHECK(text_edit->get_word_under_caret() == "Lorem\ndolor"); |
| 6787 |
text_edit->remove_secondary_carets(); |
| 6788 |
|
| 6789 |
|
| 6790 |
text_edit->set_caret_column(5); |
| 6791 |
CHECK(text_edit->get_word_under_caret() == ""); |
| 6792 |
|
| 6793 |
text_edit->set_caret_column(6); |
| 6794 |
CHECK(text_edit->get_word_under_caret() == ""); |
| 6795 |
|
| 6796 |
text_edit->set_caret_line(1); |
| 6797 |
CHECK(text_edit->get_caret_line() == 1); |
| 6798 |
|
| 6799 |
text_edit->set_caret_line(-1); |
| 6800 |
CHECK(text_edit->get_caret_line() == 0); |
| 6801 |
text_edit->set_caret_line(100); |
| 6802 |
CHECK(text_edit->get_caret_line() == 3); |
| 6803 |
|
| 6804 |
text_edit->set_caret_column(-1); |
| 6805 |
CHECK(text_edit->get_caret_column() == 0); |
| 6806 |
text_edit->set_caret_column(10000000); |
| 6807 |
CHECK(text_edit->get_caret_column() == 141); |
| 6808 |
|
| 6809 |
memdelete(text_edit); |
| 6810 |
} |
| 6811 |
|
| 6812 |
TEST_CASE("[SceneTree][TextEdit] multicaret") { |
| 6813 |
TextEdit *text_edit = memnew(TextEdit); |
| 6814 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 6815 |
text_edit->set_multiple_carets_enabled(true); |
| 6816 |
|
| 6817 |
Array empty_signal_args = { {} }; |
| 6818 |
|
| 6819 |
SIGNAL_WATCH(text_edit, "caret_changed"); |
| 6820 |
|
| 6821 |
text_edit->set_text("this is\nsome test\ntext"); |
| 6822 |
text_edit->set_caret_line(0); |
| 6823 |
text_edit->set_caret_column(0); |
| 6824 |
MessageQueue::get_singleton()->flush(); |
| 6825 |
SIGNAL_DISCARD("caret_changed"); |
| 6826 |
|
| 6827 |
SUBCASE("[TextEdit] add remove caret") { |
| 6828 |
|
| 6829 |
CHECK(text_edit->add_caret(0, 0) == -1); |
| 6830 |
MessageQueue::get_singleton()->flush(); |
| 6831 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6832 |
|
| 6833 |
|
| 6834 |
text_edit->select(2, 4, 0, 0); |
| 6835 |
|
| 6836 |
|
| 6837 |
CHECK(text_edit->add_caret(0, 0) == -1); |
| 6838 |
CHECK(text_edit->add_caret(2, 4) == -1); |
| 6839 |
CHECK(text_edit->add_caret(1, 2) == -1); |
| 6840 |
|
| 6841 |
|
| 6842 |
CHECK(text_edit->add_caret(-1, 0) == -1); |
| 6843 |
CHECK(text_edit->add_caret(5, 0) == -1); |
| 6844 |
CHECK(text_edit->add_caret(0, 100) == -1); |
| 6845 |
|
| 6846 |
MessageQueue::get_singleton()->flush(); |
| 6847 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6848 |
|
| 6849 |
CHECK(text_edit->get_caret_count() == 1); |
| 6850 |
|
| 6851 |
text_edit->deselect(); |
| 6852 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6853 |
|
| 6854 |
CHECK(text_edit->add_caret(0, 1) == 1); |
| 6855 |
MessageQueue::get_singleton()->flush(); |
| 6856 |
SIGNAL_CHECK("caret_changed", empty_signal_args); |
| 6857 |
CHECK(text_edit->get_caret_count() == 2); |
| 6858 |
|
| 6859 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 6860 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 6861 |
|
| 6862 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 6863 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 6864 |
|
| 6865 |
ERR_PRINT_OFF; |
| 6866 |
text_edit->remove_caret(-1); |
| 6867 |
text_edit->remove_caret(5); |
| 6868 |
ERR_PRINT_ON; |
| 6869 |
CHECK(text_edit->get_caret_count() == 2); |
| 6870 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6871 |
|
| 6872 |
text_edit->remove_caret(0); |
| 6873 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 6874 |
CHECK(text_edit->get_caret_count() == 1); |
| 6875 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 6876 |
CHECK(text_edit->get_caret_column(0) == 1); |
| 6877 |
|
| 6878 |
ERR_PRINT_OFF; |
| 6879 |
text_edit->remove_caret(0); |
| 6880 |
CHECK(text_edit->get_caret_count() == 1); |
| 6881 |
ERR_PRINT_ON; |
| 6882 |
} |
| 6883 |
|
| 6884 |
SUBCASE("[TextEdit] sort carets") { |
| 6885 |
Vector<int> sorted_carets = { 0, 1, 2 }; |
| 6886 |
|
| 6887 |
|
| 6888 |
text_edit->remove_secondary_carets(); |
| 6889 |
text_edit->add_caret(0, 1); |
| 6890 |
text_edit->add_caret(1, 0); |
| 6891 |
CHECK(text_edit->get_sorted_carets() == sorted_carets); |
| 6892 |
|
| 6893 |
|
| 6894 |
sorted_carets = { 2, 1, 0 }; |
| 6895 |
text_edit->remove_secondary_carets(); |
| 6896 |
text_edit->set_caret_line(1); |
| 6897 |
text_edit->add_caret(0, 1); |
| 6898 |
text_edit->add_caret(0, 0); |
| 6899 |
CHECK(text_edit->get_sorted_carets() == sorted_carets); |
| 6900 |
|
| 6901 |
|
| 6902 |
sorted_carets = { 0, 2, 1, 3 }; |
| 6903 |
text_edit->remove_secondary_carets(); |
| 6904 |
text_edit->set_caret_line(0); |
| 6905 |
text_edit->add_caret(1, 0); |
| 6906 |
text_edit->add_caret(0, 1); |
| 6907 |
text_edit->add_caret(1, 1); |
| 6908 |
CHECK(text_edit->get_sorted_carets() == sorted_carets); |
| 6909 |
|
| 6910 |
|
| 6911 |
sorted_carets = { 0, 1, 3, 2 }; |
| 6912 |
text_edit->remove_secondary_carets(); |
| 6913 |
text_edit->add_caret(0, 1); |
| 6914 |
text_edit->add_caret(1, 2); |
| 6915 |
text_edit->add_caret(0, 2); |
| 6916 |
text_edit->set_caret_column(1, false, 3); |
| 6917 |
CHECK(text_edit->get_sorted_carets() == sorted_carets); |
| 6918 |
|
| 6919 |
|
| 6920 |
sorted_carets = { 1, 0 }; |
| 6921 |
text_edit->remove_secondary_carets(); |
| 6922 |
text_edit->select(1, 3, 1, 5); |
| 6923 |
text_edit->add_caret(2, 0); |
| 6924 |
text_edit->select(1, 0, 2, 0, 1); |
| 6925 |
CHECK(text_edit->get_sorted_carets() == sorted_carets); |
| 6926 |
} |
| 6927 |
|
| 6928 |
SUBCASE("[TextEdit] merge carets") { |
| 6929 |
text_edit->set_text("this is some text\nfor selection"); |
| 6930 |
MessageQueue::get_singleton()->flush(); |
| 6931 |
|
| 6932 |
|
| 6933 |
text_edit->set_caret_line(0); |
| 6934 |
text_edit->set_caret_column(4); |
| 6935 |
text_edit->add_caret(0, 6); |
| 6936 |
text_edit->add_caret(1, 6); |
| 6937 |
text_edit->merge_overlapping_carets(); |
| 6938 |
CHECK(text_edit->get_caret_count() == 3); |
| 6939 |
CHECK_FALSE(text_edit->has_selection()); |
| 6940 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 6941 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 6942 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 6943 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 6944 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 6945 |
CHECK(text_edit->get_caret_column(2) == 6); |
| 6946 |
text_edit->remove_secondary_carets(); |
| 6947 |
|
| 6948 |
|
| 6949 |
text_edit->begin_multicaret_edit(); |
| 6950 |
text_edit->set_caret_line(0); |
| 6951 |
text_edit->set_caret_column(4); |
| 6952 |
text_edit->add_caret(0, 4); |
| 6953 |
text_edit->merge_overlapping_carets(); |
| 6954 |
CHECK(text_edit->is_in_mulitcaret_edit()); |
| 6955 |
CHECK_FALSE(text_edit->has_selection()); |
| 6956 |
CHECK(text_edit->get_caret_count() == 2); |
| 6957 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 6958 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 6959 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 6960 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 6961 |
|
| 6962 |
|
| 6963 |
text_edit->end_multicaret_edit(); |
| 6964 |
CHECK_FALSE(text_edit->is_in_mulitcaret_edit()); |
| 6965 |
CHECK_FALSE(text_edit->has_selection()); |
| 6966 |
CHECK(text_edit->get_caret_count() == 1); |
| 6967 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 6968 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 6969 |
|
| 6970 |
|
| 6971 |
text_edit->set_caret_line(0); |
| 6972 |
text_edit->set_caret_column(4); |
| 6973 |
text_edit->add_caret(0, 2); |
| 6974 |
text_edit->add_caret(1, 4); |
| 6975 |
text_edit->select(0, 4, 1, 2, 0); |
| 6976 |
text_edit->select(0, 2, 0, 3, 1); |
| 6977 |
text_edit->select(1, 4, 1, 8, 2); |
| 6978 |
text_edit->merge_overlapping_carets(); |
| 6979 |
CHECK(text_edit->get_caret_count() == 3); |
| 6980 |
CHECK(text_edit->has_selection(0)); |
| 6981 |
CHECK(text_edit->has_selection(1)); |
| 6982 |
CHECK(text_edit->has_selection(2)); |
| 6983 |
text_edit->remove_secondary_carets(); |
| 6984 |
text_edit->deselect(); |
| 6985 |
|
| 6986 |
|
| 6987 |
text_edit->set_caret_line(0); |
| 6988 |
text_edit->set_caret_column(4); |
| 6989 |
text_edit->add_caret(1, 2); |
| 6990 |
text_edit->select(0, 4, 1, 2, 0); |
| 6991 |
text_edit->select(1, 2, 1, 5, 1); |
| 6992 |
text_edit->merge_overlapping_carets(); |
| 6993 |
CHECK(text_edit->get_caret_count() == 2); |
| 6994 |
CHECK(text_edit->has_selection(0)); |
| 6995 |
CHECK(text_edit->has_selection(1)); |
| 6996 |
text_edit->remove_secondary_carets(); |
| 6997 |
text_edit->deselect(); |
| 6998 |
|
| 6999 |
|
| 7000 |
text_edit->set_caret_line(0); |
| 7001 |
text_edit->set_caret_column(3); |
| 7002 |
text_edit->add_caret(0, 2); |
| 7003 |
text_edit->add_caret(1, 4); |
| 7004 |
text_edit->add_caret(1, 8); |
| 7005 |
text_edit->add_caret(1, 10); |
| 7006 |
text_edit->select(0, 2, 1, 8, 0); |
| 7007 |
text_edit->merge_overlapping_carets(); |
| 7008 |
CHECK(text_edit->get_caret_count() == 2); |
| 7009 |
CHECK(text_edit->has_selection(0)); |
| 7010 |
CHECK(text_edit->get_selection_from_line(0) == 0); |
| 7011 |
CHECK(text_edit->get_selection_from_column(0) == 2); |
| 7012 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 7013 |
CHECK(text_edit->get_selection_to_column(0) == 8); |
| 7014 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 7015 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 7016 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7017 |
CHECK(text_edit->get_caret_column(1) == 10); |
| 7018 |
text_edit->remove_secondary_carets(); |
| 7019 |
text_edit->deselect(); |
| 7020 |
|
| 7021 |
|
| 7022 |
text_edit->set_caret_line(0); |
| 7023 |
text_edit->set_caret_column(1); |
| 7024 |
text_edit->add_caret(0, 2); |
| 7025 |
text_edit->add_caret(0, 3); |
| 7026 |
text_edit->select(0, 2, 0, 6, 0); |
| 7027 |
text_edit->select(0, 4, 1, 3, 1); |
| 7028 |
text_edit->select(1, 0, 1, 5, 2); |
| 7029 |
text_edit->merge_overlapping_carets(); |
| 7030 |
CHECK(text_edit->get_caret_count() == 1); |
| 7031 |
CHECK(text_edit->has_selection(0)); |
| 7032 |
CHECK(text_edit->get_selection_from_line(0) == 0); |
| 7033 |
CHECK(text_edit->get_selection_from_column(0) == 2); |
| 7034 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 7035 |
CHECK(text_edit->get_selection_to_column(0) == 5); |
| 7036 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 7037 |
text_edit->remove_secondary_carets(); |
| 7038 |
text_edit->deselect(); |
| 7039 |
|
| 7040 |
|
| 7041 |
text_edit->set_caret_line(0); |
| 7042 |
text_edit->set_caret_column(1); |
| 7043 |
text_edit->add_caret(0, 2); |
| 7044 |
text_edit->add_caret(0, 3); |
| 7045 |
text_edit->select(0, 2, 0, 6, 0); |
| 7046 |
text_edit->select(0, 8, 1, 3, 1); |
| 7047 |
text_edit->select(0, 2, 1, 5, 2); |
| 7048 |
text_edit->merge_overlapping_carets(); |
| 7049 |
CHECK(text_edit->get_caret_count() == 1); |
| 7050 |
CHECK(text_edit->has_selection(0)); |
| 7051 |
CHECK(text_edit->get_selection_from_line(0) == 0); |
| 7052 |
CHECK(text_edit->get_selection_from_column(0) == 2); |
| 7053 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 7054 |
CHECK(text_edit->get_selection_to_column(0) == 5); |
| 7055 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 7056 |
text_edit->remove_secondary_carets(); |
| 7057 |
text_edit->deselect(); |
| 7058 |
|
| 7059 |
|
| 7060 |
text_edit->set_caret_line(0); |
| 7061 |
text_edit->set_caret_column(1); |
| 7062 |
text_edit->add_caret(0, 2); |
| 7063 |
text_edit->select(0, 2, 1, 6, 0); |
| 7064 |
text_edit->select(0, 2, 1, 6, 1); |
| 7065 |
text_edit->merge_overlapping_carets(); |
| 7066 |
CHECK(text_edit->has_selection(0)); |
| 7067 |
CHECK(text_edit->get_selection_from_line(0) == 0); |
| 7068 |
CHECK(text_edit->get_selection_from_column(0) == 2); |
| 7069 |
CHECK(text_edit->get_selection_to_line(0) == 1); |
| 7070 |
CHECK(text_edit->get_selection_to_column(0) == 6); |
| 7071 |
CHECK(text_edit->is_caret_after_selection_origin(0)); |
| 7072 |
} |
| 7073 |
|
| 7074 |
SUBCASE("[TextEdit] collapse carets") { |
| 7075 |
text_edit->set_text("this is some text\nfor selection"); |
| 7076 |
|
| 7077 |
|
| 7078 |
text_edit->add_caret(0, 9); |
| 7079 |
text_edit->add_caret(1, 0); |
| 7080 |
text_edit->add_caret(1, 2); |
| 7081 |
text_edit->add_caret(1, 6); |
| 7082 |
text_edit->begin_multicaret_edit(); |
| 7083 |
|
| 7084 |
text_edit->collapse_carets(0, 8, 1, 2); |
| 7085 |
CHECK(text_edit->get_caret_count() == 5); |
| 7086 |
CHECK_FALSE(text_edit->has_selection()); |
| 7087 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7088 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 7089 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 7090 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 7091 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7092 |
CHECK(text_edit->get_caret_column(2) == 8); |
| 7093 |
CHECK(text_edit->get_caret_line(3) == 1); |
| 7094 |
CHECK(text_edit->get_caret_column(3) == 2); |
| 7095 |
CHECK(text_edit->get_caret_line(4) == 1); |
| 7096 |
CHECK(text_edit->get_caret_column(4) == 6); |
| 7097 |
CHECK_FALSE(text_edit->multicaret_edit_ignore_caret(0)); |
| 7098 |
CHECK(text_edit->multicaret_edit_ignore_caret(1)); |
| 7099 |
CHECK(text_edit->multicaret_edit_ignore_caret(2)); |
| 7100 |
CHECK_FALSE(text_edit->multicaret_edit_ignore_caret(3)); |
| 7101 |
CHECK_FALSE(text_edit->multicaret_edit_ignore_caret(4)); |
| 7102 |
|
| 7103 |
|
| 7104 |
text_edit->end_multicaret_edit(); |
| 7105 |
CHECK(text_edit->get_caret_count() == 4); |
| 7106 |
CHECK_FALSE(text_edit->has_selection()); |
| 7107 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7108 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 7109 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 7110 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 7111 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 7112 |
CHECK(text_edit->get_caret_column(2) == 2); |
| 7113 |
CHECK(text_edit->get_caret_line(3) == 1); |
| 7114 |
CHECK(text_edit->get_caret_column(3) == 6); |
| 7115 |
text_edit->remove_secondary_carets(); |
| 7116 |
|
| 7117 |
|
| 7118 |
text_edit->set_caret_line(0); |
| 7119 |
text_edit->set_caret_column(3); |
| 7120 |
text_edit->add_caret(1, 2); |
| 7121 |
text_edit->collapse_carets(0, 3, 1, 2, true); |
| 7122 |
CHECK(text_edit->get_caret_count() == 1); |
| 7123 |
CHECK_FALSE(text_edit->has_selection()); |
| 7124 |
CHECK(text_edit->get_caret_line() == 0); |
| 7125 |
CHECK(text_edit->get_caret_column() == 3); |
| 7126 |
text_edit->remove_secondary_carets(); |
| 7127 |
|
| 7128 |
|
| 7129 |
text_edit->select(0, 5, 0, 7); |
| 7130 |
text_edit->collapse_carets(0, 3, 1, 2); |
| 7131 |
CHECK_FALSE(text_edit->has_selection()); |
| 7132 |
CHECK(text_edit->get_caret_line() == 0); |
| 7133 |
CHECK(text_edit->get_caret_column() == 3); |
| 7134 |
|
| 7135 |
|
| 7136 |
text_edit->select(0, 1, 0, 7); |
| 7137 |
text_edit->collapse_carets(0, 3, 1, 2); |
| 7138 |
CHECK(text_edit->has_selection()); |
| 7139 |
CHECK(text_edit->get_caret_line() == 0); |
| 7140 |
CHECK(text_edit->get_caret_column() == 3); |
| 7141 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 7142 |
CHECK(text_edit->get_selection_origin_column() == 1); |
| 7143 |
text_edit->deselect(); |
| 7144 |
|
| 7145 |
|
| 7146 |
text_edit->select(0, 7, 0, 1); |
| 7147 |
text_edit->collapse_carets(0, 3, 1, 2); |
| 7148 |
CHECK(text_edit->has_selection()); |
| 7149 |
CHECK(text_edit->get_caret_line() == 0); |
| 7150 |
CHECK(text_edit->get_caret_column() == 1); |
| 7151 |
CHECK(text_edit->get_selection_origin_line() == 0); |
| 7152 |
CHECK(text_edit->get_selection_origin_column() == 3); |
| 7153 |
text_edit->deselect(); |
| 7154 |
} |
| 7155 |
|
| 7156 |
SUBCASE("[TextEdit] add caret at carets") { |
| 7157 |
text_edit->remove_secondary_carets(); |
| 7158 |
text_edit->set_caret_line(1); |
| 7159 |
text_edit->set_caret_column(9); |
| 7160 |
|
| 7161 |
|
| 7162 |
text_edit->add_caret_at_carets(true); |
| 7163 |
CHECK(text_edit->get_caret_count() == 2); |
| 7164 |
CHECK_FALSE(text_edit->has_selection()); |
| 7165 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7166 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 7167 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7168 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7169 |
|
| 7170 |
|
| 7171 |
text_edit->add_caret_at_carets(true); |
| 7172 |
CHECK(text_edit->get_caret_count() == 2); |
| 7173 |
CHECK_FALSE(text_edit->has_selection()); |
| 7174 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7175 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 7176 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7177 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7178 |
|
| 7179 |
|
| 7180 |
text_edit->add_caret_at_carets(false); |
| 7181 |
CHECK(text_edit->get_caret_count() == 3); |
| 7182 |
CHECK_FALSE(text_edit->has_selection()); |
| 7183 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7184 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 7185 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7186 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7187 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7188 |
CHECK(text_edit->get_caret_column(2) == 7); |
| 7189 |
|
| 7190 |
|
| 7191 |
text_edit->add_caret_at_carets(false); |
| 7192 |
CHECK(text_edit->get_caret_count() == 3); |
| 7193 |
CHECK_FALSE(text_edit->has_selection()); |
| 7194 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7195 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 7196 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7197 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7198 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7199 |
CHECK(text_edit->get_caret_column(2) == 7); |
| 7200 |
|
| 7201 |
|
| 7202 |
text_edit->remove_secondary_carets(); |
| 7203 |
text_edit->select(2, 1, 2, 4); |
| 7204 |
text_edit->add_caret_at_carets(true); |
| 7205 |
CHECK(text_edit->get_caret_count() == 1); |
| 7206 |
CHECK(text_edit->has_selection(0)); |
| 7207 |
CHECK(text_edit->get_selection_origin_line(0) == 2); |
| 7208 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 7209 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 7210 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7211 |
|
| 7212 |
|
| 7213 |
text_edit->select(0, 1, 0, 4); |
| 7214 |
text_edit->add_caret_at_carets(false); |
| 7215 |
CHECK(text_edit->get_caret_count() == 1); |
| 7216 |
CHECK(text_edit->has_selection(0)); |
| 7217 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 7218 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 7219 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7220 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7221 |
|
| 7222 |
|
| 7223 |
text_edit->select(0, 0, 0, 4); |
| 7224 |
text_edit->add_caret_at_carets(true); |
| 7225 |
CHECK(text_edit->get_caret_count() == 2); |
| 7226 |
CHECK(text_edit->has_selection(0)); |
| 7227 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 7228 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 7229 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7230 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7231 |
CHECK(text_edit->has_selection(1)); |
| 7232 |
CHECK(text_edit->get_selection_origin_line(1) == 1); |
| 7233 |
CHECK(text_edit->get_selection_origin_column(1) == 0); |
| 7234 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7235 |
CHECK(text_edit->get_caret_column(1) == 3); |
| 7236 |
|
| 7237 |
|
| 7238 |
text_edit->add_caret_at_carets(true); |
| 7239 |
CHECK(text_edit->get_caret_count() == 3); |
| 7240 |
CHECK(text_edit->has_selection(0)); |
| 7241 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 7242 |
CHECK(text_edit->get_selection_origin_column(0) == 0); |
| 7243 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7244 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7245 |
CHECK(text_edit->has_selection(1)); |
| 7246 |
CHECK(text_edit->get_selection_origin_line(1) == 1); |
| 7247 |
CHECK(text_edit->get_selection_origin_column(1) == 0); |
| 7248 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7249 |
CHECK(text_edit->get_caret_column(1) == 3); |
| 7250 |
CHECK(text_edit->has_selection(2)); |
| 7251 |
CHECK(text_edit->get_selection_origin_line(2) == 2); |
| 7252 |
CHECK(text_edit->get_selection_origin_column(2) == 0); |
| 7253 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 7254 |
CHECK(text_edit->get_caret_column(2) == 4); |
| 7255 |
|
| 7256 |
text_edit->set_text("\tthis is\nsome\n\ttest text"); |
| 7257 |
MessageQueue::get_singleton()->flush(); |
| 7258 |
|
| 7259 |
|
| 7260 |
text_edit->remove_secondary_carets(); |
| 7261 |
text_edit->deselect(); |
| 7262 |
text_edit->set_caret_line(0); |
| 7263 |
text_edit->set_caret_column(6); |
| 7264 |
text_edit->add_caret_at_carets(true); |
| 7265 |
text_edit->add_caret_at_carets(true); |
| 7266 |
CHECK_FALSE(text_edit->has_selection()); |
| 7267 |
CHECK(text_edit->get_caret_count() == 3); |
| 7268 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7269 |
CHECK(text_edit->get_caret_column(0) == 6); |
| 7270 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7271 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7272 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 7273 |
CHECK(text_edit->get_caret_column(2) == 6); |
| 7274 |
|
| 7275 |
|
| 7276 |
text_edit->remove_secondary_carets(); |
| 7277 |
text_edit->deselect(); |
| 7278 |
text_edit->set_caret_line(2); |
| 7279 |
text_edit->set_caret_column(9); |
| 7280 |
text_edit->add_caret_at_carets(false); |
| 7281 |
text_edit->add_caret_at_carets(false); |
| 7282 |
CHECK_FALSE(text_edit->has_selection()); |
| 7283 |
CHECK(text_edit->get_caret_count() == 3); |
| 7284 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 7285 |
CHECK(text_edit->get_caret_column(0) == 9); |
| 7286 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7287 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7288 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7289 |
CHECK(text_edit->get_caret_column(2) == 8); |
| 7290 |
|
| 7291 |
|
| 7292 |
text_edit->remove_secondary_carets(); |
| 7293 |
text_edit->deselect(); |
| 7294 |
text_edit->select(0, 8, 0, 5); |
| 7295 |
text_edit->add_caret_at_carets(true); |
| 7296 |
text_edit->add_caret_at_carets(true); |
| 7297 |
CHECK(text_edit->get_caret_count() == 3); |
| 7298 |
CHECK(text_edit->has_selection(0)); |
| 7299 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 7300 |
CHECK(text_edit->get_selection_origin_column(0) == 8); |
| 7301 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7302 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 7303 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 7304 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7305 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7306 |
CHECK(text_edit->has_selection(2)); |
| 7307 |
CHECK(text_edit->get_selection_origin_line(2) == 2); |
| 7308 |
CHECK(text_edit->get_selection_origin_column(2) == 7); |
| 7309 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 7310 |
CHECK(text_edit->get_caret_column(2) == 5); |
| 7311 |
|
| 7312 |
|
| 7313 |
text_edit->remove_secondary_carets(); |
| 7314 |
text_edit->deselect(); |
| 7315 |
text_edit->select(2, 9, 2, 5); |
| 7316 |
text_edit->add_caret_at_carets(false); |
| 7317 |
text_edit->add_caret_at_carets(false); |
| 7318 |
CHECK(text_edit->get_caret_count() == 3); |
| 7319 |
CHECK(text_edit->has_selection(0)); |
| 7320 |
CHECK(text_edit->get_selection_origin_line(0) == 2); |
| 7321 |
CHECK(text_edit->get_selection_origin_column(0) == 9); |
| 7322 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 7323 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 7324 |
CHECK_FALSE(text_edit->has_selection(1)); |
| 7325 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7326 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7327 |
CHECK(text_edit->has_selection(2)); |
| 7328 |
CHECK(text_edit->get_selection_origin_line(2) == 0); |
| 7329 |
CHECK(text_edit->get_selection_origin_column(2) == 8); |
| 7330 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7331 |
CHECK(text_edit->get_caret_column(2) == 5); |
| 7332 |
|
| 7333 |
|
| 7334 |
text_edit->remove_secondary_carets(); |
| 7335 |
text_edit->deselect(); |
| 7336 |
text_edit->select(0, 1, 0, 5); |
| 7337 |
text_edit->add_caret(1, 0); |
| 7338 |
text_edit->select(1, 1, 1, 3, 1); |
| 7339 |
text_edit->add_caret_at_carets(true); |
| 7340 |
CHECK(text_edit->get_caret_count() == 3); |
| 7341 |
CHECK(text_edit->has_selection(0)); |
| 7342 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 7343 |
CHECK(text_edit->get_selection_origin_column(0) == 1); |
| 7344 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7345 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 7346 |
CHECK(text_edit->has_selection(1)); |
| 7347 |
CHECK(text_edit->get_selection_origin_line(1) == 1); |
| 7348 |
CHECK(text_edit->get_selection_origin_column(1) == 1); |
| 7349 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7350 |
CHECK(text_edit->get_caret_column(1) == 4); |
| 7351 |
CHECK(text_edit->has_selection(2)); |
| 7352 |
CHECK(text_edit->get_selection_origin_line(2) == 2); |
| 7353 |
CHECK(text_edit->get_selection_origin_column(2) == 0); |
| 7354 |
CHECK(text_edit->get_caret_line(2) == 2); |
| 7355 |
CHECK(text_edit->get_caret_column(2) == 3); |
| 7356 |
|
| 7357 |
|
| 7358 |
text_edit->remove_secondary_carets(); |
| 7359 |
text_edit->deselect(); |
| 7360 |
text_edit->set_caret_line(0); |
| 7361 |
text_edit->set_caret_column(1); |
| 7362 |
text_edit->select(0, 3, 1, 1); |
| 7363 |
text_edit->add_caret_at_carets(true); |
| 7364 |
CHECK(text_edit->get_caret_count() == 2); |
| 7365 |
CHECK(text_edit->has_selection(0)); |
| 7366 |
CHECK(text_edit->get_selection_origin_line(0) == 0); |
| 7367 |
CHECK(text_edit->get_selection_origin_column(0) == 3); |
| 7368 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7369 |
CHECK(text_edit->get_caret_column(0) == 1); |
| 7370 |
CHECK(text_edit->has_selection(1)); |
| 7371 |
CHECK(text_edit->get_selection_origin_line(1) == 1); |
| 7372 |
CHECK(text_edit->get_selection_origin_column(1) == 3); |
| 7373 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7374 |
CHECK(text_edit->get_caret_column(1) == 0); |
| 7375 |
|
| 7376 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 7377 |
text_edit->set_size(Size2(50, 100)); |
| 7378 |
|
| 7379 |
CHECK(text_edit->is_line_wrapped(0)); |
| 7380 |
MessageQueue::get_singleton()->flush(); |
| 7381 |
|
| 7382 |
|
| 7383 |
text_edit->remove_secondary_carets(); |
| 7384 |
text_edit->deselect(); |
| 7385 |
text_edit->set_caret_line(0); |
| 7386 |
text_edit->set_caret_column(4); |
| 7387 |
text_edit->add_caret_at_carets(true); |
| 7388 |
CHECK_FALSE(text_edit->has_selection()); |
| 7389 |
CHECK(text_edit->get_caret_count() == 2); |
| 7390 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7391 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7392 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 7393 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 7394 |
|
| 7395 |
|
| 7396 |
text_edit->add_caret_at_carets(true); |
| 7397 |
CHECK_FALSE(text_edit->has_selection()); |
| 7398 |
CHECK(text_edit->get_caret_count() == 3); |
| 7399 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7400 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7401 |
CHECK(text_edit->get_caret_line(1) == 0); |
| 7402 |
CHECK(text_edit->get_caret_column(1) == 8); |
| 7403 |
CHECK(text_edit->get_caret_line(2) == 1); |
| 7404 |
CHECK(text_edit->get_caret_column(2) == 1); |
| 7405 |
|
| 7406 |
|
| 7407 |
text_edit->remove_secondary_carets(); |
| 7408 |
text_edit->deselect(); |
| 7409 |
text_edit->set_caret_line(2); |
| 7410 |
text_edit->set_caret_column(5); |
| 7411 |
text_edit->add_caret_at_carets(true); |
| 7412 |
CHECK_FALSE(text_edit->has_selection()); |
| 7413 |
CHECK(text_edit->get_caret_count() == 2); |
| 7414 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 7415 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 7416 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7417 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 7418 |
|
| 7419 |
|
| 7420 |
text_edit->add_caret_at_carets(true); |
| 7421 |
CHECK_FALSE(text_edit->has_selection()); |
| 7422 |
CHECK(text_edit->get_caret_count() == 2); |
| 7423 |
CHECK(text_edit->get_caret_line(0) == 2); |
| 7424 |
CHECK(text_edit->get_caret_column(0) == 5); |
| 7425 |
CHECK(text_edit->get_caret_line(1) == 2); |
| 7426 |
CHECK(text_edit->get_caret_column(1) == 6); |
| 7427 |
|
| 7428 |
|
| 7429 |
text_edit->remove_secondary_carets(); |
| 7430 |
text_edit->deselect(); |
| 7431 |
text_edit->set_caret_line(1); |
| 7432 |
text_edit->set_caret_column(4); |
| 7433 |
text_edit->add_caret_at_carets(false); |
| 7434 |
CHECK_FALSE(text_edit->has_selection()); |
| 7435 |
CHECK(text_edit->get_caret_count() == 2); |
| 7436 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7437 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7438 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7439 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 7440 |
|
| 7441 |
|
| 7442 |
text_edit->add_caret_at_carets(false); |
| 7443 |
CHECK_FALSE(text_edit->has_selection()); |
| 7444 |
CHECK(text_edit->get_caret_count() == 3); |
| 7445 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7446 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7447 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7448 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 7449 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7450 |
CHECK(text_edit->get_caret_column(2) == 8); |
| 7451 |
|
| 7452 |
|
| 7453 |
text_edit->add_caret_at_carets(false); |
| 7454 |
CHECK_FALSE(text_edit->has_selection()); |
| 7455 |
CHECK(text_edit->get_caret_count() == 4); |
| 7456 |
CHECK(text_edit->get_caret_line(0) == 1); |
| 7457 |
CHECK(text_edit->get_caret_column(0) == 4); |
| 7458 |
CHECK(text_edit->get_caret_line(1) == 1); |
| 7459 |
CHECK(text_edit->get_caret_column(1) == 1); |
| 7460 |
CHECK(text_edit->get_caret_line(2) == 0); |
| 7461 |
CHECK(text_edit->get_caret_column(2) == 8); |
| 7462 |
CHECK(text_edit->get_caret_line(3) == 0); |
| 7463 |
CHECK(text_edit->get_caret_column(3) == 4); |
| 7464 |
|
| 7465 |
|
| 7466 |
text_edit->remove_secondary_carets(); |
| 7467 |
text_edit->deselect(); |
| 7468 |
text_edit->set_caret_line(0); |
| 7469 |
text_edit->set_caret_column(0); |
| 7470 |
text_edit->add_caret_at_carets(false); |
| 7471 |
CHECK_FALSE(text_edit->has_selection()); |
| 7472 |
CHECK(text_edit->get_caret_count() == 1); |
| 7473 |
CHECK(text_edit->get_caret_line(0) == 0); |
| 7474 |
CHECK(text_edit->get_caret_column(0) == 0); |
| 7475 |
|
| 7476 |
|
| 7477 |
text_edit->set_multiple_carets_enabled(false); |
| 7478 |
text_edit->add_caret_at_carets(true); |
| 7479 |
CHECK(text_edit->get_caret_count() == 1); |
| 7480 |
} |
| 7481 |
|
| 7482 |
memdelete(text_edit); |
| 7483 |
} |
| 7484 |
|
| 7485 |
TEST_CASE("[SceneTree][TextEdit] line wrapping") { |
| 7486 |
TextEdit *text_edit = memnew(TextEdit); |
| 7487 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 7488 |
text_edit->grab_focus(); |
| 7489 |
|
| 7490 |
|
| 7491 |
text_edit->set_size(Size2(800, 200)); |
| 7492 |
text_edit->set_line(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); |
| 7493 |
CHECK_FALSE(text_edit->is_line_wrapped(0)); |
| 7494 |
CHECK(text_edit->get_line_wrap_count(0) == 0); |
| 7495 |
CHECK(text_edit->get_line_wrap_index_at_column(0, 130) == 0); |
| 7496 |
CHECK(text_edit->get_line_wrapped_text(0).size() == 1); |
| 7497 |
|
| 7498 |
SIGNAL_WATCH(text_edit, "text_set"); |
| 7499 |
SIGNAL_WATCH(text_edit, "text_changed"); |
| 7500 |
SIGNAL_WATCH(text_edit, "lines_edited_from"); |
| 7501 |
SIGNAL_WATCH(text_edit, "caret_changed"); |
| 7502 |
|
| 7503 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 7504 |
SIGNAL_CHECK_FALSE("text_set"); |
| 7505 |
SIGNAL_CHECK_FALSE("text_changed"); |
| 7506 |
SIGNAL_CHECK_FALSE("lines_edited_from"); |
| 7507 |
SIGNAL_CHECK_FALSE("caret_changed"); |
| 7508 |
|
| 7509 |
CHECK(text_edit->is_line_wrapped(0)); |
| 7510 |
CHECK(text_edit->get_line_wrap_count(0) == 1); |
| 7511 |
CHECK(text_edit->get_line_wrap_index_at_column(0, 130) == 1); |
| 7512 |
CHECK(text_edit->get_line_wrapped_text(0).size() == 2); |
| 7513 |
|
| 7514 |
SIGNAL_UNWATCH(text_edit, "text_set"); |
| 7515 |
SIGNAL_UNWATCH(text_edit, "text_changed"); |
| 7516 |
SIGNAL_UNWATCH(text_edit, "lines_edited_from"); |
| 7517 |
SIGNAL_UNWATCH(text_edit, "caret_changed"); |
| 7518 |
|
| 7519 |
ERR_PRINT_OFF; |
| 7520 |
CHECK_FALSE(text_edit->is_line_wrapped(-1)); |
| 7521 |
CHECK_FALSE(text_edit->is_line_wrapped(1)); |
| 7522 |
CHECK(text_edit->get_line_wrap_count(-1) == 0); |
| 7523 |
CHECK(text_edit->get_line_wrap_count(1) == 0); |
| 7524 |
CHECK(text_edit->get_line_wrap_index_at_column(-1, 0) == 0); |
| 7525 |
CHECK(text_edit->get_line_wrap_index_at_column(0, -1) == 0); |
| 7526 |
CHECK(text_edit->get_line_wrap_index_at_column(1, 0) == 0); |
| 7527 |
CHECK(text_edit->get_line_wrap_index_at_column(0, 10000) == 0); |
| 7528 |
CHECK(text_edit->get_line_wrapped_text(-1).size() == 0); |
| 7529 |
CHECK(text_edit->get_line_wrapped_text(1).size() == 0); |
| 7530 |
ERR_PRINT_ON; |
| 7531 |
|
| 7532 |
memdelete(text_edit); |
| 7533 |
} |
| 7534 |
|
| 7535 |
TEST_CASE("[SceneTree][TextEdit] viewport") { |
| 7536 |
TextEdit *text_edit = memnew(TextEdit); |
| 7537 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 7538 |
|
| 7539 |
|
| 7540 |
text_edit->set_size(Size2(800, 600)); |
| 7541 |
for (int i = 0; i < 50; i++) { |
| 7542 |
text_edit->insert_line_at(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vasius mattis leo, sed porta ex lacinia bibendum. Nunc bibendum pellentesque."); |
| 7543 |
} |
| 7544 |
MessageQueue::get_singleton()->flush(); |
| 7545 |
|
| 7546 |
const int visible_lines = text_edit->get_visible_line_count(); |
| 7547 |
const int total_visible_lines = text_edit->get_total_visible_line_count(); |
| 7548 |
CHECK(total_visible_lines == 51); |
| 7549 |
|
| 7550 |
|
| 7551 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7552 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7553 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7554 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7555 |
|
| 7556 |
text_edit->set_line_as_first_visible(visible_lines); |
| 7557 |
MessageQueue::get_singleton()->flush(); |
| 7558 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7559 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(visible_lines))); |
| 7560 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7561 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7562 |
|
| 7563 |
ERR_PRINT_OFF; |
| 7564 |
text_edit->set_line_as_first_visible(-1); |
| 7565 |
text_edit->set_line_as_first_visible(500); |
| 7566 |
text_edit->set_line_as_first_visible(0, -1); |
| 7567 |
text_edit->set_line_as_first_visible(0, 500); |
| 7568 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7569 |
ERR_PRINT_ON; |
| 7570 |
|
| 7571 |
|
| 7572 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 7573 |
MessageQueue::get_singleton()->flush(); |
| 7574 |
CHECK(text_edit->get_total_visible_line_count() > total_visible_lines); |
| 7575 |
|
| 7576 |
text_edit->set_line_as_first_visible(5, 1); |
| 7577 |
MessageQueue::get_singleton()->flush(); |
| 7578 |
CHECK(text_edit->get_first_visible_line() == 5); |
| 7579 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(11))); |
| 7580 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 6); |
| 7581 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 1); |
| 7582 |
|
| 7583 |
|
| 7584 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_NONE); |
| 7585 |
MessageQueue::get_singleton()->flush(); |
| 7586 |
CHECK(text_edit->get_total_visible_line_count() == total_visible_lines); |
| 7587 |
text_edit->set_line_as_first_visible(0); |
| 7588 |
MessageQueue::get_singleton()->flush(); |
| 7589 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7590 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7591 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7592 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7593 |
|
| 7594 |
|
| 7595 |
text_edit->set_line_as_last_visible(visible_lines * 2); |
| 7596 |
MessageQueue::get_singleton()->flush(); |
| 7597 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7598 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(visible_lines))); |
| 7599 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7600 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7601 |
|
| 7602 |
ERR_PRINT_OFF; |
| 7603 |
text_edit->set_line_as_last_visible(-1); |
| 7604 |
text_edit->set_line_as_last_visible(500); |
| 7605 |
text_edit->set_line_as_last_visible(0, -1); |
| 7606 |
text_edit->set_line_as_last_visible(0, 500); |
| 7607 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7608 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7609 |
ERR_PRINT_ON; |
| 7610 |
|
| 7611 |
|
| 7612 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 7613 |
MessageQueue::get_singleton()->flush(); |
| 7614 |
CHECK(text_edit->get_total_visible_line_count() > total_visible_lines); |
| 7615 |
|
| 7616 |
text_edit->set_line_as_last_visible(visible_lines + 5, 1); |
| 7617 |
MessageQueue::get_singleton()->flush(); |
| 7618 |
CHECK(text_edit->get_first_visible_line() == 16); |
| 7619 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(32.0))); |
| 7620 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines + 5); |
| 7621 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7622 |
|
| 7623 |
|
| 7624 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_NONE); |
| 7625 |
MessageQueue::get_singleton()->flush(); |
| 7626 |
CHECK(text_edit->get_total_visible_line_count() == total_visible_lines); |
| 7627 |
text_edit->set_line_as_first_visible(0); |
| 7628 |
MessageQueue::get_singleton()->flush(); |
| 7629 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7630 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7631 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7632 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7633 |
|
| 7634 |
|
| 7635 |
text_edit->set_line_as_center_visible(visible_lines + (visible_lines / 2)); |
| 7636 |
MessageQueue::get_singleton()->flush(); |
| 7637 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7638 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(visible_lines))); |
| 7639 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7640 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7641 |
|
| 7642 |
ERR_PRINT_OFF; |
| 7643 |
text_edit->set_line_as_last_visible(-1); |
| 7644 |
text_edit->set_line_as_last_visible(500); |
| 7645 |
text_edit->set_line_as_last_visible(0, -1); |
| 7646 |
text_edit->set_line_as_last_visible(0, 500); |
| 7647 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7648 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7649 |
ERR_PRINT_ON; |
| 7650 |
|
| 7651 |
|
| 7652 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 7653 |
MessageQueue::get_singleton()->flush(); |
| 7654 |
CHECK(text_edit->get_total_visible_line_count() > total_visible_lines); |
| 7655 |
|
| 7656 |
text_edit->set_line_as_center_visible(visible_lines + (visible_lines / 2) + 5, 1); |
| 7657 |
MessageQueue::get_singleton()->flush(); |
| 7658 |
CHECK(text_edit->get_first_visible_line() == visible_lines + (visible_lines / 2)); |
| 7659 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double((visible_lines * 3)))); |
| 7660 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7661 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 1); |
| 7662 |
|
| 7663 |
|
| 7664 |
int line_count = text_edit->get_line_count(); |
| 7665 |
text_edit->set_scroll_past_end_of_file_enabled(true); |
| 7666 |
MessageQueue::get_singleton()->flush(); |
| 7667 |
text_edit->set_line_as_center_visible(line_count - 1); |
| 7668 |
MessageQueue::get_singleton()->flush(); |
| 7669 |
|
| 7670 |
CHECK(text_edit->get_first_visible_line() == (visible_lines * 2) + 3); |
| 7671 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double((visible_lines * 4))) + 6); |
| 7672 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) + 8); |
| 7673 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7674 |
|
| 7675 |
text_edit->set_scroll_past_end_of_file_enabled(false); |
| 7676 |
MessageQueue::get_singleton()->flush(); |
| 7677 |
CHECK(text_edit->get_first_visible_line() == (visible_lines * 2) + 3); |
| 7678 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double((visible_lines * 4))) - 4); |
| 7679 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) + 8); |
| 7680 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7681 |
|
| 7682 |
|
| 7683 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_NONE); |
| 7684 |
MessageQueue::get_singleton()->flush(); |
| 7685 |
CHECK(text_edit->get_total_visible_line_count() == total_visible_lines); |
| 7686 |
text_edit->set_line_as_first_visible(0); |
| 7687 |
MessageQueue::get_singleton()->flush(); |
| 7688 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7689 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7690 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7691 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7692 |
|
| 7693 |
|
| 7694 |
|
| 7695 |
MessageQueue::get_singleton()->flush(); |
| 7696 |
CHECK_FALSE(text_edit->is_caret_visible()); |
| 7697 |
text_edit->set_caret_line(visible_lines + 5, false); |
| 7698 |
CHECK_FALSE(text_edit->is_caret_visible()); |
| 7699 |
text_edit->adjust_viewport_to_caret(); |
| 7700 |
MessageQueue::get_singleton()->flush(); |
| 7701 |
CHECK(text_edit->is_caret_visible()); |
| 7702 |
CHECK(text_edit->get_first_visible_line() == 5); |
| 7703 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(5))); |
| 7704 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines - 1) + 5); |
| 7705 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7706 |
|
| 7707 |
text_edit->center_viewport_to_caret(); |
| 7708 |
MessageQueue::get_singleton()->flush(); |
| 7709 |
CHECK(text_edit->get_first_visible_line() == visible_lines - 5); |
| 7710 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(visible_lines - 5))); |
| 7711 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 6); |
| 7712 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7713 |
|
| 7714 |
|
| 7715 |
text_edit->adjust_viewport_to_caret(); |
| 7716 |
MessageQueue::get_singleton()->flush(); |
| 7717 |
CHECK(text_edit->get_first_visible_line() == visible_lines - 5); |
| 7718 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(visible_lines - 5))); |
| 7719 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 6); |
| 7720 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7721 |
|
| 7722 |
|
| 7723 |
text_edit->set_caret_line(1, false); |
| 7724 |
MessageQueue::get_singleton()->flush(); |
| 7725 |
text_edit->adjust_viewport_to_caret(); |
| 7726 |
MessageQueue::get_singleton()->flush(); |
| 7727 |
CHECK(text_edit->is_caret_visible()); |
| 7728 |
CHECK(text_edit->get_first_visible_line() == 1); |
| 7729 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(1))); |
| 7730 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines); |
| 7731 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7732 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7733 |
|
| 7734 |
text_edit->set_line_as_first_visible(0); |
| 7735 |
MessageQueue::get_singleton()->flush(); |
| 7736 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7737 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7738 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7739 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7740 |
|
| 7741 |
text_edit->adjust_viewport_to_caret(); |
| 7742 |
MessageQueue::get_singleton()->flush(); |
| 7743 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7744 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7745 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7746 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7747 |
|
| 7748 |
|
| 7749 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_BOUNDARY); |
| 7750 |
MessageQueue::get_singleton()->flush(); |
| 7751 |
CHECK(text_edit->get_total_visible_line_count() > total_visible_lines); |
| 7752 |
|
| 7753 |
text_edit->set_caret_line(visible_lines + 5, false, true, 1); |
| 7754 |
MessageQueue::get_singleton()->flush(); |
| 7755 |
text_edit->adjust_viewport_to_caret(); |
| 7756 |
MessageQueue::get_singleton()->flush(); |
| 7757 |
|
| 7758 |
CHECK(text_edit->get_first_visible_line() == (visible_lines / 2) + 6); |
| 7759 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double((visible_lines + (visible_lines / 2)))) + 1); |
| 7760 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines) + 5); |
| 7761 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7762 |
CHECK(text_edit->get_caret_wrap_index() == 1); |
| 7763 |
|
| 7764 |
text_edit->center_viewport_to_caret(); |
| 7765 |
MessageQueue::get_singleton()->flush(); |
| 7766 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7767 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double((visible_lines * 2))) + 1); |
| 7768 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 11); |
| 7769 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 1); |
| 7770 |
|
| 7771 |
|
| 7772 |
text_edit->adjust_viewport_to_caret(); |
| 7773 |
MessageQueue::get_singleton()->flush(); |
| 7774 |
CHECK(text_edit->get_first_visible_line() == visible_lines); |
| 7775 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double((visible_lines * 2))) + 1); |
| 7776 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 11); |
| 7777 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 1); |
| 7778 |
|
| 7779 |
|
| 7780 |
text_edit->set_caret_line(1, false, true, 1); |
| 7781 |
MessageQueue::get_singleton()->flush(); |
| 7782 |
text_edit->adjust_viewport_to_caret(); |
| 7783 |
MessageQueue::get_singleton()->flush(); |
| 7784 |
CHECK(text_edit->is_caret_visible()); |
| 7785 |
CHECK(text_edit->get_first_visible_line() == 1); |
| 7786 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(3))); |
| 7787 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines / 2) + 1); |
| 7788 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 1); |
| 7789 |
CHECK(text_edit->get_caret_wrap_index() == 1); |
| 7790 |
|
| 7791 |
text_edit->set_line_as_first_visible(0); |
| 7792 |
MessageQueue::get_singleton()->flush(); |
| 7793 |
CHECK(text_edit->is_caret_visible()); |
| 7794 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7795 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(0))); |
| 7796 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 11); |
| 7797 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7798 |
|
| 7799 |
text_edit->adjust_viewport_to_caret(); |
| 7800 |
MessageQueue::get_singleton()->flush(); |
| 7801 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7802 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(0))); |
| 7803 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 11); |
| 7804 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7805 |
|
| 7806 |
|
| 7807 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_NONE); |
| 7808 |
MessageQueue::get_singleton()->flush(); |
| 7809 |
CHECK(text_edit->get_total_visible_line_count() == total_visible_lines); |
| 7810 |
text_edit->set_line_as_first_visible(0); |
| 7811 |
MessageQueue::get_singleton()->flush(); |
| 7812 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7813 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(0))); |
| 7814 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7815 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7816 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7817 |
|
| 7818 |
|
| 7819 |
text_edit->set_v_scroll_speed(10); |
| 7820 |
CHECK(text_edit->get_v_scroll_speed() == 10); |
| 7821 |
ERR_PRINT_OFF; |
| 7822 |
text_edit->set_v_scroll_speed(-1); |
| 7823 |
CHECK(text_edit->get_v_scroll_speed() == 10); |
| 7824 |
|
| 7825 |
text_edit->set_v_scroll_speed(0); |
| 7826 |
CHECK(text_edit->get_v_scroll_speed() == 10); |
| 7827 |
|
| 7828 |
text_edit->set_v_scroll_speed(1); |
| 7829 |
CHECK(text_edit->get_v_scroll_speed() == 1); |
| 7830 |
ERR_PRINT_ON; |
| 7831 |
|
| 7832 |
|
| 7833 |
int v_scroll = text_edit->get_v_scroll(); |
| 7834 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); |
| 7835 |
CHECK(text_edit->get_v_scroll() > v_scroll); |
| 7836 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); |
| 7837 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(v_scroll))); |
| 7838 |
|
| 7839 |
|
| 7840 |
text_edit->set_smooth_scroll_enabled(true); |
| 7841 |
|
| 7842 |
v_scroll = text_edit->get_v_scroll(); |
| 7843 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); |
| 7844 |
text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); |
| 7845 |
CHECK(text_edit->get_v_scroll() >= v_scroll); |
| 7846 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); |
| 7847 |
text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); |
| 7848 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(v_scroll))); |
| 7849 |
|
| 7850 |
v_scroll = text_edit->get_v_scroll(); |
| 7851 |
text_edit->set_v_scroll_speed(10000); |
| 7852 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_DOWN, MouseButtonMask::NONE, Key::NONE); |
| 7853 |
text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); |
| 7854 |
CHECK(text_edit->get_v_scroll() >= v_scroll); |
| 7855 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2i(10, 10), MouseButton::WHEEL_UP, MouseButtonMask::NONE, Key::NONE); |
| 7856 |
text_edit->notification(TextEdit::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); |
| 7857 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(v_scroll))); |
| 7858 |
|
| 7859 |
ERR_PRINT_OFF; |
| 7860 |
CHECK(text_edit->get_scroll_pos_for_line(-1) == 0); |
| 7861 |
CHECK(text_edit->get_scroll_pos_for_line(1000) == 0); |
| 7862 |
CHECK(text_edit->get_scroll_pos_for_line(1, -1) == 0); |
| 7863 |
CHECK(text_edit->get_scroll_pos_for_line(1, 100) == 0); |
| 7864 |
ERR_PRINT_ON; |
| 7865 |
|
| 7866 |
text_edit->set_h_scroll(-100); |
| 7867 |
CHECK(text_edit->get_h_scroll() == 0); |
| 7868 |
|
| 7869 |
text_edit->set_h_scroll(10000000); |
| 7870 |
CHECK(text_edit->get_h_scroll() == 307); |
| 7871 |
CHECK(text_edit->get_h_scroll_bar()->get_combined_minimum_size().x == 8); |
| 7872 |
|
| 7873 |
text_edit->set_h_scroll(-100); |
| 7874 |
CHECK(text_edit->get_h_scroll() == 0); |
| 7875 |
|
| 7876 |
text_edit->set_smooth_scroll_enabled(false); |
| 7877 |
|
| 7878 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7879 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(0))); |
| 7880 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7881 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7882 |
|
| 7883 |
text_edit->grab_focus(); |
| 7884 |
SEND_GUI_ACTION("ui_text_scroll_down"); |
| 7885 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7886 |
CHECK(text_edit->get_caret_line() == 1); |
| 7887 |
CHECK(text_edit->get_first_visible_line() == 1); |
| 7888 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(1))); |
| 7889 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines); |
| 7890 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7891 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7892 |
|
| 7893 |
SEND_GUI_ACTION("ui_text_scroll_up"); |
| 7894 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7895 |
CHECK(text_edit->get_caret_line() == 1); |
| 7896 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7897 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7898 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7899 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7900 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7901 |
|
| 7902 |
|
| 7903 |
SEND_GUI_ACTION("ui_text_caret_page_down"); |
| 7904 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7905 |
CHECK(text_edit->get_caret_line() == 21); |
| 7906 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 7907 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(0))); |
| 7908 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines - 1); |
| 7909 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7910 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7911 |
|
| 7912 |
SEND_GUI_ACTION("ui_text_caret_page_down"); |
| 7913 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7914 |
CHECK(text_edit->get_caret_line() == 41); |
| 7915 |
CHECK(text_edit->get_first_visible_line() == 20); |
| 7916 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(20))); |
| 7917 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines - 1) * 2); |
| 7918 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7919 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7920 |
|
| 7921 |
SEND_GUI_ACTION("ui_text_caret_page_up"); |
| 7922 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7923 |
CHECK(text_edit->get_caret_line() == 21); |
| 7924 |
CHECK(text_edit->get_first_visible_line() == 20); |
| 7925 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(20))); |
| 7926 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines - 1) * 2); |
| 7927 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7928 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7929 |
|
| 7930 |
SEND_GUI_ACTION("ui_text_caret_page_up"); |
| 7931 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7932 |
CHECK(text_edit->get_caret_line() == 1); |
| 7933 |
CHECK(text_edit->get_first_visible_line() == 1); |
| 7934 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(1))); |
| 7935 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines); |
| 7936 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7937 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7938 |
|
| 7939 |
text_edit->set_line_wrapping_mode(TextEdit::LineWrappingMode::LINE_WRAPPING_NONE); |
| 7940 |
MessageQueue::get_singleton()->flush(); |
| 7941 |
|
| 7942 |
text_edit->grab_focus(); |
| 7943 |
SEND_GUI_ACTION("ui_text_scroll_down"); |
| 7944 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7945 |
CHECK(text_edit->get_caret_line() == 2); |
| 7946 |
CHECK(text_edit->get_first_visible_line() == 2); |
| 7947 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(2))); |
| 7948 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines + 1); |
| 7949 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7950 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7951 |
|
| 7952 |
SEND_GUI_ACTION("ui_text_scroll_up"); |
| 7953 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7954 |
CHECK(text_edit->get_caret_line() == 2); |
| 7955 |
CHECK(text_edit->get_first_visible_line() == 1); |
| 7956 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(1))); |
| 7957 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines); |
| 7958 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7959 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7960 |
|
| 7961 |
|
| 7962 |
SEND_GUI_ACTION("ui_text_caret_page_down"); |
| 7963 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7964 |
CHECK(text_edit->get_caret_line() == 22); |
| 7965 |
CHECK(text_edit->get_first_visible_line() == 1); |
| 7966 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(1))); |
| 7967 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines); |
| 7968 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7969 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7970 |
|
| 7971 |
SEND_GUI_ACTION("ui_text_caret_page_down"); |
| 7972 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7973 |
CHECK(text_edit->get_caret_line() == 42); |
| 7974 |
CHECK(text_edit->get_first_visible_line() == 21); |
| 7975 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(21))); |
| 7976 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7977 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7978 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7979 |
|
| 7980 |
SEND_GUI_ACTION("ui_text_caret_page_up"); |
| 7981 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7982 |
CHECK(text_edit->get_caret_line() == 22); |
| 7983 |
CHECK(text_edit->get_first_visible_line() == 21); |
| 7984 |
CHECK(Math::is_equal_approx(Math::floor(text_edit->get_v_scroll()), double(21))); |
| 7985 |
CHECK(text_edit->get_last_full_visible_line() == (visible_lines * 2) - 1); |
| 7986 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7987 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7988 |
|
| 7989 |
SEND_GUI_ACTION("ui_text_caret_page_up"); |
| 7990 |
CHECK(text_edit->get_viewport()->is_input_handled()); |
| 7991 |
CHECK(text_edit->get_caret_line() == 2); |
| 7992 |
CHECK(text_edit->get_first_visible_line() == 2); |
| 7993 |
CHECK(Math::is_equal_approx(text_edit->get_v_scroll(), double(2))); |
| 7994 |
CHECK(text_edit->get_last_full_visible_line() == visible_lines + 1); |
| 7995 |
CHECK(text_edit->get_last_full_visible_line_wrap_index() == 0); |
| 7996 |
CHECK(text_edit->get_caret_wrap_index() == 0); |
| 7997 |
|
| 7998 |
|
| 7999 |
text_edit->set_caret_line(0); |
| 8000 |
text_edit->set_caret_column(0); |
| 8001 |
text_edit->set_line_as_first_visible(5); |
| 8002 |
MessageQueue::get_singleton()->flush(); |
| 8003 |
CHECK(text_edit->get_first_visible_line() == 5); |
| 8004 |
|
| 8005 |
SEND_GUI_KEY_EVENT(Key::A); |
| 8006 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 8007 |
|
| 8008 |
text_edit->set_line_as_first_visible(5); |
| 8009 |
MessageQueue::get_singleton()->flush(); |
| 8010 |
CHECK(text_edit->get_first_visible_line() == 5); |
| 8011 |
|
| 8012 |
text_edit->undo(); |
| 8013 |
MessageQueue::get_singleton()->flush(); |
| 8014 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 8015 |
|
| 8016 |
text_edit->set_line_as_first_visible(5); |
| 8017 |
MessageQueue::get_singleton()->flush(); |
| 8018 |
CHECK(text_edit->get_first_visible_line() == 5); |
| 8019 |
|
| 8020 |
text_edit->redo(); |
| 8021 |
MessageQueue::get_singleton()->flush(); |
| 8022 |
CHECK(text_edit->get_first_visible_line() == 0); |
| 8023 |
|
| 8024 |
memdelete(text_edit); |
| 8025 |
} |
| 8026 |
|
| 8027 |
TEST_CASE("[SceneTree][TextEdit] small height value") { |
| 8028 |
TextEdit *text_edit = memnew(TextEdit); |
| 8029 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 8030 |
|
| 8031 |
text_edit->set_size(Size2(800, 32)); |
| 8032 |
text_edit->set_text("0\n1\n2"); |
| 8033 |
MessageQueue::get_singleton()->flush(); |
| 8034 |
|
| 8035 |
text_edit->set_v_scroll(100); |
| 8036 |
CHECK(text_edit->get_v_scroll() < 3); |
| 8037 |
|
| 8038 |
memdelete(text_edit); |
| 8039 |
} |
| 8040 |
|
| 8041 |
TEST_CASE("[SceneTree][TextEdit] setter getters") { |
| 8042 |
TextEdit *text_edit = memnew(TextEdit); |
| 8043 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 8044 |
|
| 8045 |
SUBCASE("[TextEdit] set and get placeholder") { |
| 8046 |
text_edit->set_placeholder("test\nplaceholder"); |
| 8047 |
CHECK(text_edit->get_placeholder() == "test\nplaceholder"); |
| 8048 |
|
| 8049 |
CHECK(text_edit->get_text() == ""); |
| 8050 |
CHECK(text_edit->get_line_count() == 1); |
| 8051 |
CHECK(text_edit->get_last_full_visible_line() == 0); |
| 8052 |
} |
| 8053 |
|
| 8054 |
SUBCASE("[TextEdit] highlight current line") { |
| 8055 |
text_edit->set_highlight_current_line(true); |
| 8056 |
CHECK(text_edit->is_highlight_current_line_enabled()); |
| 8057 |
text_edit->set_highlight_current_line(false); |
| 8058 |
CHECK_FALSE(text_edit->is_highlight_current_line_enabled()); |
| 8059 |
} |
| 8060 |
|
| 8061 |
SUBCASE("[TextEdit] highlight all occurrences") { |
| 8062 |
text_edit->set_highlight_all_occurrences(true); |
| 8063 |
CHECK(text_edit->is_highlight_all_occurrences_enabled()); |
| 8064 |
text_edit->set_highlight_all_occurrences(false); |
| 8065 |
CHECK_FALSE(text_edit->is_highlight_all_occurrences_enabled()); |
| 8066 |
} |
| 8067 |
|
| 8068 |
SUBCASE("[TextEdit] draw control chars") { |
| 8069 |
text_edit->set_draw_control_chars(true); |
| 8070 |
CHECK(text_edit->get_draw_control_chars()); |
| 8071 |
text_edit->set_draw_control_chars(false); |
| 8072 |
CHECK_FALSE(text_edit->get_draw_control_chars()); |
| 8073 |
} |
| 8074 |
|
| 8075 |
SUBCASE("[TextEdit] draw tabs") { |
| 8076 |
text_edit->set_draw_tabs(true); |
| 8077 |
CHECK(text_edit->is_drawing_tabs()); |
| 8078 |
text_edit->set_draw_tabs(false); |
| 8079 |
CHECK_FALSE(text_edit->is_drawing_tabs()); |
| 8080 |
} |
| 8081 |
|
| 8082 |
SUBCASE("[TextEdit] draw spaces") { |
| 8083 |
text_edit->set_draw_spaces(true); |
| 8084 |
CHECK(text_edit->is_drawing_spaces()); |
| 8085 |
text_edit->set_draw_spaces(false); |
| 8086 |
CHECK_FALSE(text_edit->is_drawing_spaces()); |
| 8087 |
} |
| 8088 |
|
| 8089 |
SUBCASE("[TextEdit] draw minimap") { |
| 8090 |
text_edit->set_draw_minimap(true); |
| 8091 |
CHECK(text_edit->is_drawing_minimap()); |
| 8092 |
text_edit->set_draw_minimap(false); |
| 8093 |
CHECK_FALSE(text_edit->is_drawing_minimap()); |
| 8094 |
} |
| 8095 |
|
| 8096 |
SUBCASE("[TextEdit] minimap width") { |
| 8097 |
text_edit->set_minimap_width(-1); |
| 8098 |
CHECK(text_edit->get_minimap_width() == -1); |
| 8099 |
text_edit->set_minimap_width(1000); |
| 8100 |
CHECK(text_edit->get_minimap_width() == 1000); |
| 8101 |
} |
| 8102 |
|
| 8103 |
SUBCASE("[TextEdit] line color background") { |
| 8104 |
ERR_PRINT_OFF; |
| 8105 |
text_edit->set_line_background_color(-1, Color("#ff0000")); |
| 8106 |
text_edit->set_line_background_color(0, Color("#00ff00")); |
| 8107 |
text_edit->set_line_background_color(1, Color("#0000ff")); |
| 8108 |
|
| 8109 |
CHECK(text_edit->get_line_background_color(-1) == Color()); |
| 8110 |
CHECK(text_edit->get_line_background_color(0) == Color("#00ff00")); |
| 8111 |
CHECK(text_edit->get_line_background_color(1) == Color()); |
| 8112 |
ERR_PRINT_ON; |
| 8113 |
|
| 8114 |
text_edit->set_line_background_color(0, Color("#ffff00")); |
| 8115 |
CHECK(text_edit->get_line_background_color(0) == Color("#ffff00")); |
| 8116 |
} |
| 8117 |
|
| 8118 |
memdelete(text_edit); |
| 8119 |
} |
| 8120 |
|
| 8121 |
TEST_CASE("[SceneTree][TextEdit] gutters") { |
| 8122 |
TextEdit *text_edit = memnew(TextEdit); |
| 8123 |
SceneTree::get_singleton()->get_root()->add_child(text_edit); |
| 8124 |
|
| 8125 |
Array empty_signal_args = { {} }; |
| 8126 |
|
| 8127 |
SIGNAL_WATCH(text_edit, "gutter_clicked"); |
| 8128 |
SIGNAL_WATCH(text_edit, "gutter_added"); |
| 8129 |
SIGNAL_WATCH(text_edit, "gutter_removed"); |
| 8130 |
|
| 8131 |
SUBCASE("[TextEdit] gutter add and remove") { |
| 8132 |
text_edit->set_text("test1\ntest2\ntest3\ntest4"); |
| 8133 |
|
| 8134 |
text_edit->add_gutter(); |
| 8135 |
CHECK(text_edit->get_gutter_count() == 1); |
| 8136 |
CHECK(text_edit->get_gutter_width(0) == 24); |
| 8137 |
CHECK(text_edit->get_total_gutter_width() == 24 + 2); |
| 8138 |
SIGNAL_CHECK("gutter_added", empty_signal_args); |
| 8139 |
|
| 8140 |
text_edit->set_gutter_name(0, "test_gutter"); |
| 8141 |
CHECK(text_edit->get_gutter_name(0) == "test_gutter"); |
| 8142 |
|
| 8143 |
text_edit->set_gutter_width(0, 10); |
| 8144 |
CHECK(text_edit->get_gutter_width(0) == 10); |
| 8145 |
CHECK(text_edit->get_total_gutter_width() == 10 + 2); |
| 8146 |
|
| 8147 |
text_edit->add_gutter(-100); |
| 8148 |
text_edit->set_gutter_width(1, 10); |
| 8149 |
CHECK(text_edit->get_gutter_width(1) == 10); |
| 8150 |
CHECK(text_edit->get_total_gutter_width() == 20 + 2); |
| 8151 |
CHECK(text_edit->get_gutter_count() == 2); |
| 8152 |
CHECK(text_edit->get_gutter_name(0) == "test_gutter"); |
| 8153 |
SIGNAL_CHECK("gutter_added", empty_signal_args); |
| 8154 |
|
| 8155 |
text_edit->set_gutter_draw(1, false); |
| 8156 |
CHECK(text_edit->get_total_gutter_width() == 10 + 2); |
| 8157 |
|
| 8158 |
text_edit->add_gutter(100); |
| 8159 |
CHECK(text_edit->get_gutter_count() == 3); |
| 8160 |
CHECK(text_edit->get_gutter_width(2) == 24); |
| 8161 |
CHECK(text_edit->get_total_gutter_width() == 34 + 2); |
| 8162 |
CHECK(text_edit->get_gutter_name(0) == "test_gutter"); |
| 8163 |
SIGNAL_CHECK("gutter_added", empty_signal_args); |
| 8164 |
|
| 8165 |
text_edit->add_gutter(0); |
| 8166 |
CHECK(text_edit->get_gutter_count() == 4); |
| 8167 |
CHECK(text_edit->get_gutter_width(0) == 24); |
| 8168 |
CHECK(text_edit->get_total_gutter_width() == 58 + 2); |
| 8169 |
CHECK(text_edit->get_gutter_name(1) == "test_gutter"); |
| 8170 |
SIGNAL_CHECK("gutter_added", empty_signal_args); |
| 8171 |
|
| 8172 |
text_edit->remove_gutter(2); |
| 8173 |
CHECK(text_edit->get_gutter_name(1) == "test_gutter"); |
| 8174 |
CHECK(text_edit->get_gutter_count() == 3); |
| 8175 |
CHECK(text_edit->get_total_gutter_width() == 58 + 2); |
| 8176 |
SIGNAL_CHECK("gutter_removed", empty_signal_args); |
| 8177 |
|
| 8178 |
text_edit->remove_gutter(0); |
| 8179 |
CHECK(text_edit->get_gutter_name(0) == "test_gutter"); |
| 8180 |
CHECK(text_edit->get_gutter_count() == 2); |
| 8181 |
CHECK(text_edit->get_total_gutter_width() == 34 + 2); |
| 8182 |
SIGNAL_CHECK("gutter_removed", empty_signal_args); |
| 8183 |
|
| 8184 |
ERR_PRINT_OFF; |
| 8185 |
text_edit->remove_gutter(-1); |
| 8186 |
SIGNAL_CHECK_FALSE("gutter_removed"); |
| 8187 |
|
| 8188 |
text_edit->remove_gutter(100); |
| 8189 |
SIGNAL_CHECK_FALSE("gutter_removed"); |
| 8190 |
|
| 8191 |
CHECK(text_edit->get_gutter_name(-1) == ""); |
| 8192 |
CHECK(text_edit->get_gutter_name(100) == ""); |
| 8193 |
ERR_PRINT_ON; |
| 8194 |
} |
| 8195 |
|
| 8196 |
SUBCASE("[TextEdit] gutter data") { |
| 8197 |
text_edit->add_gutter(); |
| 8198 |
CHECK(text_edit->get_gutter_count() == 1); |
| 8199 |
SIGNAL_CHECK("gutter_added", empty_signal_args); |
| 8200 |
|
| 8201 |
text_edit->set_gutter_name(0, "test_gutter"); |
| 8202 |
CHECK(text_edit->get_gutter_name(0) == "test_gutter"); |
| 8203 |
|
| 8204 |
text_edit->set_gutter_width(0, 10); |
| 8205 |
CHECK(text_edit->get_gutter_width(0) == 10); |
| 8206 |
|
| 8207 |
text_edit->set_gutter_clickable(0, true); |
| 8208 |
CHECK(text_edit->is_gutter_clickable(0)); |
| 8209 |
|
| 8210 |
text_edit->set_gutter_overwritable(0, true); |
| 8211 |
CHECK(text_edit->is_gutter_overwritable(0)); |
| 8212 |
|
| 8213 |
text_edit->set_gutter_type(0, TextEdit::GutterType::GUTTER_TYPE_CUSTOM); |
| 8214 |
CHECK(text_edit->get_gutter_type(0) == TextEdit::GutterType::GUTTER_TYPE_CUSTOM); |
| 8215 |
|
| 8216 |
text_edit->set_text("test\ntext"); |
| 8217 |
|
| 8218 |
ERR_PRINT_OFF; |
| 8219 |
text_edit->set_line_gutter_metadata(1, 0, "test"); |
| 8220 |
text_edit->set_line_gutter_metadata(0, -1, "test"); |
| 8221 |
text_edit->set_line_gutter_metadata(0, 2, "test"); |
| 8222 |
text_edit->set_line_gutter_metadata(2, 0, "test"); |
| 8223 |
text_edit->set_line_gutter_metadata(-1, 0, "test"); |
| 8224 |
|
| 8225 |
CHECK(text_edit->get_line_gutter_metadata(1, 0) == "test"); |
| 8226 |
CHECK(text_edit->get_line_gutter_metadata(0, -1) == ""); |
| 8227 |
CHECK(text_edit->get_line_gutter_metadata(0, 2) == ""); |
| 8228 |
CHECK(text_edit->get_line_gutter_metadata(2, 0) == ""); |
| 8229 |
CHECK(text_edit->get_line_gutter_metadata(-1, 0) == ""); |
| 8230 |
|
| 8231 |
text_edit->set_line_gutter_text(1, 0, "test"); |
| 8232 |
text_edit->set_line_gutter_text(0, -1, "test"); |
| 8233 |
text_edit->set_line_gutter_text(0, 2, "test"); |
| 8234 |
text_edit->set_line_gutter_text(2, 0, "test"); |
| 8235 |
text_edit->set_line_gutter_text(-1, 0, "test"); |
| 8236 |
|
| 8237 |
CHECK(text_edit->get_line_gutter_text(1, 0) == "test"); |
| 8238 |
CHECK(text_edit->get_line_gutter_text(0, -1) == ""); |
| 8239 |
CHECK(text_edit->get_line_gutter_text(0, 2) == ""); |
| 8240 |
CHECK(text_edit->get_line_gutter_text(2, 0) == ""); |
| 8241 |
CHECK(text_edit->get_line_gutter_text(-1, 0) == ""); |
| 8242 |
|
| 8243 |
text_edit->set_line_gutter_item_color(1, 0, Color(1, 0, 0)); |
| 8244 |
text_edit->set_line_gutter_item_color(0, -1, Color(1, 0, 0)); |
| 8245 |
text_edit->set_line_gutter_item_color(0, 2, Color(1, 0, 0)); |
| 8246 |
text_edit->set_line_gutter_item_color(2, 0, Color(1, 0, 0)); |
| 8247 |
text_edit->set_line_gutter_item_color(-1, 0, Color(1, 0, 0)); |
| 8248 |
|
| 8249 |
CHECK(text_edit->get_line_gutter_item_color(1, 0) == Color(1, 0, 0)); |
| 8250 |
CHECK(text_edit->get_line_gutter_item_color(0, -1) == Color()); |
| 8251 |
CHECK(text_edit->get_line_gutter_item_color(0, 2) == Color()); |
| 8252 |
CHECK(text_edit->get_line_gutter_item_color(2, 0) == Color()); |
| 8253 |
CHECK(text_edit->get_line_gutter_item_color(-1, 0) == Color()); |
| 8254 |
|
| 8255 |
text_edit->set_line_gutter_clickable(1, 0, true); |
| 8256 |
text_edit->set_line_gutter_clickable(0, -1, true); |
| 8257 |
text_edit->set_line_gutter_clickable(0, 2, true); |
| 8258 |
text_edit->set_line_gutter_clickable(2, 0, true); |
| 8259 |
text_edit->set_line_gutter_clickable(-1, 0, true); |
| 8260 |
|
| 8261 |
CHECK(text_edit->is_line_gutter_clickable(1, 0) == true); |
| 8262 |
CHECK(text_edit->is_line_gutter_clickable(0, -1) == false); |
| 8263 |
CHECK(text_edit->is_line_gutter_clickable(0, 2) == false); |
| 8264 |
CHECK(text_edit->is_line_gutter_clickable(2, 0) == false); |
| 8265 |
CHECK(text_edit->is_line_gutter_clickable(-1, 0) == false); |
| 8266 |
ERR_PRINT_ON; |
| 8267 |
|
| 8268 |
|
| 8269 |
} |
| 8270 |
|
| 8271 |
SUBCASE("[TextEdit] gutter mouse") { |
| 8272 |
DisplayServerMock *DS = (DisplayServerMock *)(DisplayServer::get_singleton()); |
| 8273 |
|
| 8274 |
text_edit->set_size(Size2(200, 200)); |
| 8275 |
|
| 8276 |
text_edit->set_text("test1\ntest2\ntest3\ntest4"); |
| 8277 |
text_edit->grab_focus(); |
| 8278 |
|
| 8279 |
text_edit->add_gutter(); |
| 8280 |
text_edit->set_gutter_name(0, "test_gutter"); |
| 8281 |
text_edit->set_gutter_width(0, 10); |
| 8282 |
text_edit->set_gutter_clickable(0, true); |
| 8283 |
|
| 8284 |
text_edit->add_gutter(); |
| 8285 |
text_edit->set_gutter_name(1, "test_gutter_not_clickable"); |
| 8286 |
text_edit->set_gutter_width(1, 10); |
| 8287 |
text_edit->set_gutter_clickable(1, false); |
| 8288 |
|
| 8289 |
text_edit->add_gutter(); |
| 8290 |
CHECK(text_edit->get_gutter_count() == 3); |
| 8291 |
text_edit->set_gutter_name(2, "test_gutter_3"); |
| 8292 |
text_edit->set_gutter_width(2, 10); |
| 8293 |
text_edit->set_gutter_clickable(2, true); |
| 8294 |
|
| 8295 |
MessageQueue::get_singleton()->flush(); |
| 8296 |
const int line_height = text_edit->get_line_height(); |
| 8297 |
|
| 8298 |
|
| 8299 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1)); |
| 8300 |
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW); |
| 8301 |
|
| 8302 |
|
| 8303 |
SEND_GUI_MOUSE_MOTION_EVENT(Point2(5, line_height + line_height / 2), MouseButtonMask::NONE, Key::NONE); |
| 8304 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(0, 1)); |
| 8305 |
SIGNAL_CHECK_FALSE("gutter_clicked"); |
| 8306 |
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_POINTING_HAND); |
| 8307 |
|
| 8308 |
|
| 8309 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(5, line_height / 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 8310 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(0, 0)); |
| 8311 |
SIGNAL_CHECK("gutter_clicked", Array({ { 0, 0 } })); |
| 8312 |
|
| 8313 |
|
| 8314 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(5, line_height * 3 + line_height / 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 8315 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(0, 3)); |
| 8316 |
SIGNAL_CHECK("gutter_clicked", Array({ { 3, 0 } })); |
| 8317 |
|
| 8318 |
|
| 8319 |
SEND_GUI_MOUSE_MOTION_EVENT(Point2(15, line_height + line_height / 2), MouseButtonMask::NONE, Key::NONE); |
| 8320 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(1, 1)); |
| 8321 |
SIGNAL_CHECK_FALSE("gutter_clicked"); |
| 8322 |
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW); |
| 8323 |
|
| 8324 |
|
| 8325 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(15, line_height * 2 + line_height / 2), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 8326 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(1, 2)); |
| 8327 |
SIGNAL_CHECK("gutter_clicked", Array({ { 2, 1 } })); |
| 8328 |
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW); |
| 8329 |
|
| 8330 |
|
| 8331 |
SEND_GUI_MOUSE_MOTION_EVENT(Point2(5, line_height * 5), MouseButtonMask::NONE, Key::NONE); |
| 8332 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1)); |
| 8333 |
SIGNAL_CHECK_FALSE("gutter_clicked"); |
| 8334 |
CHECK(DS->get_cursor_shape() == DisplayServer::CURSOR_ARROW); |
| 8335 |
|
| 8336 |
|
| 8337 |
SEND_GUI_MOUSE_BUTTON_EVENT(Point2(5, line_height * 5), MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE); |
| 8338 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1)); |
| 8339 |
SIGNAL_CHECK_FALSE("gutter_clicked"); |
| 8340 |
|
| 8341 |
|
| 8342 |
SEND_GUI_MOUSE_MOTION_EVENT(Point2(5, line_height + line_height / 2), MouseButtonMask::NONE, Key::NONE); |
| 8343 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(0, 1)); |
| 8344 |
SEND_GUI_MOUSE_MOTION_EVENT(Point2(-1, -1), MouseButtonMask::NONE, Key::NONE); |
| 8345 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1)); |
| 8346 |
|
| 8347 |
|
| 8348 |
SEND_GUI_MOUSE_MOTION_EVENT(Point2(25, line_height + line_height / 2), MouseButtonMask::NONE, Key::NONE); |
| 8349 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(2, 1)); |
| 8350 |
text_edit->remove_gutter(2); |
| 8351 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(-1, -1)); |
| 8352 |
|
| 8353 |
|
| 8354 |
text_edit->set_gutter_width(1, 20); |
| 8355 |
CHECK(text_edit->get_hovered_gutter() == Vector2i(1, 1)); |
| 8356 |
} |
| 8357 |
|
| 8358 |
SIGNAL_UNWATCH(text_edit, "gutter_clicked"); |
| 8359 |
SIGNAL_UNWATCH(text_edit, "gutter_added"); |
| 8360 |
SIGNAL_UNWATCH(text_edit, "gutter_removed"); |
| 8361 |
memdelete(text_edit); |
| 8362 |
} |
| 8363 |
|
| 8364 |
} |