efl

Форк
0
/
elm_code_test_widget_selection.c 
718 строк · 21.2 Кб
1
#ifdef HAVE_CONFIG_H
2
# include "elementary_config.h"
3
#endif
4

5
#include "elm_suite.h"
6
#include "Elementary.h"
7
#include "elm_code_widget_private.h"
8
#include "elm_code_widget_selection.h"
9

10
EFL_START_TEST(elm_code_test_widget_selection_set)
11
{
12
   Elm_Code *code;
13
   Elm_Code_File *file;
14
   Elm_Code_Widget *widget;
15
   Evas_Object *win;
16

17
   char *args[] = { "exe" };
18
   elm_init(1, args);
19
   code = elm_code_create();
20
   file = elm_code_file_new(code);
21
   elm_code_file_line_append(file, "test", 4, NULL);
22

23
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
24
   widget = elm_code_widget_add(win, code);
25

26
   elm_code_widget_selection_start(widget, 1, 2);
27
   elm_code_widget_selection_end(widget, 1, 3);
28
   elm_code_widget_selection_clear(widget);
29

30
   elm_code_free(code);
31
   elm_shutdown();
32
}
33
EFL_END_TEST
34

35
EFL_START_TEST(elm_code_test_widget_selection_normalized_get)
36
{
37
   Elm_Code *code;
38
   Elm_Code_File *file;
39
   Elm_Code_Widget *widget;
40
   Elm_Code_Widget_Selection_Data *selection;
41
   Evas_Object *win;
42

43
   char *args[] = { "exe" };
44
   elm_init(1, args);
45
   code = elm_code_create();
46
   file = elm_code_file_new(code);
47
   elm_code_file_line_append(file, "test", 4, NULL);
48

49
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
50
   widget = elm_code_widget_add(win, code);
51

52
   elm_code_widget_selection_start(widget, 1, 3);
53
   elm_code_widget_selection_end(widget, 1, 2);
54
   selection = elm_code_widget_selection_normalized_get(widget);
55

56
   ck_assert_int_eq(selection->start_col, 2);
57
   ck_assert_int_eq(selection->end_col, 3);
58
   elm_code_widget_selection_clear(widget);
59
   free(selection);
60

61
   elm_code_file_line_append(file, "another", 7, NULL);
62
   elm_code_widget_selection_start(widget, 2, 2);
63
   elm_code_widget_selection_end(widget, 1, 3);
64
   selection = elm_code_widget_selection_normalized_get(widget);
65

66
   ck_assert_int_eq(selection->start_line, 1);
67
   ck_assert_int_eq(selection->start_col, 3);
68
   ck_assert_int_eq(selection->end_line, 2);
69
   ck_assert_int_eq(selection->end_col, 2);
70
   elm_code_widget_selection_clear(widget);
71
   free(selection);
72

73
   elm_code_free(code);
74
   elm_shutdown();
75
}
76
EFL_END_TEST
77

78
EFL_START_TEST(elm_code_test_widget_selection_text_get)
79
{
80
   Elm_Code *code;
81
   Elm_Code_File *file;
82
   Elm_Code_Widget *widget;
83
   Evas_Object *win;
84
   char *selection;
85

86
   char *args[] = { "exe" };
87
   elm_init(1, args);
88
   code = elm_code_create();
89
   file = elm_code_file_new(code);
90
   elm_code_file_line_append(file, "test", 4, NULL);
91

92
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
93
   widget = elm_code_widget_add(win, code);
94

95
   ck_assert_str_eq("", elm_code_widget_selection_text_get(widget));
96

97
   elm_code_widget_selection_start(widget, 1, 2);
98
   elm_code_widget_selection_end(widget, 1, 3);
99

100
   selection = elm_code_widget_selection_text_get(widget);
101
   ck_assert_str_eq("es", selection);
102
   free(selection);
103

104
   elm_code_widget_selection_clear(widget);
105
   ck_assert_str_eq("", elm_code_widget_selection_text_get(widget));
106

107
   elm_code_free(code);
108
   elm_shutdown();
109
}
110
EFL_END_TEST
111

