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 );
92 // Get the input paragraph.
93 TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
95 if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
97 inputParagraphLayout = *relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin();
101 TextViewRelayout::LineLayoutInfo resultLayoutInfo;
103 CalculateLineLayout( test.parentWidth,
105 inputParagraphLayout,
111 if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
113 tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
117 if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
119 tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
123 if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
125 tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
132 //////////////////////////////////////////////////////////////////
134 struct AlignmentOffsetTest
136 Toolkit::Alignment::Type alignment;
143 bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
147 switch( test.alignment )
149 case Toolkit::Alignment::HorizontalLeft:
150 case Toolkit::Alignment::HorizontalCenter:
151 case Toolkit::Alignment::HorizontalRight:
153 offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
156 case Toolkit::Alignment::VerticalTop:
157 case Toolkit::Alignment::VerticalCenter:
158 case Toolkit::Alignment::VerticalBottom:
160 offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
166 if( !TestEqual( test.resultOffset, offset ) )
168 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
175 //////////////////////////////////////////////////////////////////
177 struct JustificationOffsetTest
179 Toolkit::TextView::LineJustification justification;
180 float wholeTextWidth;
186 bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
188 float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
191 if( !TestEqual( test.resultOffset, offset ) )
193 tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
200 //////////////////////////////////////////////////////////////////
202 struct CalculateVisibilityTest
207 TextViewRelayout::VisibilityTestType type;
212 bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
214 if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
216 tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
223 //////////////////////////////////////////////////////////////////
228 int UtcDaliTextViewDefaultConstructorDestructor_RU(void)
230 ToolkitTestApplication application;
232 tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
234 // Test RelayoutParameters defaults.
235 TextViewRelayout::RelayoutParameters relayoutParameters;
237 DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
238 DALI_TEST_EQUALS( relayoutParameters.mParagraphSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
239 DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
240 DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
241 DALI_TEST_EQUALS( relayoutParameters.mIndices.mParagraphIndex, 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.mIsNewParagraphCharacter );
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 LineLayoutInfo defaults
310 TextViewRelayout::LineLayoutInfo lineLayoutInfo;
312 DALI_TEST_EQUALS( lineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
313 DALI_TEST_EQUALS( lineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
314 DALI_TEST_EQUALS( lineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
318 int UtcDaliTextViewCalculateLineLayout(void)
320 ToolkitTestApplication application;
322 tet_infoline("UtcDaliTextViewCalculateLineLayout : ");
324 struct CalculateLineLayoutTest calculateLineLayoutTest[] =
328 "The paragraph is wraped by character. All characters have the same size.",
329 "Hello world", // input paragraph
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 paragraph is wraped by character. There are characters with different sizes.",
343 "Hello <font size='14'>world</font>", // input paragraph
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 paragraph 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 paragraph
358 100.f, // parent width
359 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 paragraph 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 paragraph
372 100.f, // parent width
373 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 paragraph is wraped by word. All characters have the same size.",
387 "Hello world", // input paragraph
388 100.f, // parent width
389 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 paragraph is wraped by word. There are characters with different sizes.",
401 "Hell<font size='14'>o</font> world", // input paragraph
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 paragraph 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 paragraph
416 100.f, // parent width
417 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 paragraph is wraped by word. The word doen't fit.",
429 "Hello world", // input paragraph
430 40.f, // parent width
431 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 paragraph 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 paragraph
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 paragraph is wraped by word and by character. All characters have the same size. There is a long word.",
459 "Helloooooooo world", // input paragraph
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 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.",
473 "Helloooooooo <font size='14'>world</font>", // input paragraph
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 paragraph 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 paragraph
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
500 //WrapByParagraphCharacterAndSplit
502 "The paragraph is wraped by end of paragraph and by character. All characters have the same size.",
503 "Hello world", // input paragraph
504 100.f, // parent width
508 TextViewRelayout::WrapByParagraphCharacterAndSplit, // 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 paragraph fits in the width.",
517 "Hello", // input paragraph
518 100.f, // parent width
522 TextViewRelayout::WrapByParagraphCharacterAndSplit, // 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 paragraph is wraped by end of paragraph and by character. All characters have the same size. It calculates the layout for the second line.",
531 "Hello world, hello world", // input paragraph
532 100.f, // parent width
536 TextViewRelayout::WrapByParagraphCharacterAndSplit, // 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 CalculateLineLayoutTest& test = calculateLineLayoutTest[index];
550 if( !TestCalculateLineLayout( 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 );