Fix google test warnings 10/123710/3
authorPawel Kurowski <p.kurowski2@samsung.com>
Thu, 6 Apr 2017 09:55:19 +0000 (11:55 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Tue, 18 Apr 2017 14:01:51 +0000 (07:01 -0700)
Redefine mocks as strict in tests

Change-Id: I88c91efc000693f547f6c859b22a525cf5dd630e

tests2/screen_reader_utils.cpp
tests2/screen_reader_utils.hpp
tests2/screen_reader_vconf.cpp
tests2/utils_description_trait.cpp
tests2/utils_display_info.cpp
tests2/utils_role_trait.cpp
tests2/utils_state_trait.cpp
tests2/utils_text_for_relation_objects.cpp

index c4ec9c4e8ec185106cbaa5494c861b375d99468b..62fde015cdd919db5296e63bf4026d326758b3c0 100644 (file)
@@ -3,6 +3,7 @@
 TEST_F(ScreenReaderUtilsFixture, WidgetHasNameNullArgs) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (nullptr)).WillOnce(Return(nullptr));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (nullptr, ATSPI_STATE_INVALID)).WillOnce(Return(FALSE));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
 
        EXPECT_EQ(widget_has_state(nullptr, ATSPI_STATE_INVALID), false);
 }
index d730d027b659dcb410f214d466fa9579c8e91676..d31b65dc0f1626c0f42c545f09e8c3e278a15b86 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef SCREEN_READER_UTILS_HPP_
 #define SCREEN_READER_UTILS_HPP_
 
+#define DEFINE_MOCKING(mock_name) StrictMock<mock_ ## mock_name> m_ ## mock_name
+
 #include <memory>
 
 #include "wrappers/mocked_screen_reader_utils.h"
@@ -20,15 +22,15 @@ protected:
        std::unique_ptr<AtspiAccessible> obj_;
        AtspiStateSet *stateSet_;
 
-       mock_atspi_accessible_get_state_set m_atspi_accessible_get_state_set;
-       mock_atspi_state_set_contains m_atspi_state_set_contains;
-       mock_g_object_unref m_g_object_unref;
+       DEFINE_MOCKING(atspi_accessible_get_state_set);
+       DEFINE_MOCKING(atspi_state_set_contains);
+       DEFINE_MOCKING(g_object_unref);
 
