Call idle functions what we might be failed to add 71/304671/5
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 23 Jan 2024 03:44:52 +0000 (12:44 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Wed, 24 Jan 2024 14:56:08 +0000 (23:56 +0900)
Since AddIdle could be failed at ecore side, we need to call given callback
synchronously, or need to print some error logs for some cases.

Change-Id: Ie0afd1fd7ddb92d43e2fdc03592144c8dae711e2
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/visuals/visual-factory-impl.cpp

index b81c693..566ca08 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -28,6 +28,7 @@
 #include <dali/integration-api/scene.h>
 #include <test-application.h>
 #include <toolkit-adaptor-impl.h>
+#include <toolkit-application.h>
 #include <toolkit-async-task-manager.h>
 #include <toolkit-scene-holder-impl.h>
 #include <toolkit-test-application.h>
@@ -85,15 +86,18 @@ Integration::Scene Adaptor::GetScene(Dali::Window window)
 
 bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
 {
-  if(hasReturnValue)
+  if(ToolkitApplication::ADD_IDLE_SUCCESS)
   {
-    mReturnCallbacks.PushBack(callback);
-  }
-  else
-  {
-    mCallbacks.PushBack(callback);
+    if(hasReturnValue)
+    {
+      mReturnCallbacks.PushBack(callback);
+    }
+    else
+    {
+      mCallbacks.PushBack(callback);
+    }
   }
-  return true;
+  return ToolkitApplication::ADD_IDLE_SUCCESS;
 }
 
 void Adaptor::RemoveIdle(CallbackBase* callback)
index 271d6ec..949c8c1 100644 (file)
 #include "toolkit-application.h"
 
 #include <dali-toolkit/public-api/dali-toolkit-common.h>
-#include <dali/public-api/signals/dali-signal.h>
 #include <dali/devel-api/adaptor-framework/orientation.h>
+#include <dali/public-api/signals/dali-signal.h>
 
 namespace Dali
 {
-
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-
 /**
  * Stub for the Application
  */
 class Application
 {
 public:
-
 public:
-
   Application(ToolkitApplication& toolkitApplication);
   ~Application();
 
 public:
-
   static std::string GetResourcePath();
 
   //Orientation& GetOrientation();
 
 public: // static methods
-
-public:  // Signals
-
+public: // Signals
 private:
-
   // Undefined
   Application(const Application&);
   Application& operator=(Application&);
@@ -88,6 +80,7 @@ std::string Application::GetResourcePath()
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
 bool ToolkitApplication::DECODED_IMAGES_SUPPORTED;
+bool ToolkitApplication::ADD_IDLE_SUCCESS = true;
 
 ToolkitApplication::ToolkitApplication()
 : mApplicationStub(new Application(*this))
index d444557..bd53962 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_TOOLKIT_APPLICATION_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -20,7 +20,6 @@
 
 namespace Dali
 {
-
 class Application;
 
 /**
@@ -30,18 +29,14 @@ class Application;
 class ToolkitApplication
 {
 public: // Construction & Destruction
-
   ToolkitApplication();
   ~ToolkitApplication();
 
 public: // Getters
-
   Application& GetApplication();
 
 public: // Signal Emissions
-
 public: // TEST FUNCTIONS
-
   // Enumeration of Application methods
   enum TestFuncEnum
   {
@@ -68,7 +63,6 @@ public: // TEST FUNCTIONS
   }
 
 private:
-
   struct TestFunctions
   {
     TestFunctions()
@@ -88,6 +82,7 @@ private:
 
 public: // Test static member
   static bool DECODED_IMAGES_SUPPORTED;
+  static bool ADD_IDLE_SUCCESS; ///< Default as true.
 };
 
 } // namespace Dali
index 2510393..bfe5db2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -4799,6 +4799,86 @@ int UtcDaliImageViewSetImageOnResourceReadySignal10(void)
   END_TEST;
 }
 
+int UtcDaliImageViewSetImageOnResourceReadySignal10WhenAddIdleFailed(void)
+{
+  tet_infoline("Test ResourceReady signal comes more than 2 times, but do not call again if AddIdle failed");
+
+  ToolkitTestApplication application;
+
+  gResourceReadySignalCounter = 0;
+
+  // Clear image view for clear test
+
+  if(gImageView1)
+  {
+    gImageView1.Reset();
+  }
+
+  // Dummy view to cache image.
+  ImageView dummyView = ImageView::New(gImage_34_RGBA);
+  application.GetScene().Add(dummyView);
+
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+  application.SendNotification();
+  application.Render();
+
+  // Make AddIdle failed.
+  ToolkitApplication::ADD_IDLE_SUCCESS = false;
+
+  try
+  {
+    gImageView1 = ImageView::New();
+    gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA);
+    gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10);
+    application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time.
+
+    tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
+
+    DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much.
+
+    for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i)
+    {
+      tet_printf("RunIdles\n");
+      // Executes the idle callbacks.
+      application.RunIdles();
+      application.SendNotification();
+      application.Render();
+      tet_printf("RunIdles done\n");
+    }
+    tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter);
+
+    DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready not called multiple times.
+
+    DALI_TEST_CHECK(true);
+  }
+  catch(...)
+  {
+    // Exception should not happened
+    DALI_TEST_CHECK(false);
+  }
+
+  ToolkitApplication::ADD_IDLE_SUCCESS = true;
+
+  // Clear cache.
+  application.SendNotification();
+  application.Render();
+
+  gResourceReadySignalCounter = 0;
+
+  gResourceReadySignalCounter = 0;
+
+  // Clear image view for clear test
+
+  if(gImageView1)
+  {
+    gImageView1.Reset();
+  }
+
+  END_TEST;
+}
+
 int UtcDaliImageViewSetImageOnResourceReadySignal11(void)
 {
   tet_infoline("Test ResourceReady Add AnimatedImageVisual and then Remove immediately.");
index 557be57..bc75ce0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
 #include <dali-toolkit/devel-api/text/rendering-backend.h>
 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
-#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
 
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/devel-api/adaptor-framework/key-devel.h>
-#include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali/devel-api/events/pan-gesture-devel.h>
+#include <dali/devel-api/text-abstraction/font-client.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/public-api/rendering/renderer.h>
@@ -391,7 +391,6 @@ public:
   bool& mFinishedCalled;
 };
 
-
 // Stores data that is populated in the callback and will be read by the test cases
 struct SignalData
 {
@@ -441,7 +440,6 @@ struct GestureReceivedFunctor
   SignalData& signalData;
 };
 
-
 } // namespace
 
 int UtcDaliToolkitTextEditorConstructorP(void)
@@ -1922,6 +1920,207 @@ int utcDaliTextEditorInputStyleChanged02(void)
   END_TEST;
 }
 
+int utcDaliTextEditorInputStyleChanged03(void)
+{
+  // Test InputStyleCahnged signal emitted even if AddIdle failed.
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorInputStyleChanged03");
+
+  // 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);
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK(editor);
+
+  editor.SetProperty(Actor::Property::SIZE, Vector2(300.f, 50.f));
+  editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+
+  editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
+  editor.SetProperty(TextEditor::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();
+  editor.InputStyleChangedSignal().Connect(&TestInputStyleChangedCallback);
+  bool inputStyleChangedSignal = false;
+  editor.ConnectSignal(testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal));
+
+  application.GetScene().Add(editor);
+
+  // 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                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Create a tap event to touch the text editor.
+  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>(TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE), TEST_LOCATION);
+
+    const std::string fontFamily = editor.GetProperty(TextEditor::Property::INPUT_FONT_FAMILY).Get<std::string>();
+    DALI_TEST_EQUALS(fontFamily, "DejaVuSerif", TEST_LOCATION);
+
+    const float pointSize = editor.GetProperty(TextEditor::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                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Create a tap event to touch the text editor.
+  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                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Create a tap event to touch the text editor.
+  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>(TextEditor::InputStyle::COLOR), TEST_LOCATION);
+
+    const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
+    DALI_TEST_EQUALS(color, Color::GREEN, TEST_LOCATION);
+  }
+  DALI_TEST_CHECK(inputStyleChangedSignal);
+
+  gInputStyleChangedCallbackCalled = false;
+  gInputStyleMask                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Make AddIdle return false.
+  ToolkitApplication::ADD_IDLE_SUCCESS = false;
+
+  // Create a tap event to touch the text editor.
+  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                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Create a tap event to touch the text editor.
+  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                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Revert AddIdle return true.
+  ToolkitApplication::ADD_IDLE_SUCCESS = true;
+
+  // Create a tap event to touch the text editor.
+  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>(TextEditor::InputStyle::FONT_STYLE), TEST_LOCATION);
+
+    Property::Map fontStyleMapSet;
+    Property::Map fontStyleMapGet;
+
+    fontStyleMapGet = editor.GetProperty<Property::Map>(TextEditor::Property::INPUT_FONT_STYLE);
+    DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
+    DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
+  }
+  DALI_TEST_CHECK(inputStyleChangedSignal);
+
+  gInputStyleChangedCallbackCalled = false;
+  gInputStyleMask                  = TextEditor::InputStyle::NONE;
+  inputStyleChangedSignal          = false;
+
+  // Create a tap event to touch the text editor.
+  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;
+}
+
 int utcDaliTextEditorEvent01(void)
 {
   ToolkitTestApplication application;
@@ -5161,7 +5360,6 @@ int utcDaliTextEditorGeometryNullPtr(void)
   END_TEST;
 }
 
-
 int utcDaliTextEditorSelectionClearedSignal(void)
 {
   ToolkitTestApplication application;
@@ -6393,7 +6591,6 @@ int utcDaliTextEditorPanGesturePropagation(void)
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   data.Reset();
 
-
   END_TEST;
 }
 
@@ -6420,10 +6617,10 @@ int utcDaliTextEditorGetTextBoundingRectangle(void)
   application.SendNotification();
   application.Render();
 
-  unsigned int startIndex    = 0;
-  unsigned int endIndex      = 15;
+  unsigned int startIndex = 0;
+  unsigned int endIndex   = 15;
 
-  Rect<> textBoundingRectangle = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
+  Rect<> textBoundingRectangle         = DevelTextEditor::GetTextBoundingRectangle(editor, startIndex, endIndex);
   Rect<> expectedTextBoundingRectangle = {0, 0, 100, 50};
 
   TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
index 202ca99..abb9c85 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -19,7 +19,6 @@
 #include <unistd.h>
 #include <iostream>
 
-
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
@@ -406,7 +405,6 @@ bool DaliTestCheckMaps(const Property::Map& fontStyleMapGet, const Property::Map
   return true;
 }
 
-
 // Stores data that is populated in the callback and will be read by the test cases
 struct SignalData
 {
@@ -1820,16 +1818,16 @@ int utcDaliTextFieldInputFilterWithInputMethodContext(void)
 
   // input text
   gInputFilteredAcceptedCallbackCalled = false;
-  imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
+  imfEvent                             = InputMethodContext::EventData(InputMethodContext::COMMIT, "Hello1234", 0, 9);
   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
   application.SendNotification();
   application.Render();
   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
   DALI_TEST_EQUALS(field.GetProperty<std::string>(TextField::Property::TEXT), std::string("1234"), TEST_LOCATION);
 
-  inputFilteredSignal = false;
+  inputFilteredSignal                  = false;
   gInputFilteredRejectedCallbackCalled = false;
-  imfEvent = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
+  imfEvent                             = InputMethodContext::EventData(InputMethodContext::COMMIT, "1234567", 0, 7);
   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
   application.SendNotification();
   application.Render();
@@ -2480,6 +2478,203 @@ int utcDaliTextFieldInputStyleChanged02(void)
   END_TEST;
 }
 
+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;
+}
+
 int utcDaliTextFieldEvent01(void)
 {
   ToolkitTestApplication application;
@@ -2981,7 +3176,7 @@ int utcDaliTextFieldEvent08(void)
   ToolkitTestApplication application;
   tet_infoline(" utcDaliTextFieldEvent08");
 
-  Dali::Clipboard clipboard = Clipboard::Get();
+  Dali::Clipboard           clipboard = Clipboard::Get();
   Dali::Clipboard::ClipData data("text/plain;charset=utf-8", "testTextFieldEvent");
   clipboard.SetData(data);
 
@@ -4934,7 +5129,6 @@ int utcDaliTextFieldGeometryGlyphMiddle(void)
   END_TEST;
 }
 
-
 int utcDaliTextFieldGeometryNullPtr(void)
 {
   ToolkitTestApplication application;
@@ -5784,7 +5978,6 @@ int utcDaliTextFieldPanGesturePropagation(void)
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   data.Reset();
 
-
   END_TEST;
 }
 
@@ -5811,10 +6004,10 @@ int utcDaliTextFieldGetTextBoundingRectangle(void)
   application.SendNotification();
   application.Render();
 
-  unsigned int startIndex    = 0;
-  unsigned int endIndex      = 15;
+  unsigned int startIndex = 0;
+  unsigned int endIndex   = 15;
 
-  Rect<> textBoundingRectangle = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
+  Rect<> textBoundingRectangle         = DevelTextField::GetTextBoundingRectangle(field, startIndex, endIndex);
   Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
 
   TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
@@ -5822,7 +6015,6 @@ int utcDaliTextFieldGetTextBoundingRectangle(void)
   END_TEST;
 }
 
-
 int utcDaliTextFieldDecoratorColor(void)
 {
   ToolkitTestApplication application;
index 9feff1c..e67be8e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -2241,7 +2241,12 @@ void Control::Impl::EmitResourceReadySignal()
       {
         // The callback manager takes the ownership of the callback object.
         mIdleCallback = MakeCallback(this, &Control::Impl::OnIdleCallback);
-        Adaptor::Get().AddIdle(mIdleCallback, true);
+        if(DALI_UNLIKELY(!Adaptor::Get().AddIdle(mIdleCallback, true)))
+        {
+          DALI_LOG_ERROR("Fail to add idle callback for control resource ready. Skip this callback.\n");
+          mIdleCallback           = nullptr;
+          mIdleCallbackRegistered = false;
+        }
       }
     }
   }
index 4f4b709..ee04c2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -825,7 +825,13 @@ void TextEditor::OnRelayout(const Vector2& size, RelayoutContainer& container)
       {
         // @note: The callback manager takes the ownership of the callback object.
         mIdleCallback = MakeCallback(this, &TextEditor::OnIdleSignal);
-        adaptor.AddIdle(mIdleCallback, false);
+        if(DALI_UNLIKELY(!adaptor.AddIdle(mIdleCallback, false)))
+        {
+          DALI_LOG_ERROR("Fail to add idle callback for text editor queue. Skip these callbacks\n");
+
+          // Set the pointer to null as the callback manager deletes the callback even AddIdle failed.
+          mIdleCallback = NULL;
+        }
       }
     }
   }
index 88919fe..d26dded 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -736,7 +736,13 @@ void TextField::OnRelayout(const Vector2& size, RelayoutContainer& container)
       {
         // @note: The callback manager takes the ownership of the callback object.
         mIdleCallback = MakeCallback(this, &TextField::OnIdleSignal);
-        adaptor.AddIdle(mIdleCallback, false);
+        if(DALI_UNLIKELY(!adaptor.AddIdle(mIdleCallback, false)))
+        {
+          DALI_LOG_ERROR("Fail to add idle callback for text field queue. Skip these callbacks\n");
+
+          // Set the pointer to null as the callback manager deletes the callback even AddIdle failed.
+          mIdleCallback = NULL;
+        }
       }
     }
   }
index 4a8a6d4..9bd6d25 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -29,6 +29,7 @@
 #include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.h>
 #include <dali-toolkit/internal/visuals/animated-image/animated-image-visual.h>
 #include <dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.h>
@@ -42,7 +43,6 @@
 #include <dali-toolkit/internal/visuals/npatch/npatch-visual.h>
 #include <dali-toolkit/internal/visuals/primitive/primitive-visual.h>
 #include <dali-toolkit/internal/visuals/svg/svg-visual.h>
-#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/internal/visuals/text-visual-shader-factory.h>
 #include <dali-toolkit/internal/visuals/text/text-visual.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
@@ -53,7 +53,6 @@
 #include <dali-toolkit/public-api/visuals/text-visual-properties.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 
-
 namespace Dali
 {
 namespace Toolkit
@@ -77,15 +76,13 @@ DALI_TYPE_REGISTRATION_BEGIN_CREATE(Toolkit::VisualFactory, Dali::BaseHandle, Cr
 DALI_TYPE_REGISTRATION_END()
 const char* const BROKEN_IMAGE_FILE_NAME = "broken.png"; ///< The file name of the broken image.
 
-static constexpr auto          SHADER_TYPE_COUNT = 2u;
-const std::string_view VertexPredefines[SHADER_TYPE_COUNT]
-{
-  "", //VisualFactoryCache::COLOR_SHADER
+static constexpr auto  SHADER_TYPE_COUNT = 2u;
+const std::string_view VertexPredefines[SHADER_TYPE_COUNT]{
+  "",                                     //VisualFactoryCache::COLOR_SHADER
   "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER
 };
-const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]
-{
-  "", //VisualFactoryCache::COLOR_SHADER
+const std::string_view FragmentPredefines[SHADER_TYPE_COUNT]{
+  "",                                     //VisualFactoryCache::COLOR_SHADER
   "#define IS_REQUIRED_ROUNDED_CORNER\n", //VisualFactoryCache::COLOR_SHADER_ROUNDED_CORNER
 };
 
@@ -420,7 +417,7 @@ void VisualFactory::UsePreCompiledShader()
 
   // Get image shader
   std::vector<RawShaderData> rawShaderList;
-  RawShaderData imageShaderData;
+  RawShaderData              imageShaderData;
   GetImageVisualShaderFactory().GetPreCompiledShader(imageShaderData);
   rawShaderList.push_back(imageShaderData);
 
@@ -434,7 +431,6 @@ void VisualFactory::UsePreCompiledShader()
   GetPreCompiledShader(colorShaderData);
   rawShaderList.push_back(colorShaderData);
 
-
   // Save all shader
   ShaderPreCompiler::Get().SavePreCompileShaderList(rawShaderList);
 }
@@ -468,20 +464,20 @@ void VisualFactory::GetPreCompiledShader(RawShaderData& shaders)
 {
   std::vector<std::string_view> vertexPrefix;
   std::vector<std::string_view> fragmentPrefix;
-  int shaderCount = 0;
-  shaders.shaderCount = 0;
-  for(uint32_t i=0u; i< SHADER_TYPE_COUNT; ++i)
+  int                           shaderCount = 0;
+  shaders.shaderCount                       = 0;
+  for(uint32_t i = 0u; i < SHADER_TYPE_COUNT; ++i)
   {
     vertexPrefix.push_back(VertexPredefines[i]);
     fragmentPrefix.push_back(FragmentPredefines[i]);
     shaderCount++;
   }
 
-  shaders.vertexPrefix = vertexPrefix;
+  shaders.vertexPrefix   = vertexPrefix;
   shaders.fragmentPrefix = fragmentPrefix;
-  shaders.vertexShader = SHADER_COLOR_VISUAL_SHADER_VERT;
+  shaders.vertexShader   = SHADER_COLOR_VISUAL_SHADER_VERT;
   shaders.fragmentShader = SHADER_COLOR_VISUAL_SHADER_FRAG;
-  shaders.shaderCount = shaderCount;
+  shaders.shaderCount    = shaderCount;
 }
 
 Internal::VisualFactoryCache& VisualFactory::GetFactoryCache()
@@ -536,10 +532,10 @@ void VisualFactory::RegisterDiscardCallback()
 
     Adaptor& adaptor = Adaptor::Get();
 
-    if(!adaptor.AddIdle(mIdleCallback, false))
+    if(DALI_UNLIKELY(!adaptor.AddIdle(mIdleCallback, false)))
     {
-      // Fail to add idle. (Maybe adaptor is paused.)
-      mIdleCallback = nullptr;
+      DALI_LOG_ERROR("Fail to add idle callback for visual factory. Call it synchronously.\n");
+      OnDiscardCallback();
     }
   }
 }