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.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit-test-suite-utils.h>
28 // Internal headers are allowed here
29 #include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
30 #include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
33 using namespace Dali::Toolkit;
34 using namespace Dali::Toolkit::Internal;
39 const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
41 // Data structures used to create an 'experiment' in TET cases
44 bool TestEqual( float x, float y )
46 return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
49 //////////////////////////////////////////////////////////////////
51 struct CalculateSubLineLayoutTest
53 std::string description;
54 std::string inputLine;
56 std::size_t groupIndex;
57 std::size_t wordIndex;
58 std::size_t characterIndex;
59 TextViewRelayout::HorizontalWrapType splitPolicy;
62 float resultLineLength;
63 float resultMaxCharHeight;
64 float resultMaxAscender;
67 bool TestCalculateSubLineLayout( const CalculateSubLineLayoutTest& test, const char* location )
69 tet_printf( "%s", test.description.c_str() );
71 // Create styled text.
72 MarkupProcessor::StyledTextArray inputStyledText;
73 MarkupProcessor::GetStyledTextArray( test.inputLine, inputStyledText, true );
75 // Create styled text layout info.
76 Toolkit::Internal::TextView::RelayoutData relayoutData;
77 TextViewProcessor::CreateTextInfo( inputStyledText,
78 DEFAULT_LAYOUT_PARAMETERS,
81 // Prepare input parameters and the result structure and call the function to be tested.
84 TextViewProcessor::TextInfoIndices indices( 0, test.groupIndex, test.wordIndex, test.characterIndex );
86 // Get the input line.
87 TextViewProcessor::LineLayoutInfo inputLineLayout;
89 if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
91 inputLineLayout = *relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin();
95 TextViewRelayout::SubLineLayoutInfo resultLayoutInfo;
97 CalculateSubLineLayout( test.parentWidth,
105 if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
107 tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
111 if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
113 tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
117 if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
119 tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
126 //////////////////////////////////////////////////////////////////
128 struct AlignmentOffsetTest
130 Toolkit::Alignment::Type alignment;
137 bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
141 switch( test.alignment )
143 case Toolkit::Alignment::HorizontalLeft:
144 case Toolkit::Alignment::HorizontalCenter:
145 case Toolkit::Alignment::HorizontalRight:
147 offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
150 case Toolkit::Alignment::VerticalTop:
151 case Toolkit::Alignment::VerticalCenter:
152 case Toolkit::Alignment::VerticalBottom:
154 offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
160 if( !TestEqual( test.resultOffset, offset ) )
162 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
169 //////////////////////////////////////////////////////////////////
171 struct JustificationOffsetTest
173 Toolkit::TextView::LineJustification justification;
174 float wholeTextWidth;
180 bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
182 float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
185 if( !TestEqual( test.resultOffset, offset ) )
187 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
194 //////////////////////////////////////////////////////////////////
196 struct CalculateVisibilityTest
201 TextViewRelayout::VisibilityTestType type;
206 bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
208 if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
210 tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
217 //////////////////////////////////////////////////////////////////
221 static void Startup();
222 static void Cleanup();
225 void (*tet_startup)() = Startup;
226 void (*tet_cleanup)() = Cleanup;
230 POSITIVE_TC_IDX = 0x01,
234 #define MAX_NUMBER_OF_TESTS 10000
236 struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
239 // Add test functionality for all APIs in the class (Positive and Negative)
240 TEST_FUNCTION( UtcDaliTextViewDefaultConstructorDestructor, POSITIVE_TC_IDX ); // Calls structs's default constructor and destructors and checks their default values.
241 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.
242 TEST_FUNCTION( UtcDaliTextViewCalculateAlignmentOffsets, POSITIVE_TC_IDX ); // Checks the horizontal and vertical alignaments (for the whole text).
243 TEST_FUNCTION( UtcDaliTextViewCalculateJustificationOffsets, POSITIVE_TC_IDX ); // Checks the justification alignment (line per line).
244 TEST_FUNCTION( UtcDaliTextViewCalculateVisibility, POSITIVE_TC_IDX ); // Checks the text-actor visibility within the text-view with a rectangle intersection test.
246 TEST_FUNCTION( UtcDaliTextViewMiscelaneousAsserts, NEGATIVE_TC_IDX ); // Tests some strange asserts.
248 // Called only once before first test is run.
249 static void Startup()
253 // Called only once after last test is run
254 static void Cleanup()
258 static void UtcDaliTextViewDefaultConstructorDestructor()
260 ToolkitTestApplication application;
262 tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
264 // Test RelayoutParameters defaults.
265 TextViewRelayout::RelayoutParameters relayoutParameters;
267 DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
268 DALI_TEST_EQUALS( relayoutParameters.mLineSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
269 DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
270 DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
271 DALI_TEST_EQUALS( relayoutParameters.mIndices.mLineIndex, 0u, TEST_LOCATION );
272 DALI_TEST_EQUALS( relayoutParameters.mIndices.mGroupIndex, 0u, TEST_LOCATION );
273 DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
274 DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
275 DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
276 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
277 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
278 DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
279 DALI_TEST_CHECK( !relayoutParameters.mIsNewLineCharacter );
280 DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
281 DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
283 // Test FadeParameter defaults
284 TextViewRelayout::FadeParameters fadeParameters;
286 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
287 DALI_TEST_EQUALS( fadeParameters.mRightFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
288 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
289 DALI_TEST_EQUALS( fadeParameters.mRightFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
290 DALI_TEST_EQUALS( fadeParameters.mRightAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
291 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
292 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
293 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
294 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
295 DALI_TEST_EQUALS( fadeParameters.mLeftAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
296 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
297 DALI_TEST_EQUALS( fadeParameters.mTopFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
298 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
299 DALI_TEST_EQUALS( fadeParameters.mTopFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
300 DALI_TEST_EQUALS( fadeParameters.mTopAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
301 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
302 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
303 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
304 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
305 DALI_TEST_EQUALS( fadeParameters.mBottomAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
306 DALI_TEST_CHECK( !fadeParameters.mIsPartiallyVisible );
308 // Test EllipsizeParameters defaults
309 TextViewRelayout::EllipsizeParameters ellipsizeParameters;
311 DALI_TEST_EQUALS( ellipsizeParameters.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
312 DALI_TEST_EQUALS( ellipsizeParameters.mLineDescender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
313 DALI_TEST_EQUALS( ellipsizeParameters.mLineWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
314 DALI_TEST_EQUALS( ellipsizeParameters.mEllipsizeBoundary, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
315 DALI_TEST_EQUALS( ellipsizeParameters.mFirstIndex, 0u, TEST_LOCATION );
316 DALI_TEST_EQUALS( ellipsizeParameters.mLastIndex, 0u, TEST_LOCATION );
317 DALI_TEST_CHECK( !ellipsizeParameters.mEllipsizeLine );
318 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineWidthFullyVisible );
319 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineHeightFullyVisible );
320 DALI_TEST_CHECK( !ellipsizeParameters.mIsNextLineFullyVisibleHeight );
321 DALI_TEST_CHECK( !ellipsizeParameters.mCreateEllipsizedTextActors );
322 DALI_TEST_CHECK( !ellipsizeParameters.mLineFits );
323 DALI_TEST_CHECK( !ellipsizeParameters.mWordFits );
325 // Test UnderlineInfo defaults
326 TextViewRelayout::UnderlineInfo underlineInfo;
328 DALI_TEST_EQUALS( underlineInfo.mMaxHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
329 DALI_TEST_EQUALS( underlineInfo.mMaxThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
330 DALI_TEST_EQUALS( underlineInfo.mPosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
332 // Test TextUnderlineStatus defaults
333 TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
335 DALI_TEST_CHECK( textUnderlineStatus.mUnderlineInfo.empty() );
336 DALI_TEST_EQUALS( textUnderlineStatus.mCharacterGlobalIndex, 0u, TEST_LOCATION );
337 DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
338 DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
340 // Test SubLineLayoutInfo defaults
341 TextViewRelayout::SubLineLayoutInfo subLineLayoutInfo;
343 DALI_TEST_EQUALS( subLineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
344 DALI_TEST_EQUALS( subLineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
345 DALI_TEST_EQUALS( subLineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
348 static void UtcDaliTextViewCalculateSubLineLayout()
350 ToolkitTestApplication application;
352 tet_infoline("UtcDaliTextViewCalculateSubLineLayout : ");
354 struct CalculateSubLineLayoutTest calculateSubLineLayoutTest[] =
358 "The line is wraped by character. All characters have the same size.",
359 "Hello world", // input line
360 100.f, // parent width
364 TextViewRelayout::WrapByCharacter, // split policy
367 91.041672f, // line length. (only fits 8 characters 8x11.38)
368 11.380209f, // max character height
369 10.242188f // max ascender
372 "The line is wraped by character. There are characters with different sizes.",
373 "Hello <font size='14'>world</font>", // input line
374 100.f, // parent width
378 TextViewRelayout::WrapByCharacter, // split policy
381 94.835075f, // line length. (only fits 8 characters 6x11.38 + 2x13.27)
382 13.276911f, // max character height
383 11.949220f // max ascender
386 "The line is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
387 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
388 100.f, // parent width
390 2, // indices. The third character of the third word starts in a new line.
392 TextViewRelayout::WrapByCharacter, // split policy
395 91.041672f, // line length. (only fits 8 characters 8x11.38)
396 11.380209f, // max character height
397 10.242188f // max ascender
400 "The line is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
401 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
402 100.f, // parent width
404 4, // indices. The fifth character of the fifth word starts in a new line.
406 TextViewRelayout::WrapByCharacter, // split policy
409 92.938377f, // line length. (only fits 8 characters 8x11.38)
410 13.276911f, // max character height
411 11.949220f // max ascender
416 "The line is wraped by word. All characters have the same size.",
417 "Hello world", // input line
418 100.f, // parent width
420 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
422 TextViewRelayout::WrapByWord, // split policy
425 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
426 11.380209f, // max character height
427 10.242188f // max ascender
430 "The line is wraped by word. There are characters with different sizes.",
431 "Hell<font size='14'>o</font> world", // input line
432 100.f, // parent width
436 TextViewRelayout::WrapByWord, // split policy
439 58.797747f, // line length. (only fits 5 characters 4x11.38 + 13.276911, white space is not counted)
440 13.276911f, // max character height
441 11.949220f // max ascender
444 "The line is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
445 "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input line
446 100.f, // parent width
448 2, // indices. The third word starts in a new line.
450 TextViewRelayout::WrapByWord, // split policy
453 60.694449f, // line length. (only fits 5 characters 2x13.276911 + 3x11.38)
454 13.276911f, // max character height
455 11.949220f // max ascender
458 "The line is wraped by word. The word doen't fit.",
459 "Hello world", // input line
460 40.f, // parent width
462 0, // indices. The third word starts in a new line.
464 TextViewRelayout::WrapByWord, // split policy
467 0.f, // line length. (The word doesn't fit)
468 11.380209f, // max character height
469 10.242188f // max ascender
474 "The line is wraped by word and by character. All characters have the same size. There is not a long word.",
475 "Hello world hello world", // input line
476 100.f, // parent width
480 TextViewRelayout::WrapByWordAndSplit, // split policy
483 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
484 11.380209f, // max character height
485 10.242188f // max ascender
488 "The line is wraped by word and by character. All characters have the same size. There is a long word.",
489 "Helloooooooo world", // input line
490 100.f, // parent width
494 TextViewRelayout::WrapByWordAndSplit, // split policy
497 91.041672f, // line length. (only fits 8 characters 8x11.38)
498 11.380209f, // max character height
499 10.242188f // max ascender
502 "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.",
503 "Helloooooooo <font size='14'>world</font>", // input line
504 100.f, // parent width
508 TextViewRelayout::WrapByWordAndSplit, // split policy
511 45.520836f, // line length. (only fits 8 characters 8x11.38)
512 11.380209f, // max character height
513 10.242188f // max ascender
516 "The line is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
517 "Helloooooooo<font size='14'> world</font>", // input line
518 100.f, // parent width
522 TextViewRelayout::WrapByWordAndSplit, // split policy
525 95.593755f, // line length. (only fits 12 characters 8x11.38)
526 7.9661463f, // max character height
527 7.169531f // max ascender
532 "The line is wraped by end of line and by character. All characters have the same size.",
533 "Hello world", // input line
534 100.f, // parent width
538 TextViewRelayout::WrapByLineAndSplit, // split policy
541 91.041672f, // line length. (only fits 8 characters 8x11.38)
542 11.380209f, // max character height
543 10.242188f // max ascender
546 "The line fits in the width.",
547 "Hello", // input line
548 100.f, // parent width
552 TextViewRelayout::WrapByLineAndSplit, // split policy
555 56.901047f, // line length. (only fits 5 characters 5x11.38)
556 11.380209f, // max character height
557 10.242188f // max ascender
560 "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.",
561 "Hello world, hello world", // input line
562 100.f, // parent width
566 TextViewRelayout::WrapByLineAndSplit, // split policy
569 91.041672f, // line length. (only fits 8 characters 8x11.38)
570 11.380209f, // max character height
571 10.242188f // max ascender
574 const std::size_t numberOfTests( 15 );
576 for( std::size_t index = 0; index < numberOfTests; ++index )
578 const CalculateSubLineLayoutTest& test = calculateSubLineLayoutTest[index];
580 if( !TestCalculateSubLineLayout( test, TEST_LOCATION ) )
582 tet_result( TET_FAIL );
586 tet_result( TET_PASS );
589 static void UtcDaliTextViewCalculateAlignmentOffsets()
591 ToolkitTestApplication application;
593 tet_infoline("UtcDaliTextViewCalculateAlignmentOffsets : ");
595 struct AlignmentOffsetTest alignmentOffsetTest[] =
598 Toolkit::Alignment::HorizontalLeft,
604 Toolkit::Alignment::HorizontalCenter,
610 Toolkit::Alignment::HorizontalRight,
616 Toolkit::Alignment::VerticalTop,
622 Toolkit::Alignment::VerticalCenter,
628 Toolkit::Alignment::VerticalBottom,
634 const std::size_t numberOfTests( 6 );
636 for( std::size_t index = 0; index < numberOfTests; ++index )
638 const AlignmentOffsetTest& test = alignmentOffsetTest[index];
640 if( !TestAlignmentOffset( test, TEST_LOCATION ) )
642 tet_result( TET_FAIL );
646 tet_result( TET_PASS );
649 static void UtcDaliTextViewCalculateJustificationOffsets()
651 ToolkitTestApplication application;
653 tet_infoline("UtcDaliTextViewCalculateJustificationOffsets : ");
655 struct JustificationOffsetTest justificationOffsetTest[] =
658 Toolkit::TextView::Left,
664 Toolkit::TextView::Justified,
670 Toolkit::TextView::Center,
676 Toolkit::TextView::Right,
682 const std::size_t numberOfTests( 4 );
684 for( std::size_t index = 0; index < numberOfTests; ++index )
686 const JustificationOffsetTest& test = justificationOffsetTest[index];
688 if( !TestJustificationOffset( test, TEST_LOCATION ) )
690 tet_result( TET_FAIL );
694 tet_result( TET_PASS );
698 static void UtcDaliTextViewCalculateVisibility()
700 ToolkitTestApplication application;
702 tet_infoline("UtcDaliTextViewCalculateVisibility : ");
704 struct CalculateVisibilityTest calculateVisibilityTest[] =
707 Vector3( 0.f, 10.f, 0.f ),
709 Size( 100.f, 100.f ),
710 TextViewRelayout::FULLY_VISIBLE,
714 Vector3( 10.f, 10.f, 0.f ),
716 Size( 100.f, 100.f ),
717 TextViewRelayout::FULLY_VISIBLE,
721 Vector3( 0.f, 10.f, 0.f ),
723 Size( 100.f, 100.f ),
724 TextViewRelayout::FULLY_VISIBLE,
728 Vector3( 0.f, 10.f, 0.f ),
730 Size( 100.f, 100.f ),
731 TextViewRelayout::FULLY_VISIBLE_WIDTH,
735 Vector3( 95.f, 10.f, 0.f ),
737 Size( 100.f, 100.f ),
738 TextViewRelayout::FULLY_VISIBLE_WIDTH,
742 Vector3( 0.f, 10.f, 0.f ),
744 Size( 100.f, 100.f ),
745 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
749 Vector3( 0.f, 0.f, 0.f ),
751 Size( 100.f, 100.f ),
752 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
756 Vector3( -10.f, 10.f, 0.f ),
757 Size( 150.f, 150.f ),
758 Size( 100.f, 100.f ),
759 TextViewRelayout::PARTIALLY_VISIBLE,
763 Vector3( -100.f, -100.f, 0.f ),
765 Size( 100.f, 100.f ),
766 TextViewRelayout::PARTIALLY_VISIBLE,
770 Vector3( -10.f, 10.f, 0.f ),
772 Size( 100.f, 100.f ),
773 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
777 Vector3( 110.f, 10.f, 0.f ),
779 Size( 100.f, 100.f ),
780 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
784 Vector3( 0.f, 20.f, 0.f ),
786 Size( 100.f, 100.f ),
787 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
791 Vector3( 0.f, -10.f, 0.f ),
793 Size( 100.f, 100.f ),
794 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
798 const std::size_t numberOfTests( 13 );
800 for( std::size_t index = 0; index < numberOfTests; ++index )
802 const CalculateVisibilityTest& test = calculateVisibilityTest[index];
804 if( !TestCalculateVisibility( test, TEST_LOCATION ) )
806 tet_result( TET_FAIL );
810 tet_result( TET_PASS );
813 static void UtcDaliTextViewMiscelaneousAsserts()
815 ToolkitTestApplication application;
817 tet_infoline("UtcDaliTextViewMiscelaneousAsserts : ");
821 bool assert1 = false;
822 bool assert2 = false;
825 offset = Toolkit::Internal::TextViewRelayout::CalculateXoffset( Toolkit::Alignment::VerticalTop, 100.f, 50.f );
827 catch( Dali::DaliException& e )
829 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
830 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
835 tet_result( TET_FAIL );
837 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
841 offset = Toolkit::Internal::TextViewRelayout::CalculateYoffset( Toolkit::Alignment::HorizontalRight, 100.f, 50.f );
843 catch( Dali::DaliException& e )
845 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
846 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
851 tet_result( TET_FAIL );
853 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
855 DALI_TEST_CHECK( assert1 && assert2 );