112
EFL_START_TEST(elm_code_test_widget_selection_reverse_text_get)
113
{
114
   Elm_Code *code;
115
   Elm_Code_File *file;
116
   Elm_Code_Widget *widget;
117
   Evas_Object *win;
118
   char *selection;
119

120
   char *args[] = { "exe" };
121
   elm_init(1, args);
122
   code = elm_code_create();
123
   file = elm_code_file_new(code);
124
   elm_code_file_line_append(file, "test", 4, NULL);
125

126
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
127
   widget = elm_code_widget_add(win, code);
128

129
   ck_assert_str_eq("", elm_code_widget_selection_text_get(widget));
130

131
   elm_code_widget_selection_start(widget, 1, 3);
132
   elm_code_widget_selection_end(widget, 1, 2);
133

134
   selection = elm_code_widget_selection_text_get(widget);
135
   ck_assert_str_eq("es", selection);
136
   free(selection);
137

138
   elm_code_widget_selection_clear(widget);
139
   ck_assert_str_eq("", elm_code_widget_selection_text_get(widget));
140

141
   elm_code_free(code);
142
   elm_shutdown();
143
}
144
EFL_END_TEST
145

146
EFL_START_TEST(elm_code_test_widget_selection_text_get_twoline)
147
{
148
   Elm_Code *code;
149
   Elm_Code_File *file;
150
   Elm_Code_Widget *widget;
151
   Evas_Object *win;
152
   char *selection;
153

154
   char *args[] = { "exe" };
155
   elm_init(1, args);
156
   code = elm_code_create();
157
   file = elm_code_file_new(code);
158
   elm_code_file_line_append(file, "test", 4, NULL);
159
   elm_code_file_line_append(file, "test", 4, NULL);
160

161
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
162
   widget = elm_code_widget_add(win, code);
163

164
   elm_code_widget_selection_start(widget, 1, 3);
165
   elm_code_widget_selection_end(widget, 2, 2);
166

167
   selection = elm_code_widget_selection_text_get(widget);
168
   ck_assert_str_eq("st\nte", selection);
169
   free(selection);
170

171
   elm_code_free(code);
172
   elm_shutdown();
173
}
174
EFL_END_TEST
175

176
EFL_START_TEST(elm_code_test_widget_selection_reverse_text_get_twoline)
177
{
178
   Elm_Code *code;
179
   Elm_Code_File *file;
180
   Elm_Code_Widget *widget;
181
   Evas_Object *win;
182
   char *selection;
183

184
   char *args[] = { "exe" };
185
   elm_init(1, args);
186
   code = elm_code_create();
187
   file = elm_code_file_new(code);
188
   elm_code_file_line_append(file, "test", 4, NULL);
189
   elm_code_file_line_append(file, "test", 4, NULL);
190

191
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
192
   widget = elm_code_widget_add(win, code);
193

194
   elm_code_widget_selection_start(widget, 2, 2);
195
   elm_code_widget_selection_end(widget, 1, 3);
196

197
   selection = elm_code_widget_selection_text_get(widget);
198
   ck_assert_str_eq("st\nte", selection);
199
   free(selection);
200

201
   elm_code_free(code);
202
   elm_shutdown();
203
}
204
EFL_END_TEST
205

206
EFL_START_TEST(elm_code_test_widget_selection_text_get_multiline)
207
{
208
   Elm_Code *code;
209
   Elm_Code_File *file;
210
   Elm_Code_Widget *widget;
211
   Evas_Object *win;
212
   char *selection;
213

214
   char *args[] = { "exe" };
215
   elm_init(1, args);
216
   code = elm_code_create();
217
   file = elm_code_file_new(code);
218
   elm_code_file_line_append(file, "test", 4, NULL);
219
   elm_code_file_line_append(file, "test", 4, NULL);
220
   elm_code_file_line_append(file, "test", 4, NULL);
221

222
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
223
   widget = elm_code_widget_add(win, code);
224

225
   elm_code_widget_selection_start(widget, 1, 3);
226
   elm_code_widget_selection_end(widget, 3, 2);
227

228
   selection = elm_code_widget_selection_text_get(widget);
229
   ck_assert_str_eq("st\ntest\nte", selection);
230
   free(selection);
231

232
   elm_code_free(code);
233
   elm_shutdown();
234
}
235
EFL_END_TEST
236

