2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
24 // Internal headers are allowed here
25 #include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
26 #include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
29 using namespace Dali::Toolkit;
30 using namespace Dali::Toolkit::Internal;
32 void dali_text_view_relayout_utils_startup(void)
34 test_return_value = TET_UNDEF;
37 void dali_text_view_relayout_utils_cleanup(void)
39 test_return_value = TET_PASS;
45 const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
47 // Data structures used to create an 'experiment' in TET cases
50 bool TestEqual( float x, float y )
52 return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
55 //////////////////////////////////////////////////////////////////
57 struct CalculateLineLayoutTest
59 std::string description;
60 std::string inputParagraph;
62 std::size_t wordIndex;
63 std::size_t characterIndex;
64 std::size_t characterParagraphIndex;
65 TextViewRelayout::HorizontalWrapType splitPolicy;
68 float resultLineLength;
69 float resultMaxCharHeight;
70 float resultMaxAscender;
73 bool TestCalculateLineLayout( const CalculateLineLayoutTest& test, const char* location )
75 tet_printf( "%s", test.description.c_str() );
77 // Create styled text.
78 MarkupProcessor::StyledTextArray inputStyledText;
79 MarkupProcessor::GetStyledTextArray( test.inputParagraph, inputStyledText, true );
81 // Create styled text layout info.
82 Toolkit::Internal::TextView::RelayoutData relayoutData;
83 TextViewProcessor::CreateTextInfo( inputStyledText,
84 DEFAULT_LAYOUT_PARAMETERS,
87 // Prepare input parameters and the result structure and call the function to be tested.
90 TextViewProcessor::TextInfoIndices indices( 0u, test.wordIndex, test.characterIndex );
91 indices.mCharacterParagraphIndex = test.characterParagraphIndex;
93 // Get the input paragraph.
94 TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
96 if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
98 inputParagraphLayout = *relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin();
102 TextViewRelayout::LineLayoutInfo resultLayoutInfo;
104 CalculateLineLayout( test.parentWidth,
106 inputParagraphLayout,
112 if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
114 tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
118 if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
120 tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
124 if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
126 tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
133 //////////////////////////////////////////////////////////////////
135 struct AlignmentOffsetTest
137 Toolkit::Alignment::Type alignment;
144 bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
148 switch( test.alignment )
150 case Toolkit::Alignment::HorizontalLeft:
151 case Toolkit::Alignment::HorizontalCenter:
152 case Toolkit::Alignment::HorizontalRight:
154 offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
157 case Toolkit::Alignment::VerticalTop:
158 case Toolkit::Alignment::VerticalCenter:
159 case Toolkit::Alignment::VerticalBottom:
161 offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
167 if( !TestEqual( test.resultOffset, offset ) )
169 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
176 //////////////////////////////////////////////////////////////////
178 struct JustificationOffsetTest
180 Toolkit::TextView::LineJustification justification;
181 float wholeTextWidth;
187 bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
189 float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
192 if( !TestEqual( test.resultOffset, offset ) )
194 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
201 //////////////////////////////////////////////////////////////////
203 struct CalculateVisibilityTest
208 TextViewRelayout::VisibilityTestType type;
213 bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
215 if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
217 tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
224 //////////////////////////////////////////////////////////////////
229 int UtcDaliTextViewDefaultConstructorDestructor_RU(void)
231 ToolkitTestApplication application;
233 tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
235 // Test RelayoutParameters defaults.
236 TextViewRelayout::RelayoutParameters relayoutParameters;
238 DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
239 DALI_TEST_EQUALS( relayoutParameters.mParagraphSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
240 DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
241 DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
242 DALI_TEST_EQUALS( relayoutParameters.mIndices.mParagraphIndex, 0u, TEST_LOCATION );
243 DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
244 DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
245 DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
246 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
247 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
248 DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
249 DALI_TEST_CHECK( !relayoutParameters.mIsNewParagraphCharacter );
250 DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
251 DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
253 // Test FadeParameter defaults
254 TextViewRelayout::FadeParameters fadeParameters;
256 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
257 DALI_TEST_EQUALS( fadeParameters.mRightFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
258 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
259 DALI_TEST_EQUALS( fadeParameters.mRightFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
260 DALI_TEST_EQUALS( fadeParameters.mRightAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
261 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
262 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
263 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
264 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
265 DALI_TEST_EQUALS( fadeParameters.mLeftAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
266 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
267 DALI_TEST_EQUALS( fadeParameters.mTopFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
268 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
269 DALI_TEST_EQUALS( fadeParameters.mTopFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
270 DALI_TEST_EQUALS( fadeParameters.mTopAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
271 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
272 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
273 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
274 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
275 DALI_TEST_EQUALS( fadeParameters.mBottomAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
276 DALI_TEST_CHECK( !fadeParameters.mIsPartiallyVisible );
278 // Test EllipsizeParameters defaults
279 TextViewRelayout::EllipsizeParameters ellipsizeParameters;
281 DALI_TEST_EQUALS( ellipsizeParameters.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
282 DALI_TEST_EQUALS( ellipsizeParameters.mLineDescender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
283 DALI_TEST_EQUALS( ellipsizeParameters.mLineWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
284 DALI_TEST_EQUALS( ellipsizeParameters.mEllipsizeBoundary, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
285 DALI_TEST_EQUALS( ellipsizeParameters.mFirstIndex, 0u, TEST_LOCATION );
286 DALI_TEST_EQUALS( ellipsizeParameters.mLastIndex, 0u, TEST_LOCATION );
287 DALI_TEST_CHECK( !ellipsizeParameters.mEllipsizeLine );
288 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineWidthFullyVisible );
289 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineHeightFullyVisible );
290 DALI_TEST_CHECK( !ellipsizeParameters.mIsNextLineFullyVisibleHeight );
291 DALI_TEST_CHECK( !ellipsizeParameters.mCreateEllipsizedTextActors );
292 DALI_TEST_CHECK( !ellipsizeParameters.mLineFits );
293 DALI_TEST_CHECK( !ellipsizeParameters.mWordFits );
295 // Test UnderlineInfo defaults
296 TextViewRelayout::UnderlineInfo underlineInfo;
298 DALI_TEST_EQUALS( underlineInfo.mMaxHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
299 DALI_TEST_EQUALS( underlineInfo.mMaxThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
300 DALI_TEST_EQUALS( underlineInfo.mPosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
302 // Test TextUnderlineStatus defaults
303 TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
305 DALI_TEST_CHECK( textUnderlineStatus.mUnderlineInfo.empty() );
306 DALI_TEST_EQUALS( textUnderlineStatus.mCharacterGlobalIndex, 0u, TEST_LOCATION );
307 DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
308 DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
310 // Test LineLayoutInfo defaults
311 TextViewRelayout::LineLayoutInfo lineLayoutInfo;
313 DALI_TEST_EQUALS( lineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
314 DALI_TEST_EQUALS( lineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
315 DALI_TEST_EQUALS( lineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
319 int UtcDaliTextViewCalculateLineLayout(void)
321 ToolkitTestApplication application;
323 tet_infoline("UtcDaliTextViewCalculateLineLayout : ");
325 struct CalculateLineLayoutTest calculateLineLayoutTest[] =
329 "The paragraph is wraped by character. All characters have the same size.",
330 "Hello world", // input paragraph
331 100.f, // parent width
335 TextViewRelayout::WrapByCharacter, // split policy
338 91.041672f, // line length. (only fits 8 characters 8x11.38)
339 11.380209f, // max character height
340 10.242188f // max ascender
343 "The paragraph is wraped by character. There are characters with different sizes.",
344 "Hello <font size='14'>world</font>", // input paragraph
345 100.f, // parent width
349 TextViewRelayout::WrapByCharacter, // split policy
352 94.835075f, // line length. (only fits 8 characters 6x11.38 + 2x13.27)
353 13.276911f, // max character height
354 11.949220f // max ascender
357 "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
358 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
359 100.f, // parent width
360 2, // indices. The third character of the third word starts in a new line.
363 TextViewRelayout::WrapByCharacter, // split policy
366 91.041672f, // line length. (only fits 8 characters 8x11.38)
367 11.380209f, // max character height
368 10.242188f // max ascender
371 "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
372 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
373 100.f, // parent width
374 4, // indices. The fifth character of the fifth word starts in a new line.
377 TextViewRelayout::WrapByCharacter, // split policy
380 92.938377f, // line length. (only fits 8 characters 8x11.38)
381 13.276911f, // max character height
382 11.949220f // max ascender
387 "The paragraph is wraped by word. All characters have the same size.",
388 "Hello world", // input paragraph
389 100.f, // parent width
390 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
393 TextViewRelayout::WrapByWord, // split policy
396 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
397 11.380209f, // max character height
398 10.242188f // max ascender
401 "The paragraph is wraped by word. There are characters with different sizes.",
402 "Hell<font size='14'>o</font> world", // input paragraph
403 100.f, // parent width
407 TextViewRelayout::WrapByWord, // split policy
410 58.797747f, // line length. (only fits 5 characters 4x11.38 + 13.276911, white space is not counted)
411 13.276911f, // max character height
412 11.949220f // max ascender
415 "The paragraph is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
416 "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input paragraph
417 100.f, // parent width
418 2, // indices. The third word starts in a new line.
421 TextViewRelayout::WrapByWord, // split policy
424 60.694449f, // line length. (only fits 5 characters 2x13.276911 + 3x11.38)
425 13.276911f, // max character height
426 11.949220f // max ascender
429 "The paragraph is wraped by word. The word doen't fit.",
430 "Hello world", // input paragraph
431 40.f, // parent width
432 0, // indices. The third word starts in a new line.
435 TextViewRelayout::WrapByWord, // split policy
438 0.f, // line length. (The word doesn't fit)
439 11.380209f, // max character height
440 10.242188f // max ascender
445 "The paragraph is wraped by word and by character. All characters have the same size. There is not a long word.",
446 "Hello world hello world", // input paragraph
447 100.f, // parent width
451 TextViewRelayout::WrapByWordAndSplit, // split policy
454 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
455 11.380209f, // max character height
456 10.242188f // max ascender
459 "The paragraph is wraped by word and by character. All characters have the same size. There is a long word.",
460 "Helloooooooo world", // input paragraph
461 100.f, // parent width
465 TextViewRelayout::WrapByWordAndSplit, // split policy
468 91.041672f, // line length. (only fits 8 characters 8x11.38)
469 11.380209f, // max character height
470 10.242188f // max ascender
473 "The paragraph is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
474 "Helloooooooo <font size='14'>world</font>", // input paragraph
475 100.f, // parent width
479 TextViewRelayout::WrapByWordAndSplit, // split policy
482 45.520836f, // line length. (only fits 8 characters 8x11.38)
483 11.380209f, // max character height
484 10.242188f // max ascender
487 "The paragraph is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
488 "Helloooooooo<font size='14'> world</font>", // input paragraph
489 100.f, // parent width
493 TextViewRelayout::WrapByWordAndSplit, // split policy
496 95.593755f, // line length. (only fits 12 characters 8x11.38)
497 7.9661463f, // max character height
498 7.169531f // max ascender
501 //WrapByParagraphCharacterAndSplit
503 "The paragraph is wraped by end of paragraph and by character. All characters have the same size.",
504 "Hello world", // input paragraph
505 100.f, // parent width
509 TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
512 91.041672f, // line length. (only fits 8 characters 8x11.38)
513 11.380209f, // max character height
514 10.242188f // max ascender
517 "The paragraph fits in the width.",
518 "Hello", // input paragraph
519 100.f, // parent width
523 TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
526 56.901047f, // line length. (only fits 5 characters 5x11.38)
527 11.380209f, // max character height
528 10.242188f // max ascender
531 "The paragraph is wraped by end of paragraph and by character. All characters have the same size. It calculates the layout for the second line.",
532 "Hello world, hello world", // input paragraph
533 100.f, // parent width
537 TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
540 91.041672f, // line length. (only fits 8 characters 8x11.38)
541 11.380209f, // max character height
542 10.242188f // max ascender
545 const std::size_t numberOfTests( 15 );
547 for( std::size_t index = 0; index < numberOfTests; ++index )
549 const CalculateLineLayoutTest& test = calculateLineLayoutTest[index];
551 if( !TestCalculateLineLayout( test, TEST_LOCATION ) )
553 tet_result( TET_FAIL );
557 tet_result( TET_PASS );
561 int UtcDaliTextViewCalculateAlignmentOffsets(void)
563 ToolkitTestApplication application;
565 tet_infoline("UtcDaliTextViewCalculateAlignmentOffsets : ");
567 struct AlignmentOffsetTest alignmentOffsetTest[] =
570 Toolkit::Alignment::HorizontalLeft,
576 Toolkit::Alignment::HorizontalCenter,
582 Toolkit::Alignment::HorizontalRight,
588 Toolkit::Alignment::VerticalTop,
594 Toolkit::Alignment::VerticalCenter,
600 Toolkit::Alignment::VerticalBottom,
606 const std::size_t numberOfTests( 6 );
608 for( std::size_t index = 0; index < numberOfTests; ++index )
610 const AlignmentOffsetTest& test = alignmentOffsetTest[index];
612 if( !TestAlignmentOffset( test, TEST_LOCATION ) )
614 tet_result( TET_FAIL );
618 tet_result( TET_PASS );
622 int UtcDaliTextViewCalculateJustificationOffsets(void)
624 ToolkitTestApplication application;
626 tet_infoline("UtcDaliTextViewCalculateJustificationOffsets : ");
628 struct JustificationOffsetTest justificationOffsetTest[] =
631 Toolkit::TextView::Left,
637 Toolkit::TextView::Justified,
643 Toolkit::TextView::Center,
649 Toolkit::TextView::Right,
655 const std::size_t numberOfTests( 4 );
657 for( std::size_t index = 0; index < numberOfTests; ++index )
659 const JustificationOffsetTest& test = justificationOffsetTest[index];
661 if( !TestJustificationOffset( test, TEST_LOCATION ) )
663 tet_result( TET_FAIL );
667 tet_result( TET_PASS );
672 int UtcDaliTextViewCalculateVisibility(void)
674 ToolkitTestApplication application;
676 tet_infoline("UtcDaliTextViewCalculateVisibility : ");
678 struct CalculateVisibilityTest calculateVisibilityTest[] =
681 Vector3( 0.f, 10.f, 0.f ),
683 Size( 100.f, 100.f ),
684 TextViewRelayout::FULLY_VISIBLE,
688 Vector3( 10.f, 10.f, 0.f ),
690 Size( 100.f, 100.f ),
691 TextViewRelayout::FULLY_VISIBLE,
695 Vector3( 0.f, 10.f, 0.f ),
697 Size( 100.f, 100.f ),
698 TextViewRelayout::FULLY_VISIBLE,
702 Vector3( 0.f, 10.f, 0.f ),
704 Size( 100.f, 100.f ),
705 TextViewRelayout::FULLY_VISIBLE_WIDTH,
709 Vector3( 95.f, 10.f, 0.f ),
711 Size( 100.f, 100.f ),
712 TextViewRelayout::FULLY_VISIBLE_WIDTH,
716 Vector3( 0.f, 10.f, 0.f ),
718 Size( 100.f, 100.f ),
719 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
723 Vector3( 0.f, 0.f, 0.f ),
725 Size( 100.f, 100.f ),
726 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
730 Vector3( -10.f, 10.f, 0.f ),
731 Size( 150.f, 150.f ),
732 Size( 100.f, 100.f ),
733 TextViewRelayout::PARTIALLY_VISIBLE,
737 Vector3( -100.f, -100.f, 0.f ),
739 Size( 100.f, 100.f ),
740 TextViewRelayout::PARTIALLY_VISIBLE,
744 Vector3( -10.f, 10.f, 0.f ),
746 Size( 100.f, 100.f ),
747 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
751 Vector3( 110.f, 10.f, 0.f ),
753 Size( 100.f, 100.f ),
754 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
758 Vector3( 0.f, 20.f, 0.f ),
760 Size( 100.f, 100.f ),
761 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
765 Vector3( 0.f, -10.f, 0.f ),
767 Size( 100.f, 100.f ),
768 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
772 const std::size_t numberOfTests( 13 );
774 for( std::size_t index = 0; index < numberOfTests; ++index )
776 const CalculateVisibilityTest& test = calculateVisibilityTest[index];
778 if( !TestCalculateVisibility( test, TEST_LOCATION ) )
780 tet_result( TET_FAIL );
784 tet_result( TET_PASS );
788 int UtcDaliTextViewMiscelaneousAsserts(void)
790 ToolkitTestApplication application;
792 tet_infoline("UtcDaliTextViewMiscelaneousAsserts : ");
796 bool assert1 = false;
797 bool assert2 = false;
800 offset = Toolkit::Internal::TextViewRelayout::CalculateXoffset( Toolkit::Alignment::VerticalTop, 100.f, 50.f );
802 catch( Dali::DaliException& e )
804 DALI_TEST_PRINT_ASSERT( e );
805 DALI_TEST_EQUALS( e.condition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
810 tet_result( TET_FAIL );
812 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
816 offset = Toolkit::Internal::TextViewRelayout::CalculateYoffset( Toolkit::Alignment::HorizontalRight, 100.f, 50.f );
818 catch( Dali::DaliException& e )
820 DALI_TEST_PRINT_ASSERT( e );
821 DALI_TEST_EQUALS( e.condition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
826 tet_result( TET_FAIL );
828 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
830 DALI_TEST_CHECK( assert1 && assert2 );