Merge "Add a callback to get textfitted font size." into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
index 5495c9d..b0f9764 100644 (file)
@@ -82,6 +82,8 @@ const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
 static bool gAnchorClickedCallBackCalled;
 static bool gAnchorClickedCallBackNotCalled;
 
+static bool gTextFitChangedCallBackCalled;
+
 struct CallbackFunctor
 {
   CallbackFunctor(bool* callbackFlag)
@@ -108,6 +110,12 @@ static void TestAnchorClickedCallback(TextLabel control, const char* href, unsig
   }
 }
 
+static void TestTextFitChangedCallback(TextLabel control)
+{
+  tet_infoline(" TestTextFitChangedCallback");
+  gTextFitChangedCallBackCalled = true;
+}
+
 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
 {
   const Property::Map::SizeType size = mapGet.Count();
@@ -836,6 +844,44 @@ int UtcDaliToolkitTextLabelEmojisP(void)
   application.SendNotification();
   application.Render();
 
+  // EMOJI + ZWJ + EMOJI case for coverage.
+  const std::string emojiWithZWJ = "&#x1f469;&#x200d;&#x1f52c;";
+  label.SetProperty( TextLabel::Property::TEXT, emojiWithZWJ );
+
+  application.SendNotification();
+  application.Render();
+
+  // EMOJI Sequences case for coverage.
+  std::string emojiSequences =
+       "Text VS15 &#x262a;&#xfe0e;\n"                                                         //text presentation sequence and selector
+      "Color VS16 &#x262a;&#xfe0f;\n"                                                        //emoji presentation sequence and selector
+      "Default &#x262a; \n"                                                                  //default presentation
+      "FamilyManWomanGirlBoy &#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;\n" // emoji multi zwj sequence
+      "WomanScientist &#x1f469;&#x200d;&#x1f52c;\n"                                          // emoji zwj sequence
+      "WomanScientistLightSkinTone&#x1F469;&#x1F3FB;&#x200D;&#x1F52C; \n"                    //emoji modifier sequence: skin tone & JWZ
+      "LeftRightArrowText&#x2194;&#xfe0e;\n"                                                 //text presentation sequence and selector
+      "LeftRightArrowEmoji&#x2194;&#xfe0f;\n"                                                //emoji presentation sequence and selector
+      "SouthKoreaFlag&#x1f1f0;&#x1f1f7;\n"                                                   //emoji flag sequence
+      "JordanFlag&#x1f1ef;&#x1f1f4;\n"                                                       // emoji flag sequence
+      "EnglandFlag&#x1F3F4;&#xE0067;&#xE0062;&#xE0065;&#xE006E;&#xE0067;&#xE007F;\n"         //emoji tag sequence like England flag
+      "Runner &#x1f3c3;&#x200d;&#x27a1;&#xfe0f; \n"
+      "VictoryHandMediumLightSkinTone:&#x270C;&#xFE0F;&#x1F3FC;\n"               //emoji modifier sequence: skin tone
+      "RainbowFlag:&#x1F3F3;&#xFE0F;&#x200D;&#x1F308; \n"                        //emoji zwj sequence: Rainbow Flag
+      "keycap# &#x0023;&#xFE0F;&#x20E3; \n"                                      // fully-qualified  emoji keycap sequence
+      "keycap#_text &#x0023;&#x20E3; \n"                                         // unqualified emoji keycap sequence
+      "keycap3 &#x0033;&#xfe0f;&#x20e3; \n"                                      // fully-qualified  emoji keycap sequence
+      "keycap3_text &#x0033;&#x20e3; \n"                                         // unqualified emoji keycap sequence
+      "two adjacent glyphs &#x262a;&#xfe0f;&#xfe0f;&#xfe0f;&#x262a;&#xfe0f;\n"   //This line should be rendered as two adjacent glyphs
+      "Digit 8&#xfe0f; 8&#xfe0e; 8\n"                                            // should be rendered according to selector
+      "Surfing Medium Skin Female:  &#x1f3c4;&#x1f3fc;&#x200d;&#x2640;&#xfe0f;"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
+
+  label.SetProperty( TextLabel::Property::TEXT, emojiSequences );
+  label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
+  label.SetProperty( TextLabel::Property::MULTI_LINE, true);
+  label.SetProperty( TextLabel::Property::ELLIPSIS, false);
+
+  application.SendNotification();
+  application.Render();
   END_TEST;
 }
 
@@ -1625,6 +1671,13 @@ int UtcDaliToolkitTextlabelTextFit(void)
   label.SetProperty( Actor::Property::SIZE, size );
   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
 
+   // connect to the text git changed signal.
+  ConnectionTracker* testTracker = new ConnectionTracker();
+  DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
+  bool textFitChangedSignal = false;
+  label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
+  gTextFitChangedCallBackCalled = false;
+
   // check point size
   Property::Map textFitMapSet;
   textFitMapSet["enable"] = true;
@@ -1644,6 +1697,9 @@ int UtcDaliToolkitTextlabelTextFit(void)
   const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
 
+  DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
+  DALI_TEST_CHECK(textFitChangedSignal);
+
   // check pixel size
   textFitMapSet.Clear();
   textFitMapSet["enable"] = true;
@@ -2020,4 +2076,4 @@ int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
 
 
   END_TEST;
-}
\ No newline at end of file
+}