237
EFL_START_TEST(elm_code_test_widget_selection_reverse_text_get_multiline)
238
{
239
   Elm_Code *code;
240
   Elm_Code_File *file;
241
   Elm_Code_Widget *widget;
242
   Evas_Object *win;
243
   char *selection;
244

245
   char *args[] = { "exe" };
246
   elm_init(1, args);
247
   code = elm_code_create();
248
   file = elm_code_file_new(code);
249
   elm_code_file_line_append(file, "test", 4, NULL);
250
   elm_code_file_line_append(file, "test", 4, NULL);
251
   elm_code_file_line_append(file, "test", 4, NULL);
252

253
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
254
   widget = elm_code_widget_add(win, code);
255

256
   elm_code_widget_selection_start(widget, 3, 2);
257
   elm_code_widget_selection_end(widget, 1, 3);
258

259
   selection = elm_code_widget_selection_text_get(widget);
260
   ck_assert_str_eq("st\ntest\nte", selection);
261
   free(selection);
262

263
   elm_code_free(code);
264
   elm_shutdown();
265
}
266
EFL_END_TEST
267

268
EFL_START_TEST(elm_code_test_widget_selection_delete)
269
{
270
   Elm_Code *code;
271
   Elm_Code_File *file;
272
   Elm_Code_Line *line;
273
   Elm_Code_Widget *widget;
274
   Evas_Object *win;
275
   const char *text;
276
   unsigned int length;
277

278
   char *args[] = { "exe" };
279
   elm_init(1, args);
280
   code = elm_code_create();
281
   file = elm_code_file_new(code);
282
   elm_code_file_line_append(file, "text", 4, NULL);
283

284
   win = win_add(NULL, "code", ELM_WIN_BASIC);
285
   widget = elm_code_widget_add(win, code);
286
   line = elm_code_file_line_get(file, 1);
287
   text = elm_code_line_text_get(line, &length);
288
   ck_assert_int_eq(4, length);
289
   ck_assert_strn_eq("text", text, length);
290

291
   elm_code_widget_selection_start(widget, 1, 2);
292
   elm_code_widget_selection_end(widget, 1, 3);
293
   elm_code_widget_selection_delete(widget);
294

295
   line = elm_code_file_line_get(file, 1);
296
   text = elm_code_line_text_get(line, &length);
297
   ck_assert_int_eq(2, length);
298
   ck_assert_strn_eq("tt", text, length);
299

300
   elm_code_free(code);
301
   elm_shutdown();
302
}
303
EFL_END_TEST
304

305
EFL_START_TEST(elm_code_test_widget_selection_reverse_delete)
306
{
307
   Elm_Code *code;
308
   Elm_Code_File *file;
309
   Elm_Code_Line *line;
310
   Elm_Code_Widget *widget;
311
   Evas_Object *win;
312
   const char *text;
313
   unsigned int length;
314

315
   char *args[] = { "exe" };
316
   elm_init(1, args);
317
   code = elm_code_create();
318
   file = elm_code_file_new(code);
319
   elm_code_file_line_append(file, "text", 4, NULL);
320

321
   win = win_add(NULL, "code", ELM_WIN_BASIC);
322
   widget = elm_code_widget_add(win, code);
323
   line = elm_code_file_line_get(file, 1);
324
   text = elm_code_line_text_get(line, &length);
325
   ck_assert_int_eq(4, length);
326
   ck_assert_strn_eq("text", text, length);
327

328
   elm_code_widget_selection_start(widget, 1, 3);
329
   elm_code_widget_selection_end(widget, 1, 2);
330
   elm_code_widget_selection_delete(widget);
331

332
   line = elm_code_file_line_get(file, 1);
333
   text = elm_code_line_text_get(line, &length);
334
   ck_assert_int_eq(2, length);
335
   ck_assert_strn_eq("tt", text, length);
336

337
   elm_code_free(code);
338
   elm_shutdown();
339
}
340
EFL_END_TEST
341

