efl/src/tests/eolian_cxx/eolian_cxx_test_binding.cc

61 lines
1.2 KiB
C++
Raw Normal View History

2014-07-16 12:14:17 -07:00
// test EFL++ generated bindings
eolain_cxx: Fix C++ support for new Eolian features Added optional constructor methods for C++ Eolian wrappers. Changed the interface of wrappers' main constructors. If there are optional constructor methods they should be passed as variadic template argument at the end of the constructor. To support variadic template arguments, the optional "parent" parameter is now the first parameter and there is another constructor without the "parent" parameter. Checking for @optinal and @nullable attributes instead of @nonull. Now @nonull is the default, and eina::optional is only used when @optional or @nullable attribute is specified. The names of constructor methods no longer have the class name prefixed. Added unit tests for checking the binding of optional constructors. Added new .eo file to be used in the test. Changed the generated documentation of constructors. Changed the efl::eo::inherit accordingly, to address these new features. Now the constructor methods should be explicit called in the efl::eo::inherit constructor, which will receive them via variadic template arguments. Added another constructor to efl::eo::inherit for passing the parent object. Updated some tests and examples to follow the new interface. Removed some code that is no longer necessary. Also, fix Eolian C++ support for constructing properties. fix assertion when parsing constructing properties. Now if a property is a constructing property eolian_cxx will generate a constructor method that have the property name (without the "_set" suffix).
2015-03-26 07:48:09 -07:00
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <generic.eo.hh>
#include <check.h>
START_TEST(eolian_cxx_test_binding_constructor_only_required)
{
efl::eo::eo_init i;
bool called1 = false;
generic g(
g.required_ctor_a(1),
g.required_ctor_b(std::bind([&called1] { called1 = true; }))
);
g.call_req_ctor_b_callback();
g.call_opt_ctor_b_callback();
fail_if(!called1);
fail_if(1 != g.req_ctor_a_value_get());
}
END_TEST
START_TEST(eolian_cxx_test_binding_constructor_all_optionals)
{
efl::eo::eo_init i;
bool called1 = false;
bool called2 = false;
generic g(
g.required_ctor_a(2),
g.required_ctor_b(std::bind([&called1] { called1 = true; })),
g.optional_ctor_a(3),
g.optional_ctor_b(std::bind([&called2] { called2 = true; }))
);
g.call_req_ctor_b_callback();
g.call_opt_ctor_b_callback();
fail_if(!called1);
fail_if(!called2);
fail_if(2 != g.req_ctor_a_value_get());
fail_if(3 != g.opt_ctor_a_value_get());
}
END_TEST
void
eolian_cxx_test_binding(TCase* tc)
{
tcase_add_test(tc, eolian_cxx_test_binding_constructor_only_required);
tcase_add_test(tc, eolian_cxx_test_binding_constructor_all_optionals);
}