2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit-test-suite-utils.h>
27 // Internal headers are allowed here
28 #include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
29 #include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
32 using namespace Dali::Toolkit;
33 using namespace Dali::Toolkit::Internal;
38 const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
40 // Data structures used to create an 'experiment' in TET cases
43 bool TestEqual( float x, float y )
45 return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
48 //////////////////////////////////////////////////////////////////
50 struct CalculateSubLineLayoutTest
52 std::string description;
53 std::string inputLine;
55 std::size_t groupIndex;
56 std::size_t wordIndex;
57 std::size_t characterIndex;
58 TextViewRelayout::HorizontalWrapType splitPolicy;
61 float resultLineLength;
62 float resultMaxCharHeight;
63 float resultMaxAscender;
66 bool TestCalculateSubLineLayout( const CalculateSubLineLayoutTest& test, const char* location )
68 tet_printf( "%s", test.description.c_str() );
70 // Create styled text.
71 MarkupProcessor::StyledTextArray inputStyledText;
72 MarkupProcessor::GetStyledTextArray( test.inputLine, inputStyledText, true );
74 // Create styled text layout info.
75 Toolkit::Internal::TextView::RelayoutData relayoutData;
76 TextViewProcessor::CreateTextInfo( inputStyledText,
77 DEFAULT_LAYOUT_PARAMETERS,
80 // Prepare input parameters and the result structure and call the function to be tested.
83 TextViewProcessor::TextInfoIndices indices( 0, test.groupIndex, test.wordIndex, test.characterIndex );
85 // Get the input line.
86 TextViewProcessor::LineLayoutInfo inputLineLayout;
88 if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
90 inputLineLayout = *relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin();
94 TextViewRelayout::SubLineLayoutInfo resultLayoutInfo;
96 CalculateSubLineLayout( test.parentWidth,
104 if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
106 tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
110 if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
112 tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
116 if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
118 tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
125 //////////////////////////////////////////////////////////////////
127 struct AlignmentOffsetTest
129 Toolkit::Alignment::Type alignment;
136 bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
140 switch( test.alignment )
142 case Toolkit::Alignment::HorizontalLeft:
143 case Toolkit::Alignment::HorizontalCenter:
144 case Toolkit::Alignment::HorizontalRight:
146 offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
149 case Toolkit::Alignment::VerticalTop:
150 case Toolkit::Alignment::VerticalCenter:
151 case Toolkit::Alignment::VerticalBottom:
153 offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
159 if( !TestEqual( test.resultOffset, offset ) )
161 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
168 //////////////////////////////////////////////////////////////////
170 struct JustificationOffsetTest
172 Toolkit::TextView::LineJustification justification;
173 float wholeTextWidth;
179 bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
181 float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
184 if( !TestEqual( test.resultOffset, offset ) )
186 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
193 //////////////////////////////////////////////////////////////////
195 struct CalculateVisibilityTest
200 TextViewRelayout::VisibilityTestType type;
205 bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
207 if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
209 tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
216 //////////////////////////////////////////////////////////////////
220 static void Startup();
221 static void Cleanup();
224 void (*tet_startup)() = Startup;
225 void (*tet_cleanup)() = Cleanup;
229 POSITIVE_TC_IDX = 0x01,
233 #define MAX_NUMBER_OF_TESTS 10000
235 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
238 // Add test functionality for all APIs in the class (Positive and Negative)
239 TEST_FUNCTION( UtcDaliTextViewDefaultConstructorDestructor, POSITIVE_TC_IDX ); // Calls structs's default constructor and destructors and checks their default values.
240 TEST_FUNCTION( UtcDaliTextViewCalculateSubLineLayout, POSITIVE_TC_IDX ); // Checks the function which calculates the layout info of the portion of the line which fits on the text-view width.
241 TEST_FUNCTION( UtcDaliTextViewCalculateAlignmentOffsets, POSITIVE_TC_IDX ); // Checks the horizontal and vertical alignaments (for the whole text).
242 TEST_FUNCTION( UtcDaliTextViewCalculateJustificationOffsets, POSITIVE_TC_IDX ); // Checks the justification alignment (line per line).
243 TEST_FUNCTION( UtcDaliTextViewCalculateVisibility, POSITIVE_TC_IDX ); // Checks the text-actor visibility within the text-view with a rectangle intersection test.
245 TEST_FUNCTION( UtcDaliTextViewMiscelaneousAsserts, NEGATIVE_TC_IDX ); // Tests some strange asserts.
247 // Called only once before first test is run.
248 static void Startup()
252 // Called only once after last test is run
253 static void Cleanup()
257 static void UtcDaliTextViewDefaultConstructorDestructor()
259 ToolkitTestApplication application;
261 tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
263 // Test RelayoutParameters defaults.
264 TextViewRelayout::RelayoutParameters relayoutParameters;
266 DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
267 DALI_TEST_EQUALS( relayoutParameters.mLineSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
268 DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
269 DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
270 DALI_TEST_EQUALS( relayoutParameters.mIndices.mLineIndex, 0u, TEST_LOCATION );
271 DALI_TEST_EQUALS( relayoutParameters.mIndices.mGroupIndex, 0u, TEST_LOCATION );
272 DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
273 DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
274 DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
275 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
276 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
277 DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
278 DALI_TEST_CHECK( !relayoutParameters.mIsNewLineCharacter );
279 DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
280 DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
282 // Test FadeParameter defaults
283 TextViewRelayout::FadeParameters fadeParameters;
285 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
286 DALI_TEST_EQUALS( fadeParameters.mRightFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
287 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
288 DALI_TEST_EQUALS( fadeParameters.mRightFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
289 DALI_TEST_EQUALS( fadeParameters.mRightAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
290 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
291 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
292 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
293 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
294 DALI_TEST_EQUALS( fadeParameters.mLeftAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
295 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
296 DALI_TEST_EQUALS( fadeParameters.mTopFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
297 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
298 DALI_TEST_EQUALS( fadeParameters.mTopFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
299 DALI_TEST_EQUALS( fadeParameters.mTopAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
300 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
301 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
302 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
303 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
304 DALI_TEST_EQUALS( fadeParameters.mBottomAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
305 DALI_TEST_CHECK( !fadeParameters.mIsPartiallyVisible );
307 // Test EllipsizeParameters defaults
308 TextViewRelayout::EllipsizeParameters ellipsizeParameters;
310 DALI_TEST_EQUALS( ellipsizeParameters.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
311 DALI_TEST_EQUALS( ellipsizeParameters.mLineDescender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
312 DALI_TEST_EQUALS( ellipsizeParameters.mLineWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
313 DALI_TEST_EQUALS( ellipsizeParameters.mEllipsizeBoundary, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
314 DALI_TEST_EQUALS( ellipsizeParameters.mFirstIndex, 0u, TEST_LOCATION );
315 DALI_TEST_EQUALS( ellipsizeParameters.mLastIndex, 0u, TEST_LOCATION );
316 DALI_TEST_CHECK( !ellipsizeParameters.mEllipsizeLine );
317 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineWidthFullyVisible );
318 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineHeightFullyVisible );
319 DALI_TEST_CHECK( !ellipsizeParameters.mIsNextLineFullyVisibleHeight );
320 DALI_TEST_CHECK( !ellipsizeParameters.mCreateEllipsizedTextActors );
321 DALI_TEST_CHECK( !ellipsizeParameters.mLineFits );
322 DALI_TEST_CHECK( !ellipsizeParameters.mWordFits );
324 // Test UnderlineInfo defaults
325 TextViewRelayout::UnderlineInfo underlineInfo;
327 DALI_TEST_EQUALS( underlineInfo.mMaxHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
328 DALI_TEST_EQUALS( underlineInfo.mMaxThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
329 DALI_TEST_EQUALS( underlineInfo.mPosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
331 // Test TextUnderlineStatus defaults
332 TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
334 DALI_TEST_CHECK( textUnderlineStatus.mUnderlineInfo.empty() );
335 DALI_TEST_EQUALS( textUnderlineStatus.mCharacterGlobalIndex, 0u, TEST_LOCATION );
336 DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
337 DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
339 // Test SubLineLayoutInfo defaults
340 TextViewRelayout::SubLineLayoutInfo subLineLayoutInfo;
342 DALI_TEST_EQUALS( subLineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
343 DALI_TEST_EQUALS( subLineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
344 DALI_TEST_EQUALS( subLineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
347 static void UtcDaliTextViewCalculateSubLineLayout()
349 ToolkitTestApplication application;
351 tet_infoline("UtcDaliTextViewCalculateSubLineLayout : ");
353 struct CalculateSubLineLayoutTest calculateSubLineLayoutTest[] =
357 "The line is wraped by character. All characters have the same size.",
358 "Hello world", // input line
359 100.f, // parent width
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 line is wraped by character. There are characters with different sizes.",
372 "Hello <font size='14'>world</font>", // input line
373 100.f, // parent width
377 TextViewRelayout::WrapByCharacter, // split policy
380 94.835075f, // line length. (only fits 8 characters 6x11.38 + 2x13.27)
381 13.276911f, // max character height
382 11.949220f // max ascender
385 "The line is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
386 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
387 100.f, // parent width
389 2, // indices. The third character of the third word starts in a new line.
391 TextViewRelayout::WrapByCharacter, // split policy
394 91.041672f, // line length. (only fits 8 characters 8x11.38)
395 11.380209f, // max character height
396 10.242188f // max ascender
399 "The line is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
400 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
401 100.f, // parent width
403 4, // indices. The fifth character of the fifth word starts in a new line.
405 TextViewRelayout::WrapByCharacter, // split policy
408 92.938377f, // line length. (only fits 8 characters 8x11.38)
409 13.276911f, // max character height
410 11.949220f // max ascender
415 "The line is wraped by word. All characters have the same size.",
416 "Hello world", // input line
417 100.f, // parent width
419 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
421 TextViewRelayout::WrapByWord, // split policy
424 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
425 11.380209f, // max character height
426 10.242188f // max ascender
429 "The line is wraped by word. There are characters with different sizes.",
430 "Hell<font size='14'>o</font> world", // input line
431 100.f, // parent width
435 TextViewRelayout::WrapByWord, // split policy
438 58.797747f, // line length. (only fits 5 characters 4x11.38 + 13.276911, white space is not counted)
439 13.276911f, // max character height
440 11.949220f // max ascender
443 "The line is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
444 "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input line
445 100.f, // parent width
447 2, // indices. The third word starts in a new line.
449 TextViewRelayout::WrapByWord, // split policy
452 60.694449f, // line length. (only fits 5 characters 2x13.276911 + 3x11.38)
453 13.276911f, // max character height
454 11.949220f // max ascender
457 "The line is wraped by word. The word doen't fit.",
458 "Hello world", // input line
459 40.f, // parent width
461 0, // indices. The third word starts in a new line.
463 TextViewRelayout::WrapByWord, // split policy
466 0.f, // line length. (The word doesn't fit)
467 11.380209f, // max character height
468 10.242188f // max ascender
473 "The line is wraped by word and by character. All characters have the same size. There is not a long word.",
474 "Hello world hello world", // input line
475 100.f, // parent width
479 TextViewRelayout::WrapByWordAndSplit, // split policy
482 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
483 11.380209f, // max character height
484 10.242188f // max ascender
487 "The line is wraped by word and by character. All characters have the same size. There is a long word.",
488 "Helloooooooo world", // input line
489 100.f, // parent width
493 TextViewRelayout::WrapByWordAndSplit, // split policy
496 91.041672f, // line length. (only fits 8 characters 8x11.38)
497 11.380209f, // max character height
498 10.242188f // max ascender
501 "The line 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.",
502 "Helloooooooo <font size='14'>world</font>", // input line
503 100.f, // parent width
507 TextViewRelayout::WrapByWordAndSplit, // split policy
510 45.520836f, // line length. (only fits 8 characters 8x11.38)
511 11.380209f, // max character height
512 10.242188f // max ascender
515 "The line is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
516 "Helloooooooo<font size='14'> world</font>", // input line
517 100.f, // parent width
521 TextViewRelayout::WrapByWordAndSplit, // split policy
524 95.593755f, // line length. (only fits 12 characters 8x11.38)
525 7.9661463f, // max character height
526 7.169531f // max ascender
531 "The line is wraped by end of line and by character. All characters have the same size.",
532 "Hello world", // input line
533 100.f, // parent width
537 TextViewRelayout::WrapByLineAndSplit, // 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 "The line fits in the width.",
546 "Hello", // input line
547 100.f, // parent width
551 TextViewRelayout::WrapByLineAndSplit, // split policy
554 56.901047f, // line length. (only fits 5 characters 5x11.38)
555 11.380209f, // max character height
556 10.242188f // max ascender
559 "The line is wraped by end of line and by character. All characters have the same size. It calculates the layout for the second line.",
560 "Hello world, hello world", // input line
561 100.f, // parent width
565 TextViewRelayout::WrapByLineAndSplit, // split policy
568 91.041672f, // line length. (only fits 8 characters 8x11.38)
569 11.380209f, // max character height
570 10.242188f // max ascender
573 const std::size_t numberOfTests( 15 );
575 for( std::size_t index = 0; index < numberOfTests; ++index )
577 const CalculateSubLineLayoutTest& test = calculateSubLineLayoutTest[index];
579 if( !TestCalculateSubLineLayout( test, TEST_LOCATION ) )
581 tet_result( TET_FAIL );
585 tet_result( TET_PASS );
588 static void UtcDaliTextViewCalculateAlignmentOffsets()
590 ToolkitTestApplication application;
592 tet_infoline("UtcDaliTextViewCalculateAlignmentOffsets : ");
594 struct AlignmentOffsetTest alignmentOffsetTest[] =
597 Toolkit::Alignment::HorizontalLeft,
603 Toolkit::Alignment::HorizontalCenter,
609 Toolkit::Alignment::HorizontalRight,
615 Toolkit::Alignment::VerticalTop,
621 Toolkit::Alignment::VerticalCenter,
627 Toolkit::Alignment::VerticalBottom,
633 const std::size_t numberOfTests( 6 );
635 for( std::size_t index = 0; index < numberOfTests; ++index )
637 const AlignmentOffsetTest& test = alignmentOffsetTest[index];
639 if( !TestAlignmentOffset( test, TEST_LOCATION ) )
641 tet_result( TET_FAIL );
645 tet_result( TET_PASS );
648 static void UtcDaliTextViewCalculateJustificationOffsets()
650 ToolkitTestApplication application;
652 tet_infoline("UtcDaliTextViewCalculateJustificationOffsets : ");
654 struct JustificationOffsetTest justificationOffsetTest[] =
657 Toolkit::TextView::Left,
663 Toolkit::TextView::Justified,
669 Toolkit::TextView::Center,
675 Toolkit::TextView::Right,
681 const std::size_t numberOfTests( 4 );
683 for( std::size_t index = 0; index < numberOfTests; ++index )
685 const JustificationOffsetTest& test = justificationOffsetTest[index];
687 if( !TestJustificationOffset( test, TEST_LOCATION ) )
689 tet_result( TET_FAIL );
693 tet_result( TET_PASS );
697 static void UtcDaliTextViewCalculateVisibility()
699 ToolkitTestApplication application;
701 tet_infoline("UtcDaliTextViewCalculateVisibility : ");
703 struct CalculateVisibilityTest calculateVisibilityTest[] =
706 Vector3( 0.f, 10.f, 0.f ),
708 Size( 100.f, 100.f ),
709 TextViewRelayout::FULLY_VISIBLE,
713 Vector3( 10.f, 10.f, 0.f ),
715 Size( 100.f, 100.f ),
716 TextViewRelayout::FULLY_VISIBLE,
720 Vector3( 0.f, 10.f, 0.f ),
722 Size( 100.f, 100.f ),
723 TextViewRelayout::FULLY_VISIBLE,
727 Vector3( 0.f, 10.f, 0.f ),
729 Size( 100.f, 100.f ),
730 TextViewRelayout::FULLY_VISIBLE_WIDTH,
734 Vector3( 95.f, 10.f, 0.f ),
736 Size( 100.f, 100.f ),
737 TextViewRelayout::FULLY_VISIBLE_WIDTH,
741 Vector3( 0.f, 10.f, 0.f ),
743 Size( 100.f, 100.f ),
744 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
748 Vector3( 0.f, 0.f, 0.f ),
750 Size( 100.f, 100.f ),
751 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
755 Vector3( -10.f, 10.f, 0.f ),
756 Size( 150.f, 150.f ),
757 Size( 100.f, 100.f ),
758 TextViewRelayout::PARTIALLY_VISIBLE,
762 Vector3( -100.f, -100.f, 0.f ),
764 Size( 100.f, 100.f ),
765 TextViewRelayout::PARTIALLY_VISIBLE,
769 Vector3( -10.f, 10.f, 0.f ),
771 Size( 100.f, 100.f ),
772 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
776 Vector3( 110.f, 10.f, 0.f ),
778 Size( 100.f, 100.f ),
779 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
783 Vector3( 0.f, 20.f, 0.f ),
785 Size( 100.f, 100.f ),
786 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
790 Vector3( 0.f, -10.f, 0.f ),
792 Size( 100.f, 100.f ),
793 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
797 const std::size_t numberOfTests( 13 );
799 for( std::size_t index = 0; index < numberOfTests; ++index )
801 const CalculateVisibilityTest& test = calculateVisibilityTest[index];
803 if( !TestCalculateVisibility( test, TEST_LOCATION ) )
805 tet_result( TET_FAIL );
809 tet_result( TET_PASS );
812 static void UtcDaliTextViewMiscelaneousAsserts()
814 ToolkitTestApplication application;
816 tet_infoline("UtcDaliTextViewMiscelaneousAsserts : ");
820 bool assert1 = false;
821 bool assert2 = false;
824 offset = Toolkit::Internal::TextViewRelayout::CalculateXoffset( Toolkit::Alignment::VerticalTop, 100.f, 50.f );
826 catch( Dali::DaliException& e )
828 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
829 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
834 tet_result( TET_FAIL );
836 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
840 offset = Toolkit::Internal::TextViewRelayout::CalculateYoffset( Toolkit::Alignment::HorizontalRight, 100.f, 50.f );
842 catch( Dali::DaliException& e )
844 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
845 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
850 tet_result( TET_FAIL );
852 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
854 DALI_TEST_CHECK( assert1 && assert2 );