342
EFL_START_TEST(elm_code_test_widget_selection_delete_twoline)
343
{
344
   Elm_Code *code;
345
   Elm_Code_File *file;
346
   Elm_Code_Line *line;
347
   Elm_Code_Widget *widget;
348
   Evas_Object *win;
349
   const char *text;
350
   unsigned int length;
351

352
   char *args[] = { "exe" };
353
   elm_init(1, args);
354
   code = elm_code_create();
355
   file = elm_code_file_new(code);
356
   elm_code_file_line_append(file, "text", 4, NULL);
357
   elm_code_file_line_append(file, "TEXT", 4, NULL);
358
   elm_code_file_line_append(file, "remove", 6, NULL);
359

360
   win = win_add(NULL, "code", ELM_WIN_BASIC);
361
   widget = elm_code_widget_add(win, code);
362
   line = elm_code_file_line_get(file, 1);
363
   text = elm_code_line_text_get(line, NULL);
364
   ck_assert_str_eq("text", text);
365
   ck_assert_int_eq(3, elm_code_file_lines_get(file));
366

367
   elm_code_widget_selection_start(widget, 1, 3);
368
   elm_code_widget_selection_end(widget, 2, 2);
369
   elm_code_widget_selection_delete(widget);
370

371
   line = elm_code_file_line_get(file, 1);
372
   text = elm_code_line_text_get(line, &length);
373
   ck_assert_strn_eq("teXT", text, length);
374
   ck_assert_int_eq(2, elm_code_file_lines_get(file));
375

376
   elm_code_widget_selection_start(widget, 1, 5);
377
   elm_code_widget_selection_end(widget, 2, 1);
378
   elm_code_widget_selection_delete(widget);
379

380
   line = elm_code_file_line_get(file, 1);
381
   text = elm_code_line_text_get(line, &length);
382
   ck_assert_strn_eq("teXTemove", text, length);
383
   ck_assert_int_eq(1, elm_code_file_lines_get(file));
384

385
   elm_code_free(code);
386
   elm_shutdown();
387
}
388
EFL_END_TEST
389

390
EFL_START_TEST(elm_code_test_widget_selection_reverse_delete_twoline)
391
{
392
   Elm_Code *code;
393
   Elm_Code_File *file;
394
   Elm_Code_Line *line;
395
   Elm_Code_Widget *widget;
396
   Evas_Object *win;
397
   const char *text;
398
   unsigned int length;
399

400
   char *args[] = { "exe" };
401
   elm_init(1, args);
402
   code = elm_code_create();
403
   file = elm_code_file_new(code);
404
   elm_code_file_line_append(file, "text", 4, NULL);
405
   elm_code_file_line_append(file, "TEXT", 4, NULL);
406
   elm_code_file_line_append(file, "remove", 6, NULL);
407

408
   win = win_add(NULL, "code", ELM_WIN_BASIC);
409
   widget = elm_code_widget_add(win, code);
410
   line = elm_code_file_line_get(file, 1);
411
   text = elm_code_line_text_get(line, NULL);
412
   ck_assert_str_eq("text", text);
413
   ck_assert_int_eq(3, elm_code_file_lines_get(file));
414

415
   elm_code_widget_selection_start(widget, 2, 2);
416
   elm_code_widget_selection_end(widget, 1, 3);
417
   elm_code_widget_selection_delete(widget);
418

419
   line = elm_code_file_line_get(file, 1);
420
   text = elm_code_line_text_get(line, &length);
421
   ck_assert_strn_eq("teXT", text, length);
422
   ck_assert_int_eq(2, elm_code_file_lines_get(file));
423

424
   elm_code_widget_selection_start(widget, 2, 1);
425
   elm_code_widget_selection_end(widget, 1, 5);
426
   elm_code_widget_selection_delete(widget);
427

428
   line = elm_code_file_line_get(file, 1);
429
   text = elm_code_line_text_get(line, &length);
430
   ck_assert_strn_eq("teXTemove", text, length);
431
   ck_assert_int_eq(1, elm_code_file_lines_get(file));
432

433
   elm_code_free(code);
434
   elm_shutdown();
435
}
436
EFL_END_TEST
437

