summaryrefslogtreecommitdiff
path: root/src/tests/edje/edje_test_edje.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 14:49:58 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-05-24 18:50:58 +0900
commitdf375ca395c669192c4a8ee7b88e3fbdb93f7901 (patch)
tree09a70739778b67fad52812ab5932c4c8e826da69 /src/tests/edje/edje_test_edje.c
parentb84c9cc376363576f893fd7b0b04cc50eb8fbb64 (diff)
Edje: fix test case (switch to efl_part)
Diffstat (limited to '')
-rw-r--r--src/tests/edje/edje_test_edje.c137
1 files changed, 39 insertions, 98 deletions
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 9e0ddfaf43..38a76ac6ff 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -513,14 +513,14 @@ START_TEST(edje_test_box_eoapi)
513 } 513 }
514 514
515 /* same test case as legacy api above */ 515 /* same test case as legacy api above */
516 efl_pack_end(efl_content_get(obj, "box"), sobjs[3]); 516 efl_pack_end(efl_part(obj, "box"), sobjs[3]);
517 efl_pack_begin(efl_content_get(obj, "box"), sobjs[1]); 517 efl_pack_begin(efl_part(obj, "box"), sobjs[1]);
518 efl_pack_before(efl_content_get(obj, "box"), sobjs[0], sobjs[1]); 518 efl_pack_before(efl_part(obj, "box"), sobjs[0], sobjs[1]);
519 efl_pack_after(efl_content_get(obj, "box"), sobjs[4], sobjs[3]); 519 efl_pack_after(efl_part(obj, "box"), sobjs[4], sobjs[3]);
520 efl_pack_at(efl_content_get(obj, "box"), sobjs[2], 2); 520 efl_pack_at(efl_part(obj, "box"), sobjs[2], 2);
521 fail_if(efl_content_count(efl_content_get(obj, "box")) != 5); 521 fail_if(efl_content_count(efl_part(obj, "box")) != 5);
522 522
523 it = efl_content_iterate(efl_content_get(obj, "box")); 523 it = efl_content_iterate(efl_part(obj, "box"));
524 i = 0; 524 i = 0;
525 EINA_ITERATOR_FOREACH(it, sobj) 525 EINA_ITERATOR_FOREACH(it, sobj)
526 fail_if(sobj != sobjs[i++]); 526 fail_if(sobj != sobjs[i++]);
@@ -528,27 +528,27 @@ START_TEST(edje_test_box_eoapi)
528 eina_iterator_free(it); 528 eina_iterator_free(it);
529 529
530 /* clear up and test a bit more */ 530 /* clear up and test a bit more */
531 efl_pack_unpack_all(efl_content_get(obj, "box")); 531 efl_pack_unpack_all(efl_part(obj, "box"));
532 fail_if(efl_content_count(efl_content_get(obj, "box")) != 0); 532 fail_if(efl_content_count(efl_part(obj, "box")) != 0);
533 533
534 efl_pack(efl_content_get(obj, "box"), sobjs[1]); 534 efl_pack(efl_part(obj, "box"), sobjs[1]);
535 efl_pack_at(efl_content_get(obj, "box"), sobjs[0], 0); 535 efl_pack_at(efl_part(obj, "box"), sobjs[0], 0);
536 efl_pack_at(efl_content_get(obj, "box"), sobjs[2], -1); 536 efl_pack_at(efl_part(obj, "box"), sobjs[2], -1);
537 it = efl_content_iterate(efl_content_get(obj, "box")); 537 it = efl_content_iterate(efl_part(obj, "box"));
538 i = 0; 538 i = 0;
539 EINA_ITERATOR_FOREACH(it, sobj) 539 EINA_ITERATOR_FOREACH(it, sobj)
540 fail_if(sobj != sobjs[i++]); 540 fail_if(sobj != sobjs[i++]);
541 fail_if(i != 3); 541 fail_if(i != 3);
542 eina_iterator_free(it); 542 eina_iterator_free(it);
543 543
544 fail_if(!efl_content_remove(efl_content_get(obj, "box"), sobjs[0])); 544 fail_if(!efl_content_remove(efl_part(obj, "box"), sobjs[0]));
545 fail_if(efl_content_count(efl_content_get(obj, "box")) != 2); 545 fail_if(efl_content_count(efl_part(obj, "box")) != 2);
546 fail_if(!efl_pack_unpack_at(efl_content_get(obj, "box"), 1)); 546 fail_if(!efl_pack_unpack_at(efl_part(obj, "box"), 1));
547 fail_if(efl_content_count(efl_content_get(obj, "box")) != 1); 547 fail_if(efl_content_count(efl_part(obj, "box")) != 1);
548 fail_if(efl_pack_index_get(efl_content_get(obj, "box"), sobjs[1]) != 0); 548 fail_if(efl_pack_index_get(efl_part(obj, "box"), sobjs[1]) != 0);
549 549
550 efl_pack_clear(efl_content_get(obj, "box")); 550 efl_pack_clear(efl_part(obj, "box"));
551 fail_if(efl_content_count(efl_content_get(obj, "box")) != 0); 551 fail_if(efl_content_count(efl_part(obj, "box")) != 0);
552 552
553 EDJE_TEST_FREE_EVAS(); 553 EDJE_TEST_FREE_EVAS();
554} 554}
@@ -632,7 +632,7 @@ END_TEST
632START_TEST(edje_test_table_eoapi) 632START_TEST(edje_test_table_eoapi)
633{ 633{
634 Evas *evas; 634 Evas *evas;
635 Evas_Object *obj, *sobj, *sobjs[4]; 635 Evas_Object *obj, *sobj, *sobjs[4], *proxy;
636 Eina_Iterator *it; 636 Eina_Iterator *it;
637 int i, k, l, cs, rs, cols, rows; 637 int i, k, l, cs, rs, cols, rows;
638 638
@@ -642,7 +642,7 @@ START_TEST(edje_test_table_eoapi)
642 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"));
643 643
644 /* check items from EDC */ 644 /* check items from EDC */
645 fail_if(efl_content_count(efl_content_get(obj, "table")) != 4); 645 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
646 for (l = 0; l < 2; l++) 646 for (l = 0; l < 2; l++)
647 for (k = 0; k < 2; k++) 647 for (k = 0; k < 2; k++)
648 { 648 {
@@ -651,7 +651,7 @@ START_TEST(edje_test_table_eoapi)
651 651
652 /* items have a text part "text" containing their position */ 652 /* items have a text part "text" containing their position */
653 sprintf(buf, "%d,%d", k, l); 653 sprintf(buf, "%d,%d", k, l);
654 sobj = efl_pack_grid_content_get(efl_content_get(obj, "table"), k, l); 654 sobj = efl_pack_grid_content_get(efl_part(obj, "table"), k, l);
655 fail_if(!sobj); 655 fail_if(!sobj);
656 //txt = efl_part_text_get(sobj, "text"); 656 //txt = efl_part_text_get(sobj, "text");
657 txt = edje_object_part_text_get(sobj, "text"); 657 txt = edje_object_part_text_get(sobj, "text");
@@ -666,16 +666,16 @@ START_TEST(edje_test_table_eoapi)
666 i = l*2 + k; 666 i = l*2 + k;
667 sobjs[i] = eo_add(EVAS_RECTANGLE_CLASS, evas); 667 sobjs[i] = eo_add(EVAS_RECTANGLE_CLASS, evas);
668 fail_if(!sobjs[i]); 668 fail_if(!sobjs[i]);
669 efl_pack_grid(efl_content_get(obj, "table"), sobjs[i], k, l + 2, 1, 1); 669 efl_pack_grid(efl_part(obj, "table"), sobjs[i], k, l + 2, 1, 1);
670 } 670 }
671 671
672 fail_if(efl_content_count(efl_content_get(obj, "table")) != 8); 672 fail_if(efl_content_count(efl_part(obj, "table")) != 8);
673 673
674 i = 0; 674 i = 0;
675 it = efl_content_iterate(efl_content_get(obj, "table")); 675 it = efl_content_iterate(efl_part(obj, "table"));
676 EINA_ITERATOR_FOREACH(it, sobj) 676 EINA_ITERATOR_FOREACH(it, sobj)
677 { 677 {
678 efl_pack_grid_position_get(efl_content_get(obj, "table"), sobj, &k, &l, &cs, &rs); 678 efl_pack_grid_position_get(efl_part(obj, "table"), sobj, &k, &l, &cs, &rs);
679 fail_if(cs != 1); 679 fail_if(cs != 1);
680 fail_if(rs != 1); 680 fail_if(rs != 1);
681 if (l >= 2) 681 if (l >= 2)
@@ -686,83 +686,24 @@ START_TEST(edje_test_table_eoapi)
686 fail_if(i != 8); 686 fail_if(i != 8);
687 687
688 /* table size and clear */ 688 /* table size and clear */
689 efl_pack_grid_size_get(efl_content_get(obj, "table"), &cols, &rows); 689 efl_pack_grid_size_get(efl_part(obj, "table"), &cols, &rows);
690 fail_if(cols != 2); 690 fail_if(cols != 2);
691 fail_if(rows != 4); 691 fail_if(rows != 4);
692 692
693 efl_pack_clear(efl_content_get(obj, "table")); 693 efl_pack_clear(efl_part(obj, "table"));
694 fail_if(efl_content_count(efl_content_get(obj, "table")) != 4); 694 fail_if(efl_content_count(efl_part(obj, "table")) != 4);
695 695
696 efl_pack_grid_size_get(efl_content_get(obj, "table"), &cols, &rows); 696 efl_pack_grid_size_get(efl_part(obj, "table"), &cols, &rows);
697 fail_if(cols != 2); 697 fail_if(cols != 2);
698 fail_if(rows != 2); 698 fail_if(rows != 2);
699 699
700 700 /* test multiple ops on a proxy object */
701 /* Test proxy object lifecycle. 701 proxy = eo_ref(efl_part(obj, "table"));
702 * 702 fail_if(!proxy);
703 * Note: Some things below this point may break if the implementation 703 fail_if(!efl_pack_clear(proxy));
704 * changes, that's OK. We only want to provide a certain level of safety 704 fail_if(!efl_pack_clear(proxy));
705 * against misuse. Only the above use case is correct. 705 fail_if(!efl_pack_clear(proxy));
706 * 706 eo_unref(proxy);
707 * Pretty much everything below this point is a misuse of the API.
708 */
709
710 Eo *table, *other;
711
712 table = efl_content_get(obj, "table");
713 fail_if(!table);
714
715 i = eo_ref_get(table);
716 fail_if(i != 1);
717 eo_unref(table);
718
719 /* this will generate eo errors */
720 k = eo_ref_get(table);
721 fail_if(k > 0);
722
723 cols = -1; rows = -1;
724 /* this will generate eo errors */
725 efl_pack_grid_size_get(table, &cols, &rows);
726 fail_if(cols != -1);
727 fail_if(rows != -1);
728
729 table = efl_content_get(obj, "table");
730 fail_if(!table);
731 other = efl_content_get(obj, "table");
732 fail_if(other != table);
733 fail_if(eo_ref_get(other) != 1);
734
735 /* delete edje and verify proxy died */
736 eo_unref(obj);
737
738 /* this will generate eo errors */
739 fail_if(eo_ref_get(table) > 0);
740
741 cols = -1; rows = -1;
742 /* this will generate eo errors */
743 efl_pack_grid_size_get(table, &cols, &rows);
744 fail_if(cols != -1);
745 fail_if(rows != -1);
746
747 /* try again but keep a ref on proxy */
748 obj = edje_object_add(evas);
749 fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
750
751 table = efl_content_get(obj, "table");
752 fail_if(!table);
753 eo_ref(table);
754 fflush(stderr);
755 eo_unref(obj);
756 /* note: obj has > 0 refs because evas likes to keep objects around a bit */
757 fail_if(eo_ref_get(table) > 1);
758
759 cols = -1; rows = -1;
760 /* this will NOT generate eo errors (table is alive) */
761 efl_pack_grid_size_get(table, &cols, &rows);
762 fail_if(cols > 0);
763 fail_if(rows > 0);
764
765 eo_unref(table);
766 707
767 EDJE_TEST_FREE_EVAS(); 708 EDJE_TEST_FREE_EVAS();
768} 709}