+int utcDaliTextFieldInputStyleChanged03(void)
+{
+ // Test InputStyleCahnged signal emitted even if AddIdle failed.
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextFieldInputStyleChanged03");
+
+ // Load some fonts.
+
+ char* pathNamePtr = get_current_dir_name();
+ const std::string pathName(pathNamePtr);
+ free(pathNamePtr);
+
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.SetDpi(93u, 93u);
+
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE);
+ fontClient.GetFontId(pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE);
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK(field);
+
+ field.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
+ field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+ field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+ field.SetProperty(TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>");
+
+ // connect to the text changed signal.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ field.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
+ bool inputStyleChangedSignal = false;
+ field.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
+
+ application.GetScene().Add(field);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 18.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE), TEST_LOCATION);
+
+ const std::string fontFamily = field.GetProperty(TextField::Property::INPUT_FONT_FAMILY).Get<std::string>();
+ DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
+
+ const float pointSize = field.GetProperty(TextField::Property::INPUT_POINT_SIZE).Get<float>();
+ DALI_TEST_EQUALS(pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 30.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 43.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::COLOR), TEST_LOCATION);
+
+ const Vector4 color = field.GetProperty(TextField::Property::INPUT_COLOR).Get<Vector4>();
+ DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Make AddIdle return false.
+ ToolkitApplication::ADD_IDLE_SUCCESS = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 88.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Execute the idle callbacks.
+ // And check whether we didn't change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 115.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Execute the idle callbacks.
+ // And check whether we didn't change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Revert AddIdle return true.
+ ToolkitApplication::ADD_IDLE_SUCCESS = true;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 164.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(gInputStyleChangedCallbackCalled);
+ if(gInputStyleChangedCallbackCalled)
+ {
+ DALI_TEST_EQUALS(static_cast<unsigned int>(gInputStyleMask), static_cast<unsigned int>(TextField::InputStyle::FONT_STYLE), TEST_LOCATION);
+
+ const std::string style = field.GetProperty(TextField::Property::INPUT_FONT_STYLE).Get<std::string>();
+ DALI_TEST_CHECK(style.empty());
+ }
+ DALI_TEST_CHECK(inputStyleChangedSignal);
+
+ gInputStyleChangedCallbackCalled = false;
+ gInputStyleMask = TextField::InputStyle::NONE;
+ inputStyleChangedSignal = false;
+
+ // Create a tap event to touch the text field.
+ TestGenerateTap(application, 191.0f, 25.0f);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Executes the idle callbacks added by the text control on the change of input style.
+ application.RunIdles();
+
+ DALI_TEST_CHECK(!gInputStyleChangedCallbackCalled);
+ DALI_TEST_CHECK(!inputStyleChangedSignal);
+
+ END_TEST;
+}
+