438
EFL_START_TEST(elm_code_test_widget_selection_delete_multiline)
439
{
440
   Elm_Code *code;
441
   Elm_Code_File *file;
442
   Elm_Code_Line *line;
443
   Elm_Code_Widget *widget;
444
   Evas_Object *win;
445
   const char *text;
446
   unsigned int length;
447

448
   char *args[] = { "exe" };
449
   elm_init(1, args);
450
   code = elm_code_create();
451
   file = elm_code_file_new(code);
452
   elm_code_file_line_append(file, "text", 4, NULL);
453
   elm_code_file_line_append(file, "remove", 6, NULL);
454
   elm_code_file_line_append(file, "TEXT", 4, NULL);
455
   elm_code_file_line_append(file, "delete", 6, NULL);
456
   elm_code_file_line_append(file, "REMOVE", 6, NULL);
457

458
   win = win_add(NULL, "code", ELM_WIN_BASIC);
459
   widget = elm_code_widget_add(win, code);
460
   line = elm_code_file_line_get(file, 1);
461
   text = elm_code_line_text_get(line, NULL);
462
   ck_assert_str_eq("text", text);
463
   ck_assert_int_eq(5, elm_code_file_lines_get(file));
464

465
   elm_code_widget_selection_start(widget, 1, 3);
466
   elm_code_widget_selection_end(widget, 3, 2);
467
   elm_code_widget_selection_delete(widget);
468

469
   line = elm_code_file_line_get(file, 1);
470
   text = elm_code_line_text_get(line, &length);
471
   ck_assert_strn_eq("teXT", text, length);
472
   ck_assert_int_eq(3, elm_code_file_lines_get(file));
473

474
   elm_code_widget_selection_start(widget, 1, 5);
475
   elm_code_widget_selection_end(widget, 3, 1);
476
   elm_code_widget_selection_delete(widget);
477

478
   line = elm_code_file_line_get(file, 1);
479
   text = elm_code_line_text_get(line, &length);
480
   ck_assert_strn_eq("teXTEMOVE", text, length);
481
   ck_assert_int_eq(1, elm_code_file_lines_get(file));
482

483
   elm_code_free(code);
484
   elm_shutdown();
485
}
486
EFL_END_TEST
487

488
EFL_START_TEST(elm_code_test_widget_selection_reverse_delete_multiline)
489
{
490
   Elm_Code *code;
491
   Elm_Code_File *file;
492
   Elm_Code_Line *line;
493
   Elm_Code_Widget *widget;
494
   Evas_Object *win;
495
   const char *text;
496
   unsigned int length;
497

498
   char *args[] = { "exe" };
499
   elm_init(1, args);
500
   code = elm_code_create();
501
   file = elm_code_file_new(code);
502
   elm_code_file_line_append(file, "text", 4, NULL);
503
   elm_code_file_line_append(file, "remove", 6, NULL);
504
   elm_code_file_line_append(file, "TEXT", 4, NULL);
505
   elm_code_file_line_append(file, "delete", 6, NULL);
506
   elm_code_file_line_append(file, "REMOVE", 6, NULL);
507

508
   win = win_add(NULL, "code", ELM_WIN_BASIC);
509
   widget = elm_code_widget_add(win, code);
510
   line = elm_code_file_line_get(file, 1);
511
   text = elm_code_line_text_get(line, NULL);
512
   ck_assert_str_eq("text", text);
513
   ck_assert_int_eq(5, elm_code_file_lines_get(file));
514

515
   elm_code_widget_selection_start(widget, 3, 2);
516
   elm_code_widget_selection_end(widget, 1, 3);
517
   elm_code_widget_selection_delete(widget);
518

519
   line = elm_code_file_line_get(file, 1);
520
   text = elm_code_line_text_get(line, &length);
521
   ck_assert_strn_eq("teXT", text, length);
522
   ck_assert_int_eq(3, elm_code_file_lines_get(file));
523

524
   elm_code_widget_selection_start(widget, 3, 1);
525
   elm_code_widget_selection_end(widget, 1, 5);
526
   elm_code_widget_selection_delete(widget);
527

528
   line = elm_code_file_line_get(file, 1);
529
   text = elm_code_line_text_get(line, &length);
530
   ck_assert_strn_eq("teXTEMOVE", text, length);
531
   ck_assert_int_eq(1, elm_code_file_lines_get(file));
532

533
   elm_code_free(code);
534
   elm_shutdown();
535
}
536
EFL_END_TEST
537