-       mock_atspi_accessible_get_role m_atspi_accessible_get_role;
-       mock_atspi_accessible_get_action_iface m_atspi_accessible_get_action_iface;
-       mock_atspi_action_get_n_actions m_atspi_action_get_n_actions;
-       mock_atspi_action_get_action_name m_atspi_action_get_action_name;
-       mock_atspi_accessible_get_role_name m_atspi_accessible_get_role_name;
+       DEFINE_MOCKING(atspi_accessible_get_role);
+       DEFINE_MOCKING(atspi_accessible_get_action_iface);
+       DEFINE_MOCKING(atspi_action_get_n_actions);
+       DEFINE_MOCKING(atspi_action_get_action_name);
+       DEFINE_MOCKING(atspi_accessible_get_role_name);
 
        void NewAtspiAccessibleObject() {
                obj_.reset(new AtspiAccessible);
index 6b6f2496f48dedfffa6830229c75381e3b20e2d4..0bed5f18da7560a51b5e138f37bb421260c14ef4 100644 (file)
@@ -1,6 +1,8 @@
 #include "wrappers/mocked_screen_reader_vconf.h"
 #include "wrappers/mocked_external.h"
 
+#define DEFINE_MOCKING(mock_name) StrictMock<mock_ ## mock_name> m_ ## mock_name
+
 // Enforce failure on non-expected calls
 using ::testing::StrictMock;
 
@@ -26,17 +28,17 @@ class ScreenReaderVconfFixture : public ::testing::Test {
   Screen_Reader_Vconf_Data_t *vconfData_;
   bool vconfDataOwned_;
 
-  mock_get_pointer_to_service_data_struct m_get_service_data;
-  mock_screen_reader_vconf_data_create m_vconf_data_create;
-  mock_screen_reader_vconf_data_destroy m_vconf_data_destroy;
-  mock_setenv m_setenv;
-  mock_vconf_set m_vconf_set;
-  mock_vconf_keylist_free m_vconf_keylist_free;
-  mock_vconf_get_bool m_vconf_get_bool;
-  mock_vconf_get_str m_vconf_get_str;
-  mock_vconf_notify_key_changed m_vconf_notify_key_changed;
-  mock_vconf_ignore_key_changed m_vconf_remove_callback;
-  mock_vconf_keynode_get_bool m_vconf_keynode_get_bool;
+  DEFINE_MOCKING(get_pointer_to_service_data_struct);
+  DEFINE_MOCKING(screen_reader_vconf_data_create);
+  DEFINE_MOCKING(screen_reader_vconf_data_destroy);
+  DEFINE_MOCKING(setenv);
+  DEFINE_MOCKING(vconf_set);
+  DEFINE_MOCKING(vconf_keylist_free);
+  DEFINE_MOCKING(vconf_get_bool);
+  DEFINE_MOCKING(vconf_get_str);
+  DEFINE_MOCKING(vconf_notify_key_changed);
+  DEFINE_MOCKING(vconf_ignore_key_changed);
+  DEFINE_MOCKING(vconf_keynode_get_bool);
 
   Screen_Reader_Vconf_Data_t *newVconfData() {
     if (vconfDataOwned_) delete vconfData_;
@@ -216,14 +218,14 @@ static int setVconfDataLanguageStr(Screen_Reader_Vconf_Data_t *vconfData, const
   return retval;
 }
 TEST_F(ScreenReaderVconfFixture, AllOK_GoesOn) {
-  mock_get_key_values m_get_key_values;
-  mock__set_vconf_callback_and_print_message_on_error_and_return_error_code m_set_n_printf;
-  mock__set_vconf_key_changed_callback_reader_description m_get_n_register_desc;
-  mock__set_vconf_key_changed_callback_reader_haptic m_get_n_register_haptic;
-  mock__set_vconf_key_changed_callback_reader_keyboard_feedback m_get_n_register_kb;
-  mock__set_vconf_key_changed_callback_reader_sound_feedback m_get_n_register_snd;
+  DEFINE_MOCKING(get_key_values);
+  StrictMock<mock__set_vconf_callback_and_print_message_on_error_and_return_error_code> m_set_n_printf;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_description> m_get_n_register_desc;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_haptic> m_get_n_register_haptic;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_keyboard_feedback> m_get_n_register_kb;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_sound_feedback> m_get_n_register_snd;
 
-  EXPECT_FUNCTION_CALL(m_vconf_data_create, ()).WillOnce(Return(vconfData()));
+  EXPECT_FUNCTION_CALL(m_screen_reader_vconf_data_create, ()).WillOnce(Return(vconfData()));
 
   EXPECT_FUNCTION_CALL(m_vconf_set, (nullptr)).WillOnce(Return(0));
   EXPECT_FUNCTION_CALL(m_vconf_keylist_free, (nullptr)).WillOnce(Return(0));
@@ -245,21 +247,21 @@ TEST_F(ScreenReaderVconfFixture, AllOK_GoesOn) {
 
 #if defined(GTEST_DEATH_TESTS_WORK)
 TEST_F(ScreenReaderVconfFixture, AllocFails_Crashes) {
-  EXPECT_FUNCTION_CALL(m_vconf_data_create, ()).WillOnce(Return(nullptr));
+  EXPECT_FUNCTION_CALL(m_screen_reader_vconf_data_create, ()).WillOnce(Return(nullptr));
 
   ASSERT_EXIT(vconf_init(), ::testing::KilledBySignal(SIGSEGV), ".*");
 }
 #endif
 
 TEST_F(ScreenReaderVconfFixture, AllFail_GoesOn) {
-  mock_get_key_values m_get_key_values;
-  mock__set_vconf_callback_and_print_message_on_error_and_return_error_code m_set_n_printf;
-  mock__set_vconf_key_changed_callback_reader_description m_get_n_register_desc;
-  mock__set_vconf_key_changed_callback_reader_haptic m_get_n_register_haptic;
-  mock__set_vconf_key_changed_callback_reader_keyboard_feedback m_get_n_register_kb;
-  mock__set_vconf_key_changed_callback_reader_sound_feedback m_get_n_register_snd;
+  DEFINE_MOCKING(get_key_values);
+  StrictMock<mock__set_vconf_callback_and_print_message_on_error_and_return_error_code> m_set_n_printf;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_description> m_get_n_register_desc;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_haptic> m_get_n_register_haptic;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_keyboard_feedback> m_get_n_register_kb;
+  StrictMock<mock__set_vconf_key_changed_callback_reader_sound_feedback> m_get_n_register_snd;
 
-  EXPECT_FUNCTION_CALL(m_vconf_data_create, ()).WillOnce(Return(vconfData()));
+  EXPECT_FUNCTION_CALL(m_screen_reader_vconf_data_create, ()).WillOnce(Return(vconfData()));
 
   EXPECT_FUNCTION_CALL(m_vconf_set, (nullptr)).WillOnce(Return(-1));
   EXPECT_FUNCTION_CALL(m_vconf_keylist_free, (nullptr)).WillOnce(Return(-1));
@@ -278,19 +280,19 @@ TEST_F(ScreenReaderVconfFixture, AllFail_GoesOn) {
 }
 
 TEST_F(ScreenReaderVconfFixture, ExitRemovesCallbacksAndFreesData) {
-  EXPECT_FUNCTION_CALL(m_vconf_remove_callback, (StrEq(vconfLangKey), display_language_cb)).WillOnce(Return(0));
-  EXPECT_FUNCTION_CALL(m_vconf_remove_callback, (StrEq(vconfReadDescKey), reader_description_cb)).WillOnce(Return(0));
-  EXPECT_FUNCTION_CALL(m_vconf_remove_callback, (StrEq(vconfHapticKey), haptic_changed_cb)).WillOnce(Return(0));
-  EXPECT_FUNCTION_CALL(m_vconf_remove_callback, (StrEq(vconfKbFeedbackKey), keyboard_feedback_cb)).WillOnce(Return(0));
-  EXPECT_FUNCTION_CALL(m_vconf_remove_callback, (StrEq(vconfSoundFeedbackKey), sound_feedback_cb)).WillOnce(Return(0));
-  EXPECT_FUNCTION_CALL(m_vconf_data_destroy, (vconfData()));
+  EXPECT_FUNCTION_CALL(m_vconf_ignore_key_changed, (StrEq(vconfLangKey), display_language_cb)).WillOnce(Return(0));
+  EXPECT_FUNCTION_CALL(m_vconf_ignore_key_changed, (StrEq(vconfReadDescKey), reader_description_cb)).WillOnce(Return(0));
+  EXPECT_FUNCTION_CALL(m_vconf_ignore_key_changed, (StrEq(vconfHapticKey), haptic_changed_cb)).WillOnce(Return(0));
+  EXPECT_FUNCTION_CALL(m_vconf_ignore_key_changed, (StrEq(vconfKbFeedbackKey), keyboard_feedback_cb)).WillOnce(Return(0));
+  EXPECT_FUNCTION_CALL(m_vconf_ignore_key_changed, (StrEq(vconfSoundFeedbackKey), sound_feedback_cb)).WillOnce(Return(0));
+  EXPECT_FUNCTION_CALL(m_screen_reader_vconf_data_destroy, (vconfData()));
 
   vconf_exit(vconfData());
 }
 
 TEST_F(ScreenReaderVconfFixture, ExitDoesNotFreeNullptr) {
   setVconfData(nullptr);
-  EXPECT_FUNCTION_CALL(m_vconf_remove_callback, (_, _)).WillRepeatedly(Return(-1));
+  EXPECT_FUNCTION_CALL(m_vconf_ignore_key_changed, (_, _)).WillRepeatedly(Return(-1));
 
   vconf_exit(vconfData());
 }
index 0435444897bbc5057a3e243ef3ad536d517a4fe7..f01d356283b38c95b349287404db0323b1fcb517 100644 (file)
@@ -2,15 +2,15 @@
 
 class ScreenReaderUtilsDescritpionTraitFixture : public ScreenReaderUtilsFixture {
 public:
-       mock_atspi_accessible_get_parent m_atspi_accessible_get_parent;
-       mock_atspi_accessible_get_child_count m_atspi_accessible_get_child_count;
-       mock_atspi_accessible_get_index_in_parent m_atspi_accessible_get_index_in_parent;
-       mock_atspi_accessible_get_selection_iface m_atspi_accessible_get_selection_iface;
-       mock_atspi_selection_is_child_selected m_atspi_selection_is_child_selected;
-       mock_atspi_selection_get_n_selected_children m_atspi_selection_get_n_selected_children;
-       mock_atspi_accessible_get_selection m_atspi_accessible_get_selection;
-       mock_atspi_accessible_get_child_at_index m_atspi_accessible_get_child_at_index;
-       mock_widget_has_action m_widget_has_action;
+       DEFINE_MOCKING(atspi_accessible_get_parent);
+       DEFINE_MOCKING(atspi_accessible_get_child_count);
+       DEFINE_MOCKING(atspi_accessible_get_index_in_parent);
+       DEFINE_MOCKING(atspi_accessible_get_selection_iface);
+       DEFINE_MOCKING(atspi_selection_is_child_selected);
+       DEFINE_MOCKING(atspi_selection_get_n_selected_children);
+       DEFINE_MOCKING(atspi_accessible_get_selection);
+       DEFINE_MOCKING(atspi_accessible_get_child_at_index);
+       DEFINE_MOCKING(widget_has_action);
 
        AtspiAccessible *NewParentObject(AtspiRole role = ATSPI_ROLE_INVALID) {
                parent_ = (AtspiAccessible *)0xdeadbeef;
@@ -70,6 +70,7 @@ TEST_F(ScreenReaderUtilsDescritpionTraitFixture, NoRole) {
 
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (obj_, nullptr)).Times(1);
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (obj_)).Times(1);
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
 
        EXPECT_STREQ(generate_description_trait(obj_), "");
 }
@@ -80,6 +81,7 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, EntryOrPasswordTextFocus
        CallGeneralDependencies(ATSPI_ROLE_ENTRY, stateSet_);
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_FOCUSED)).WillOnce(Return(true));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
 
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_ST_BODY_EDITING_T_TTS");
 }
@@ -91,6 +93,7 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, EntryOrPasswordTextNotFo
        CallGeneralDependencies(ATSPI_ROLE_ENTRY, stateSet_);
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_FOCUSED)).WillOnce(Return(false));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
 
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_ST_BODY_DOUBLE_TAP_TO_ENTER_TEXT_T_TTS");
 }
