summaryrefslogtreecommitdiff
path: root/src/tests/edje
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-05-09 14:37:22 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-05-09 14:42:47 +0900
commit5ba58353f006d54f096c371e9c773d24cf4263cc (patch)
tree915b6200b35bc00df1f37fb4022387855bb86e45 /src/tests/edje
parent290b3d8926460a7731935dc554694e34a4edb540 (diff)
Edje: Fix test case to show proper use of part APIs
The one and only valid use case is calling a function directly on the part handle, like: func(part_get(obj, "part"), args). This does not change the actual proxy object lifecycle or resolve any potential issues, but this should clear up things in terms of scope for proper (supported) use. efl_content_get may become efl_part() and return a temporary object, valid for a single function call. Those are "details" still to be refined.
Diffstat (limited to 'src/tests/edje')
-rw-r--r--src/tests/edje/edje_test_edje.c88
1 files changed, 43 insertions, 45 deletions
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 71969b0728..bcd36f1385 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -499,7 +499,6 @@ START_TEST(edje_test_box_eoapi)
499 Evas *evas; 499 Evas *evas;
500 Evas_Object *obj, *sobj, *sobjs[5]; 500 Evas_Object *obj, *sobj, *sobjs[5];
501 Eina_Iterator *it; 501 Eina_Iterator *it;
502 Eo *box;
503 int i; 502 int i;
504 503
505 evas = EDJE_TEST_INIT_EVAS(); 504 evas = EDJE_TEST_INIT_EVAS();
@@ -514,17 +513,14 @@ START_TEST(edje_test_box_eoapi)
514 } 513 }
515 514
516 /* same test case as legacy api above */ 515 /* same test case as legacy api above */
517 box = efl_content_get(obj, "box"); 516 efl_pack_end(efl_content_get(obj, "box"), sobjs[3]);
518 fail_if(!box); 517 efl_pack_begin(efl_content_get(obj, "box"), sobjs[1]);
519 518 efl_pack_before(efl_content_get(obj, "box"), sobjs[0], sobjs[1]);
520 efl_pack_end(box, sobjs[3]); 519 efl_pack_after(efl_content_get(obj, "box"), sobjs[4], sobjs[3]);
521 efl_pack_begin(box, sobjs[1]); 520 efl_pack_at(efl_content_get(obj, "box"), sobjs[2], 2);
522 efl_pack_before(box, sobjs[0], sobjs[1]); 521 fail_if(efl_content_count(efl_content_get(obj, "box")) != 5);
523 efl_pack_after(box, sobjs[4], sobjs[3]); 522
524 efl_pack_at(box, sobjs[2], 2); 523 it = efl_content_iterate(efl_content_get(obj, "box"));
525 fail_if(efl_content_count(box) != 5);
526
527 it = efl_content_iterate(box);
528 i = 0; 524 i = 0;
529 EINA_ITERATOR_FOREACH(it, sobj) 525 EINA_ITERATOR_FOREACH(it, sobj)
530 fail_if(sobj != sobjs[i++]); 526 fail_if(sobj != sobjs[i++]);
@@ -532,29 +528,27 @@ START_TEST(edje_test_box_eoapi)
532 eina_iterator_free(it); 528 eina_iterator_free(it);
533 529
534 /* clear up and test a bit more */ 530 /* clear up and test a bit more */
535 efl_pack_unpack_all(box); 531 efl_pack_unpack_all(efl_content_get(obj, "box"));
536 fail_if(efl_content_count(box) != 0); 532 fail_if(efl_content_count(efl_content_get(obj, "box")) != 0);
537 533
538 efl_pack(box, sobjs[1]); 534 efl_pack(efl_content_get(obj, "box"), sobjs[1]);
539 efl_pack_at(box, sobjs[0], 0); 535 efl_pack_at(efl_content_get(obj, "box"), sobjs[0], 0);
540 efl_pack_at(box, sobjs[2], -1); 536 efl_pack_at(efl_content_get(obj, "box"), sobjs[2], -1);
541 it = efl_content_iterate(box); 537 it = efl_content_iterate(efl_content_get(obj, "box"));
542 i = 0; 538 i = 0;
543 EINA_ITERATOR_FOREACH(it, sobj) 539 EINA_ITERATOR_FOREACH(it, sobj)
544 fail_if(sobj != sobjs[i++]); 540 fail_if(sobj != sobjs[i++]);
545 fail_if(i != 3); 541 fail_if(i != 3);
546 eina_iterator_free(it); 542 eina_iterator_free(it);
547 543
548 fail_if(!efl_content_remove(box, sobjs[0])); 544 fail_if(!efl_content_remove(efl_content_get(obj, "box"), sobjs[0]));
549 fail_if(efl_content_count(box) != 2); 545 fail_if(efl_content_count(efl_content_get(obj, "box")) != 2);
550 fail_if(!efl_pack_unpack_at(box, 1)); 546 fail_if(!efl_pack_unpack_at(efl_content_get(obj, "box"), 1));
551 fail_if(efl_content_count(box) != 1); 547 fail_if(efl_content_count(efl_content_get(obj, "box")) != 1);
552 fail_if(efl_pack_index_get(box, sobjs[1]) != 0); 548 fail_if(efl_pack_index_get(efl_content_get(obj, "box"), sobjs[1]) != 0);
553 549
554 efl_pack_clear(box); 550 efl_pack_clear(efl_content_get(obj, "box"));
555 fail_if(efl_content_count(box) != 0); 551 fail_if(efl_content_count(efl_content_get(obj, "box")) != 0);
556
557 eo_del(box);
558 552
559 EDJE_TEST_FREE_EVAS(); 553 EDJE_TEST_FREE_EVAS();
560} 554}
@@ -640,7 +634,6 @@ START_TEST(edje_test_table_eoapi)
640 Evas *evas; 634 Evas *evas;
641 Evas_Object *obj, *sobj, *sobjs[4]; 635 Evas_Object *obj, *sobj, *sobjs[4];
642 Eina_Iterator *it; 636 Eina_Iterator *it;
643 Eo *table, *other;
644 int i, k, l, cs, rs, cols, rows; 637 int i, k, l, cs, rs, cols, rows;
645 638
646 evas = EDJE_TEST_INIT_EVAS(); 639 evas = EDJE_TEST_INIT_EVAS();
@@ -648,11 +641,8 @@ START_TEST(edje_test_table_eoapi)
648 obj = edje_object_add(evas); 641 obj = edje_object_add(evas);
649 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group")); 642 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
650 643
651 table = efl_content_get(obj, "table");
652 fail_if(!table);
653
654 /* check items from EDC */ 644 /* check items from EDC */
655 fail_if(efl_content_count(table) != 4); 645 fail_if(efl_content_count(efl_content_get(obj, "table")) != 4);
656 for (l = 0; l < 2; l++) 646 for (l = 0; l < 2; l++)
657 for (k = 0; k < 2; k++) 647 for (k = 0; k < 2; k++)
658 { 648 {
@@ -661,7 +651,7 @@ START_TEST(edje_test_table_eoapi)
661 651
662 /* items have a text part "text" containing their position */ 652 /* items have a text part "text" containing their position */
663 sprintf(buf, "%d,%d", k, l); 653 sprintf(buf, "%d,%d", k, l);
664 sobj = efl_pack_grid_content_get(table, k, l); 654 sobj = efl_pack_grid_content_get(efl_content_get(obj, "table"), k, l);
665 fail_if(!sobj); 655 fail_if(!sobj);
666 //txt = efl_part_text_get(sobj, "text"); 656 //txt = efl_part_text_get(sobj, "text");
667 txt = edje_object_part_text_get(sobj, "text"); 657 txt = edje_object_part_text_get(sobj, "text");
@@ -676,16 +666,16 @@ START_TEST(edje_test_table_eoapi)
676 i = l*2 + k; 666 i = l*2 + k;
677 sobjs[i] = eo_add(EVAS_RECTANGLE_CLASS, evas); 667 sobjs[i] = eo_add(EVAS_RECTANGLE_CLASS, evas);
678 fail_if(!sobjs[i]); 668 fail_if(!sobjs[i]);
679 efl_pack_grid(table, sobjs[i], k, l + 2, 1, 1); 669 efl_pack_grid(efl_content_get(obj, "table"), sobjs[i], k, l + 2, 1, 1);
680 } 670 }
681 671
682 fail_if(efl_content_count(table) != 8); 672 fail_if(efl_content_count(efl_content_get(obj, "table")) != 8);
683 673
684 i = 0; 674 i = 0;
685 it = efl_content_iterate(table); 675 it = efl_content_iterate(efl_content_get(obj, "table"));
686 EINA_ITERATOR_FOREACH(it, sobj) 676 EINA_ITERATOR_FOREACH(it, sobj)
687 { 677 {
688 efl_pack_grid_position_get(table, sobj, &k, &l, &cs, &rs); 678 efl_pack_grid_position_get(efl_content_get(obj, "table"), sobj, &k, &l, &cs, &rs);
689 fail_if(cs != 1); 679 fail_if(cs != 1);
690 fail_if(rs != 1); 680 fail_if(rs != 1);
691 if (l >= 2) 681 if (l >= 2)
@@ -696,24 +686,32 @@ START_TEST(edje_test_table_eoapi)
696 fail_if(i != 8); 686 fail_if(i != 8);
697 687
698 /* table size and clear */ 688 /* table size and clear */
699 efl_pack_grid_size_get(table, &cols, &rows); 689 efl_pack_grid_size_get(efl_content_get(obj, "table"), &cols, &rows);
700 fail_if(cols != 2); 690 fail_if(cols != 2);
701 fail_if(rows != 4); 691 fail_if(rows != 4);
702 692
703 efl_pack_clear(table); 693 efl_pack_clear(efl_content_get(obj, "table"));
704 fail_if(efl_content_count(table) != 4); 694 fail_if(efl_content_count(efl_content_get(obj, "table")) != 4);
705 695
706 efl_pack_grid_size_get(table, &cols, &rows); 696 efl_pack_grid_size_get(efl_content_get(obj, "table"), &cols, &rows);
707 fail_if(cols != 2); 697 fail_if(cols != 2);
708 fail_if(rows != 2); 698 fail_if(rows != 2);
709 699
710 700
711 /* test proxy object references 701 /* Test proxy object lifecycle.
712 * exact reference count is not part of API, 702 *
713 * only lifecycle of object matters 703 * Note: Some things below this point may break if the implementation
704 * changes, that's OK. We only want to provide a certain level of safety
705 * against misuse. Only the above use case is correct.
714 * 706 *
715 * very ugly code below - test case only! 707 * Pretty much everything below this point is a misuse of the API.
716 */ 708 */
709
710 Eo *table, *other;
711
712 table = efl_content_get(obj, "table");
713 fail_if(!table);
714
717 i = eo_ref_get(table); 715 i = eo_ref_get(table);
718 fail_if(i != 1); 716 fail_if(i != 1);
719 eo_del(table); 717 eo_del(table);