538
EFL_START_TEST(elm_code_test_widget_selection_select_line)
539
{
540
   Elm_Code *code;
541
   Elm_Code_File *file;
542
   Elm_Code_Widget *widget;
543
   Evas_Object *win;
544
   char *selection;
545

546
   char *args[] = { "exe" };
547
   elm_init(1, args);
548
   code = elm_code_create();
549
   file = elm_code_file_new(code);
550
   elm_code_file_line_append(file, "line selection", 14, NULL);
551
   elm_code_file_line_append(file, "line2", 5, NULL);
552
   elm_code_file_line_append(file, "\ttab", 4, NULL);
553

554
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
555
   widget = elm_code_widget_add(win, code);
556

557
   elm_code_widget_selection_select_line(widget, 1);
558
   selection = elm_code_widget_selection_text_get(widget);
559
   ck_assert_str_eq("line selection", selection);
560
   free(selection);
561

562
   elm_code_widget_selection_select_line(widget, 2);
563
   selection = elm_code_widget_selection_text_get(widget);
564
   ck_assert_str_eq("line2", selection);
565
   free(selection);
566

567
   elm_code_widget_selection_select_line(widget, 3);
568
   selection = elm_code_widget_selection_text_get(widget);
569
   ck_assert_str_eq("\ttab", selection);
570
   free(selection);
571

572
   elm_shutdown();
573
}
574
EFL_END_TEST
575

576
EFL_START_TEST(elm_code_test_widget_selection_select_word)
577
{
578
   Elm_Code *code;
579
   Elm_Code_File *file;
580
   Elm_Code_Widget *widget;
581
   Evas_Object *win;
582
   char *selection;
583

584
   char *args[] = { "exe" };
585
   elm_init(1, args);
586
   code = elm_code_create();
587
   file = elm_code_file_new(code);
588
   elm_code_file_line_append(file, "word selection test", 19, NULL);
589
   elm_code_file_line_append(file, "more stuff\tto test", 18, NULL);
590
   elm_code_file_line_append(file, "word \"symbols\" test", 19, NULL);
591

592
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
593
   widget = elm_code_widget_add(win, code);
594

595
   elm_code_widget_selection_select_word(widget, 1, 3);
596
   selection = elm_code_widget_selection_text_get(widget);
597
   ck_assert_str_eq("word", selection);
598
   free(selection);
599

600
   elm_code_widget_selection_select_word(widget, 1, 16);
601
   selection = elm_code_widget_selection_text_get(widget);
602
   ck_assert_str_eq("test", selection);
603
   free(selection);
604

605
   elm_code_widget_selection_select_word(widget, 2, 9);
606
   selection = elm_code_widget_selection_text_get(widget);
607
   ck_assert_str_eq("stuff", selection);
608
   free(selection);
609

610
   elm_code_widget_selection_select_word(widget, 3, 9);
611
   selection = elm_code_widget_selection_text_get(widget);
612
   ck_assert_str_eq("symbols", selection);
613
   free(selection);
614
   elm_shutdown();
615
}
616
EFL_END_TEST
617