@@ -103,6 +106,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, MenuItemNoToolbar) {
        CallGeneralDependencies(ATSPI_ROLE_MENU_ITEM, stateSet_);
        CallParentWithRoleDependencies();
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(2);
+
        EXPECT_STREQ(generate_description_trait(obj_), "");
 }
 
@@ -114,6 +119,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, MenuItemWithToolbarSelec
        CallMenuRoleDependencies();
 
        EXPECT_FUNCTION_CALL(m_atspi_selection_is_child_selected, (_, _, _)).WillOnce(Return(true));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(2);
 
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_ACCS_BODY_TAB_P1SD_OF_P2SD, IDS_ACCS_BODY_SELECTED_TTS");
 }
@@ -126,6 +133,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, MenuItemWithToolbarNotSe
        CallMenuRoleDependencies();
 
        EXPECT_FUNCTION_CALL(m_atspi_selection_is_child_selected, (_, _, _)).WillOnce(Return(false));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(2);
 
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_ACCS_BODY_TAB_P1SD_OF_P2SD, IDS_ACCS_BODY_DOUBLE_TAP_TO_SELECT_TTS");
 }
@@ -140,7 +149,12 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemNoAdditionalRole
 
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_parent, (obj_, nullptr)).WillOnce(Return(parent_));
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (parent_, nullptr)).WillOnce(Return(parentRole_));
-       EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (parent_)).Times(1);
+       EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (parent_));
+       EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, _)).Times(4);
+       EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (nullptr, _));
+
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(2);
 
        EXPECT_STREQ(generate_description_trait(obj_), "");
 }
