From: maneesha Date: Wed, 8 Nov 2017 05:59:40 +0000 (+0530) Subject: [TBT][tbtcoreapp][ACR-957][DPTTIZEN-2928 : Added TCs for CBHM APIs] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F159528%2F6;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][tbtcoreapp][ACR-957][DPTTIZEN-2928 : Added TCs for CBHM APIs] Change-Id: I2ca297ba71c0101021150935f284ea7e1b523950 Signed-off-by: maneesha --- diff --git a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk index c3130bf..3de5c98 100644 Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ diff --git a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk index 6c8408c..4af3362 100644 Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-x86.tpk differ diff --git a/tbtcoreapp/.cproject b/tbtcoreapp/.cproject index e79b3f3..88dae34 100644 --- a/tbtcoreapp/.cproject +++ b/tbtcoreapp/.cproject @@ -21,17 +21,16 @@ - + - + @@ -316,24 +320,19 @@ - + - + diff --git a/tbtcoreapp/inc/model/tbt-info.h b/tbtcoreapp/inc/model/tbt-info.h index dbc2dbc..679b58d 100755 --- a/tbtcoreapp/inc/model/tbt-info.h +++ b/tbtcoreapp/inc/model/tbt-info.h @@ -306,7 +306,10 @@ typedef enum { TBT_APP_MULTICLASS, TBT_APP_USBHOST, - TBT_APP_MOTION_DETECTION + TBT_APP_MOTION_DETECTION, + TBT_APP_CBHM_CHANGE_CALLBACK, + TBT_APP_CBHM_MONITOR_CALLBACK, + TBT_APP_CBHM_TYPE_GET //TBT_APP_DALI_SCROLL_BAR } tbt_app_type_e; diff --git a/tbtcoreapp/inc/utils/app_module_config.h b/tbtcoreapp/inc/utils/app_module_config.h index e036b7e..4f21240 100755 --- a/tbtcoreapp/inc/utils/app_module_config.h +++ b/tbtcoreapp/inc/utils/app_module_config.h @@ -300,4 +300,8 @@ #define TBT_MODULE_APP_USBHOST #define TBT_MODULE_MOTION #define TBT_MODULE_APP_MOTION_DETECTION +#define TBT_MODULE_CBHM +#define TBT_MODULE_APP_CBHM_CHANGE_CALLBACK +#define TBT_MODULE_APP_CBHM_TYPE_GET +#define TBT_MODULE_APP_CBHM_MONITOR_CALLBACK #endif diff --git a/tbtcoreapp/inc/view/tbt-cbhm-view.h b/tbtcoreapp/inc/view/tbt-cbhm-view.h new file mode 100644 index 0000000..bd90698 --- /dev/null +++ b/tbtcoreapp/inc/view/tbt-cbhm-view.h @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +/** + * @file tbt-cbhm-callbacks.h + * @brief covers cbhm callbacks for item changes, monitor and type get + * @since_tizen 4.0 + * @author Maneesha Karn(maneesha.k@samsung.com) + * @date November, 2017 + * @bug NA + * @credit + * + */ + +#ifndef __TBT_CBHM_CALLBACKS_H__ +#define __TBT_CBHM_CALLBACKS_H__ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_CBHM + +#include +#include "model/tbt-list.h" + + +/** + * @typedef cbhm_callbacks_view + * @since_tizen 4.0 + */ +typedef struct _cbhm_callbacks_view cbhm_callbacks_view; + +/** + * @brief Create CBHM test view + * @since_tizen 4.0 + * @param[in] navi Parent naviframe + * @param[in] custom structute to hold tbt application information + * @param[in] item of the main tbt menu + * @return Pointer of cbhm_callbacks_view on success, otherwise NULL + */ +cbhm_callbacks_view *cbhm_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item); + +#endif +#endif // __TBT_LOCAL_VIEW_H__ diff --git a/tbtcoreapp/res/edje/3.0/mobile/cbhm_callback_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/cbhm_callback_viewer.edc new file mode 100755 index 0000000..ff25c93 --- /dev/null +++ b/tbtcoreapp/res/edje/3.0/mobile/cbhm_callback_viewer.edc @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +collections +{ + base_scale: 1.8; + group + { + name: "cbhm_test"; + parts{ + part{ + name: "_title"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.0;} + rel2 {relative: 1.0 0.1;} + } + } + + part{ + name: "_callback"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.1;} + rel2 {relative: 1.0 0.2;} + } + } + part{ + name: "controlr_part"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 {relative: 0.0 0.8;} + rel2 {relative: 1.0 1.0;} + visible: 1; + } + } + + swallow { + name: "_edittext"; + type: SWALLOW; + desc { + state: "default" 0 0; + visible: 1; + align: 0.5 0.5; + color: 236 255 255 249; + rel1.relative: 0.0 0.3; + rel2.relative: 1.0 0.70; + } + } + } + } +} \ No newline at end of file diff --git a/tbtcoreapp/res/edje/4.0/mobile/cbhm_callback_viewer.edc b/tbtcoreapp/res/edje/4.0/mobile/cbhm_callback_viewer.edc new file mode 100755 index 0000000..d645787 --- /dev/null +++ b/tbtcoreapp/res/edje/4.0/mobile/cbhm_callback_viewer.edc @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +collections +{ + base_scale: 1.8; + group + { + name: "cbhm_test"; + parts{ + part{ + name: "_title"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.0; } + rel2 {relative: 1.0 0.1; } + } + } + + part{ + name: "_callback"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.1;} + rel2 {relative: 1.0 0.2;} + } + } + part{ + name: "controlr_part"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 {relative: 0.0 0.8;} + rel2 {relative: 1.0 1.0;} + visible: 1; + } + } + + swallow { + name: "_edittext"; + type: SWALLOW; + desc { + state: "default" 0 0; + visible: 1; + align: 0.5 0.5; + color: 236 255 255 249; + rel1.relative: 0.0 0.3; + rel2.relative: 1.0 0.70; + } + } + } + } +} diff --git a/tbtcoreapp/src/model/tbt-list.c b/tbtcoreapp/src/model/tbt-list.c index 4fc6210..1bfaeab 100755 --- a/tbtcoreapp/src/model/tbt-list.c +++ b/tbtcoreapp/src/model/tbt-list.c @@ -2850,6 +2850,38 @@ static tbt_info tbtapps[] = .result = 0, .required_features_count = 1, .features_required = {FEATURE_ACTIVITY_RECOGNITION} + }, + #endif +#endif +#ifdef TBT_MODULE_CBHM + #ifdef TBT_MODULE_APP_CBHM_CHANGE_CALLBACK + { + .name = "CBHM Change Item Callback", + .parent = "CBHM", + .apptype = TBT_APP_CBHM_CHANGE_CALLBACK, + .icon_name = "dummy", + .info = "1.Please type text into the Editor
2.Copy the Text - Notice Label does not change
3.Now Press 'Add Callback' button
4. Select another text and copy or 'Show ClipBoard' and delete any element, this action should display Callback Message
5. Now press 'Remove Callback'
6. Copy text into the ClipBoard and Label should not change
7. You can click 'Clear Label' to display fresh alerts", + .result = 0 + }, + #endif + #ifdef TBT_MODULE_APP_CBHM_MONITOR_CALLBACK + { + .name = "CBHM Monitor Callback", + .parent = "CBHM", + .apptype = TBT_APP_CBHM_MONITOR_CALLBACK, + .icon_name = "dummy", + .info = "1.Please press 'Add Monitor CB' button it should display message with active status as one.
2. Press 'Remove Monitor CB' and it should Display it in label without error
3. If both above steps are proper Test Case Passes else it Fails", + .result = 0 + }, + #endif + #ifdef TBT_MODULE_APP_CBHM_TYPE_GET + { + .name = "CBHM last Item Type Get", + .parent = "CBHM", + .apptype = TBT_APP_CBHM_TYPE_GET, + .icon_name = "dummy", + .info = "1.Please press any one of Copy button to copy the type of element to ClipBoard.
2. Press 'Display Type' button to display the last item added to clipboard
If The displayed type is as per selection the Test Case Passes else it Fails", + .result = 0 } #endif #endif diff --git a/tbtcoreapp/src/view/tbt-cbhm-view.c b/tbtcoreapp/src/view/tbt-cbhm-view.c new file mode 100755 index 0000000..4a25660 --- /dev/null +++ b/tbtcoreapp/src/view/tbt-cbhm-view.c @@ -0,0 +1,558 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +/** + * @file tbt-cbhm-callbacks.c + * @brief Checks cbhm callbacks added, removed for item change, monitor add and get type of item copied to clipboard + * + * @author Maneesha Karn (maneesha.k@samsung.com) + * @date November, 2017 + * @bug NA + * @credit + * + */ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_CBHM + +#include +#include + +#include "utils/logger.h" +#include "utils/config.h" +#include "utils/ui-utils.h" +#include "view/tbt-cbhm-view.h" +#include "view/tbt-common-view.h" +#include "utils/config.h" +#include "cbhm.h" + +bool __is_cbhm_test_running = false; + +struct _cbhm_callbacks_view { + common_view* view; + location_manager_h manager; + + Evas_Object *lat_label; + Evas_Object *lon_label; + Evas_Object *button1; + Evas_Object *button2; + Evas_Object *button3; + Evas_Object *button4; + Evas_Object *editfield; + tbt_app_type_e apptype; + cbhm_h cbhm_handle; + bool callbackAdded; + bool monitorAdded; +}; + +static void _app_destroy_cb(void* this); +static Evas_Object *add_control_layout(cbhm_callbacks_view *this, + Evas_Object *parent); +static void update(cbhm_callbacks_view *this); +static void _add_cb_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _rem_cb_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _clear_label_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _show_clipboard_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _add_monitor_callback_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _remove_monitor_callback_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void on_cbhm_item_changed(cbhm_h cbhm_handle, int item_count, + void *data); +static void on_monitor_item_changed(cbhm_h cbhm_handle, bool active_state, + void *data); +static void _text_type_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _markup_type_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _html_type_button_pressed_cb(void *data, Evas_Object *obj, + void *event_info); +static void _selection_type_set_cb(cbhm_sel_type_e type, + void *data); +static void _selection_type_show(void *data, Evas_Object *obj, + void *event_info); +static char *get_selection_type(cbhm_sel_type_e type); + + +static char *get_selection_type(cbhm_sel_type_e type) +{ + char msg[40]; + switch(type) + { + case CBHM_SEL_TYPE_TEXT : + snprintf(msg, sizeof(msg), "CBHM_SEL_TYPE_TEXT"); + break; + case CBHM_SEL_TYPE_HTML : + snprintf(msg, sizeof(msg), "CBHM_SEL_TYPE_HTML"); + break; + case CBHM_SEL_TYPE_MARKUP : + snprintf(msg, sizeof(msg), "CBHM_SEL_TYPE_MARKUP"); + break; + case CBHM_SEL_TYPE_NONE : + snprintf(msg, sizeof(msg), "CBHM_SEL_TYPE_NONE"); + break; + case CBHM_SEL_TYPE_IMAGE : + snprintf(msg, sizeof(msg), "CBHM_SEL_TYPE_IMAGE"); + break; + default : + snprintf(msg, sizeof(msg), "Unknow Type"); + + } + return strdup(msg); +} + + +/** + * @function cbhm_callbacks_view_add + * @since_tizen 4.0 + * @description CBHM Callbacks View Add + * @parameter Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer + * @return cbhm_callbacks_view* + */ +cbhm_callbacks_view *cbhm_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item) +{ + + RETVM_IF(NULL == navi, NULL, "navi is null"); + + int nRet; + char msg[100]; + cbhm_callbacks_view *this = NULL; + + this = calloc(1, sizeof(cbhm_callbacks_view)); + RETVM_IF(!this, NULL, "calloc failed"); + + this->view = calloc(1, sizeof(common_view)); + RETVM_IF(!this->view, NULL, "calloc failed"); + + tbt_info->layout_group = "cbhm_test"; + tbt_info->layout_file = get_edje_path("cbhm_callback_viewer.edj"); + + common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); + + + RETVM_IF(NULL == this->view, NULL, "navi is null"); + nRet = cbhm_open_service(&(this->cbhm_handle)); + RETVM_IF(nRet != CBHM_ERROR_NONE, NULL, "cbhm_open_service failed"); + RETVM_IF(this->cbhm_handle == NULL, NULL, "cbhm_handle is NULL"); + + this->apptype = tbt_info->apptype; + this->lat_label = ui_utils_label_add(this->view->layout, "???"); + this->lon_label = ui_utils_label_add(this->view->layout, "???"); + + elm_label_line_wrap_set(this->lat_label, ELM_WRAP_CHAR); + elm_label_line_wrap_set(this->lat_label, ELM_WRAP_CHAR); + + ui_utils_label_set_text(this->lat_label, "???", "left"); + ui_utils_label_set_text(this->lon_label, "???", "left"); + + elm_object_part_content_set(this->view->layout, "_title", + this->lat_label); + elm_object_part_content_set(this->view->layout, "_callback", + this->lon_label); + + Evas_Object *table = add_control_layout(this, this->view->layout); + elm_object_part_content_set(this->view->layout, "controlr_part", + table); + + if(this->apptype == TBT_APP_CBHM_CHANGE_CALLBACK) + { + //Create an editfield + this->editfield = ui_utils_entry_add(this, this->view->layout, ELM_INPUT_PANEL_LAYOUT_NORMAL, "Trial Text"); + elm_entry_input_panel_language_set(this->editfield, ELM_INPUT_PANEL_LANG_AUTOMATIC); + snprintf(msg, sizeof(msg), "Editor - Please click and type here"); + elm_object_part_text_set(this->editfield, PART_ENTRY_GUIDE, msg); + elm_object_part_content_set(this->view->layout, "_edittext", this->editfield); + } + __is_cbhm_test_running = true; + this->callbackAdded = false; + this->monitorAdded = false; + update(this); + + return this; +} + + +/** + * @function add_control_layout + * @since_tizen 4.0 + * @description Add Control Layout + * @parameter cbhm_callbacks_view*: CBHM Callbacks View Pointer, Evas_Object*: Evas Object Pointer + * @return static Evas_Object* + */ +static Evas_Object *add_control_layout(cbhm_callbacks_view *this, Evas_Object *parent) +{ + RETVM_IF(NULL == this, NULL, "view is NULL"); + + Evas_Object *table = elm_table_add(parent); + + evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(table); + + elm_table_padding_set(table, TABLE_PADDING_HORIZONTAL, + TABLE_PADDING_VERTICAL); + + if(this->apptype == TBT_APP_CBHM_CHANGE_CALLBACK ) + { + this->button1 = ui_utils_push_button_add(this, table, "Add Callback", + _add_cb_button_pressed_cb); + this->button2 = ui_utils_push_button_add(this, table, "Remove Callback", + _rem_cb_button_pressed_cb); + this->button3= ui_utils_push_button_add(this, table, "Clear Label", + _clear_label_button_pressed_cb); + this->button4= ui_utils_push_button_add(this, table, "Show ClipBoard", + _show_clipboard_button_pressed_cb); + } + else if(this->apptype == TBT_APP_CBHM_MONITOR_CALLBACK) + { + this->button1= ui_utils_push_button_add(this, table, "Add Monitor CB", + _add_monitor_callback_button_pressed_cb); + this->button2 = ui_utils_push_button_add(this, table, "Remove Monitor CB", + _remove_monitor_callback_button_pressed_cb); + this->button3= ui_utils_push_button_add(this, table, "Clear Label", + _clear_label_button_pressed_cb); + this->button4 = ui_utils_push_button_add(this, table, "Show Clipboard", + _show_clipboard_button_pressed_cb); + } + else + { + this->button1 = ui_utils_push_button_add(this, table, "Copy Text", + _text_type_button_pressed_cb); + this->button2 = ui_utils_push_button_add(this, table, "Copy Markup", + _markup_type_button_pressed_cb); + this->button3 = ui_utils_push_button_add(this, table, "Copy HTML", + _html_type_button_pressed_cb); + this->button4 = ui_utils_push_button_add(this, table, "Display Type", + _selection_type_show); + } + elm_table_pack(table, this->button1, 0, 0, 1, 1); + elm_table_pack(table, this->button2, 1, 0, 2, 1); + elm_table_pack(table, this->button3, 0, 1, 1, 2); + elm_table_pack(table, this->button4, 1, 1, 2, 2); + return table; +} + +/** + * @function _add_cb_button_pressed_cb + * @since_tizen 4.0 + * @description Add Callback Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _add_cb_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + + int nRet = 0; + + if(this->callbackAdded == false) + { + nRet = cbhm_item_changed_callback_add(this->cbhm_handle, on_cbhm_item_changed, data); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_item_changed_callback_add failed"); + this->callbackAdded = true; + } + + update(this); +} + +/** + * @function _rem_cb_button_pressed_cb + * @since_tizen 4.0 + * @description Remove Callback Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _rem_cb_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + int nRet = 0; + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + + if(this->callbackAdded == true) + { + nRet = cbhm_item_changed_callback_remove(this->cbhm_handle, on_cbhm_item_changed, data); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_item_changed_callback_remove failed"); + this->callbackAdded = false; + } + + update(this); +} + +/** + * @function _clear_label_button_pressed_cb + * @since_tizen 4.0 + * @description Clear Label Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _clear_label_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + ui_utils_label_set_text(this->lat_label, "Cleared Label", "left"); + ui_utils_label_set_text(this->lon_label, "Waiting for Event", "left"); +} + + + +/** + * @function _show_clipboard_button_pressed_cb + * @since_tizen 4.0 + * @description Show Clipboard Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _show_clipboard_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + int nRet = cbhm_show(this->cbhm_handle); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_show failed"); + ui_utils_label_set_text(this->lat_label, "Show Clipboard", "left"); +} + + +/** + * @function _add_monitor_callback_button_pressed_cb + * @since_tizen 4.0 + * @description Add Monitor Callback Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _add_monitor_callback_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + if(this->monitorAdded == false) + { + int nRet = cbhm_monitor_callback_add(this->cbhm_handle, on_monitor_item_changed, data); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_monitor_callback_add failed"); + ui_utils_label_set_text(this->lat_label, "Add Monitor Callback", "left"); + this->monitorAdded = true; + } +} + + +/** + * @function _remove_monitor_callback_button_pressed_cb + * @since_tizen 4.0 + * @description Remove Monitor Calback Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _remove_monitor_callback_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + if(this->monitorAdded == true) + { + int nRet = cbhm_monitor_callback_remove(this->cbhm_handle, on_monitor_item_changed, data); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_monitor_callback_remove failed"); + ui_utils_label_set_text(this->lat_label, "Remove Monitor Callback", "left"); + this->monitorAdded = false; + } +} + +/** + * @function _text_type_button_pressed_cb + * @since_tizen 4.0 + * @description Text Type Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _text_type_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + _selection_type_set_cb(CBHM_SEL_TYPE_TEXT, data); +} + +/** + * @function _markup_type_button_pressed_cb + * @since_tizen 4.0 + * @description Markup Type BUtton Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ + +static void _markup_type_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + _selection_type_set_cb(CBHM_SEL_TYPE_MARKUP, data); +} + +/** + * @function _html_type_button_pressed_cb + * @since_tizen 4.0 + * @description HTML type Button Pressed Cb + * @parameter void*: Void Pointer, Evas_Object*: Evas Object Pointer, void*: Void Pointer + * @return static void + */ +static void _html_type_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + _selection_type_set_cb(CBHM_SEL_TYPE_HTML, data); +} + +/** + * @function _selection_type_set_cb + * @since_tizen 4.0 + * @description Selection Type Set Cb + * @parameter cbhm_sel_type_e: Type, void *: Data + * @return static void + */ +static void _selection_type_set_cb(cbhm_sel_type_e type, void *data) +{ + int nRet; + char *hello_str; + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + hello_str = (char *) malloc(50); + snprintf(hello_str, 50, "String : %s", get_selection_type(type)); + + nRet = cbhm_selection_type_set(this->cbhm_handle, type); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_selection_type_set failed"); + + nRet = cbhm_selection_set(this->cbhm_handle, type, hello_str, strlen(hello_str)); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_selection_set failed"); +} + + +/** + * @function _selection_type_show + * @since_tizen 4.0 + * @description Show the selection type + * @parameter void* : Data, Evas_Object*: Evas Object Pointer, void* : Event Information + * @return static void + */ +static void _selection_type_show(void *data, Evas_Object *obj, void *event_info) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + int nRet; + cbhm_sel_type_e sType; + + nRet = cbhm_latest_item_type_get(this->cbhm_handle, &sType); + RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_latest_item_type_get failed"); + + switch(sType) + { + case CBHM_SEL_TYPE_MARKUP : + ui_utils_label_set_text(this->lat_label, "Selection Type is Markup", "left"); + break; + case CBHM_SEL_TYPE_TEXT : + ui_utils_label_set_text(this->lat_label, "Selection Type is Text", "left"); + break; + case CBHM_SEL_TYPE_HTML : + ui_utils_label_set_text(this->lat_label, "Selection Type is HTML", "left"); + break; + default : + ui_utils_label_set_text(this->lat_label, "Unknown Type", "left"); + } +} + + +/** + * @function update + * @since_tizen 4.0 + * @description Update + * @parameter cbhm_callbacks_view*: CBHM Callbacks View Pointer + * @return static void + */ +static void update(cbhm_callbacks_view *this) +{ + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + + if (this->callbackAdded) + { + ui_utils_label_set_text(this->lat_label, "Callback added", "left"); + ui_utils_label_set_text(this->lon_label, "Waiting for callback...", + "left"); + } + else + { + ui_utils_label_set_text(this->lat_label, "No Callback Added", "left"); + ui_utils_label_set_text(this->lon_label, "Waiting for callback...", + "left"); + } +} + + +/** + * @function on_cbhm_item_changed + * @since_tizen 4.0 + * @description Callback on CBHM Item Changed + * @parameter cbhm_handle: CBHM Handle, int: Item Count, void*: Void Pointer + * @return static void + */ +static void on_cbhm_item_changed(cbhm_h cbhm_handle, int item_count, void *data) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + char msg[100]; + snprintf(msg, sizeof(msg), "CBHM Item Changed Callback Hit with item number %d", item_count); + ui_utils_label_set_text(this->lon_label, msg, + "left"); +} + + +/** + * @function on_monitor_item_changed + * @since_tizen 4.0 + * @description Callback on Monitor Item Changed + * @parameter cbhm_handle: CBHM Handle ,bool: active state, void*: Void Pointer + * @return static void + */ +static void on_monitor_item_changed(cbhm_h cbhm_handle, bool active_state, void *data) +{ + cbhm_callbacks_view *this = (cbhm_callbacks_view*) data; + RETM_IF(NULL == this, "cbhm_callbacks_view is null"); + char msg[100]; + snprintf(msg, sizeof(msg), "CBHM Monitor Changed Callback Hit with active state %d", active_state); + ui_utils_label_set_text(this->lon_label, msg, + "left"); +return; +} + + +/** + * @function _app_destroy_cb + * @since_tizen 4.0 + * @description App Destroy Cb + * @parameter void*: Void Pointer + * @return static void + */ +static void _app_destroy_cb(void* this) +{ + RETM_IF(NULL == this, "data is NULL"); + + cbhm_callbacks_view *view = NULL; + view = (cbhm_callbacks_view*) this; + RETM_IF(NULL == view, "view is NULL"); + + __is_cbhm_test_running = false; + + if(view->callbackAdded == true) + cbhm_item_changed_callback_remove(view->cbhm_handle, on_cbhm_item_changed, view); + + if(view->monitorAdded == true) + cbhm_monitor_callback_remove(view->cbhm_handle, on_monitor_item_changed, view); + + if(view->cbhm_handle != NULL) + cbhm_close_service(view->cbhm_handle); + + SAFE_DELETE(view->view); + SAFE_DELETE(view); +} + + +#endif diff --git a/tbtcoreapp/src/view/tbt-genlist-view.c b/tbtcoreapp/src/view/tbt-genlist-view.c index 8c8d083..d0b1e75 100755 --- a/tbtcoreapp/src/view/tbt-genlist-view.c +++ b/tbtcoreapp/src/view/tbt-genlist-view.c @@ -102,6 +102,8 @@ #include "view/tbt-multiclass-view.h" #include "view/tbt-usb-host-view.h" #include "view/tbt-motion-detection-view.h" +#include "view/tbt-cbhm-view.h" + typedef struct { Evas_Object *win; @@ -1257,6 +1259,17 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void motion_detection_view_add(view->navi, info, it); break; #endif + #ifdef TBT_MODULE_CBHM + case TBT_APP_CBHM_CHANGE_CALLBACK : + cbhm_view_add(view->navi, info, it); + break; + case TBT_APP_CBHM_MONITOR_CALLBACK : + cbhm_view_add(view->navi, info, it); + break; + case TBT_APP_CBHM_TYPE_GET : + cbhm_view_add(view->navi, info, it); + break; + #endif default: assert(false); break;