618
EFL_START_TEST(elm_code_test_widget_selection_select_word_punctuation)
619
{
620
   Elm_Code *code;
621
   Elm_Code_File *file;
622
   Elm_Code_Widget *widget;
623
   Evas_Object *win;
624
   char *selection;
625

626
   char *args[] = { "exe" };
627
   elm_init(1, args);
628
   code = elm_code_create();
629
   file = elm_code_file_new(code);
630
   elm_code_file_line_append(file, "comma, stop. question? mark!", 38, NULL);
631

632
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
633
   widget = elm_code_widget_add(win, code);
634

635
   elm_code_widget_selection_select_word(widget, 1, 3);
636
   selection = elm_code_widget_selection_text_get(widget);
637
   ck_assert_str_eq("comma", selection);
638
   free(selection);
639

640
   elm_code_widget_selection_select_word(widget, 1, 10);
641
   selection = elm_code_widget_selection_text_get(widget);
642
   ck_assert_str_eq("stop", selection);
643
   free(selection);
644

645
   elm_code_widget_selection_select_word(widget, 1, 20);
646
   selection = elm_code_widget_selection_text_get(widget);
647
   ck_assert_str_eq("question", selection);
648
   free(selection);
649

650
   elm_code_widget_selection_select_word(widget, 1, 25);
651
   selection = elm_code_widget_selection_text_get(widget);
652
   ck_assert_str_eq("mark", selection);
653
   free(selection);
654
   elm_shutdown();
655
}
656
EFL_END_TEST
657

658
EFL_START_TEST(elm_code_test_widget_selection_select_word_symbols)
659
{
660
   Elm_Code *code;
661
   Elm_Code_File *file;
662
   Elm_Code_Widget *widget;
663
   Evas_Object *win;
664
   char *selection;
665

666
   char *args[] = { "exe" };
667
   elm_init(1, args);
668
   code = elm_code_create();
669
   file = elm_code_file_new(code);
670
   elm_code_file_line_append(file, "colon: [array] (brackets) {braces}", 38, NULL);
671

672
   win = win_add(NULL, "entry", ELM_WIN_BASIC);
673
   widget = elm_code_widget_add(win, code);
674

675
   elm_code_widget_selection_select_word(widget, 1, 3);
676
   selection = elm_code_widget_selection_text_get(widget);
677
   ck_assert_str_eq("colon", selection);
678
   free(selection);
679

680
   elm_code_widget_selection_select_word(widget, 1, 10);
681
   selection = elm_code_widget_selection_text_get(widget);
682
   ck_assert_str_eq("array", selection);
683
   free(selection);
684

685
   elm_code_widget_selection_select_word(widget, 1, 20);
686
   selection = elm_code_widget_selection_text_get(widget);
687
   ck_assert_str_eq("brackets", selection);
688
   free(selection);
689

690
   elm_code_widget_selection_select_word(widget, 1, 30);
691
   selection = elm_code_widget_selection_text_get(widget);
692
   ck_assert_str_eq("braces", selection);
693
   free(selection);
694
   elm_shutdown();
695
}
696
EFL_END_TEST
697

698
void elm_code_test_widget_selection(TCase *tc)
699
{
700
   tcase_add_test(tc, elm_code_test_widget_selection_set);
701
   tcase_add_test(tc, elm_code_test_widget_selection_normalized_get);
702
   tcase_add_test(tc, elm_code_test_widget_selection_text_get);
703
   tcase_add_test(tc, elm_code_test_widget_selection_reverse_text_get);
704
   tcase_add_test(tc, elm_code_test_widget_selection_text_get_twoline);
705
   tcase_add_test(tc, elm_code_test_widget_selection_reverse_text_get_twoline);
706
   tcase_add_test(tc, elm_code_test_widget_selection_text_get_multiline);
707
   tcase_add_test(tc, elm_code_test_widget_selection_reverse_text_get_multiline);
708
   tcase_add_test(tc, elm_code_test_widget_selection_delete);
709
   tcase_add_test(tc, elm_code_test_widget_selection_reverse_delete);
710
   tcase_add_test(tc, elm_code_test_widget_selection_delete_twoline);
711
   tcase_add_test(tc, elm_code_test_widget_selection_reverse_delete_twoline);
712
   tcase_add_test(tc, elm_code_test_widget_selection_delete_multiline);
713
   tcase_add_test(tc, elm_code_test_widget_selection_reverse_delete_multiline);
714
   tcase_add_test(tc, elm_code_test_widget_selection_select_line);
715
   tcase_add_test(tc, elm_code_test_widget_selection_select_word);
716
   tcase_add_test(tc, elm_code_test_widget_selection_select_word_punctuation);
717
   tcase_add_test(tc, elm_code_test_widget_selection_select_word_symbols);
718
}
719

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.