1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "utc_blink_ewk_base.h"
7 class utc_blink_cb_inputmethod_changed : public utc_blink_ewk_base
10 utc_blink_cb_inputmethod_changed()
12 memset(&panel_rect, 0, sizeof panel_rect);
16 const char* default_context_id = ecore_imf_context_default_id_get();
17 ASSERT_TRUE(default_context_id) << "This TC can't be run without default imf context - it will fail anyway";
22 evas_object_smart_callback_add(GetEwkWebView(), "inputmethod,changed", ToSmartCallback(inputmethod_changed_cb), this);
27 evas_object_smart_callback_del(GetEwkWebView(), "inputmethod,changed", ToSmartCallback(inputmethod_changed_cb));
30 void LoadFinished(Evas_Object*)
32 EventLoopStop(utc_blink_ewk_base::Success);
35 static void inputmethod_changed_cb(utc_blink_cb_inputmethod_changed* owner, Evas_Object*, Eina_Rectangle* rect)
37 utc_message("%p", rect);
40 owner->panel_rect = *rect;
43 owner->EventLoopStop(utc_blink_ewk_base::Success);
47 Eina_Rectangle panel_rect;
51 * @brief Test "inputmethod,changed" callback
53 * The name of the callback may be misguiding - it doesn't mean that the way you input text has changed.
54 * It means that geometry of input panel has changed.
56 TEST_F(utc_blink_cb_inputmethod_changed, callback)
58 char htmlBuffer[] = "<html>"
61 "<input id=\"e\" type=\"text\"/><br/>"
62 "<a id=\"focus\" onclick=\"document.getElementById('e').focus();\">Focus</a><br/>"
63 "<a id=\"unfocus\" onclick=\"document.getElementById('e').blur();\">Unfocus</a><br/>"
68 ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
69 // This TC will timeout on desktop as there is no input method context
70 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart());
72 // We need to focus on window
73 elm_object_focus_set(GetEwkWebView(), EINA_TRUE);
75 // This script execute should produce user gesture and should show software keyboard on mobile
76 ASSERT_EQ(EINA_TRUE, ewk_view_script_execute(GetEwkWebView(), "document.getElementById('focus').click();", NULL, NULL));
79 // When opening ime geometry is sent two times (by efl). First rect will be empty, second not
80 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart()) << "inputmethod,changed smart callback timeout";
81 ASSERT_EQ(EINA_TRUE, eina_rectangle_is_empty(&panel_rect));
83 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart()) << "inputmethod,changed smart callback timeout";
84 ASSERT_EQ(EINA_FALSE, eina_rectangle_is_empty(&panel_rect));
86 // This script execute should produce user gesture and should show software keyboard on mobile
87 ASSERT_EQ(EINA_TRUE, ewk_view_script_execute(GetEwkWebView(), "document.getElementById('unfocus').click();", NULL, NULL));
89 ASSERT_EQ(utc_blink_ewk_base::Success, EventLoopStart()) << "inputmethod,changed smart callback timeout";
90 ASSERT_EQ(EINA_TRUE, eina_rectangle_is_empty(&panel_rect));