csharp: Fix factory instantiation

After 892c26f906, widget factories require
a widget to be their parents.

This commit updates C# tests and adds a warning message to elementary if the user does
not provide one.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10122
This commit is contained in:
Lauro Moura 2019-09-24 20:06:29 +00:00 committed by Cedric Bail
parent 9d18fdeeed
commit 4234dcfc3e
4 changed files with 16 additions and 5 deletions

View File

@ -49,7 +49,11 @@ static Efl_Object *
_efl_ui_widget_factory_efl_object_finalize(Eo *obj, Efl_Ui_Widget_Factory_Data *pd) _efl_ui_widget_factory_efl_object_finalize(Eo *obj, Efl_Ui_Widget_Factory_Data *pd)
{ {
pd->parenting_widget = efl_provider_find(obj, EFL_UI_WIDGET_CLASS); pd->parenting_widget = efl_provider_find(obj, EFL_UI_WIDGET_CLASS);
if (!pd->parenting_widget) return NULL; if (!pd->parenting_widget)
{
ERR("Widget_Factory requires a Widget as parent.");
return NULL;
}
return efl_finalize(efl_super(obj, EFL_UI_WIDGET_FACTORY_CLASS)); return efl_finalize(efl_super(obj, EFL_UI_WIDGET_FACTORY_CLASS));
} }
@ -397,7 +401,7 @@ _efl_ui_property_bind_part_efl_ui_property_bind_property_bind(Eo *obj EINA_UNUSE
if (!pd->pd) if (!pd->pd)
{ {
EINA_LOG_ERR("Trying to bind part property without specifying which part"); ERR("Trying to bind part property without specifying which part");
return ENOENT; return ENOENT;
} }

View File

@ -65,7 +65,9 @@ public class TestModel {
{ {
string propertyBound = null; string propertyBound = null;
bool callbackCalled = false; bool callbackCalled = false;
var factory = new Efl.Ui.ItemFactory<Efl.Ui.Button>(); var parent = new Efl.Ui.Win(null);
parent.Visible = false;
var factory = new Efl.Ui.ItemFactory<Efl.Ui.Button>(parent);
factory.PropertyBoundEvent += (object sender, Efl.Ui.PropertyBindPropertyBoundEventArgs args) => { factory.PropertyBoundEvent += (object sender, Efl.Ui.PropertyBindPropertyBoundEventArgs args) => {
propertyBound = args.arg; propertyBound = args.arg;
callbackCalled = true; callbackCalled = true;

View File

@ -43,7 +43,9 @@ public static class TestMVVMParts
{ {
public static void mvvm_dynamic_parts() public static void mvvm_dynamic_parts()
{ {
var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(); var parent = new Efl.Ui.Win(null);
parent.Visible = false;
var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(parent);
var bindablePart = factory.TextPart(); var bindablePart = factory.TextPart();
var error = bindablePart.Markup().Bind("name"); var error = bindablePart.Markup().Bind("name");
@ -53,7 +55,9 @@ public static class TestMVVMParts
public static void mvvm_factory_properties() public static void mvvm_factory_properties()
{ {
var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(); var parent = new Efl.Ui.Win(null);
parent.Visible = false;
var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(parent);
var iconFactory = new Efl.Ui.ImageFactory(null); var iconFactory = new Efl.Ui.ImageFactory(null);
iconFactory.BindProperty("filename", "modelProperty"); iconFactory.BindProperty("filename", "modelProperty");
var error = factory.IconPart().BindFactory(iconFactory); var error = factory.IconPart().BindFactory(iconFactory);

View File

@ -92,6 +92,7 @@ efl_mono_suite = executable('efl-mono-suite',
env_mono = environment() env_mono = environment()
env_mono.set('MONO_PATH', efl_mono_test_suite_path ) env_mono.set('MONO_PATH', efl_mono_test_suite_path )
env_mono.set('EFL_RUN_IN_TREE', '1')
if (cs_is_dotnet) if (cs_is_dotnet)
copy_prog = find_program(['cp', 'copy']) copy_prog = find_program(['cp', 'copy'])