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);
}
#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"
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);
#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;
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_;
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));
#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));
}
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());
}
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;
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_), "");
}
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");
}
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");
}
CallGeneralDependencies(ATSPI_ROLE_MENU_ITEM, stateSet_);
CallParentWithRoleDependencies();
+ EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_)).Times(2);
+
EXPECT_STREQ(generate_description_trait(obj_), "");
}
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");
}
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");
}
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_), "");
}
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");
}
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");
}
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;
}
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");
}
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");
}
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");
}
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");
}
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_), "");
}
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");
}
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");
}
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");
}
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");
}
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_)
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);
}
};
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_);
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) {
}
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_);
}
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() {
}
TEST_F(RoleTraitFixture, NullObject) {
- AtspiAccessible *obj_ = GetAtspiAccessibleObject();
+ AtspiAccessible *obj_ = nullptr;
RunGenRoleTraitAndFreeMemory(obj_, "");
}
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");
}
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_, "");
}
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");
}
}
TEST_F(RoleTraitFixture, Slider) {
- mock_add_slider_description m_add_slider_description;
+ DEFINE_MOCKING(add_slider_description);
AtspiAccessible *obj_ = GetAtspiAccessibleObject();
CallGeneralDependencies(ATSPI_ROLE_SLIDER);
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));
CallGeneralDependencies(ATSPI_ROLE_INVALID, stateSet_);
+ EXPECT_FUNCTION_CALL(m_g_object_unref, (stateSet_));
+
RunGenStateTraitAndFreeMemory(obj_, "");
}
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_, "");
}
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_, "");
}
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");
}
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_, "");
}
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");
}
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_, "");
}
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");
}
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");
}
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");
}
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_, "");
}
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};
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);
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);