@@ -156,6 +170,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemParentIsTreeTabl
 
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (parent_)).Times(2);
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (_, ATSPI_STATE_MULTISELECTABLE)).WillOnce(Return(false));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr)).Times(2);
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(3);
 
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_BR_BODY_IMAGE_T_TTS");
 }
@@ -173,6 +189,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemParentIsTreeTabl
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_MULTISELECTABLE)).WillOnce(Return(true));
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_selection, (parent_)).Times(1);
        EXPECT_FUNCTION_CALL(m_atspi_selection_get_n_selected_children, (_, nullptr)).Times(1);
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr)).Times(1);
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(5);
 
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_BR_BODY_IMAGE_T_TTSIDS_SCR_BODY_PD_SELECTED_IN_TOTAL_TTS");
 }
@@ -198,6 +216,9 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemNotExpandable) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_child_at_index, (obj_, 0, _)).WillOnce(Return(childIter));
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (childIter, _)).WillOnce(Return(ATSPI_ROLE_CHECK_BOX));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(3);
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (childIter));
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_AM_OPT_HEADER_TTS, IDS_SCR_TBOPT_TICKBOX_FOR_ENTIRE_GROUP");
        delete childIter;
 }
@@ -215,6 +236,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemExpandableAndExp
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EXPANDABLE)).WillRepeatedly(Return(true));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EXPANDED)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(3);
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_TPLATFORM_BODY_EXPANDABLE_LIST, IDS_ACCS_BODY_DOUBLE_TAP_TO_COLLAPSE_THE_LIST_T_TTS");
 }
 
@@ -232,6 +255,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemExpandableAndNot
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EXPANDABLE)).WillRepeatedly(Return(true));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EXPANDED)).WillOnce(Return(false));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(3);
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_TPLATFORM_BODY_EXPANDABLE_LIST, IDS_ACCS_BODY_DOUBLE_TAP_TO_EXPAND_THE_LIST_T_TTS");
 }
 
@@ -252,6 +277,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ListItemAnimated) {
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_ANIMATED)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(3);
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_BR_BODY_DOUBLE_TAP_AND_HOLD_THEN_DRAG_TO_REORDER_TTS");
 }
 
@@ -262,6 +289,9 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, PopupMenu) {
        NewParentObject();
        CallParentWithRoleDependencies();
 
+       EXPECT_FUNCTION_CALL(m_atspi_accessible_get_child_count, (obj_, nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(2);
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_WEBVIEW_BODY_SHOWING_PD_ITEMS_TTS");
 }
 
@@ -271,6 +301,10 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, Dialog) {
 
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_parent, (obj_, _)).Times(1);
 
+       EXPECT_FUNCTION_CALL(m_atspi_accessible_get_child_count, (obj_, nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        EXPECT_STREQ(generate_description_trait(obj_), "");
 }
 
@@ -280,6 +314,9 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ComboBoxOrGlassPane) {
 
        CallGeneralDependencies(ATSPI_ROLE_COMBO_BOX, stateSet_);
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_ST_BODY_DOUBLE_TAP_TO_OPEN_THE_MENU_T_TTS");
 }
 
@@ -293,6 +330,9 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, CheckBoxOrRadioButton) {
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(false));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EDITABLE)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        EXPECT_STREQ(generate_description_trait(obj_), "WDS_TTS_TBBODY_DOUBLE_TAP_TO_EDIT");
 }
 
