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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
23 // Internal headers are allowed here
24 #include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
25 #include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
28 using namespace Dali::Toolkit;
29 using namespace Dali::Toolkit::Internal;
31 void dali_text_view_relayout_utils_startup(void)
33 test_return_value = TET_UNDEF;
36 void dali_text_view_relayout_utils_cleanup(void)
38 test_return_value = TET_PASS;
44 const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
46 // Data structures used to create an 'experiment' in TET cases
49 bool TestEqual( float x, float y )
51 return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
54 //////////////////////////////////////////////////////////////////
56 struct CalculateSubLineLayoutTest
58 std::string description;
59 std::string inputLine;
61 std::size_t groupIndex;
62 std::size_t wordIndex;
63 std::size_t characterIndex;
64 TextViewRelayout::HorizontalWrapType splitPolicy;
67 float resultLineLength;
68 float resultMaxCharHeight;
69 float resultMaxAscender;
72 bool TestCalculateSubLineLayout( const CalculateSubLineLayoutTest& test, const char* location )
74 tet_printf( "%s", test.description.c_str() );
76 // Create styled text.
77 MarkupProcessor::StyledTextArray inputStyledText;
78 MarkupProcessor::GetStyledTextArray( test.inputLine, inputStyledText, true );
80 // Create styled text layout info.
81 Toolkit::Internal::TextView::RelayoutData relayoutData;
82 TextViewProcessor::CreateTextInfo( inputStyledText,
83 DEFAULT_LAYOUT_PARAMETERS,
86 // Prepare input parameters and the result structure and call the function to be tested.
89 TextViewProcessor::TextInfoIndices indices( 0, test.groupIndex, test.wordIndex, test.characterIndex );
91 // Get the input line.
92 TextViewProcessor::LineLayoutInfo inputLineLayout;
94 if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
96 inputLineLayout = *relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin();
100 TextViewRelayout::SubLineLayoutInfo resultLayoutInfo;
102 CalculateSubLineLayout( test.parentWidth,
110 if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
112 tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
116 if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
118 tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
122 if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
124 tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
131 //////////////////////////////////////////////////////////////////
133 struct AlignmentOffsetTest
135 Toolkit::Alignment::Type alignment;
142 bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
146 switch( test.alignment )
148 case Toolkit::Alignment::HorizontalLeft:
149 case Toolkit::Alignment::HorizontalCenter:
150 case Toolkit::Alignment::HorizontalRight:
152 offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
155 case Toolkit::Alignment::VerticalTop:
156 case Toolkit::Alignment::VerticalCenter:
157 case Toolkit::Alignment::VerticalBottom:
159 offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
165 if( !TestEqual( test.resultOffset, offset ) )
167 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
174 //////////////////////////////////////////////////////////////////
176 struct JustificationOffsetTest
178 Toolkit::TextView::LineJustification justification;
179 float wholeTextWidth;
185 bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
187 float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
190 if( !TestEqual( test.resultOffset, offset ) )
192 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
199 //////////////////////////////////////////////////////////////////
201 struct CalculateVisibilityTest
206 TextViewRelayout::VisibilityTestType type;
211 bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
213 if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
215 tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
222 //////////////////////////////////////////////////////////////////
227 int UtcDaliTextViewDefaultConstructorDestructor_RU(void)
229 ToolkitTestApplication application;
231 tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
233 // Test RelayoutParameters defaults.
234 TextViewRelayout::RelayoutParameters relayoutParameters;
236 DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
237 DALI_TEST_EQUALS( relayoutParameters.mLineSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
238 DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
239 DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
240 DALI_TEST_EQUALS( relayoutParameters.mIndices.mLineIndex, 0u, TEST_LOCATION );
241 DALI_TEST_EQUALS( relayoutParameters.mIndices.mGroupIndex, 0u, TEST_LOCATION );
242 DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
243 DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
244 DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
245 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
246 DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
247 DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
248 DALI_TEST_CHECK( !relayoutParameters.mIsNewLineCharacter );
249 DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
250 DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
252 // Test FadeParameter defaults
253 TextViewRelayout::FadeParameters fadeParameters;
255 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
256 DALI_TEST_EQUALS( fadeParameters.mRightFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
257 DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
258 DALI_TEST_EQUALS( fadeParameters.mRightFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
259 DALI_TEST_EQUALS( fadeParameters.mRightAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
260 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
261 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
262 DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
263 DALI_TEST_EQUALS( fadeParameters.mLeftFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
264 DALI_TEST_EQUALS( fadeParameters.mLeftAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
265 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
266 DALI_TEST_EQUALS( fadeParameters.mTopFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
267 DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
268 DALI_TEST_EQUALS( fadeParameters.mTopFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
269 DALI_TEST_EQUALS( fadeParameters.mTopAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
270 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
271 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
272 DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
273 DALI_TEST_EQUALS( fadeParameters.mBottomFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
274 DALI_TEST_EQUALS( fadeParameters.mBottomAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
275 DALI_TEST_CHECK( !fadeParameters.mIsPartiallyVisible );
277 // Test EllipsizeParameters defaults
278 TextViewRelayout::EllipsizeParameters ellipsizeParameters;
280 DALI_TEST_EQUALS( ellipsizeParameters.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
281 DALI_TEST_EQUALS( ellipsizeParameters.mLineDescender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
282 DALI_TEST_EQUALS( ellipsizeParameters.mLineWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
283 DALI_TEST_EQUALS( ellipsizeParameters.mEllipsizeBoundary, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
284 DALI_TEST_EQUALS( ellipsizeParameters.mFirstIndex, 0u, TEST_LOCATION );
285 DALI_TEST_EQUALS( ellipsizeParameters.mLastIndex, 0u, TEST_LOCATION );
286 DALI_TEST_CHECK( !ellipsizeParameters.mEllipsizeLine );
287 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineWidthFullyVisible );
288 DALI_TEST_CHECK( !ellipsizeParameters.mIsLineHeightFullyVisible );
289 DALI_TEST_CHECK( !ellipsizeParameters.mIsNextLineFullyVisibleHeight );
290 DALI_TEST_CHECK( !ellipsizeParameters.mCreateEllipsizedTextActors );
291 DALI_TEST_CHECK( !ellipsizeParameters.mLineFits );
292 DALI_TEST_CHECK( !ellipsizeParameters.mWordFits );
294 // Test UnderlineInfo defaults
295 TextViewRelayout::UnderlineInfo underlineInfo;
297 DALI_TEST_EQUALS( underlineInfo.mMaxHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
298 DALI_TEST_EQUALS( underlineInfo.mMaxThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
299 DALI_TEST_EQUALS( underlineInfo.mPosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
301 // Test TextUnderlineStatus defaults
302 TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
304 DALI_TEST_CHECK( textUnderlineStatus.mUnderlineInfo.empty() );
305 DALI_TEST_EQUALS( textUnderlineStatus.mCharacterGlobalIndex, 0u, TEST_LOCATION );
306 DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
307 DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
309 // Test SubLineLayoutInfo defaults
310 TextViewRelayout::SubLineLayoutInfo subLineLayoutInfo;
312 DALI_TEST_EQUALS( subLineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
313 DALI_TEST_EQUALS( subLineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
314 DALI_TEST_EQUALS( subLineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
318 int UtcDaliTextViewCalculateSubLineLayout(void)
320 ToolkitTestApplication application;
322 tet_infoline("UtcDaliTextViewCalculateSubLineLayout : ");
324 struct CalculateSubLineLayoutTest calculateSubLineLayoutTest[] =
328 "The line is wraped by character. All characters have the same size.",
329 "Hello world", // input line
330 100.f, // parent width
334 TextViewRelayout::WrapByCharacter, // split policy
337 91.041672f, // line length. (only fits 8 characters 8x11.38)
338 11.380209f, // max character height
339 10.242188f // max ascender
342 "The line is wraped by character. There are characters with different sizes.",
343 "Hello <font size='14'>world</font>", // input line
344 100.f, // parent width
348 TextViewRelayout::WrapByCharacter, // split policy
351 94.835075f, // line length. (only fits 8 characters 6x11.38 + 2x13.27)
352 13.276911f, // max character height
353 11.949220f // max ascender
356 "The line is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
357 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
358 100.f, // parent width
360 2, // indices. The third character of the third word starts in a new line.
362 TextViewRelayout::WrapByCharacter, // split policy
365 91.041672f, // line length. (only fits 8 characters 8x11.38)
366 11.380209f, // max character height
367 10.242188f // max ascender
370 "The line is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
371 "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input line
372 100.f, // parent width
374 4, // indices. The fifth character of the fifth word starts in a new line.
376 TextViewRelayout::WrapByCharacter, // split policy
379 92.938377f, // line length. (only fits 8 characters 8x11.38)
380 13.276911f, // max character height
381 11.949220f // max ascender
386 "The line is wraped by word. All characters have the same size.",
387 "Hello world", // input line
388 100.f, // parent width
390 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
392 TextViewRelayout::WrapByWord, // split policy
395 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
396 11.380209f, // max character height
397 10.242188f // max ascender
400 "The line is wraped by word. There are characters with different sizes.",
401 "Hell<font size='14'>o</font> world", // input line
402 100.f, // parent width
406 TextViewRelayout::WrapByWord, // split policy
409 58.797747f, // line length. (only fits 5 characters 4x11.38 + 13.276911, white space is not counted)
410 13.276911f, // max character height
411 11.949220f // max ascender
414 "The line is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
415 "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input line
416 100.f, // parent width
418 2, // indices. The third word starts in a new line.
420 TextViewRelayout::WrapByWord, // split policy
423 60.694449f, // line length. (only fits 5 characters 2x13.276911 + 3x11.38)
424 13.276911f, // max character height
425 11.949220f // max ascender
428 "The line is wraped by word. The word doen't fit.",
429 "Hello world", // input line
430 40.f, // parent width
432 0, // indices. The third word starts in a new line.
434 TextViewRelayout::WrapByWord, // split policy
437 0.f, // line length. (The word doesn't fit)
438 11.380209f, // max character height
439 10.242188f // max ascender
444 "The line is wraped by word and by character. All characters have the same size. There is not a long word.",
445 "Hello world hello world", // input line
446 100.f, // parent width
450 TextViewRelayout::WrapByWordAndSplit, // split policy
453 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
454 11.380209f, // max character height
455 10.242188f // max ascender
458 "The line is wraped by word and by character. All characters have the same size. There is a long word.",
459 "Helloooooooo world", // input line
460 100.f, // parent width
464 TextViewRelayout::WrapByWordAndSplit, // split policy
467 91.041672f, // line length. (only fits 8 characters 8x11.38)
468 11.380209f, // max character height
469 10.242188f // max ascender
472 "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.",
473 "Helloooooooo <font size='14'>world</font>", // input line
474 100.f, // parent width
478 TextViewRelayout::WrapByWordAndSplit, // split policy
481 45.520836f, // line length. (only fits 8 characters 8x11.38)
482 11.380209f, // max character height
483 10.242188f // max ascender
486 "The line is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
487 "Helloooooooo<font size='14'> world</font>", // input line
488 100.f, // parent width
492 TextViewRelayout::WrapByWordAndSplit, // split policy
495 95.593755f, // line length. (only fits 12 characters 8x11.38)
496 7.9661463f, // max character height
497 7.169531f // max ascender
502 "The line is wraped by end of line and by character. All characters have the same size.",
503 "Hello world", // input line
504 100.f, // parent width
508 TextViewRelayout::WrapByLineAndSplit, // split policy
511 91.041672f, // line length. (only fits 8 characters 8x11.38)
512 11.380209f, // max character height
513 10.242188f // max ascender
516 "The line fits in the width.",
517 "Hello", // input line
518 100.f, // parent width
522 TextViewRelayout::WrapByLineAndSplit, // split policy
525 56.901047f, // line length. (only fits 5 characters 5x11.38)
526 11.380209f, // max character height
527 10.242188f // max ascender
530 "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.",
531 "Hello world, hello world", // input line
532 100.f, // parent width
536 TextViewRelayout::WrapByLineAndSplit, // split policy
539 91.041672f, // line length. (only fits 8 characters 8x11.38)
540 11.380209f, // max character height
541 10.242188f // max ascender
544 const std::size_t numberOfTests( 15 );
546 for( std::size_t index = 0; index < numberOfTests; ++index )
548 const CalculateSubLineLayoutTest& test = calculateSubLineLayoutTest[index];
550 if( !TestCalculateSubLineLayout( test, TEST_LOCATION ) )
552 tet_result( TET_FAIL );
556 tet_result( TET_PASS );
560 int UtcDaliTextViewCalculateAlignmentOffsets(void)
562 ToolkitTestApplication application;
564 tet_infoline("UtcDaliTextViewCalculateAlignmentOffsets : ");
566 struct AlignmentOffsetTest alignmentOffsetTest[] =
569 Toolkit::Alignment::HorizontalLeft,
575 Toolkit::Alignment::HorizontalCenter,
581 Toolkit::Alignment::HorizontalRight,
587 Toolkit::Alignment::VerticalTop,
593 Toolkit::Alignment::VerticalCenter,
599 Toolkit::Alignment::VerticalBottom,
605 const std::size_t numberOfTests( 6 );
607 for( std::size_t index = 0; index < numberOfTests; ++index )
609 const AlignmentOffsetTest& test = alignmentOffsetTest[index];
611 if( !TestAlignmentOffset( test, TEST_LOCATION ) )
613 tet_result( TET_FAIL );
617 tet_result( TET_PASS );
621 int UtcDaliTextViewCalculateJustificationOffsets(void)
623 ToolkitTestApplication application;
625 tet_infoline("UtcDaliTextViewCalculateJustificationOffsets : ");
627 struct JustificationOffsetTest justificationOffsetTest[] =
630 Toolkit::TextView::Left,
636 Toolkit::TextView::Justified,
642 Toolkit::TextView::Center,
648 Toolkit::TextView::Right,
654 const std::size_t numberOfTests( 4 );
656 for( std::size_t index = 0; index < numberOfTests; ++index )
658 const JustificationOffsetTest& test = justificationOffsetTest[index];
660 if( !TestJustificationOffset( test, TEST_LOCATION ) )
662 tet_result( TET_FAIL );
666 tet_result( TET_PASS );
671 int UtcDaliTextViewCalculateVisibility(void)
673 ToolkitTestApplication application;
675 tet_infoline("UtcDaliTextViewCalculateVisibility : ");
677 struct CalculateVisibilityTest calculateVisibilityTest[] =
680 Vector3( 0.f, 10.f, 0.f ),
682 Size( 100.f, 100.f ),
683 TextViewRelayout::FULLY_VISIBLE,
687 Vector3( 10.f, 10.f, 0.f ),
689 Size( 100.f, 100.f ),
690 TextViewRelayout::FULLY_VISIBLE,
694 Vector3( 0.f, 10.f, 0.f ),
696 Size( 100.f, 100.f ),
697 TextViewRelayout::FULLY_VISIBLE,
701 Vector3( 0.f, 10.f, 0.f ),
703 Size( 100.f, 100.f ),
704 TextViewRelayout::FULLY_VISIBLE_WIDTH,
708 Vector3( 95.f, 10.f, 0.f ),
710 Size( 100.f, 100.f ),
711 TextViewRelayout::FULLY_VISIBLE_WIDTH,
715 Vector3( 0.f, 10.f, 0.f ),
717 Size( 100.f, 100.f ),
718 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
722 Vector3( 0.f, 0.f, 0.f ),
724 Size( 100.f, 100.f ),
725 TextViewRelayout::FULLY_VISIBLE_HEIGHT,
729 Vector3( -10.f, 10.f, 0.f ),
730 Size( 150.f, 150.f ),
731 Size( 100.f, 100.f ),
732 TextViewRelayout::PARTIALLY_VISIBLE,
736 Vector3( -100.f, -100.f, 0.f ),
738 Size( 100.f, 100.f ),
739 TextViewRelayout::PARTIALLY_VISIBLE,
743 Vector3( -10.f, 10.f, 0.f ),
745 Size( 100.f, 100.f ),
746 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
750 Vector3( 110.f, 10.f, 0.f ),
752 Size( 100.f, 100.f ),
753 TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
757 Vector3( 0.f, 20.f, 0.f ),
759 Size( 100.f, 100.f ),
760 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
764 Vector3( 0.f, -10.f, 0.f ),
766 Size( 100.f, 100.f ),
767 TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
771 const std::size_t numberOfTests( 13 );
773 for( std::size_t index = 0; index < numberOfTests; ++index )
775 const CalculateVisibilityTest& test = calculateVisibilityTest[index];
777 if( !TestCalculateVisibility( test, TEST_LOCATION ) )
779 tet_result( TET_FAIL );
783 tet_result( TET_PASS );
787 int UtcDaliTextViewMiscelaneousAsserts(void)
789 ToolkitTestApplication application;
791 tet_infoline("UtcDaliTextViewMiscelaneousAsserts : ");
795 bool assert1 = false;
796 bool assert2 = false;
799 offset = Toolkit::Internal::TextViewRelayout::CalculateXoffset( Toolkit::Alignment::VerticalTop, 100.f, 50.f );
801 catch( Dali::DaliException& e )
803 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
804 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
809 tet_result( TET_FAIL );
811 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
815 offset = Toolkit::Internal::TextViewRelayout::CalculateYoffset( Toolkit::Alignment::HorizontalRight, 100.f, 50.f );
817 catch( Dali::DaliException& e )
819 tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
820 DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
825 tet_result( TET_FAIL );
827 DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
829 DALI_TEST_CHECK( assert1 && assert2 );