+int UtcDaliToolkitTextlabelTextFitStressTest(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
+ TextLabel label = TextLabel::New();
+ Vector2 size(460.0f, 100.0f);
+ 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 with veryvery big range
+ Property::Map textFitMapSet;
+ textFitMapSet["enable"] = true;
+ textFitMapSet["minSize"] = 10.f;
+ textFitMapSet["maxSize"] = 10000.f;
+ textFitMapSet["stepSize"] = -1.0f;
+ textFitMapSet["fontSizeType"] = "pointSize";
+
+ label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
+ label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
+
+ application.GetScene().Add(label);
+
+ application.SendNotification();
+ application.Render();
+
+ const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
+ DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
+
+ DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
+ DALI_TEST_CHECK(textFitChangedSignal);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextlabelFastTextFitStressTest(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
+ TextLabel label = TextLabel::New();
+ label.SetProperty(TextLabel::Property::TEXT, "Hello world");
+ label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
+
+ // 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;
+
+ application.GetScene().Add(label);
+
+ // check text label width at range [100, 299]
+ for(int i=100; i<300; i++)
+ {
+ Vector2 size((float)i, 200.f);
+ label.SetProperty(Actor::Property::SIZE, size);
+
+ // check point size with veryvery big range
+ Property::Map textFitMapSet;
+ textFitMapSet["enable"] = true;
+ textFitMapSet["minSize"] = 10.f;
+ textFitMapSet["maxSize"] = 10000.f;
+ textFitMapSet["stepSize"] = -1.0f;
+ textFitMapSet["fontSizeType"] = "pointSize";
+
+ label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
+
+ application.SendNotification();
+ application.Render();
+ }
+
+ DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
+ DALI_TEST_CHECK(textFitChangedSignal);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextlabelTextFitMultiLine(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
+ TextLabel label = TextLabel::New();
+ Vector2 size(500.0f, 100.0f);
+ label.SetProperty(Actor::Property::SIZE, size);
+ label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
+ label.SetProperty(TextLabel::Property::MULTI_LINE, true);
+
+ // 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;
+
+ Property::Map textFitMapSet;
+ textFitMapSet["enable"] = true;
+ textFitMapSet["minSize"] = 10.f;
+ textFitMapSet["maxSize"] = 100.f;
+ textFitMapSet["stepSize"] = -1.0f;
+ textFitMapSet["fontSizeType"] = "pointSize";
+
+ label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
+ label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
+
+ application.GetScene().Add(label);
+
+ application.SendNotification();
+ application.Render();
+
+ float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
+ DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
+
+ DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
+ DALI_TEST_CHECK(textFitChangedSignal);
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextlabelTextFitArray(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
+ TextLabel label = TextLabel::New();
+ Vector2 size(300.0f, 80.0f);
+ label.SetProperty(Actor::Property::SIZE, size);
+ label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
+ label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
+ label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
+ application.GetScene().Add(label);
+
+ // make sorted options.
+ std::vector<DevelTextLabel::FitOption> fitOptions;
+ fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
+ fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
+ fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
+ fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
+ fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
+ fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
+ fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
+
+ DevelTextLabel::SetTextFitArray(label, true, fitOptions);
+
+ application.SendNotification();
+ application.Render();
+
+ bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
+ DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
+
+ std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
+ size_t numberOfFitOptions = getFitOptions.size();
+ DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
+
+ const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
+ DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
+
+ std::vector<DevelTextLabel::FitOption> emptyFitOptions;
+ DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
+
+ application.SendNotification();
+ application.Render();
+
+ enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
+ DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
+
+ const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
+ DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
+
+ // make unsorted options.
+ std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
+ unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
+ unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
+ unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
+ unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
+
+ DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
+
+ END_TEST;
+}
+