@@ -302,6 +342,8 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, ProgressBar) {
 
        CallGeneralDependencies(ATSPI_ROLE_PROGRESS_BAR, stateSet_);
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_ACCS_TBBODY_IN_PROGRESS");
 }
 
@@ -313,5 +355,7 @@ TEST_F(DescriptionTraitWithAccessibleObjectAndStateSet, Slider) {
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_ENABLED)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        EXPECT_STREQ(generate_description_trait(obj_), "IDS_TPLATFORM_BODY_FLICK_UP_AND_DOWN_TO_ADJUST_THE_POSITION_T_TTS");
 }
index 8df8ab6b3997c087cfe9f7491cbcd6973223bad9..f9a30ef3885bbd4c22ac6b34a49e4aa4f9c9ee0e 100644 (file)
@@ -5,11 +5,11 @@ protected:
        AtspiAccessible *obj_;
        AtspiComponent *comp_;
 
-       mock_atspi_accessible_get_child_count m_atspi_accessible_get_child_count;
-       mock_atspi_accessible_get_component_iface m_atspi_accessible_get_component_iface;
-       mock_atspi_component_get_highlight_index m_atspi_component_get_highlight_index;
-       mock_atspi_accessible_get_index_in_parent m_atspi_accessible_get_index_in_parent;
-       mock_atspi_accessible_get_object_locale m_atspi_accessible_get_object_locale;
+       DEFINE_MOCKING(atspi_accessible_get_child_count);
+       DEFINE_MOCKING(atspi_accessible_get_component_iface);
+       DEFINE_MOCKING(atspi_component_get_highlight_index);
+       DEFINE_MOCKING(atspi_accessible_get_index_in_parent);
+       DEFINE_MOCKING(atspi_accessible_get_object_locale);
 
        AtspiAccessible *newAtspiAccessibleObject() {
                if (obj_)
@@ -46,31 +46,31 @@ public:
 
 class ScreenReaderUtilsDisplayInfoMainFunctionFixture : public ScreenReaderUtilsDisplayInfoFixture {
 protected:
-       mock__debug_display_object_parent_info m_display_parent_info;
+       DEFINE_MOCKING(_debug_display_object_parent_info);
 
-       mock__debug_display_object_name m_display_name;
-       mock__debug_display_object_role m_display_role;
-       mock__debug_display_object_description m_display_description;
-       mock__debug_display_object_iface_values m_display_iface_values;
-       mock__debug_display_object_states m_display_states;
-       mock__debug_display_rect_screen m_display_rect_screen;
-       mock__debug_display_win_screen m_display_win_screen;
-       mock__debug_display_object_ifaces m_display_ifaces;
+       DEFINE_MOCKING(_debug_display_object_name);
+       DEFINE_MOCKING(_debug_display_object_role);
+       DEFINE_MOCKING(_debug_display_object_description);
+       DEFINE_MOCKING(_debug_display_object_iface_values);
+       DEFINE_MOCKING(_debug_display_object_states);
+       DEFINE_MOCKING(_debug_display_rect_screen);
+       DEFINE_MOCKING(_debug_display_win_screen);
+       DEFINE_MOCKING(_debug_display_object_ifaces);
 
        void CallDependenciesWithoutParentInfo(AtspiAccessible *obj_) {
-               EXPECT_FUNCTION_CALL(m_display_name, (obj_)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_role, (obj_)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_description, (obj_)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_object_name, (obj_)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_object_role, (obj_)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_object_description, (obj_)).Times(1);
                EXPECT_FUNCTION_CALL(m_atspi_accessible_get_child_count, (obj_, nullptr)).Times(1);
                EXPECT_FUNCTION_CALL(m_atspi_accessible_get_component_iface, (obj_)).Times(1);
                EXPECT_FUNCTION_CALL(m_atspi_component_get_highlight_index, (nullptr, nullptr)).Times(1);
                EXPECT_FUNCTION_CALL(m_atspi_accessible_get_index_in_parent, (obj_, nullptr)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_iface_values, (obj_)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_states, (obj_)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_object_iface_values, (obj_)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_object_states, (obj_)).Times(1);
                EXPECT_FUNCTION_CALL(m_atspi_accessible_get_object_locale, (obj_, nullptr)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_rect_screen, (nullptr)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_win_screen, (nullptr)).Times(1);
-               EXPECT_FUNCTION_CALL(m_display_ifaces, (obj_)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_rect_screen, (nullptr)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_win_screen, (nullptr)).Times(1);
+               EXPECT_FUNCTION_CALL(m__debug_display_object_ifaces, (obj_)).Times(1);
        }
 };
 
@@ -92,7 +92,7 @@ TEST_F(ScreenReaderUtilsDisplayInfoMainFunctionFixture, DisplayInfoWithParentInf
        bool displayParentInfo_ = true;
        AtspiAccessible *obj_ = newAtspiAccessibleObject();
 
-       EXPECT_FUNCTION_CALL(m_display_parent_info, (obj_)).Times(1);
+       EXPECT_FUNCTION_CALL(m__debug_display_object_parent_info, (obj_)).Times(1);
        CallDependenciesWithoutParentInfo(obj_);
 
        debug_display_info_about_object(obj_, displayParentInfo_);
@@ -100,18 +100,18 @@ TEST_F(ScreenReaderUtilsDisplayInfoMainFunctionFixture, DisplayInfoWithParentInf
 
 class ScreenReaderUtilsDisplayInfoDependenciesFixture : public ScreenReaderUtilsDisplayInfoFixture {
 protected:
-       mock_atspi_component_get_extents m_atspi_component_get_extents;
-       mock_atspi_accessible_get_parent m_atspi_accessible_get_parent;
-       mock_atspi_accessible_get_interfaces m_atspi_accessible_get_interfaces;
-       mock_atspi_accessible_get_state_set m_atspi_accessible_get_state_set;
-       mock_atspi_state_set_get_states m_atspi_state_set_get_states;
-       mock_atspi_accessible_get_value_iface m_atspi_accessible_get_value_iface;
-       mock_atspi_value_get_current_value m_atspi_value_get_current_value;
-       mock_atspi_value_get_maximum_value m_atspi_value_get_maximum_value;
-       mock_atspi_value_get_minimum_value m_atspi_value_get_minimum_value;
-       mock_atspi_accessible_get_description m_atspi_accessible_get_description;
-       mock_atspi_accessible_get_localized_role_name m_atspi_accessible_get_localized_role_name;
-       mock_atspi_accessible_get_name m_atspi_accessible_get_name;
+       DEFINE_MOCKING(atspi_component_get_extents);
+       DEFINE_MOCKING(atspi_accessible_get_parent);
+       DEFINE_MOCKING(atspi_accessible_get_interfaces);
+       DEFINE_MOCKING(atspi_accessible_get_state_set);
+       DEFINE_MOCKING(atspi_state_set_get_states);
+       DEFINE_MOCKING(atspi_accessible_get_value_iface);
+       DEFINE_MOCKING(atspi_value_get_current_value);
+       DEFINE_MOCKING(atspi_value_get_maximum_value);
+       DEFINE_MOCKING(atspi_value_get_minimum_value);
+       DEFINE_MOCKING(atspi_accessible_get_description);
+       DEFINE_MOCKING(atspi_accessible_get_localized_role_name);
+       DEFINE_MOCKING(atspi_accessible_get_name);
 };
 
 TEST_F(ScreenReaderUtilsDisplayInfoDependenciesFixture, DisplayWinScreenWithNullComponent) {
@@ -155,11 +155,11 @@ TEST_F(ScreenReaderUtilsDisplayInfoDependenciesFixture, DisplayRectScreen) {
 }
 
 TEST_F(ScreenReaderUtilsDisplayInfoDependenciesFixture, DisplayParentInfoWithNullParent) {
-       mock_debug_display_info_about_object m_display_info;
+       DEFINE_MOCKING(debug_display_info_about_object);
        newAtspiAccessibleObject();
 
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_parent, (obj_, nullptr)).WillOnce(Return(nullptr));
-       EXPECT_FUNCTION_CALL(m_display_info, (nullptr, false)).Times(0);
+       EXPECT_FUNCTION_CALL(m_debug_display_info_about_object, (nullptr, false)).Times(0);
 
        _debug_display_object_parent_info(obj_);
 }
index e2a41c078ffbd6450c7c0ba0710b897074555dbd..28c262ef6635a4d64ce6d24904a31c22401ded1c 100644 (file)
@@ -2,17 +2,17 @@
 
 class RoleTraitFixture : public ScreenReaderUtilsFixture {
 protected:
-       mock_atspi_accessible_get_localized_role_name m_atspi_accessible_get_localized_role_name;
-       mock_atspi_value_get_minimum_increment m_atspi_value_get_minimum_increment;
-       mock_atspi_value_get_current_value m_atspi_value_get_current_value;
-       mock_atspi_accessible_get_value_iface m_atspi_accessible_get_value_iface;
-       mock_atspi_value_get_maximum_value m_atspi_value_get_maximum_value;
-       mock_atspi_value_get_minimum_value m_atspi_value_get_minimum_value;
-       mock_atspi_accessible_get_child_count m_atspi_accessible_get_child_count;
-       mock_atspi_accessible_get_parent m_atspi_accessible_get_parent;
-       mock_atspi_accessible_get_state_set m_atspi_accessible_get_state_set;
-       mock_atspi_state_set_contains m_atspi_state_set_contains;
-       mock_g_object_unref m_g_object_unref;
+       DEFINE_MOCKING(atspi_accessible_get_localized_role_name);
+       DEFINE_MOCKING(atspi_value_get_minimum_increment);
+       DEFINE_MOCKING(atspi_value_get_current_value);
+       DEFINE_MOCKING(atspi_accessible_get_value_iface);
+       DEFINE_MOCKING(atspi_value_get_maximum_value);
+       DEFINE_MOCKING(atspi_value_get_minimum_value);
+       DEFINE_MOCKING(atspi_accessible_get_child_count);
+       DEFINE_MOCKING(atspi_accessible_get_parent);
+       DEFINE_MOCKING(atspi_accessible_get_state_set);
+       DEFINE_MOCKING(atspi_state_set_contains);
+       DEFINE_MOCKING(g_object_unref);
 
 public:
        void SetUp() {
@@ -65,7 +65,7 @@ TEST_F(RoleTraitFixture, AddSliderDescriptionWithValueIface) {
 }
 
 TEST_F(RoleTraitFixture, NullObject) {
-       AtspiAccessible *obj_ = GetAtspiAccessibleObject();
+       AtspiAccessible *obj_ = nullptr;
        RunGenRoleTraitAndFreeMemory(obj_, "");
 }
 
@@ -130,6 +130,8 @@ TEST_F(RoleTraitFixture, GlassPane) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_parent, (obj_, nullptr)).WillOnce(Return(parent_));
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_child_count, (parent_, nullptr)).WillOnce(Return(children_count));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+
        RunGenRoleTraitAndFreeMemory(obj_, "IDS_ACCS_BODY_DROPDOWN_LIST_TTS IDS_WEBVIEW_BODY_SHOWING_PD_ITEMS_TTS");
 }
 
@@ -143,6 +145,9 @@ TEST_F(RoleTraitFixture, ListItemParentNotAnimated) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (parent_)).WillOnce(Return(parentStateSet_));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (parentStateSet_, ATSPI_STATE_ANIMATED)).WillOnce(Return(false));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parentStateSet_));
+
        RunGenRoleTraitAndFreeMemory(obj_, "");
 }
 
