From: Priya Kohli Date: Wed, 15 May 2019 07:31:48 +0000 (+0530) Subject: [TBT][Autofill][NonACR][TIZEN-710, Added new TBT TC for Autofill Framework] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43020dd952a252eac6672cf4cca65c3e8cb10d97;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][Autofill][NonACR][TIZEN-710, Added new TBT TC for Autofill Framework] Change-Id: Ibe2c93a035f67b116c4646c9a1149564f1361ac4 Signed-off-by: Priya Kohli --- diff --git a/release/binary-armv7l/org.tizen.autofill-service-0.1.5-1.armv7l.rpm b/release/binary-armv7l/org.tizen.autofill-service-0.1.5-1.armv7l.rpm new file mode 100755 index 0000000..0f76c4a Binary files /dev/null and b/release/binary-armv7l/org.tizen.autofill-service-0.1.5-1.armv7l.rpm differ 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 88c9b3a..034b274 100755 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.autofill-service-0.1.5-1.armv7l.rpm b/release/binary-x86/org.tizen.autofill-service-0.1.5-1.armv7l.rpm new file mode 100755 index 0000000..0f76c4a Binary files /dev/null and b/release/binary-x86/org.tizen.autofill-service-0.1.5-1.armv7l.rpm 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 1e8fa1f..89d2ba3 100755 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/scripts_tpk/tpkbuild.sh b/scripts_tpk/tpkbuild.sh index a2542fe..ea9f095 100755 --- a/scripts_tpk/tpkbuild.sh +++ b/scripts_tpk/tpkbuild.sh @@ -172,6 +172,13 @@ modulearray=(org.tizen.coretbt_dataprovider org.tizen.coretbt_serviceapp org.tiz fi echo ""$reset fi + + echo $yellow"Installing Autofill service rpm" + sdb shell "mount -o remount,rw /" + sdb push $PWD/release/binary-$ARCH/org.tizen.autofill-service-0.1.5-1.armv7l.rpm /home/$EXECUTION_USER/apps_rw + sdb shell su -c "rpm -Uvh /home/$EXECUTION_USER/apps_rw/org.tizen.autofill-service-0.1.5-1.armv7l.rpm --nodeps --force" + sdb shell su -c "tpk-backend -y org.tizen.autofill-service --preload" + echo $yellow"Pushing media files" sdb push $PWD/release/binary-$ARCH/dog_1024_960.gif /home/$EXECUTION_USER/media/Images sdb push $PWD/release/binary-$ARCH/SampleMP3.mp3 /home/$EXECUTION_USER/media/Sounds diff --git a/tbtcoreapp/inc/model/tbt-info.h b/tbtcoreapp/inc/model/tbt-info.h index 478b27a..796e604 100644 --- a/tbtcoreapp/inc/model/tbt-info.h +++ b/tbtcoreapp/inc/model/tbt-info.h @@ -247,8 +247,8 @@ typedef enum { TBT_APP_STT_ERROR, TBT_APP_SMARTCARD, - TBT_APP_MOTION_DETECTION - + TBT_APP_MOTION_DETECTION, + TBT_APP_AUTOFILL } tbt_app_type_e; diff --git a/tbtcoreapp/inc/utils/app_module_config.h b/tbtcoreapp/inc/utils/app_module_config.h index e346003..878efed 100644 --- a/tbtcoreapp/inc/utils/app_module_config.h +++ b/tbtcoreapp/inc/utils/app_module_config.h @@ -246,4 +246,7 @@ #define TBT_MODULE_MOTION #define TBT_MODULE_APP_MOTION_DETECTION + +#define TBT_MODULE_AUTOFILL +#define TBT_MODULE_APP_AUTOFILL #endif diff --git a/tbtcoreapp/inc/utils/config.h b/tbtcoreapp/inc/utils/config.h index 8c6d90f..b7fb774 100644 --- a/tbtcoreapp/inc/utils/config.h +++ b/tbtcoreapp/inc/utils/config.h @@ -113,8 +113,6 @@ extern bool __is_efl_test_running; #define STT_START_RECORDING_SOUND "sounds/start_record.wav" - - #define WIDGET_VIEW_APPID "org.tizen.coretbtwidgetapp"; #define VIEWER_VIEW_APP_PACKAGE_NAME "org.tizen.widget_viewer_sdk"; @@ -124,6 +122,7 @@ extern bool __is_efl_test_running; #define DATA_CONTROL_PROVIDER_ID "http://coretbt_dataprovider.com/datacontrol/provider/coretbt_dataprovider"; #define DATA_CONTROL_MAP_PROVIDER_ID "http://coretbt_dataprovider.com/datacontrol/provider/coretbt_dataprovider_map"; +#define AUTOFILL_VIEW_APP_PACKAGE_NAME "org.tizen.autofill-test"; #define USE_GENLIST diff --git a/tbtcoreapp/inc/view/tbt-autofill-view.h b/tbtcoreapp/inc/view/tbt-autofill-view.h new file mode 100755 index 0000000..8864177 --- /dev/null +++ b/tbtcoreapp/inc/view/tbt-autofill-view.h @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2019 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-autofill-view.h + * @brief This view provide the Apps tested the autofill functionality. + * @since_tizen 5.5 + * @author Priya Kohli (priya.kohli@samsung.com) + * @date May, 2019 + * @bug No known bug. + * @credit Tizen Application framework Example + * + */ + +#ifndef __TBT_AUTOFILL_VIEW_H__ +#define __TBT_AUTOFILL_VIEW_H__ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_AUTOFILL + +#include +#include "model/tbt-list.h" + +/** + * @typedef _autofill_view + * @since_tizen 5.5 + * @brief A autofill viewer view handle. + */ +typedef struct _autofill_view autofill_view; + +/** + * @brief Create autofill_view_add + * @since_tizen 5.5 + * @param[in] navi Parent naviframe + * @param[in] tbt_info Custom struct contains all the necessary information of the modules + * @param[in] item Is the selected item of the Application home genlist + * @return Pointer of autofill_view on success, otherwise NULL + */ +autofill_view *autofill_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item); + +#endif +#endif // __TBT_AUTOFILL_VIEW_H__ diff --git a/tbtcoreapp/res/edje/2.3.1/wearable_360_360/autofill_viewer.edc b/tbtcoreapp/res/edje/2.3.1/wearable_360_360/autofill_viewer.edc new file mode 100755 index 0000000..c67cbc5 --- /dev/null +++ b/tbtcoreapp/res/edje/2.3.1/wearable_360_360/autofill_viewer.edc @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "wearable_circle_toolbar.edc" + +collections +{ + base_scale: 1.8; + group + { + name: "autofill_viewer"; + parts{ + part { name: "controller_part"; + type: SWALLOW; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { + relative: 0.0 0.40; + } + rel2 { + relative: 1.0 0.55; + } + visible: 1; + } + } + WEARABLE_TOOLBAR_PART + } + } +} diff --git a/tbtcoreapp/src/model/tbt-list.c b/tbtcoreapp/src/model/tbt-list.c index 61df3fc..da9b466 100644 --- a/tbtcoreapp/src/model/tbt-list.c +++ b/tbtcoreapp/src/model/tbt-list.c @@ -2536,11 +2536,22 @@ static tbt_info tbtapps[] = .result = 0, .required_features_count = 1, .features_required = {FEATURE_ACTIVITY_RECOGNITION} - } + }, + #endif +#endif +#ifdef TBT_MODULE_AUTOFILL + #ifdef TBT_MODULE_APP_AUTOFILL + //AUTO FILL Test + { + .name = "Autofill", + .parent = "Autofill", + .apptype = TBT_APP_AUTOFILL, + .icon_name = "dummy", + .info = "1. In 'Settings' select 'Autofill service' and then 'Tizen autofill service.'.
2.Launch Autofill TC, enter any string in each field, exit by pressing back key.
3.Lauch Autofill TC again, click on 'Login with Autofill' button.
4.The data entered before will be filled in the entry boxes", + .result = 0 + }, #endif #endif - - }; diff --git a/tbtcoreapp/src/view/tbt-autofill-view.c b/tbtcoreapp/src/view/tbt-autofill-view.c new file mode 100755 index 0000000..80d0040 --- /dev/null +++ b/tbtcoreapp/src/view/tbt-autofill-view.c @@ -0,0 +1,419 @@ +/******************************************************************************* + * Copyright (c) 2019 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-autofill-view.c + * @brief This view provide the Apps tested the autofill functionality. + * @author Priya Kohli (priya.kohli@samsung.com) + * @date May, 2019 + * @bug No known bug. + * @credit Tizen Autofill framework Example + * + */ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_AUTOFILL + +#include "utils/logger.h" +#include "utils/config.h" +#include "utils/ui-utils.h" +#include "view/tbt-autofill-view.h" +#include "view/tbt-common-view.h" + +#include + +struct _autofill_view +{ + common_view* view; + Evas_Object* btn_autofill; +}; + +struct _Entry +{ + Evas_Object *entry_bg; + Evas_Object *entry_obj; + autofill_item_h ai_h; + autofill_save_item_h si_h; +}; +typedef struct _Entry Entry; +static Entry en[2]; + +static autofill_h g_ah = NULL; + +static void _app_destroy_cb(void* this); +static void save_autofill_view_info(autofill_h ah); + +static void connection_status_changed_cb(autofill_h ah, autofill_connection_status_e status, void *user_data) +{ + switch (status) { + case AUTOFILL_CONNECTION_STATUS_CONNECTED: + DBG("connected"); + break; + case AUTOFILL_CONNECTION_STATUS_DISCONNECTED: + DBG("disconnected"); + break; + case AUTOFILL_CONNECTION_STATUS_REJECTED: + DBG("rejected"); + break; + default: + break; + } +} + +static bool fill_response_item_cb(autofill_fill_response_item_h item, void *user_data) +{ + char *id = NULL; + char *value = NULL; + char *presentation_text = NULL; + + char *id1 = NULL, *id2 = NULL; + + autofill_item_get_id(en[0].ai_h, &id1); + autofill_item_get_id(en[1].ai_h, &id2); + + autofill_fill_response_item_get_id(item, &id); + autofill_fill_response_item_get_presentation_text(item, &presentation_text); + autofill_fill_response_item_get_value(item, &value); + + DBG("id : %s, value : %s, presentation text : %s", id, value, presentation_text); + + if (id1 && strcmp(id, id1) == 0) + elm_object_text_set(en[0].entry_obj, value);/* show last group item */ + else if (id2 && strcmp(id, id2) == 0) + elm_object_text_set(en[1].entry_obj, value); + + if (id) + free(id); + + if (value) + free(value); + + if (presentation_text) + free(presentation_text); + + return true; +} + +static bool fill_response_multi_item_cb(autofill_fill_response_item_h item, void *user_data) +{ + char *id = NULL; + char *value = NULL; + char *presentation_text = NULL; + char *id1 = NULL, *id2 = NULL; + + autofill_fill_response_group_h group_h = (autofill_fill_response_group_h)user_data; + + autofill_item_get_id(en[0].ai_h, &id1); + autofill_item_get_id(en[1].ai_h, &id2); + + autofill_fill_response_item_get_id(item, &id); + autofill_fill_response_item_get_presentation_text(item, &presentation_text); + autofill_fill_response_item_get_value(item, &value); + + DBG("id : %s, value : %s, presentation text : %s", id, value, presentation_text); + + if (id) + free(id); + + if (value) + free(value); + + if (presentation_text) + free(presentation_text); + + return true; +} + +static bool fill_response_group_cb(autofill_fill_response_group_h group_h, void *user_data) +{ + int count = *(int *)user_data; + + if (count == 1) + autofill_fill_response_group_foreach_item(group_h, fill_response_item_cb, NULL); + else if (count > 1) + autofill_fill_response_group_foreach_item(group_h, fill_response_multi_item_cb, group_h); + + return true; +} + +static void fill_response_received_cb(autofill_h ah, autofill_fill_response_h fill_response, void *data) +{ + if (!fill_response) + return; + + /* get fill response group count */ + int count; + autofill_fill_response_get_group_count(fill_response, &count); + DBG("group count : %d", count); + + autofill_fill_response_foreach_group(fill_response, fill_response_group_cb, &count); +} + +static autofill_view_info_h create_autofill_view_info() +{ + autofill_view_info_h vi_h; + char *app_id = NULL; + app_get_id(&app_id); + + /* create autofill view info */ + autofill_view_info_create(&vi_h); + autofill_view_info_set_app_id(vi_h, app_id); + autofill_view_info_set_view_id(vi_h, "login"); + + /* append autofill item in autofill view */ + autofill_view_info_add_item(vi_h, en[0].ai_h); + autofill_view_info_add_item(vi_h, en[1].ai_h); + + if (app_id) + free(app_id); + + return vi_h; +} + +static void send_fill_request(autofill_h ah) +{ + autofill_view_info_h vi_h = create_autofill_view_info(); + + /* Set callback function for receiving autofill fill response */ + autofill_fill_response_set_received_cb(ah, fill_response_received_cb, NULL); + + /* Send request to get autofill fill response */ + int ret = autofill_fill_request(ah, vi_h); + if (ret == AUTOFILL_ERROR_NONE) + DBG("Succeeded to request fill"); + else + DBG("Failed to request fill : %d", ret); + + autofill_view_info_destroy(vi_h); +} + +static void delete_input_field(Entry *en) +{ + if (!en) return; + + if (en->ai_h) { + autofill_item_destroy(en->ai_h); + en->ai_h = NULL; + } + + if (en->si_h) { + autofill_save_item_destroy(en->si_h); + en->si_h = NULL; + } + + if (en->entry_bg) { + evas_object_del(en->entry_bg); + en->entry_bg = NULL; + } + + if (en->entry_obj) { + evas_object_del(en->entry_obj); + en->entry_obj = NULL; + } +} + +static void entry_del_cb(void *data, Evas *e, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Entry *en = data; + save_autofill_view_info(g_ah); + delete_input_field(en); +} + +static void +create_input_field(Evas_Object *win, Entry *en, const char *id, const char *label, bool sensitive, autofill_hint_e autofill_hint, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + if (!en) return; + + // create the background for text input field + en->entry_bg = elm_bg_add(win); + elm_bg_color_set(en->entry_bg, 100, 100, 100); + elm_object_focus_allow_set(en->entry_bg, EINA_TRUE); + evas_object_move(en->entry_bg, x, y); + evas_object_resize(en->entry_bg, w, h); + evas_object_show(en->entry_bg); + evas_object_data_set(en->entry_bg, "Entry", en); + + en->entry_obj = elm_entry_add(win); + evas_object_move(en->entry_obj, x, y); + evas_object_resize(en->entry_obj, w, h); + evas_object_show(en->entry_obj); + + // create autofill item + autofill_item_create(&en->ai_h); + autofill_item_set_autofill_hint(en->ai_h, autofill_hint); + autofill_item_set_id(en->ai_h, id); + autofill_item_set_label(en->ai_h, label); + autofill_item_set_sensitive_data(en->ai_h, sensitive); + DBG("en : %p, ai_h : %p\n", &en, en->ai_h); + + // create autofill item for save + autofill_save_item_create(&en->si_h); + autofill_save_item_set_autofill_hint(en->si_h, autofill_hint); + autofill_save_item_set_id(en->si_h, id); + autofill_save_item_set_label(en->si_h, label); + autofill_save_item_set_sensitive_data(en->si_h, sensitive); + DBG("en : %p, si_h : %p\n", &en, en->si_h); + + // register callback + evas_object_event_callback_add(en->entry_obj, EVAS_CALLBACK_DEL, entry_del_cb, en); +} + +static void save_autofill_item(Entry *en) +{ + const char *str; + char *plain_str; + + str = elm_object_text_get(en->entry_obj); + DBG("str = %s\n", str); + plain_str = elm_entry_markup_to_utf8(str); + DBG("plain_str = %s\n", plain_str); + autofill_save_item_set_value(en->si_h, plain_str ? plain_str : ""); + + if (plain_str) + free(plain_str); +} + +static void save_autofill_view_info(autofill_h ah) +{ + int ret; + char *app_id; + autofill_save_view_info_h svi_h = NULL; + + app_get_id(&app_id); + + /* create autofill item for saving */ + save_autofill_item(&en[0]); + save_autofill_item(&en[1]); + + /* create autofill save view info */ + autofill_save_view_info_create(&svi_h); + autofill_save_view_info_set_app_id(svi_h, app_id); + autofill_save_view_info_set_view_id(svi_h, "login"); + + /* append autofill save item in autofill save view */ + autofill_save_view_info_add_item(svi_h, en[0].si_h); + autofill_save_view_info_add_item(svi_h, en[1].si_h); + + if (app_id) + free(app_id); + + /* Send request to save autofill data */ + ret = autofill_commit(ah, svi_h); + if (ret == AUTOFILL_ERROR_NONE) + DBG("Succeeded to commit"); + else + DBG("Failed to commit. error code: 0x%X, error message: '%s'", ret, get_error_message(ret)); + + autofill_save_view_info_destroy(svi_h); +} + +static void win_focus_out_cb(void *data, Evas_Object *obj, void *event_info) +{ + RETM_IF(NULL == g_ah, "g_ah is NULL"); + save_autofill_view_info(g_ah); +} + +static void autofill_app_launch_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) +{ + send_fill_request(g_ah); +} + +static void add_control_layout(autofill_view *this, Evas_Object *parent) +{ + RETM_IF(NULL == this, "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); + + this->btn_autofill = ui_utils_push_button_add(this, table, "Login with Autofill", autofill_app_launch_button_pressed_cb); + elm_table_pack(table, this->btn_autofill, 0, 0, 1, 1); + elm_object_part_content_set(this->view->layout, "controller_part", this->btn_autofill); + + memset(&en[0], 0, sizeof(en[0])); + memset(&en[1], 0, sizeof(en[1])); + create_input_field(this->view->layout, &en[0], "id", "ID", false, AUTOFILL_HINT_ID, 40, 80, 280, 40); + create_input_field(this->view->layout, &en[1], "password", "Password", true, AUTOFILL_HINT_PASSWORD, 40, 130, 280, 40); + + evas_object_smart_callback_add(parent, "unfocused", win_focus_out_cb, NULL); +} + +autofill_view *autofill_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item) +{ + RETVM_IF(NULL == navi, NULL, "navi is null"); + + autofill_view *this = NULL; + this = calloc(1, sizeof(autofill_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 = "autofill_viewer"; + tbt_info->layout_file = get_edje_path("autofill_viewer.edj"); + + common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); + RETVM_IF(NULL == this->view, NULL, "navi is null"); + + add_control_layout(this, this->view->layout); + + int ret; + ret = autofill_create(&g_ah); + if (ret == AUTOFILL_ERROR_NONE) + DBG("Succeeded to create autofill"); + else + { + DBG("Failed to create autofill. error code: 0x%X, error message: '%s'", ret, get_error_message(ret)); + return this; + } + + ret = autofill_connect(g_ah, connection_status_changed_cb, NULL); + if (ret == AUTOFILL_ERROR_NONE) + DBG("Succeeded to connect"); + else + DBG("Failed to connect. error code: 0x%X, error message: '%s'", ret, get_error_message(ret)); + + return this; +} + +static void _app_destroy_cb(void* this) +{ + RETM_IF(NULL == this, "data is NULL"); + + autofill_view *view = NULL; + view = (autofill_view*)this; + RETM_IF(NULL == view, "view is NULL"); + + RETM_IF(NULL == g_ah, "g_ah is NULL"); + if (g_ah) + save_autofill_view_info(g_ah); + + SAFE_DELETE(view->view); + SAFE_DELETE(view); +} + +static void app_terminate(void *data) +{ + RETM_IF(NULL == g_ah, "g_ah is NULL"); + save_autofill_view_info(g_ah); + autofill_destroy(g_ah); + g_ah = NULL; +} +#endif diff --git a/tbtcoreapp/src/view/tbt-genlist-view.c b/tbtcoreapp/src/view/tbt-genlist-view.c index 045ad83..1308dd0 100644 --- a/tbtcoreapp/src/view/tbt-genlist-view.c +++ b/tbtcoreapp/src/view/tbt-genlist-view.c @@ -99,6 +99,7 @@ #include "view/tbt-stt-view.h" #include "view/tbt-smartcard-view.h" #include "view/tbt-motion-detection-view.h" +#include "view/tbt-autofill-view.h" typedef struct { @@ -1250,6 +1251,11 @@ 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_AUTOFILL + case TBT_APP_AUTOFILL: + autofill_view_add(view->navi, info, it); + break; + #endif default: assert(false); break;