forked from enlightenment/efl
tests/spec: pre-create a ton of widgets during test init
Summary: similar to existing mechanics for elm/efl_ui tests, this pre-creates all the widgets used as test contents for all the test cases so they can be forked and reused without needing to spend time in every single test creating the same test contents Depends on D10573 Reviewers: cedric Reviewed By: cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10574
This commit is contained in:
parent
7cd9113f1f
commit
5d69afdc09
|
@ -473,7 +473,8 @@ object_setup(void)
|
|||
{
|
||||
if (widget_klass == EFL_UI_GROUP_ITEM_CLASS)
|
||||
{
|
||||
Efl_Ui_Collection *collection = efl_add(EFL_UI_GRID_CLASS, win);
|
||||
Efl_Ui_Collection *collection = collection_grid;
|
||||
if (!collection) collection = efl_add(EFL_UI_GRID_CLASS, win);
|
||||
efl_content_set(win, collection);
|
||||
efl_pack_end(collection, widget);
|
||||
}
|
||||
|
|
|
@ -10,12 +10,17 @@
|
|||
|
||||
Evas_Object *win = NULL;
|
||||
Evas_Object *widget = NULL;
|
||||
Eo *collection_grid = NULL;
|
||||
const Efl_Class *test_content_klass = NULL;
|
||||
const Efl_Class *widget_klass = NULL;
|
||||
EFL_CLASS_SIMPLE_CLASS(efl_ui_widget, "efl_ui_widget", EFL_UI_WIDGET_CLASS);
|
||||
EFL_CLASS_SIMPLE_CLASS(efl_ui_item, "efl_ui_item", EFL_UI_ITEM_CLASS);
|
||||
#define EFL_UI_ITEM_REALIZED_CLASS efl_ui_item_realized_class_get()
|
||||
|
||||
|
||||
#define NUM_TEST_WIDGETS 30
|
||||
static Eina_Hash *test_widgets;
|
||||
|
||||
static void
|
||||
_setup_window_and_widget(const Efl_Class *klass, const Efl_Class *content_klass)
|
||||
{
|
||||
|
@ -37,11 +42,42 @@ _setup_window_and_widget(const Efl_Class *klass, const Efl_Class *content_klass)
|
|||
Eo*
|
||||
create_test_widget(void)
|
||||
{
|
||||
static unsigned int i;
|
||||
|
||||
if (is_forked())
|
||||
{
|
||||
Eo **widgets = eina_hash_find(test_widgets, &test_content_klass);
|
||||
ck_assert_int_lt(i, NUM_TEST_WIDGETS);
|
||||
ck_assert(widgets[i]);
|
||||
return widgets[i++];
|
||||
}
|
||||
Eo *ret = efl_add(test_content_klass, win);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
spec_suite_setup(Eo *global_win)
|
||||
{
|
||||
const Efl_Class *test_classes[] =
|
||||
{
|
||||
EFL_UI_GRID_DEFAULT_ITEM_CLASS,
|
||||
EFL_UI_LIST_DEFAULT_ITEM_CLASS,
|
||||
EFL_UI_RADIO_CLASS,
|
||||
EFL_UI_TAB_BAR_DEFAULT_ITEM_CLASS,
|
||||
WIDGET_CLASS
|
||||
};
|
||||
collection_grid = efl_add(EFL_UI_GRID_CLASS, global_win);
|
||||
test_widgets = eina_hash_pointer_new(NULL);
|
||||
for (unsigned int t = 0; t < EINA_C_ARRAY_LENGTH(test_classes); t++)
|
||||
{
|
||||
Eo **widgets = malloc(NUM_TEST_WIDGETS * sizeof(void*));
|
||||
for (unsigned int i = 0; i < NUM_TEST_WIDGETS; i++)
|
||||
efl_wref_add(efl_add(test_classes[t], global_win), &widgets[i]);
|
||||
eina_hash_set(test_widgets, &test_classes[t], widgets);
|
||||
}
|
||||
}
|
||||
|
||||
#include "efl_ui_spec_suite_gen.x"
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -54,6 +90,8 @@ main(int argc, char **argv)
|
|||
if (!_efl_test_option_disp(argc, argv, etc))
|
||||
return 0;
|
||||
|
||||
suite_setup_cb_set(spec_suite_setup);
|
||||
|
||||
failed_count = suite_setup(EINA_FALSE);
|
||||
|
||||
failed_count += _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
extern Eo *win;
|
||||
extern Eo *widget;
|
||||
extern Eo *collection_grid;
|
||||
extern const Efl_Class *widget_klass;
|
||||
|
||||
void efl_pack_behavior_test(TCase *tc);
|
||||
|
|
Loading…
Reference in New Issue