@@ -156,6 +161,9 @@ TEST_F(RoleTraitFixture, ListItemParentIsAnimated) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_state_set, (parent_)).WillOnce(Return(parentStateSet_));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (parentStateSet_, ATSPI_STATE_ANIMATED)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parentStateSet_));
+
        RunGenRoleTraitAndFreeMemory(obj_, "IDS_GALLERY_OPT_REORDER");
 }
 
@@ -213,7 +221,7 @@ TEST_F(RoleTraitFixture, ToggleButton) {
 }
 
 TEST_F(RoleTraitFixture, Slider) {
-       mock_add_slider_description m_add_slider_description;
+       DEFINE_MOCKING(add_slider_description);
        AtspiAccessible *obj_ = GetAtspiAccessibleObject();
 
        CallGeneralDependencies(ATSPI_ROLE_SLIDER);
index 643a9743905014b44ec9614007041c20f5d8a29d..088914fda0ee02e887cfe0076b3b3733d2c99375 100644 (file)
@@ -3,7 +3,7 @@
 class StateTraitFixture : public ScreenReaderUtilsFixture {
 
 protected:
-       mock_atspi_accessible_get_parent m_atspi_accessible_get_parent;
+       DEFINE_MOCKING(atspi_accessible_get_parent);
 
        void CallGeneralDependencies(AtspiRole role, AtspiStateSet *stateSet_) {
                EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (obj_.get(), nullptr)).WillOnce(Return(role));
@@ -44,6 +44,8 @@ TEST_F(StateTraitFixture, InvalidRole) {
 
        CallGeneralDependencies(ATSPI_ROLE_INVALID, stateSet_);
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "");
 }
 
@@ -57,6 +59,9 @@ TEST_F(StateTraitFixture, ListItemParentIsNotTreeTable) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_parent, (obj_, nullptr)).WillOnce(Return(parent_));
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (parent_, nullptr)).WillOnce(Return(ATSPI_ROLE_INVALID));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "");
 }
 
@@ -71,6 +76,9 @@ TEST_F(StateTraitFixture, ListItemParentIsTreeTableNoSelected) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (parent_, nullptr)).WillOnce(Return(ATSPI_ROLE_TREE_TABLE));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (_, ATSPI_STATE_SELECTED)).WillOnce(Return(FALSE));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "");
 }
 
@@ -85,6 +93,9 @@ TEST_F(StateTraitFixture, ListItemParentIsTreeTableIsSelected) {
        EXPECT_FUNCTION_CALL(m_atspi_accessible_get_role, (parent_, nullptr)).WillOnce(Return(ATSPI_ROLE_TREE_TABLE));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (_, ATSPI_STATE_SELECTED)).WillOnce(Return(TRUE));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "IDS_ACCS_BODY_SELECTED_TTS");
 }
 
@@ -101,6 +112,9 @@ TEST_F(StateTraitFixture, CheckBoxOrRadioButtonNoTrait) {
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(false));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EDITABLE)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "");
 }
 
@@ -116,6 +130,9 @@ TEST_F(StateTraitFixture, CheckBoxOrRadioButtonSelected) {
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "IDS_ACCS_BODY_SELECTED_TTS");
 }
 
@@ -132,6 +149,9 @@ TEST_F(StateTraitFixture, CheckBoxOrRadioButtonParentIsColorChooser) {
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(false));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EDITABLE)).WillOnce(Return(false));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "");
 }
 
@@ -148,6 +168,9 @@ TEST_F(StateTraitFixture, CheckBoxOrRadioButtonParentIsNotColorChooser) {
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(false));
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_EDITABLE)).WillOnce(Return(false));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (parent_));
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "IDS_ACCS_OPT_NOT_SELECTED_TTS");
 }
 
@@ -159,6 +182,8 @@ TEST_F(StateTraitFixture, ToggleButtonChecked) {
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(true));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "IDS_MSG_BODY_ON_T_TTS");
 }
 
@@ -170,6 +195,8 @@ TEST_F(StateTraitFixture, ToggleButtonNotChecked) {
 
        EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, ATSPI_STATE_CHECKED)).WillOnce(Return(false));
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "IDS_STORYALBUM_BODY_OFF_T_TTS");
 }
 
@@ -179,5 +206,9 @@ TEST_F(StateTraitFixture, RadioMenuItem) {
 
        CallGeneralDependencies(ATSPI_ROLE_RADIO_MENU_ITEM, stateSet_);
 
+       EXPECT_FUNCTION_CALL(m_atspi_state_set_contains, (stateSet_, _));
+
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
        RunGenStateTraitAndFreeMemory(obj_, "");
 }
index 40fdfaca1527b4afc463837c25d248c10b264b2a..a044d7ce48bf557245d46e769af4d744a52f5fe1 100644 (file)
@@ -27,19 +27,21 @@ public:
                guint element_size = sizeof(AtspiRelation *);
                GArray *relations = g_array_new(FALSE, FALSE, element_size);
 
-               for (size_t i = 0; i < size; ++i)
+               for (size_t i = 0; i < size; ++i) {
                        g_array_append_val(relations, coockieRelations[i]);
+                       EXPECT_FUNCTION_CALL(m_g_object_unref, ((void *) coockieRelations[i]));
+               }
 
                return relations;
        }
 
 protected:
-       mock_atspi_accessible_get_relation_set m_atspi_accessible_get_relation_set;
-       mock_atspi_relation_get_relation_type m_atspi_relation_get_relation_type;
-       mock_atspi_relation_get_n_targets m_atspi_relation_get_n_targets;
-       mock_atspi_relation_get_target m_atspi_relation_get_target;
-       mock_eina_strbuf_new m_eina_strbuf_new;
-       mock_eina_strbuf_string_steal m_eina_strbuf_string_steal;
+       DEFINE_MOCKING(atspi_accessible_get_relation_set);
+       DEFINE_MOCKING(atspi_relation_get_relation_type);
+       DEFINE_MOCKING(atspi_relation_get_n_targets);
+       DEFINE_MOCKING(atspi_relation_get_target);
+       DEFINE_MOCKING(eina_strbuf_new);
+       DEFINE_MOCKING(eina_strbuf_string_steal);
 
        std::vector<unsigned> coockieRelations = {0xaaddcafe, 0xbaddcafe, 0xcaddcafe};
 
@@ -131,6 +133,8 @@ TEST_F(TextForRelationObjects, RelationSetTwoLenOneMatches) {
 
        EXPECT_FUNCTION_CALL(m_eina_strbuf_string_steal, (_)).Times(1);
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr));
+
        RunGenTextForRelationsAndFreeMemory(obj_, ATSPI_RELATION_FLOWS_TO, nullptr);
        EXPECT_EQ(IsCallbackVisited(), true);
        g_array_free(relations, FALSE);
@@ -154,6 +158,8 @@ TEST_F(TextForRelationObjects, RelationSetTwoLenTwoMatches) {
 
        EXPECT_FUNCTION_CALL(m_eina_strbuf_string_steal, (_)).Times(1);
 
+       EXPECT_FUNCTION_CALL(m_g_object_unref, (nullptr)).Times(2);
+
        RunGenTextForRelationsAndFreeMemory(obj_, ATSPI_RELATION_FLOWS_TO, nullptr);
        EXPECT_EQ(IsCallbackVisited(), true);
        g_array_free(relations, FALSE);