# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
utc-Dali-PushButton.cpp
- utc-Dali-TextView-HelperAndDebug.cpp
- utc-Dali-TextView-Processor-Types.cpp
- utc-Dali-TextView-Processor.cpp
- utc-Dali-TextView-Relayout-Utilities.cpp
- utc-Dali-TextView.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-// Internal headers are allowed here
-#include <dali-toolkit/internal/controls/text-view/split-by-new-line-char-policies.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-processor-helper-functions.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-processor-dbg.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_helper_and_debug_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_helper_and_debug_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
-const Toolkit::Internal::TextView::VisualParameters DEFAULT_VISUAL_PARAMETERS;
-
-struct GetIndicesFromGlobalCharacterIndexTest
-{
- std::string description;
- std::string input;
- std::size_t position;
- std::size_t paragraphIndex;
- std::size_t wordIndex;
- std::size_t characterIndex;
-};
-
-/**
- * Gets the paragraph, word, and character indices for a given text and a given position and checks the results with the given indices.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param input The input text.
- * @param position Global position of the character. i.e in a text with with 1000 characters, position could be any value from 0 to 1000.
- * @param resultParagraphIndex Index to the paragraph where the character is located.
- * @param resultWordIndex Index to the word within the paragraph where the character is located.
- * @param resultCharacterIndex Index to the character within the word where the character is located.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestGetIndicesFromGlobalCharacterIndex( const std::string& description,
- const std::string& input,
- const std::size_t position,
- const std::size_t resultParagraphIndex,
- const std::size_t resultWordIndex,
- const std::size_t resultCharacterIndex,
- const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create natural size, layout and text-actor info for the input word.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::GetIndicesFromGlobalCharacterIndex( position,
- inputLayout,
- indices );
-
- if( indices.mParagraphIndex != resultParagraphIndex )
- {
- tet_printf( "Fail. different paragraph index. %s", location );
- return false;
- }
- if( indices.mWordIndex != resultWordIndex )
- {
- tet_printf( "Fail. different word index. %s", location );
- return false;
- }
- if( indices.mCharacterIndex != resultCharacterIndex )
- {
- tet_printf( "Fail. different character index. %s", location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-} // namespace
-
-
-int UtcDaliTextViewGetIndicesFromGlobalCharacterIndex(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewGetIndicesFromGlobalCharacterIndex : ");
- struct GetIndicesFromGlobalCharacterIndexTest getIndicesFromGlobalCharacterIndexTests[] =
- {
- {
- std::string( "Test position 0" ),
- std::string( "text te<font size='30'>xt text te</font>xt text\n"
- "text t<font size='30'>ext טקסט טקסט te</font>xt\n"
- "text text text text text\n"
- "\n" ),
- 0,
- 0,
- 0,
- 0
- },
- {
- std::string( "Test position 76. (just after the last \\n)" ),
- std::string( "t<font size='30'>ext text te</font>xt text text\n"
- "text text טקסט טקסט text\n"
- "text text te<font size='30'>xt text</font> text\n"
- "\n" ),
- 76,
- 4,
- 0,
- 0
- },
- {
- std::string( "Test position 73. (the last \\n)" ),
- std::string( "text te<font size='30'>xt text text </font>text\n"
- "text text טק<font size='30'>סט טקס</font>ט text\n"
- "text text text text text\n"
- "\n" ),
- 75,
- 3,
- 0,
- 0
- },
- {
- std::string( "Test position 35. (first hebrew character)" ),
- std::string( "text text text text text\n"
- "text text טקסט טקסט text\n"
- "text text text text text\n"
- "\n" ),
- 35,
- 1,
- 4,
- 0
- },
- {
- std::string( "Test position 3. (end of the first word)" ),
- std::string( "text te<font size='30'>xt text text text\n</font>"
- "text text טק<font size='30'>סט טקסט </font>text\n"
- "text te<font size='30'>xt text text</font> text\n"
- "\n" ),
- 3,
- 0,
- 0,
- 3
- },
- {
- std::string( "Test position 33. (end of the second word of the second paragraph)" ),
- std::string( "text te<font size='30'>xt text text text\n</font>"
- "text text טק<font size='30'>סט טקסט </font>text\n"
- "text te<font size='30'>xt text text</font> text\n"
- "\n" ),
- 33,
- 1,
- 2,
- 3
- },
- {
- std::string( "Test position 43. (last hebrew character)" ),
- std::string( "text te<font size='30'>xt text text text\n</font>"
- "text text טק<font size='30'>סט טקסט </font>text\n"
- "text te<font size='30'>xt text text</font> text\n"
- "\n" ),
- 43,
- 1,
- 6,
- 3
- },
- };
- const std::size_t numberOfTests( 7 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const GetIndicesFromGlobalCharacterIndexTest& test = getIndicesFromGlobalCharacterIndexTests[index];
-
- if( !TestGetIndicesFromGlobalCharacterIndex( test.description, test.input, test.position, test.paragraphIndex, test.wordIndex, test.characterIndex, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewDebugCouts(void)
-{
- /////////////////////////////////////////////////////
- // Text debug functions to not to penalize coverage
- /////////////////////////////////////////////////////
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDebugCouts : ");
-
- Toolkit::Internal::TextView::RelayoutData relayoutData;
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( std::string( "Hello world\nhello world" ), inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- Actor dummy = Actor::New();
- Toolkit::Internal::SplitByNewLineChar::Relayout( dummy,
- Toolkit::Internal::TextView::RELAYOUT_ALL,
- DEFAULT_LAYOUT_PARAMETERS,
- DEFAULT_VISUAL_PARAMETERS,
- relayoutData );
-
- TextViewProcessor::dbgPrint( relayoutData.mTextLayoutInfo );
-
- TextStyle textStyle;
- TextViewProcessor::dbgPrint( textStyle );
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::dbgPrint( indices );
-
- TextViewProcessor::dbgPrint( inputStyledText );
-
- tet_result( TET_PASS );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-// Internal headers are allowed here
-#include <dali-toolkit/internal/controls/text-view/text-view-processor-types.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_processor_types_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_processor_types_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-//////////////////////////////////////////////////////////////////
-} // namespace
-
-
-int UtcDaliTextViewDefaultConstructorDestructor_PT(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
-
- TextViewProcessor::TextInfoIndices indices;
- DALI_TEST_EQUALS( indices.mParagraphIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( indices.mWordIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( indices.mCharacterIndex, 0u, TEST_LOCATION );
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mBearing, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mOffset, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mUnderlineThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mUnderlinePosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !characterLayoutInfo.mGlyphActor );
- DALI_TEST_EQUALS( characterLayoutInfo.mColorAlpha, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( NULL == characterLayoutInfo.mGradientInfo );
- DALI_TEST_CHECK( characterLayoutInfo.mIsVisible );
- DALI_TEST_CHECK( !characterLayoutInfo.mSetText );
- DALI_TEST_CHECK( !characterLayoutInfo.mSetStyle );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo;
- DALI_TEST_EQUALS( wordLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo.mType, TextViewProcessor::NoSeparator, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo.mCharactersLayoutInfo.size(), 0u, TEST_LOCATION );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo;
- DALI_TEST_EQUALS( paragraphLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mLineHeightOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mWordsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo;
- DALI_TEST_EQUALS( textLayoutInfo.mWholeTextSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mMaxWordWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mParagraphsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mMaxItalicsOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mType, TextViewProcessor::NoSeparator, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mEllipsizeLayoutInfo.mCharactersLayoutInfo.size(), 0u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewCopyConstructorOperator(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCopyConstructorOperator : ");
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
- characterLayoutInfo.mBearing = 1.f;
- characterLayoutInfo.mPosition = Vector3( 1.f, 1.f, 1.f );
- characterLayoutInfo.mOffset = Vector2( 1.f, 1.f );
- characterLayoutInfo.mAscender = 1.f;
- characterLayoutInfo.mUnderlineThickness = 1.f;
- characterLayoutInfo.mUnderlinePosition = 1.f;
-
- characterLayoutInfo.mGlyphActor = TextActor::New( "Hello" );
-
- TextViewProcessor::GradientInfo* info = new TextViewProcessor::GradientInfo();
- info->mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
- info->mStartPoint = Vector2( 1.f, 1.f );
- info->mEndPoint = Vector2( 1.f, 1.f );
-
- characterLayoutInfo.mColorAlpha = 0.f;
- characterLayoutInfo.mGradientInfo = info;
-
- characterLayoutInfo.mIsVisible = false;
- characterLayoutInfo.mSetText = false;
- characterLayoutInfo.mSetStyle = false;
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo1;
- characterLayoutInfo1 = characterLayoutInfo;
-
- DALI_TEST_EQUALS( characterLayoutInfo1.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mUnderlineThickness, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mUnderlinePosition, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( characterLayoutInfo1.mGlyphActor );
- DALI_TEST_EQUALS( characterLayoutInfo1.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !characterLayoutInfo1.mIsVisible );
- DALI_TEST_CHECK( !characterLayoutInfo1.mSetText );
- DALI_TEST_CHECK( !characterLayoutInfo1.mSetStyle );
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo2( characterLayoutInfo );
- DALI_TEST_EQUALS( characterLayoutInfo2.mBearing, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mPosition, Vector3( 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mOffset, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mUnderlineThickness, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mUnderlinePosition, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( characterLayoutInfo2.mGlyphActor );
- DALI_TEST_EQUALS( characterLayoutInfo2.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientInfo->mEndPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !characterLayoutInfo2.mIsVisible );
- DALI_TEST_CHECK( !characterLayoutInfo2.mSetText );
- DALI_TEST_CHECK( !characterLayoutInfo2.mSetStyle );
-
- // Increases coverage.
- characterLayoutInfo2.mGlyphActor.Reset();
- characterLayoutInfo1 = characterLayoutInfo2;
- DALI_TEST_CHECK( !characterLayoutInfo1.mGlyphActor );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo;
- wordLayoutInfo.mSize = Vector2( 1.f, 1.f );
- wordLayoutInfo.mAscender = 1.f;
- wordLayoutInfo.mType = TextViewProcessor::ParagraphSeparator;
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo1;
- wordLayoutInfo1 = wordLayoutInfo;
-
- DALI_TEST_EQUALS( wordLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo1.mType, TextViewProcessor::ParagraphSeparator, TEST_LOCATION );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo2( wordLayoutInfo );
-
- DALI_TEST_EQUALS( wordLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordLayoutInfo2.mType, TextViewProcessor::ParagraphSeparator, TEST_LOCATION );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo;
- paragraphLayoutInfo.mSize = Vector2( 1.f, 1.f );
- paragraphLayoutInfo.mAscender = 1.f;
- paragraphLayoutInfo.mLineHeightOffset = 1.f;
- paragraphLayoutInfo.mNumberOfCharacters = 1u;
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo1;
- paragraphLayoutInfo1 = paragraphLayoutInfo;
-
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo2( paragraphLayoutInfo );
-
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( paragraphLayoutInfo2.mNumberOfCharacters, 1u, TEST_LOCATION );
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo;
- textLayoutInfo.mWholeTextSize = Vector2( 1.f, 1.f );
- textLayoutInfo.mMaxWordWidth = 1.f;
- textLayoutInfo.mNumberOfCharacters = 1u;
- textLayoutInfo.mMaxItalicsOffset = 1.f;
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo1;
- textLayoutInfo1 = textLayoutInfo;
-
- DALI_TEST_EQUALS( textLayoutInfo1.mWholeTextSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo1.mMaxWordWidth, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo1.mMaxItalicsOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- TextViewProcessor::TextLayoutInfo textLayoutInfo2( textLayoutInfo );
-
- DALI_TEST_EQUALS( textLayoutInfo2.mWholeTextSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mMaxWordWidth, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mNumberOfCharacters, 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mMaxItalicsOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewEqualityOperator(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewEqualityOperator : ");
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::TextInfoIndices indices1( 1u, 1u, 1u );
-
- DALI_TEST_CHECK( !( indices == indices1 ) );
-
- indices = indices1;
-
- DALI_TEST_CHECK( indices == indices1 );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-// Internal headers are allowed here
-#include <dali-toolkit/internal/controls/text-view/text-processor.h>
-#include <dali-toolkit/internal/controls/text-view/text-processor-bidirectional-info.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_processor_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_processor_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-//////////////////////////////////////////////////////////////////
-
-struct BeginsRightToLeftCharacterTest
-{
- std::string description;
- std::string input;
- bool result;
-};
-
-bool TestBeginsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
-{
- // Creates a text with the string.
- Text text( input );
-
- const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( text ) );
-
- if( !ret )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Input : %s", input.c_str() );
- }
-
- return ret;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct ContainsRightToLeftCharacterTest
-{
- std::string description;
- std::string input;
- bool result;
-};
-
-bool TestContainsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
-{
- // Creates a text with the string.
- Text text( input );
-
- const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( text ) );
-
- if( !ret )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Input : %s", input.c_str() );
- }
-
- return ret;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct FindNearestWordTest
-{
- std::string description;
- std::string input;
- std::size_t offset;
- std::size_t start;
- std::size_t end;
-};
-
-bool TestFindNearestWord( const std::string& description, const std::string& input, const std::size_t offset, const std::size_t startResult, const std::size_t endResult, const char* location )
-{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( input, styledText, true );
-
- std::size_t start;
- std::size_t end;
- TextProcessor::FindNearestWord( styledText, offset, start, end );
-
- const bool ret = ( start == startResult ) && ( end == endResult );
-
- if( !ret )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Input : %s, offset %d, start %d, end %d", input.c_str(), offset, start, end );
- }
-
- return ret;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct SplitInParagraphsTest
-{
- std::string inputText;
-
- std::size_t resultNumberOfParagraphs;
-};
-
-bool TestSplitInParagraphs( const SplitInParagraphsTest& test, const char* location )
-{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( test.inputText, styledText, true );
-
- std::vector<Text> paragraphs;
- std::vector< Vector<TextStyle*> > styles;
-
- TextProcessor::SplitInParagraphs( styledText,
- paragraphs,
- styles );
-
- if( paragraphs.size() != test.resultNumberOfParagraphs )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Different number of paragraphs, result %d, expected result %d", paragraphs.size(), test.resultNumberOfParagraphs );
-
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct SplitInWordsTest
-{
- std::string inputText;
-
- std::size_t resultNumberOfSeparators;
-};
-
-bool TestSplitInWords( const SplitInWordsTest& test, const char* location )
-{
- // Creates a text with the string.
- Text text( test.inputText );
-
- Vector<std::size_t> positions;
-
- TextProcessor::SplitInWords( text,
- positions );
-
- if( positions.Count() != test.resultNumberOfSeparators )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Different number of separators, result %d, expected result %d", positions.Count(), test.resultNumberOfSeparators );
-
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-} // namespace
-
-
-int UtcDaliTextViewSplitInParagraphs(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitInParagraphs : ");
-
- struct SplitInParagraphsTest splitInParagraphsTest[] =
- {
- {
- std::string( "Hello world\nhello world." ),
- 2
- },
- {
- std::string( "Hello world\nhello world.\n\n" ),
- 4
- }
- };
- const std::size_t numberOfTests( 2 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const SplitInParagraphsTest& test = splitInParagraphsTest[index];
-
- if( !TestSplitInParagraphs( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewSplitInWords(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitInWords : ");
-
- struct SplitInWordsTest splitInWordsTest[] =
- {
- {
- std::string( "Hello world, hello word!" ),
- 3u
- },
- {
- std::string( "Hello world\n" ),
- 2u
- }
- };
- const std::size_t numberOfTests( 2u );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const SplitInWordsTest& test = splitInWordsTest[index];
-
- if( !TestSplitInWords( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewBeginsRightToLeftCharacter(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewBeginsRightToLeftCharacter : ");
-
- struct BeginsRightToLeftCharacterTest beginsRightToLeftCharacterTest[] =
- {
- {
- std::string( "Test if it begins with a right to left character. Should return false." ),
- std::string( "Hello world مرحبا العالم." ),
- false
- },
- {
- std::string( "Test if it begins with a right to left character. Should return true." ),
- std::string( "مرحبا العالم Hola mundo." ),
- true
- }
- };
- const std::size_t numberOfTests( 2 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const BeginsRightToLeftCharacterTest& test = beginsRightToLeftCharacterTest[index];
-
- if( !TestBeginsRightToLeftCharacter( test.description, test.input, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewContainsRightToLeftCharacter(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewContainsRightToLeftCharacter : ");
-
- struct ContainsRightToLeftCharacterTest containsRightToLeftCharacterTest[] =
- {
- {
- std::string( "Test if it contains a right to left character. Should return true." ),
- std::string( "Hello world مرحبا العالم." ),
- true
- },
- {
- std::string( "Test if it contains a right to left character. Should return true." ),
- std::string( "مرحبا العالم Hola mundo." ),
- true
- },
- {
- std::string( "Test if it contains a right to left character. Should return false." ),
- std::string( "Hello world." ),
- false
- },
- {
- std::string( "Test if it contains a right to left character. Should return true." ),
- std::string( "مرحبا العالم." ),
- true
- }
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const ContainsRightToLeftCharacterTest& test = containsRightToLeftCharacterTest[index];
-
- if( !TestContainsRightToLeftCharacter( test.description, test.input, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewFindNearestWord(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewFindNearestWord : ");
-
- struct FindNearestWordTest findNearestWordTest[] =
- {
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 0u,
- 0u,
- 5u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 7u,
- 6u,
- 12u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 11u,
- 6u,
- 12u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 23u,
- 18u,
- 23u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo" ),
- 5u,
- 0u,
- 5u
- },
- {
- std::string( "" ),
- std::string( "Hello world, hola mundo مرحبا العالم" ),
- 24u,
- 25u,
- 30u
- }
- };
-
- const std::size_t numberOfTests( 6 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const FindNearestWordTest& test = findNearestWordTest[index];
-
- if( !TestFindNearestWord( test.description, test.input, test.offset, test.start, test.end, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-// Internal headers are allowed here
-#include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_relayout_utils_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_relayout_utils_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
-
-// Data structures used to create an 'experiment' in TET cases
-
-
-bool TestEqual( float x, float y )
-{
- return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct CalculateLineLayoutTest
-{
- std::string description;
- std::string inputParagraph;
- float parentWidth;
- std::size_t wordIndex;
- std::size_t characterIndex;
- std::size_t characterParagraphIndex;
- TextViewRelayout::HorizontalWrapType splitPolicy;
- float shrinkFactor;
-
- float resultLineLength;
- float resultMaxCharHeight;
- float resultMaxAscender;
-};
-
-bool TestCalculateLineLayout( const CalculateLineLayoutTest& test, const char* location )
-{
- tet_printf( "%s", test.description.c_str() );
-
- // Create styled text.
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( test.inputParagraph, inputStyledText, true );
-
- // Create styled text layout info.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- // Prepare input parameters and the result structure and call the function to be tested.
-
- // Creaqte indices.
- TextViewProcessor::TextInfoIndices indices( 0u, test.wordIndex, test.characterIndex );
- indices.mCharacterParagraphIndex = test.characterParagraphIndex;
-
- // Get the input paragraph.
- TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
-
- if( !relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.empty() )
- {
- inputParagraphLayout = *relayoutData.mTextLayoutInfo.mParagraphsLayoutInfo.begin();
- }
-
- // Result struct.
- TextViewRelayout::LineLayoutInfo resultLayoutInfo;
-
- CalculateLineLayout( test.parentWidth,
- indices,
- inputParagraphLayout,
- test.splitPolicy,
- test.shrinkFactor,
- resultLayoutInfo );
-
- // Check results.
- if( !TestEqual( test.resultLineLength, resultLayoutInfo.mLineLength ) )
- {
- tet_printf( "Fail. different line length %f == %f. %s", test.resultLineLength, resultLayoutInfo.mLineLength, location );
- return false;
- }
-
- if( !TestEqual( test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight ) )
- {
- tet_printf( "Fail. different max character height %f == %f. %s", test.resultMaxCharHeight, resultLayoutInfo.mMaxCharHeight, location );
- return false;
- }
-
- if( !TestEqual( test.resultMaxAscender, resultLayoutInfo.mMaxAscender ) )
- {
- tet_printf( "Fail. different max ascender %f == %f. %s", test.resultMaxAscender, resultLayoutInfo.mMaxAscender, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct AlignmentOffsetTest
-{
- Toolkit::Alignment::Type alignment;
- float parentSize;
- float wholeTextSize;
-
- float resultOffset;
-};
-
-bool TestAlignmentOffset( const AlignmentOffsetTest& test, const char* location )
-{
- float offset = 0.f;
-
- switch( test.alignment )
- {
- case Toolkit::Alignment::HorizontalLeft:
- case Toolkit::Alignment::HorizontalCenter:
- case Toolkit::Alignment::HorizontalRight:
- {
- offset = TextViewRelayout::CalculateXoffset( test.alignment, test.parentSize, test.wholeTextSize );
- break;
- }
- case Toolkit::Alignment::VerticalTop:
- case Toolkit::Alignment::VerticalCenter:
- case Toolkit::Alignment::VerticalBottom:
- {
- offset = TextViewRelayout::CalculateYoffset( test.alignment, test.parentSize, test.wholeTextSize );
- break;
- }
- }
-
- // Check results.
- if( !TestEqual( test.resultOffset, offset ) )
- {
- tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct JustificationOffsetTest
-{
- Toolkit::TextView::LineJustification justification;
- float wholeTextWidth;
- float lineLength;
-
- float resultOffset;
-};
-
-bool TestJustificationOffset( const JustificationOffsetTest& test, const char* location )
-{
- float offset = TextViewRelayout::CalculateJustificationOffset( test.justification, test.wholeTextWidth, test.lineLength );
-
- // Check results.
- if( !TestEqual( test.resultOffset, offset ) )
- {
- tet_printf( "Fail. different offset %f == %f. %s", test.resultOffset, offset, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct CalculateVisibilityTest
-{
- Vector3 position;
- Size size;
- Size parentSize;
- TextViewRelayout::VisibilityTestType type;
-
- bool resultVisible;
-};
-
-bool TestCalculateVisibility( const CalculateVisibilityTest& test, const char* location )
-{
- if( test.resultVisible != TextViewRelayout::IsVisible( test.position, test.size, test.parentSize, test.type ) )
- {
- tet_printf( "Fail. different visibility. Type %d, %s", test.type, location );
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-} // namespace
-
-
-int UtcDaliTextViewDefaultConstructorDestructor_RU(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
-
- // Test RelayoutParameters defaults.
- TextViewRelayout::RelayoutParameters relayoutParameters;
-
- DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mParagraphSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mWordSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mCharacterSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mParagraphIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mWordIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mCharacterIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mCharacterGlobalIndex, 0u, TEST_LOCATION );
- DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacter );
- DALI_TEST_CHECK( !relayoutParameters.mIsFirstCharacterOfWord );
- DALI_TEST_CHECK( !relayoutParameters.mIsNewLine );
- DALI_TEST_CHECK( !relayoutParameters.mIsNewParagraphCharacter );
- DALI_TEST_CHECK( !relayoutParameters.mIsWhiteSpace );
- DALI_TEST_CHECK( !relayoutParameters.mIsVisible );
-
- // Test FadeParameter defaults
- TextViewRelayout::FadeParameters fadeParameters;
-
- DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mRightAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mLeftAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mTopAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundary, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeThreshold, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeBoundaryOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomFadeThresholdOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeParameters.mBottomAlphaCoeficients, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_CHECK( !fadeParameters.mIsPartiallyVisible );
-
- // Test EllipsizeParameters defaults
- TextViewRelayout::EllipsizeParameters ellipsizeParameters;
-
- DALI_TEST_EQUALS( ellipsizeParameters.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mLineDescender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mLineWidth, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mEllipsizeBoundary, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mFirstIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( ellipsizeParameters.mLastIndex, 0u, TEST_LOCATION );
- DALI_TEST_CHECK( !ellipsizeParameters.mEllipsizeLine );
- DALI_TEST_CHECK( !ellipsizeParameters.mIsLineWidthFullyVisible );
- DALI_TEST_CHECK( !ellipsizeParameters.mIsLineHeightFullyVisible );
- DALI_TEST_CHECK( !ellipsizeParameters.mIsNextLineFullyVisibleHeight );
- DALI_TEST_CHECK( !ellipsizeParameters.mCreateEllipsizedTextActors );
- DALI_TEST_CHECK( !ellipsizeParameters.mLineFits );
- DALI_TEST_CHECK( !ellipsizeParameters.mWordFits );
-
- // Test UnderlineInfo defaults
- TextViewRelayout::UnderlineInfo underlineInfo;
-
- DALI_TEST_EQUALS( underlineInfo.mMaxHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( underlineInfo.mMaxThickness, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( underlineInfo.mPosition, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- // Test TextUnderlineStatus defaults
- TextViewRelayout::TextUnderlineStatus textUnderlineStatus;
-
- DALI_TEST_CHECK( textUnderlineStatus.mUnderlineInfo.empty() );
- DALI_TEST_EQUALS( textUnderlineStatus.mCharacterGlobalIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textUnderlineStatus.mLineGlobalIndex, 0u, TEST_LOCATION );
- DALI_TEST_CHECK( !textUnderlineStatus.mCurrentUnderlineStatus );
-
- // Test LineLayoutInfo defaults
- TextViewRelayout::LineLayoutInfo lineLayoutInfo;
-
- DALI_TEST_EQUALS( lineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewCalculateLineLayout(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateLineLayout : ");
-
- struct CalculateLineLayoutTest calculateLineLayoutTest[] =
- {
- //WrapByCharacter
- {
- "The paragraph is wraped by character. All characters have the same size.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by character. There are characters with different sizes.",
- "Hello <font size='14'>world</font>", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 94.835075f, // line length. (only fits 8 characters 6x11.38 + 2x13.27)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
- {
- "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
- 100.f, // parent width
- 2, // indices. The third character of the third word starts in a new line.
- 2,
- 8,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by character. There are characters with different sizes. It calculates the layout for the third line.",
- "Hello <font size='14'>wo</font>rld hell<font size='14'>o world</font>", // input paragraph
- 100.f, // parent width
- 4, // indices. The fifth character of the fifth word starts in a new line.
- 4,
- 16,
- TextViewRelayout::WrapByCharacter, // split policy
- 1.f,
- // results
- 92.938377f, // line length. (only fits 8 characters 8x11.38)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
-
- //WrapByWord
- {
- "The paragraph is wraped by word. All characters have the same size.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
- 9999999,
- 9999999,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word. There are characters with different sizes.",
- "Hell<font size='14'>o</font> world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 0,
- 0,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 58.797747f, // line length. (only fits 5 characters 4x11.38 + 13.276911, white space is not counted)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
- {
- "The paragraph is wraped by word. There are characters with different sizes. It calculates the layout for the second line.",
- "Hello <font size='14'>wo</font>rld <font size='16'>hello world</font>", // input paragraph
- 100.f, // parent width
- 2, // indices. The third word starts in a new line.
- 0,
- 6,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 60.694449f, // line length. (only fits 5 characters 2x13.276911 + 3x11.38)
- 13.276911f, // max character height
- 11.949220f // max ascender
- },
- {
- "The paragraph is wraped by word. The word doen't fit.",
- "Hello world", // input paragraph
- 40.f, // parent width
- 0, // indices. The third word starts in a new line.
- 0,
- 0,
- TextViewRelayout::WrapByWord, // split policy
- 1.f,
- // results
- 0.f, // line length. (The word doesn't fit)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
-
- //WrapByWordAndSplit
- {
- "The paragraph is wraped by word and by character. All characters have the same size. There is not a long word.",
- "Hello world hello world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 0,
- 0,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 1.f,
- // results
- 56.901047f, // line length. (only fits 5 characters 5x11.38, white space is not counted)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word and by character. All characters have the same size. There is a long word.",
- "Helloooooooo world", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 0,
- 0,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "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.",
- "Helloooooooo <font size='14'>world</font>", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 8,
- 8,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 1.f,
- // results
- 45.520836f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph is wraped by word and by character. There are characters with different sizes. There is a shrink factor.",
- "Helloooooooo<font size='14'> world</font>", // input paragraph
- 100.f, // parent width
- 0, // indices.
- 8,
- 8,
- TextViewRelayout::WrapByWordAndSplit, // split policy
- 0.7f,
- // results
- 95.593755f, // line length. (only fits 12 characters 8x11.38)
- 7.9661463f, // max character height
- 7.169531f // max ascender
- },
-
- //WrapByParagraphCharacterAndSplit
- {
- "The paragraph is wraped by end of paragraph and by character. All characters have the same size.",
- "Hello world", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "The paragraph fits in the width.",
- "Hello", // input paragraph
- 100.f, // parent width
- 0, // indices
- 0,
- 0,
- TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
- 1.f,
- // results
- 56.901047f, // line length. (only fits 5 characters 5x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- {
- "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.",
- "Hello world, hello world", // input paragraph
- 100.f, // parent width
- 2, // indices
- 2,
- 8,
- TextViewRelayout::WrapByParagraphCharacterAndSplit, // split policy
- 1.f,
- // results
- 91.041672f, // line length. (only fits 8 characters 8x11.38)
- 11.380209f, // max character height
- 10.242188f // max ascender
- },
- };
- const std::size_t numberOfTests( 15 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const CalculateLineLayoutTest& test = calculateLineLayoutTest[index];
-
- if( !TestCalculateLineLayout( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewCalculateAlignmentOffsets(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateAlignmentOffsets : ");
-
- struct AlignmentOffsetTest alignmentOffsetTest[] =
- {
- {
- Toolkit::Alignment::HorizontalLeft,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::Alignment::HorizontalCenter,
- 100.f,
- 75.f,
- 12.5f
- },
- {
- Toolkit::Alignment::HorizontalRight,
- 100.f,
- 75.f,
- 25.f
- },
- {
- Toolkit::Alignment::VerticalTop,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::Alignment::VerticalCenter,
- 100.f,
- 75.f,
- 12.5f
- },
- {
- Toolkit::Alignment::VerticalBottom,
- 100.f,
- 75.f,
- 25.f
- }
- };
- const std::size_t numberOfTests( 6 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const AlignmentOffsetTest& test = alignmentOffsetTest[index];
-
- if( !TestAlignmentOffset( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewCalculateJustificationOffsets(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateJustificationOffsets : ");
-
- struct JustificationOffsetTest justificationOffsetTest[] =
- {
- {
- Toolkit::TextView::Left,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::TextView::Justified,
- 100.f,
- 75.f,
- 0.f
- },
- {
- Toolkit::TextView::Center,
- 100.f,
- 150.f,
- -25.f
- },
- {
- Toolkit::TextView::Right,
- 100.f,
- 75.f,
- 25.f
- },
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const JustificationOffsetTest& test = justificationOffsetTest[index];
-
- if( !TestJustificationOffset( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-
-int UtcDaliTextViewCalculateVisibility(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateVisibility : ");
-
- struct CalculateVisibilityTest calculateVisibilityTest[] =
- {
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE,
- true
- },
- {
- Vector3( 10.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE,
- true
- },
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 150.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE,
- false
- },
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_WIDTH,
- true
- },
- {
- Vector3( 95.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_WIDTH,
- false
- },
- {
- Vector3( 0.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_HEIGHT,
- true
- },
- {
- Vector3( 0.f, 0.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::FULLY_VISIBLE_HEIGHT,
- false
- },
- {
- Vector3( -10.f, 10.f, 0.f ),
- Size( 150.f, 150.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE,
- true
- },
- {
- Vector3( -100.f, -100.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE,
- false
- },
- {
- Vector3( -10.f, 10.f, 0.f ),
- Size( 50.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
- true
- },
- {
- Vector3( 110.f, 10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_WIDTH,
- false
- },
- {
- Vector3( 0.f, 20.f, 0.f ),
- Size( 10.f, 50.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
- true
- },
- {
- Vector3( 0.f, -10.f, 0.f ),
- Size( 10.f, 10.f ),
- Size( 100.f, 100.f ),
- TextViewRelayout::PARTIALLY_VISIBLE_HEIGHT,
- false
- },
- };
- const std::size_t numberOfTests( 13 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const CalculateVisibilityTest& test = calculateVisibilityTest[index];
-
- if( !TestCalculateVisibility( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMiscelaneousAsserts(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMiscelaneousAsserts : ");
-
- float offset = 0.f;
-
- bool assert1 = false;
- bool assert2 = false;
- try
- {
- offset = Toolkit::Internal::TextViewRelayout::CalculateXoffset( Toolkit::Alignment::VerticalTop, 100.f, 50.f );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong horizontal text alignment. Did you set a vertical one?\"", TEST_LOCATION );
- assert1 = true;
- }
- catch( ... )
- {
- tet_result( TET_FAIL );
- }
- DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- try
- {
- offset = Toolkit::Internal::TextViewRelayout::CalculateYoffset( Toolkit::Alignment::HorizontalRight, 100.f, 50.f );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewRelayout::CalculateXoffset: Wrong vertical text alignment. Did you set an horizontal one?\"", TEST_LOCATION );
- assert2 = true;
- }
- catch( ... )
- {
- tet_result( TET_FAIL );
- }
- DALI_TEST_EQUALS( offset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- DALI_TEST_CHECK( assert1 && assert2 );
-
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-// Internal headers are allowed here
-#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-processor-dbg.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-paragraph-processor.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
-#include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-void dali_text_view_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_text_view_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-
-const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
-const Toolkit::Internal::TextView::VisualParameters DEFAULT_VISUAL_PARAMETERS;
-
-// Data structures used to create an 'experiment' in TET cases
-
-struct SplitWordTest
-{
- std::string description;
- std::string input;
- std::size_t position;
- std::string firstResult;
- std::string lastResult;
-};
-
-struct SplitParagraphTest
-{
- std::string description;
- std::string input;
- std::size_t wordIndex;
- std::size_t characterIndex;
- std::size_t characterParagraphIndex;
- float lineHeightOffset;
- std::string firstResult;
- std::string lastResult;
-};
-
-struct MergeWordsTest
-{
- std::string description;
- std::string inputFirst;
- std::string inputLast;
- std::string result;
-};
-
-struct MergeParagraphsTest
-{
- std::string description;
- std::string inputFirst;
- std::string inputLast;
- float lineHeightOffset;
- std::string result;
-};
-
-struct RemoveCharactersFromWordTest
-{
- std::string description;
- std::string input;
- std::size_t position;
- std::size_t numberOfCharacters;
- std::string result;
-};
-
-struct RemoveWordsFromParagraphTest
-{
- std::string description;
- std::string input;
- std::size_t wordIndex;
- std::size_t numberOfWords;
- float lineHeightOffset;
- std::string result;
-};
-
-enum UpdateTextInfoOperation
-{
- Insert,
- Remove,
- Replace
-};
-
-struct UpdateTextInfoTest
-{
- std::string description;
- UpdateTextInfoOperation operation;
- std::string input;
- std::size_t position;
- std::size_t numberOfCharacters;
- std::string inputText;
- float lineHeightOffset;
- std::string result;
-};
-
-// Useful Print functions when something goes wrong.
-
-void Print( const TextViewProcessor::CharacterLayoutInfo& character )
-{
- std::cout << " height : " << character.mSize.height << std::endl;
- std::cout << " advance : " << character.mSize.width << std::endl;
- std::cout << " bearing : " << character.mBearing << std::endl;
- std::cout << " ascender : " << character.mAscender << std::endl;
- std::cout << " position : " << character.mPosition << std::endl;
-
- TextActor textActor = TextActor::DownCast( character.mGlyphActor );
- if( textActor )
- {
- std::cout << "[" << textActor.GetText() << "]";
- }
-}
-
-void Print( const TextViewProcessor::WordLayoutInfo& word )
-{
- std::cout << "[";
- std::cout << " mSize : " << word.mSize << std::endl;
- std::cout << " mAscender : " << word.mAscender << std::endl;
- std::cout << " mType : " << word.mType << std::endl;
- std::cout << "mNumberOfCharacters : " << word.mCharactersLayoutInfo.size() << std::endl;
- std::cout << "[";
- for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it = word.mCharactersLayoutInfo.begin(), endIt = word.mCharactersLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << "]"; std::cout << std::endl;
- std::cout << "]"; std::cout << std::endl;
-}
-
-void Print( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
-{
- std::cout << "<";
- std::cout << " mSize : " << paragraph.mSize << std::endl;
- std::cout << " mAscender : " << paragraph.mAscender << std::endl;
- std::cout << "mNumberOfCharacters : " << paragraph.mNumberOfCharacters << std::endl;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << ">" << std::endl;
-}
-
-void Print( const TextViewProcessor::TextLayoutInfo& text )
-{
- std::cout << "||";
- for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it = text.mParagraphsLayoutInfo.begin(), endIt = text.mParagraphsLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << "||" << std::endl;
-}
-
-std::string GetText( const TextViewProcessor::WordLayoutInfo& word, const Text& paragraphText )
-{
- Text text;
-
- paragraphText.GetSubText( word.mFirstCharacter, word.mFirstCharacter + word.mCharactersLayoutInfo.size() - 1u, text );
-
- return text.GetText();
-}
-
-std::string GetText( const TextViewProcessor::ParagraphLayoutInfo& paragraph )
-{
- std::string text;
-
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = paragraph.mWordsLayoutInfo.begin(), endIt = paragraph.mWordsLayoutInfo.end(); it != endIt; ++it )
- {
- text += GetText( *it, paragraph.mText );
- }
-
- return text;
-}
-
-// Test functions used to check if two data structures are equal.
-
-bool TestEqual( float x, float y )
-{
- return ( fabsf( x - y ) < 0.001f );
-}
-
-bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
- const TextViewProcessor::CharacterLayoutInfo& character2 )
-{
- if( !TestEqual( character1.mSize.height, character2.mSize.height ) )
- {
- return false;
- }
- if( !TestEqual( character1.mSize.width, character2.mSize.width ) )
- {
- return false;
- }
- if( !TestEqual( character1.mBearing, character2.mBearing ) )
- {
- return false;
- }
-
- if( !TestEqual( character1.mPosition.x, character2.mPosition.x ) )
- {
- return false;
- }
- if( !TestEqual( character1.mPosition.y, character2.mPosition.y ) )
- {
- return false;
- }
-
- if( !TestEqual( character1.mAscender, character2.mAscender ) )
- {
- return false;
- }
-
- if( character1.mGlyphActor && !character2.mGlyphActor )
- {
- return false;
- }
-
- if( !character1.mGlyphActor && character2.mGlyphActor )
- {
- return false;
- }
-
- std::string text1;
- std::string text2;
- TextStyle style1;
- TextStyle style2;
-
- TextActor textActor1 = TextActor::DownCast( character1.mGlyphActor );
- TextActor textActor2 = TextActor::DownCast( character2.mGlyphActor );
- if( textActor1 )
- {
- text1 = textActor1.GetText();
- style1 = textActor1.GetTextStyle();
-
- text2 = textActor2.GetText();
- style2 = textActor2.GetTextStyle();
- }
-
- if( text1 != text2 )
- {
- return false;
- }
-
- if( style1 != style2 )
- {
- return false;
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::WordLayoutInfo& word1,
- const TextViewProcessor::WordLayoutInfo& word2 )
-{
- if( !TestEqual( word1.mSize.x, word2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( word1.mSize.y, word2.mSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( word1.mAscender, word2.mAscender ) )
- {
- return false;
- }
-
- if( word1.mType != word2.mType )
- {
- return false;
- }
-
- if( word1.mCharactersLayoutInfo.size() != word2.mCharactersLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::CharacterLayoutInfoContainer::const_iterator it1 = word1.mCharactersLayoutInfo.begin(), endIt1 = word1.mCharactersLayoutInfo.end(),
- it2 = word2.mCharactersLayoutInfo.begin(), endIt2 = word2.mCharactersLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::ParagraphLayoutInfo& paragraph1,
- const TextViewProcessor::ParagraphLayoutInfo& paragraph2 )
-{
- if( !TestEqual( paragraph1.mSize.x, paragraph2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( paragraph1.mSize.y, paragraph2.mSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( paragraph1.mAscender, paragraph2.mAscender ) )
- {
- return false;
- }
-
- if( paragraph1.mNumberOfCharacters != paragraph2.mNumberOfCharacters )
- {
- return false;
- }
-
- if( paragraph1.mWordsLayoutInfo.size() != paragraph2.mWordsLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = paragraph1.mWordsLayoutInfo.begin(), endIt1 = paragraph1.mWordsLayoutInfo.end(),
- it2 = paragraph2.mWordsLayoutInfo.begin(), endIt2 = paragraph2.mWordsLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::TextLayoutInfo& text1,
- const TextViewProcessor::TextLayoutInfo& text2 )
-{
- if( !TestEqual( text1.mWholeTextSize.x, text2.mWholeTextSize.x ) )
- {
- return false;
- }
- if( !TestEqual( text1.mWholeTextSize.y, text2.mWholeTextSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( text1.mMaxWordWidth, text2.mMaxWordWidth ) )
- {
- return false;
- }
-
- if( text1.mNumberOfCharacters != text2.mNumberOfCharacters )
- {
- return false;
- }
-
- if( text1.mParagraphsLayoutInfo.size() != text2.mParagraphsLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::ParagraphLayoutInfoContainer::const_iterator it1 = text1.mParagraphsLayoutInfo.begin(), endIt1 = text1.mParagraphsLayoutInfo.end(),
- it2 = text2.mParagraphsLayoutInfo.begin(), endIt2 = text2.mParagraphsLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * Splits the \e input word in two by the given \e position and checks the results with \e firstResult and \e lastResult.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Split the word from the beginning. (position 0)".
- * @param input The input word.
- * @param position Where to split the word.
- * @param firstResult First part of the split word.
- * @param lastResult Last part of the split word.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestSplitWord( const std::string& description, const std::string& input, const size_t position, const std::string& firstResult, const std::string& lastResult, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input word.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputWordLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the first part of the result (after split the word)
-
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray firstResultStyledText;
- MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( firstResultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- firstRelayoutData );
-
- // Get the first result word
- TextViewProcessor::WordLayoutInfo firstResultWordLayout;
-
- if( !firstResultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *firstResultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- firstResultWordLayout = *( *firstResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the last part of the result (after split the word)
-
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray lastResultStyledText;
- MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( lastResultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- lastRelayoutData );
-
- // Get the last result word
- TextViewProcessor::WordLayoutInfo lastResultWordLayout;
-
- if( !lastResultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *lastResultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- lastResultWordLayout = *( *lastResultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Split the word.
-
- TextViewProcessor::WordLayoutInfo lastWordLayoutInfo;
-
- SplitWord( position,
- inputWordLayout,
- lastWordLayoutInfo );
-
- // Test results
- if( !TestEqual( inputWordLayout, firstResultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- if( !TestEqual( lastWordLayoutInfo, lastResultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Splits the \e input paragraph in two by the given \e wordIndex and \e characterIndex and checks the results with \e firstResult and \e lastResult.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Split the paragraph from the beginning. (wordIndex 0 and characterIndex 0)".
- * @param input The input word.
- * @param wordIndex Index to the word within the paragraph where to split it.
- * @param characterIndex Where to split the word.
- * @param characterIndex Character index within the paragraph.
- * @param lineHeightOffset Offset between lines.
- * @param firstResult First part of the split paragraph.
- * @param lastResult Last part of the split paragraph.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestSplitParagraph( const std::string& description,
- const std::string& input,
- size_t wordIndex,
- size_t characterIndex,
- size_t characterParagraphIndex,
- float lineHeightOffset,
- const std::string& firstResult,
- const std::string& lastResult,
- const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input paragraph.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- relayoutData );
-
- // Get the input paragraph
- TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the first part of the result (after split the paragraph)
-
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& firstResultLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray firstResultStyledText;
- MarkupProcessor::GetStyledTextArray( firstResult, firstResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( firstResultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- firstRelayoutData );
-
- // Get the first result paragraph
- TextViewProcessor::ParagraphLayoutInfo firstResultParagraphLayout;
-
- if( !firstResultLayout.mParagraphsLayoutInfo.empty() )
- {
- firstResultParagraphLayout = *firstResultLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the last part of the result (after split the paragraph)
-
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& lastResultLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray lastResultStyledText;
- MarkupProcessor::GetStyledTextArray( lastResult, lastResultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( lastResultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- lastRelayoutData );
-
- // Get the last result paragraph
- TextViewProcessor::ParagraphLayoutInfo lastResultParagraphLayout;
-
- if( !lastResultLayout.mParagraphsLayoutInfo.empty() )
- {
- lastResultParagraphLayout = *lastResultLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Split the paragraph.
-
- TextViewProcessor::ParagraphLayoutInfo lastParagraphLayoutInfo;
-
- TextViewProcessor::TextInfoIndices indices( 0, wordIndex, characterIndex );
- indices.mCharacterParagraphIndex = characterParagraphIndex;
-
- SplitParagraph( indices,
- PointSize( lineHeightOffset ),
- inputParagraphLayout,
- lastParagraphLayoutInfo );
-
- // Test results
- if( !TestEqual( inputParagraphLayout, firstResultParagraphLayout ) )
- {
- tet_printf( "Fail. different first layout info. %s\n", location );
- return false;
- }
-
- if( !TestEqual( lastParagraphLayoutInfo, lastResultParagraphLayout ) )
- {
- tet_printf( "Fail. different last layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Merges the \e inputFirst word and the \e inputLast word, and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Merge two words with same style".
- * @param inputFirst The first part of the word.
- * @param inputLast The last part of the word.
- * @param result The merged word.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestMergeWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the inputFirst word.
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputFirstStyledText;
- MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputFirstStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- firstRelayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputFirstWordLayout;
-
- if( !inputFirstLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputFirstLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputFirstWordLayout = *( *inputFirstLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the inputLast word.
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputLastStyledText;
- MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputLastStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- lastRelayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputLastWordLayout;
-
- if( !inputLastLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLastLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputLastWordLayout = *( *inputLastLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the result word.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::WordLayoutInfo resultWordLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- MergeWord( inputFirstWordLayout,
- inputLastWordLayout );
-
- if( !TestEqual( inputFirstWordLayout, resultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Merges the \e inputFirst paragraph and the \e inputLast paragraph, and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param inputFirst The first part of the paragraph.
- * @param inputLast The last part of the paragraph.
- * @param lineHeightOffset Offset between lines.
- * @param result The merged paragraph.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestMergeParagraphs( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const float lineHeightOffset, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the inputFirst paragraph.
- Toolkit::Internal::TextView::RelayoutData firstRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputFirstLayout( firstRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputFirstStyledText;
- MarkupProcessor::GetStyledTextArray( inputFirst, inputFirstStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputFirstStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- firstRelayoutData );
-
- // Get the input word
- TextViewProcessor::ParagraphLayoutInfo inputFirstParagraphLayout;
-
- if( !inputFirstLayout.mParagraphsLayoutInfo.empty() )
- {
- inputFirstParagraphLayout = *inputFirstLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the inputLast paragraph.
- Toolkit::Internal::TextView::RelayoutData lastRelayoutData;
- TextViewProcessor::TextLayoutInfo& inputLastLayout( lastRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputLastStyledText;
- MarkupProcessor::GetStyledTextArray( inputLast, inputLastStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputLastStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- lastRelayoutData );
-
- // Get the input word
- TextViewProcessor::ParagraphLayoutInfo inputLastParagraphLayout;
-
- if( !inputLastLayout.mParagraphsLayoutInfo.empty() )
- {
- inputLastParagraphLayout = *inputLastLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the result word.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin();
- }
-
- MergeParagraph( inputFirstParagraphLayout,
- inputLastParagraphLayout );
-
- if( !TestEqual( inputFirstParagraphLayout, resultParagraphLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Removes from the \e input word the \e numberOfCharacters characters starting from the given \e position and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment. i.e. "Remove a whole word. Merge".
- * @param input The input word.
- * @param position Where to start to remove characters
- * @param numberOfCharacters The number of characters to remove.
- * @param result The word without the removed characters.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestRemoveCharactersFromWord( const std::string& description, const std::string& input, const std::size_t position, const std::size_t numberOfCharacters, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input word.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
- // Get the input word
- TextViewProcessor::WordLayoutInfo inputWordLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *inputLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- inputWordLayout = *( *inputLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the result word.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- DEFAULT_LAYOUT_PARAMETERS,
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::WordLayoutInfo resultWordLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- const TextViewProcessor::ParagraphLayoutInfo& paragraph( *resultLayout.mParagraphsLayoutInfo.begin() );
- if( !paragraph.mWordsLayoutInfo.empty() )
- {
- resultWordLayout = *( *resultLayout.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
-
- RemoveCharactersFromWord( position,
- numberOfCharacters,
- inputWordLayout );
-
- if( !TestEqual( inputWordLayout, resultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Removes from the \e input paragraph the \e numberOfWords words starting from the given \e wordIndex and checks the results with \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param input The input paragraph.
- * @param wordIndex Index within the paragraph where to start to remove words.
- * @param numberOfWords The number of words to remove.
- * @param lineHeightOffset Offset between lines.
- * @param result The paragraph without the removed words.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestRemoveWordsFromParagraph( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const float lineHeightOffset, const std::string& result, const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input paragraph.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- relayoutData );
-
- // Get the input paragraph
- TextViewProcessor::ParagraphLayoutInfo inputParagraphLayout;
-
- if( !inputLayout.mParagraphsLayoutInfo.empty() )
- {
- inputParagraphLayout = *inputLayout.mParagraphsLayoutInfo.begin();
- }
-
- // Create layout info for the result paragraph.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- resultRelayoutData );
-
- // Get the result paragraph
- TextViewProcessor::ParagraphLayoutInfo resultParagraphLayout;
-
- if( !resultLayout.mParagraphsLayoutInfo.empty() )
- {
- resultParagraphLayout = *resultLayout.mParagraphsLayoutInfo.begin();
- }
-
- RemoveWordsFromParagraph( wordIndex,
- numberOfWords,
- lineHeightOffset,
- inputParagraphLayout );
-
- if( !TestEqual( inputParagraphLayout, resultParagraphLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
- tet_printf( " input : [%s]\n", input.c_str() );
- tet_printf( " result : [%s]\n", GetText( resultParagraphLayout ).c_str() );
- tet_printf( " expected result : [%s]\n\n", result.c_str() );
-
- Print(inputParagraphLayout); std::cout << std::endl << std::endl;
- Print(resultParagraphLayout); std::cout << std::endl;
- return false;
- }
-
- return true;
-}
-
-/**
- * Tests inserts, removes and updates operation in the given \e input text and checks with the given \e result.
- *
- * If the test fails it prints a short description and the line where this function was called.
- *
- * @param description Short description of the experiment.
- * @param operation Type of update operation (insert, remove, replace)
- * @param input The input text.
- * @param position Where to insert, remove or replace text.
- * @param numberOfCharacters Number of characters to remove or replace.
- * @param inputText Inserted or updated text.
- * @param lineHeightOffset Offset between lines.
- * @param result Expected result.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestUpdateTextInfo( const std::string& description,
- UpdateTextInfoOperation operation,
- const std::string& input,
- std::size_t position,
- std::size_t numberOfCharacters,
- const std::string& inputText,
- float lineHeightOffset,
- const std::string& result,
- const char* location )
-{
- tet_printf( "%s\n", description.c_str() );
-
- // Create layout info for the input.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& inputLayout( relayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( input, inputStyledText, true );
-
- TextViewProcessor::CreateTextInfo( inputStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- relayoutData );
-
- // Create layout info for the result.
- Toolkit::Internal::TextView::RelayoutData resultRelayoutData;
- TextViewProcessor::TextLayoutInfo& resultLayout( resultRelayoutData.mTextLayoutInfo );
-
- MarkupProcessor::StyledTextArray resultStyledText;
- MarkupProcessor::GetStyledTextArray( result, resultStyledText, true );
-
- TextViewProcessor::CreateTextInfo( resultStyledText,
- Toolkit::Internal::TextView::LayoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true ),
- resultRelayoutData );
-
- // Choose operation and call appropiate UpdateTextInfo() method.
- const Toolkit::Internal::TextView::LayoutParameters layoutParameters( Toolkit::TextView::SplitByNewLineChar,
- Toolkit::TextView::Original,
- Toolkit::TextView::Original,
- static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ),
- Toolkit::TextView::Center,
- PointSize( lineHeightOffset ),
- true );
-
- switch( operation )
- {
- case Insert:
- {
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( inputText, inputStyledText, true );
-
- TextViewProcessor::UpdateTextInfo( position,
- inputStyledText,
- layoutParameters,
- relayoutData );
- break;
- }
- case Remove:
- {
- TextViewProcessor::UpdateTextInfo( position,
- numberOfCharacters,
- layoutParameters,
- relayoutData,
- TextViewProcessor::CLEAR_TEXT );
- break;
- }
- case Replace:
- {
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( inputText, inputStyledText, true );
-
- TextViewProcessor::UpdateTextInfo( position,
- numberOfCharacters,
- inputStyledText,
- layoutParameters,
- relayoutData );
- break;
- }
- default:
- {
- tet_printf( "TestUpdateTextInfo: unknown update operation. %s\n", location );
- return false;
- }
- }
-
- if( !TestEqual( inputLayout, resultLayout ) )
- {
- tet_printf( "Fail. different layout info. %s\n", location );
-
- // std::cout << " result : "; Print( inputLayout );
- // std::cout << " expected result : "; Print( resultLayout );
- return false;
- }
-
- return true;
-}
-
-} // namespace
-
-
-int UtcDaliTextViewCreateTextInfo(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCreateTextInfo : ");
-
- // Metrics for characters
-
- // Font size = 10
- // size : [9.48351, 9.48351]
- // advance : 9.48351
- // bearing : 8.53516
- // ascender : 8.53516
-
- // Font size = 12
- // size : [11.3802, 11.3802]
- // advance : 11.3802
- // bearing : 10.2422
- // ascender : 10.2422
-
- // Font size = 14
- // size : [13.2769, 13.2769]
- // advance : 13.2769
- // bearing : 11.9492
- // ascender : 11.9492
-
- const float HEIGHT_10( 9.48351f );
- const float ADVANCE_10( 9.48351f );
- const float BEARING_10( 8.53516f );
- const float ASCENDER_10( 8.53516f );
-
- const float HEIGHT_12( 11.3802f );
- const float ADVANCE_12( 11.3802f );
- const float BEARING_12( 10.2422f );
- const float ASCENDER_12( 10.2422f );
-
-
- // Generate a text.
- Toolkit::Internal::TextView::RelayoutData relayoutData;
- TextViewProcessor::TextLayoutInfo& textLayoutInfo( relayoutData.mTextLayoutInfo );
-
- std::string text( "Hel<font size='10'>lo wo</font>rld!\n"
- "\n" );
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( text, styledText, true );
-
- TextViewProcessor::CreateTextInfo( styledText,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData );
-
-
- // Build the text info with metric values.
-
- // Characters
-
- TextViewProcessor::CharacterLayoutInfo layoutInfo10; // ( [lo wo])
- layoutInfo10.mSize.height = HEIGHT_10;
- layoutInfo10.mSize.width = ADVANCE_10;
- layoutInfo10.mBearing = BEARING_10;
- layoutInfo10.mAscender = ASCENDER_10;
- TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
- layoutInfo12.mSize.height = HEIGHT_12;
- layoutInfo12.mSize.width = ADVANCE_12;
- layoutInfo12.mBearing = BEARING_12;
- layoutInfo12.mAscender = ASCENDER_12;
-
- // Words
-
- TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
-
- // Hello
- wordLayout1.mSize = Size( 3.f * ADVANCE_12 + 2.f * ADVANCE_10, HEIGHT_12 );
- wordLayout1.mAscender = ASCENDER_12;
- wordLayout1.mType = TextViewProcessor::NoSeparator;
-
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
-
- // (white space)
- wordLayout2.mSize = Size( ADVANCE_10, HEIGHT_10 );
- wordLayout2.mAscender = ASCENDER_10;
- wordLayout2.mType = TextViewProcessor::WordSeparator;
- wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
-
- // world!
- wordLayout3.mSize = Size( 2.f * ADVANCE_10 + 4.f * ADVANCE_12, HEIGHT_12 );
- wordLayout3.mAscender = ASCENDER_12;
- wordLayout3.mType = TextViewProcessor::NoSeparator;
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
-
- // (new paragraph character)
- wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
- wordLayout4.mAscender = ASCENDER_12;
- wordLayout4.mType = TextViewProcessor::ParagraphSeparator;
- layoutInfo12.mSize.width = 0.f;
- wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new paragraph char)
-
- // Paragraphs
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayout1, paragraphLayout2, paragraphLayout3;
-
- paragraphLayout1.mSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, HEIGHT_12 );
- paragraphLayout1.mAscender = ASCENDER_12;
- paragraphLayout1.mNumberOfCharacters = 13;
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
- paragraphLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
-
- paragraphLayout2.mSize = Size( 0.f, HEIGHT_12 );
- paragraphLayout2.mAscender = ASCENDER_12;
- paragraphLayout2.mNumberOfCharacters = 1;
- paragraphLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
-
- paragraphLayout3.mSize = Size( 0.f, HEIGHT_12 );
-
- // Text (layout)
- TextViewProcessor::TextLayoutInfo textLayout;
-
- textLayout.mWholeTextSize = Size( 5.f * ADVANCE_10 + 7.f * ADVANCE_12, 3.f * HEIGHT_12 );
- textLayout.mMaxWordWidth = 2.f * ADVANCE_10 + 4.f * ADVANCE_12;
- textLayout.mNumberOfCharacters = 14;
- textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout1 );
- textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout2 );
- textLayout.mParagraphsLayoutInfo.push_back( paragraphLayout3 );
-
- if(!TestEqual( textLayout, textLayoutInfo ))
- {
- std::cout << "Layout fails" << std::endl;
- Print(textLayout); std::cout << std::endl;
- Print(textLayoutInfo); std::cout << std::endl;
- }
-
- DALI_TEST_CHECK( TestEqual( textLayout, textLayoutInfo ) );
- END_TEST;
-}
-
-int UtcDaliTextViewSplitWord(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitWord : ");
-
- struct SplitWordTest splitWordTests[] =
- {
- {
- std::string( "Split word, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- 0,
- std::string( "" ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- },
- {
- std::string( "Split word, position 8." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- 8,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- std::string( "" ),
- },
- {
- std::string( "Split word, position 2." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- 2,
- std::string( "<font size='10'>He</font>" ),
- std::string( "<font size='12'>ll</font><font size='10'>oooo</font>" ),
- },
- {
- std::string( "Split word, position 3." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- 3,
- std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
- std::string( "<font size='12'>l</font><font size='10'>oooo</font>" ),
- },
- {
- std::string( "Split word, position 4." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- 4,
- std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
- std::string( "<font size='10'>oooo</font>" ),
- },
- };
- const std::size_t numberOfTests( 5u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const SplitWordTest& test = splitWordTests[index];
-
- if( !TestSplitWord( test.description, test.input, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewUpdateTextInfo(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewUpdateTextInfo : ");
-
- struct UpdateTextInfoTest updateTextInfoTest[] =
- {
- // Remove operations
-
- {
- std::string( "Remove from new paragraph character to first character next paragraph." ),
- Remove,
- std::string("Hello world\nhello world."),
- 11,
- 2,
- std::string(""),
- 0.f,
- std::string("Hello worldello world."),
- },
- {
- std::string( "Replace style from new paragraph character to first character next paragraph." ),
- Replace,
- std::string("Hello world\nhello world."),
- 11,
- 2,
- std::string("<b>\nh</b>"),
- 0.f,
- std::string("Hello world<b>\nh</b>ello world."),
- },
- {
- std::string( "Remove from the beginning to the middle of last word." ),
- Remove,
- std::string("Hello world, hello world."),
- 0,
- 22,
- std::string(), // Not used.
- 0.f,
- std::string("ld."),
- },
- {
- std::string( "Remove from the beginning to the middle of the text." ),
- Remove,
- std::string("Hello world hello world."),
- 0,
- 12,
- std::string(), // Not used.
- 0.f,
- std::string("hello world."),
- },
- // Remove within the same word:
- // * within the same group of characters with same style.
- {
- std::string( "Remove within the same word, within the same group of characters with same style" ),
- Remove,
- std::string("Hello <font size='30'>world\nhello</font> world"),
- 7,
- 3,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello <font size='30'>wd\nhello</font> world" )
- },
- // * whole group of characters (merge adjacent group of characters)
- {
- std::string( "Remove within the same word, whole group of characters (merge adjacent group of characters)" ),
- Remove,
- std::string("Hello <font size='30'>w<font size='20'>orl</font>d\nhello</font> world"),
- 7,
- 3,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello <font size='30'>wd\nhello</font> world" )
- },
- // * whole group of characters (don't merge adjacent gtoup of characters)
- {
- std::string( "Remove within the same word, whole group of characters (don't merge adjacent gtoup of characters)" ),
- Remove,
- std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
- 7,
- 3,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello <font size='30'>w</font><font size='10'>d\nhello</font> world" )
- },
- // * Remove whole word (merge words)
- {
- std::string( "Remove within the same word, whole word (merge words)" ),
- Remove,
- std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
- 5,
- 1,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello<font size='30'>w</font>orl<font size='10'>d\nhello</font> world" )
- },
- // * Remove whole word (don't merge words)
- {
- std::string( "Remove within the same word, whole word (don't merge words)" ),
- Remove,
- std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
- 6,
- 5,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello <font size='10'>\nhello</font> world" )
- },
- // * Remove whole word (merge paragraphs)
- {
- std::string( "Remove within the same word, whole word (merge paragraphs)" ),
- Remove,
- std::string("Hello <font size='30'>w</font>orl<font size='10'>d\nhello</font> world"),
- 11,
- 1,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello <font size='30'>w</font>orl<font size='10'>dhello</font> world" )
- },
- // * Remove RTL text within LTR
- {
- std::string( "Remove within the same paragraph, RTL text within LTR." ),
- Remove,
- std::string("Hello world, שלום עולם, hello world"),
- 10,
- 15,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello worlello world" )
- },
- // * Remove whole paragraph
- {
- std::string( "Remove whole paragraph" ),
- Remove,
- std::string("Hello world, hello world\n"
- "Hello world, hello world\n"
- "Hello world, hello world\n"
- "Hello world, hello world\n"),
- 25,
- 25,
- std::string(), // Not used.
- 0.f,
- std::string("Hello world, hello world\n"
- "Hello world, hello world\n"
- "Hello world, hello world\n"),
- },
- {
- std::string( "Remove whole paragraph" ),
- Remove,
- std::string("Hello world, hello world\n"
- "H"),
- 25,
- 1,
- std::string(), // Not used.
- 0.f,
- std::string("Hello world, hello world\n"),
- },
-
-
- // Insert operations
- {
- std::string( "insert some text" ),
- Insert,
- std::string("inpuext"),
- 4,
- 0, // Not used
- std::string( "t t" ),
- 0.f,
- std::string( "input text" )
- },
- {
- std::string( "Insert text at the end" ),
- Insert,
- std::string("touch "),
- 6,
- 0,
- std::string("me\nhello"),
- 0.f,
- std::string("touch me\nhello")
- },
-
- // Replace operations.
- {
- std::string( "Replace style from the beginning to some point in the middle of the text." ),
- Replace,
- std::string( "Hello <font color='green'>world</font>" ),
- 0,
- 7,
- std::string( "<font color='red'>Hello w</font>" ),
- 0.f,
- std::string( "<font color='red'>Hello w</font><font color='green'>orld</font>" )
- },
- {
- std::string( "Replace style from the middle of the text to the end." ),
- Replace,
- std::string( "Touch me\nhello" ),
- 6,
- 8,
- std::string( "<b>me\nhello</b>" ),
- 0.f,
- std::string( "Touch <b>me\nhello</b>" )
- },
- {
- std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 1." ),
- Remove,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 8,
- std::string( "" ),
- 0.f,
- std::string( "Touch \nworld" )
- },
- {
- std::string( "Insert styled text in the middle of a text. Previous: Replace style from the middle of the text 1." ),
- Insert,
- std::string( "Touch \nworld" ),
- 6,
- 0,
- std::string( "<b>me\nhello</b>" ),
- 0.f,
- std::string( "Touch <b>me\nhello</b>\nworld" )
- },
- {
- std::string( "Replace style from the middle of the text 1." ),
- Replace,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 8,
- std::string( "<b>me\nhello</b>" ),
- 0.f,
- std::string( "Touch <b>me\nhello</b>\nworld" )
- },
- {
- std::string( "Remove characters from text. Previous next test:Replace style from the middle of the text 2." ),
- Remove,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 9,
- std::string( "" ),
- 0.f,
- std::string( "Touch world" )
- },
- {
- std::string( "Replace style from the middle of the text 2." ),
- Replace,
- std::string( "Touch me\nhello\nworld" ),
- 6,
- 9,
- std::string( "<b>me\nhello\n</b>" ),
- 0.f,
- std::string( "Touch <b>me\nhello\n</b>world" )
- },
- };
- const std::size_t numberOfTests( 22u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const UpdateTextInfoTest& test = updateTextInfoTest[index];
-
- if( !TestUpdateTextInfo( test.description, test.operation, test.input, test.position, test.numberOfCharacters, test.inputText, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewSplitParagraph(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitParagraph : ");
-
- struct SplitParagraphTest splitParagraphTests[] =
- {
- {
- std::string( "Split paragraph, wordPosition 0, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 0,
- 0,
- 0,
- 3.f,
- std::string( "" ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- },
- {
- std::string( "Split paragraph, wordPosition 10, position 4." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 10,
- 4,
- 36,
- 0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- std::string( "" ),
- },
- {
- std::string( "Split paragraph, wordPosition 2, position 4." ),
- std::string("<font size='10'>Hello </font>wor<font size='12'>ld, hello wo</font>rld"),
- 2,
- 4,
- 10,
- 0.f,
- std::string("<font size='10'>Hello </font>wor<font size='12'>l</font>"),
- std::string("<font size='12'>d, hello wo</font>rld")
- },
- {
- std::string( "Split paragraph, wordPosition 6, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 6,
- 0,
- 21,
- 0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום " ),
- std::string( "עולם text text" ),
- },
- {
- std::string( "Split paragraph, wordPosition 4, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 4,
- 0,
- 17,
- 0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> " ),
- std::string( "שלום עולם text text" ),
- },
- {
- std::string( "Split paragraph2, wordPosition 8, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 8,
- 0,
- 27,
- 6.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם " ),
- std::string( "text text" ),
- },
- };
- const std::size_t numberOfTests( 6u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const SplitParagraphTest& test = splitParagraphTests[index];
-
- if( !TestSplitParagraph( test.description,
- test.input,
- test.wordIndex,
- test.characterIndex,
- test.characterParagraphIndex,
- test.lineHeightOffset,
- test.firstResult,
- test.lastResult,
- TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMergeWord01(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeWord01 : ");
-
- struct MergeWordsTest mergeWordsTests[] =
- {
- {
- std::string( "Merge words with same style." ),
- std::string( "Hel" ),
- std::string( "lo" ),
- std::string( "Hello" ),
- },
- {
- std::string( "Merge words with different styles." ),
- std::string( "<font size='10>Hel</font>" ),
- std::string( "<font size='20'>lo</font>" ),
- std::string( "<font size='10'>Hel</font><font size='20'>lo</font>" )
- },
- };
- const std::size_t numberOfTests( 2u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const MergeWordsTest& test = mergeWordsTests[index];
-
- if( !TestMergeWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMergeWord02(void)
-{
- // Negative test.
- // It test white spaces and new paragraph characters can't be merged to other words.
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeWord02 : ");
-
- // Generate three words
-
- Toolkit::Internal::TextView::RelayoutData relayoutData01;
- Toolkit::Internal::TextView::RelayoutData relayoutData02;
- Toolkit::Internal::TextView::RelayoutData relayoutData03;
- TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
- TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
- TextViewProcessor::TextLayoutInfo& textLayoutInfo03( relayoutData03.mTextLayoutInfo );
-
- std::string text01( " " );
- std::string text02( "\n" );
- std::string text03( "a" );
- MarkupProcessor::StyledTextArray styledText01;
- MarkupProcessor::StyledTextArray styledText02;
- MarkupProcessor::StyledTextArray styledText03;
- MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
- MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
- MarkupProcessor::GetStyledTextArray( text03, styledText03, true );
-
- TextViewProcessor::CreateTextInfo( styledText01,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData01 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo01;
-
- wordLayoutInfo01 = *( *textLayoutInfo01.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
-
- wordLayoutInfo02 = *( *textLayoutInfo02.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText03,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData03 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
-
- wordLayoutInfo03 = *( *textLayoutInfo03.mParagraphsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- // Test MergeWord() asserts if white spaces or new paragraph chars are merged.
- bool assert1 = false;
- bool assert2 = false;
- bool assert3 = false;
- bool assert4 = false;
- bool assert5 = false;
- bool assert6 = false;
-
- try
- {
- MergeWord( wordLayoutInfo01,
- wordLayoutInfo02 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert1 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo01,
- wordLayoutInfo03 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert2 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo02,
- wordLayoutInfo01 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert3 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo02,
- wordLayoutInfo03 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert4 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo03,
- wordLayoutInfo01 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert5 = true;
- }
- try
- {
- MergeWord( wordLayoutInfo03,
- wordLayoutInfo02 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeWord(). ERROR: White spaces or new paragraph characters can't be merged with other words.\"", TEST_LOCATION );
- assert6 = true;
- }
-
- if( assert1 && assert2 && assert3 && assert4 && assert5 && assert6 )
- {
- tet_result( TET_PASS );
- }
- else
- {
- tet_result( TET_FAIL );
- }
- END_TEST;
-}
-
-int UtcDaliTextViewMergeParagraph01(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeParagraph01 : ");
-
- struct MergeParagraphsTest mergeParagraphsTests[] =
- {
- {
- std::string( "Merge a void first paragraph." ),
- std::string( "" ),
- std::string( "Hello world, this is a whole paragraph" ),
- 2.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- {
- std::string( "Merge a void last paragraph." ),
- std::string( "Hello world, this is a whole paragraph" ),
- std::string( "" ),
- 0.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- {
- std::string( "Merge paragraphs: last starting with RTL text and first ending with RTL" ),
- std::string( "Hello world, שלום" ),
- std::string( " עולם, hello world." ),
- 6.f,
- std::string( "Hello world, שלום עולם, hello world." )
- },
- {
- std::string( "Merge paragraphs and don't merge last and first words." ),
- std::string( "Hello world, " ),
- std::string( "שלום עולם, hello world." ),
- 3.f,
- std::string( "Hello world, שלום עולם, hello world." )
- },
- {
- std::string( "Merge paragraphs. Don't merge words" ),
- std::string( "Hello world," ),
- std::string( " this is a whole paragraph" ),
- 0.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- {
- std::string( "Merge paragraphs. Merge words" ),
- std::string( "Hello world, th" ),
- std::string( "is is a whole paragraph" ),
- 0.f,
- std::string( "Hello world, this is a whole paragraph" )
- },
- };
- const std::size_t numberOfTests( 6u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const MergeParagraphsTest& test = mergeParagraphsTests[index];
-
- if( !TestMergeParagraphs( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewMergeParagraph02(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeParagraph02 : ");
-
- Toolkit::Internal::TextView::RelayoutData relayoutData01;
- Toolkit::Internal::TextView::RelayoutData relayoutData02;
- TextViewProcessor::TextLayoutInfo& textLayoutInfo01( relayoutData01.mTextLayoutInfo );
- TextViewProcessor::TextLayoutInfo& textLayoutInfo02( relayoutData02.mTextLayoutInfo );
-
- std::string text01( "Hello world\n" );
- std::string text02( "hello world" );
- MarkupProcessor::StyledTextArray styledText01;
- MarkupProcessor::StyledTextArray styledText02;
- MarkupProcessor::GetStyledTextArray( text01, styledText01, true );
- MarkupProcessor::GetStyledTextArray( text02, styledText02, true );
-
- TextViewProcessor::CreateTextInfo( styledText01,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData01 );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo01;
-
- paragraphLayoutInfo01 = *textLayoutInfo01.mParagraphsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::ParagraphLayoutInfo paragraphLayoutInfo02;
-
- paragraphLayoutInfo02 = *textLayoutInfo02.mParagraphsLayoutInfo.begin();
-
- bool assert1 = false;
-
- try
- {
- MergeParagraph( paragraphLayoutInfo01,
- paragraphLayoutInfo02 );
- }
- catch( Dali::DaliException& e )
- {
- tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() );
- DALI_TEST_EQUALS( e.mCondition, "!\"TextViewProcessor::MergeParagraph(). ERROR: A paragraph can't be merged to another paragraph which finishes with a new paragraph character.\"", TEST_LOCATION );
- assert1 = true;
- }
-
- if( assert1 )
- {
- tet_result( TET_PASS );
- }
- else
- {
- tet_result( TET_FAIL );
- }
- END_TEST;
-}
-
-int UtcDaliTextViewRemoveCharactersFromWord(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeWord02 : ");
-
- struct RemoveCharactersFromWordTest removeCharactersFromWordTests[] =
- {
- {
- std::string( "Delete 0 characters." ),
- std::string( "Hello" ),
- 3,
- 0,
- std::string( "Hello" ),
- },
- {
- std::string( "Delete within the same group of characters. Starting from the beginning" ),
- std::string( "Hello" ),
- 0,
- 3,
- std::string( "lo" ),
- },
- {
- std::string( "Delete within the same group of characters. Somewhere in the middle" ),
- std::string( "Hello" ),
- 2,
- 2,
- std::string( "Heo" ),
- },
- {
- std::string( "Delete within the same group of characters. Starting somewhere in the middle to the end" ),
- std::string( "Hello" ),
- 3,
- 2,
- std::string( "Hel" ),
- },
- {
- std::string( "Delete within the same group of characters. Finish just before a new one." ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
- 1,
- 2,
- std::string( "<font size='10'>H</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
- },
- {
- std::string( "Delete starting in one group of characters and finishing in a different one. No merge of groups." ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
- 2,
- 3,
- std::string( "<font size='10'>He</font><font size='20'>Wo</font><font size='30'>rld</font>" ),
- },
- {
- std::string( "Delete within the same group of characters. Starting just after a different one." ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
- 7,
- 2,
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>d</font>" ),
- },
- {
- std::string( "Delete whole group of characters. No merge" ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
- 3,
- 4,
- std::string( "<font size='10'>Hel</font><font size='30'>rld</font>" ),
- },
- {
- std::string( "Delete whole group of characters and part of the adjacent ones. No merge" ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='30'>rld</font>" ),
- 2,
- 6,
- std::string( "<font size='10'>He</font><font size='30'>ld</font>" ),
- },
- {
- std::string( "Delete whole group of characters. Merge" ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
- 3,
- 4,
- std::string( "<font size='10'>Helrld</font>" ),
- },
- {
- std::string( "Delete whole group of characters and part of the adjacent ones. Merge" ),
- std::string( "<font size='10'>Hel</font><font size='20'>loWo</font><font size='10'>rld</font>" ),
- 2,
- 6,
- std::string( "<font size='10'>Held</font>" ),
- },
- };
- const std::size_t numberOfTests( 11u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const RemoveCharactersFromWordTest& test = removeCharactersFromWordTests[index];
-
- if( !TestRemoveCharactersFromWord( test.description, test.input, test.position, test.numberOfCharacters, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
-
-int UtcDaliTextViewRemoveWordsFromParagraph(void)
-{
- // Note: Currently RemoveWordsFromParagraph() function is only used to remove a number of words from the beginning, or
- // from a given index to the end.
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewRemoveWordsFromParagraph : ");
- struct RemoveWordsFromParagraphTest removeWordsFromParagraphTest[] =
- {
- {
- std::string( "Delete 0 words." ),
- std::string( "Hello hello, שלום עולם hello hello" ),
- 0,
- 0,
- 2.f,
- std::string( "Hello hello, שלום עולם hello hello" ),
- },
- {
- std::string( "Delete from the middle to the end." ),
- std::string( "Hello hello, שלום עולם hello hello" ),
- 4,
- 7,
- 0.f,
- std::string( "Hello hello, " ),
- },
- {
- std::string( "Delete from the beginning to the middle." ),
- std::string( "Hello hello, שלום עולם hello hello" ),
- 0,
- 8,
- 6.f,
- std::string( "hello hello" ),
- },
- };
- const std::size_t numberOfTests( 3u );
-
- for( std::size_t index = 0u; index < numberOfTests; ++index )
- {
- const RemoveWordsFromParagraphTest& test = removeWordsFromParagraphTest[index];
-
- if( !TestRemoveWordsFromParagraph( test.description, test.input, test.wordIndex, test.numberOfWords, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
- END_TEST;
-}
utc-Dali-ItemView.cpp
utc-Dali-KeyboardFocusManager.cpp
utc-Dali-ScrollViewEffect.cpp
- utc-Dali-TextInput.cpp
utc-Dali-StyleManager.cpp
utc-Dali-RadioButton.cpp
)
namespace
{
-//
-// Note: To avoid escaping double quotes single quotes are used and then replaced
-// before parsing. JSON uses double quotes
-//
-
- std::string JSON_TEXT_ACTOR("\
-{ \
- 'templates': \
- { \
- 'basic-text': \
- { \
- 'type':'TextActor', \
- 'text':'Template Hello', \
- 'size': [150,170,1], \
- 'position':[-10,10,0] \
- } \
- }, \
- 'styles': \
- { \
- 'basic-text': \
- { \
- 'text':'Hello', \
- 'font':'', \
- 'parent-origin':[0.0,0.0,0], \
- 'anchor-point' :[0.5,0.5,0], \
- 'size': [150,170,1], \
- 'position':[-10,10,0] \
- } \
- }, \
- 'animations': \
- { \
- 'rotate': \
- { \
- 'duration': 10, \
- 'properties': \
- [ \
- { \
- 'actor':'text', \
- 'property':'rotation', \
- 'value':[0, 3, 0, 0], \
- 'alpha-function': 'EASE_IN_OUT', \
- 'time-period': {'delay': 0, 'duration': 3 } \
- } \
- ] \
- } \
- }, \
- 'stage': \
- [ \
- { \
- 'name':'text', \
- 'type':'basic-text', \
- 'text':'Hello' \
- }, \
- { \
- 'name':'text2', \
- 'type':'basic-text', \
- 'text':'Hello', \
- 'signals': \
- [ \
- { 'name': 'on-stage', 'action':'set', 'actor':'text2', 'property':'text', 'value':'Jaylo' } \
- ] \
- } \
- ], \
- 'other': \
- [ \
- { \
- 'name':'other-text', \
- 'type':'basic-text', \
- 'text':'Hello' \
- } \
- ] \
-} \
-");
-
-
- std::string JSON_CORE_ACTOR_TREE("\
-{ \
- 'templates': \
- { \
- 'my-camera': { \
- 'type':'CameraActor', \
- 'camera-type':'FreeLook', \
- 'field-of-view': 0.125, \
- 'aspect-ratio':5.0, \
- 'near-plane-distance': 100, \
- 'far-plane-distance': 200 \
- }, \
- 'basic-text': { \
- 'type':'TextActor', \
- 'text':'Hello', \
- 'font':'Freesans', \
- 'smooth-edge':0.2, \
- 'position': [-10.0, 10.0, -1000.0], \
- 'size': [300.0, 250.0, 0.0] \
- } \
- }, \
- 'styles': \
- { \
- 'theme2-text': { \
- 'type':'TextActor', \
- 'text':'Hello', \
- 'font':'Freesans', \
- 'smooth-edge':0.8 \
- } \
- }, \
- 'stage': \
- [ \
- {'name':'txt1', \
- 'type':'TextActor', \
- 'text':'Hello World', \
- 'font':'freesans', \
- 'parent-origin':'CENTER', \
- 'actors': \
- [ \
- { 'type':'basic-text', 'text':'Hello', 'position-y':50 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':100 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':150 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':200 }, \
- { 'type':'basic-text', 'text':'Hello', 'position-y':250 } \
- ] \
- } \
- ] \
-} \
-");
-
std::string ReplaceQuotes(const std::string &in_s)
{
test_return_value = TET_PASS;
}
-int UtcDaliBuilderTextActorCreate(void)
-{
- ToolkitTestApplication application;
- Stage stage = Stage::GetCurrent();
-
- tet_infoline(" UtcDaliBuilderTextActorCreate");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- TextActor actor( TextActor::DownCast( builder.Create("basic-text") ) );
-
- DALI_TEST_CHECK( actor );
-
- stage.GetRootLayer().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Vector3 v;
-
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
-
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
-
- DALI_TEST_CHECK(actor.GetText() == "Template Hello");
-
- actor = TextActor::DownCast( builder.Create("*(&^") );
- DALI_TEST_CHECK(!actor);
-
- END_TEST;
-}
-
-int UtcDaliBuilderTextActorCreateAnimation(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderTextActorCreateAnimation");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- Animation anim = builder.CreateAnimation("rotate");
- DALI_TEST_CHECK( anim );
-
- DALI_TEST_CHECK( 10.0f == anim.GetDuration() );
-
- END_TEST;
-}
-
-int UtcDaliBuilderTextActorApplyFromStyle(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderTextActorApplyFromStyle");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- TextActor actor = TextActor::New("a");
-
- builder.ApplyStyle("basic-text", actor);
-
- DALI_TEST_CHECK( actor );
-
- Stage::GetCurrent().GetRootLayer().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Vector3 v;
-
- v = actor.GetCurrentPosition();
- DALI_TEST_CHECK(v.x == -10.0);
- DALI_TEST_CHECK(v.y == 10.0);
- DALI_TEST_CHECK(v.z == 0.0);
-
- v = actor.GetCurrentSize();
- DALI_TEST_CHECK(v.x == 150.0);
- DALI_TEST_CHECK(v.y == 170.0);
- DALI_TEST_CHECK(v.z == 1.0);
-
- DALI_TEST_CHECK(actor.GetText() == "Hello");
-
- END_TEST;
-}
-
-int UtcDaliBuilderAddActors(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderAddActors");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
-
- END_TEST;
-}
-
-int UtcDaliBuilderAddActorsOther(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderAddActorsOther");
-
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( "other", rootActor );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("other-text") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK(actor.GetText() == "Hello");
-
- END_TEST;
-}
-
-
-int UtcDaliBuilderStyles(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderStyles");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_CORE_ACTOR_TREE));
-
- BaseHandle handle = builder.Create("my-camera");
- CameraActor camera = CameraActor::DownCast(handle);
-
- DALI_TEST_CHECK(camera);
-
- Property::Value v;
-
- v = camera.GetProperty( camera.GetPropertyIndex("field-of-view") );
- DALI_TEST_CHECK( 0.125f == v.Get<float>() );
-
- v = camera.GetProperty( camera.GetPropertyIndex("aspect-ratio") );
- DALI_TEST_CHECK( 5.0f == v.Get<float>() );
-
- handle = builder.Create("basic-text");
- TextActor textActor = TextActor::DownCast(handle);
-
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
-
- DALI_TEST_CHECK( 0.2f == v.Get<float>() );
-
- // test ApplyStyle another
- builder.ApplyStyle("theme2-text", textActor);
-
- v = textActor.GetProperty( textActor.GetPropertyIndex("smooth-edge") );
- DALI_TEST_CHECK( 0.8f == v.Get<float>() );
-
- END_TEST;
-}
-
-int UtcDaliBuilderSetProperty(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderSetProperty");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- builder.AddActors( Stage::GetCurrent().GetRootLayer() );
-
- application.SendNotification();
- application.Render();
-
- TextActor actor = TextActor::DownCast( Stage::GetCurrent().GetRootLayer().FindChildByName("text2") );
-
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == "Jaylo" );
-
- END_TEST;
-}
-
-int UtcDaliBuilderCreateFromJson(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderCreateFromJson");
-
- Builder builder = Builder::New();
-
- TextActor actor = TextActor::DownCast( builder.CreateFromJson("foobar") );
-
- DALI_TEST_CHECK( !actor );
-
- actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
-
- DALI_TEST_CHECK( actor );
-
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
-
- END_TEST;
-}
-
-int UtcDaliBuilderApplyFromJson(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderApplyFromJson");
-
- Builder builder = Builder::New();
-
- TextActor actor = TextActor::DownCast(
- builder.CreateFromJson(
- ReplaceQuotes("{'type':'TextActor','text':'Hi'}") ) );
-
- DALI_TEST_CHECK( actor );
-
- DALI_TEST_CHECK( actor.GetText() == "Hi" );
-
- DALI_TEST_CHECK( !builder.ApplyFromJson(actor, ReplaceQuotes("foobar") ) );
-
- builder.ApplyFromJson(actor, ReplaceQuotes("{'text':'low'}") );
-
- DALI_TEST_CHECK( actor.GetText() == "low" );
-
- END_TEST;
-}
-
int UtcDaliBuilderQuitSignal(void)
{
ToolkitTestApplication application;
tet_infoline( "UtcDaliNavigationControlCreateNavigationTitleBar" );
ImageActor background = CreateSolidColorActor( Color::RED );
- TextStyle textStyle;
Stage stage = Stage::GetCurrent();
NavigationControl naviControl = NavigationControl::New();
stage.Add( naviControl );
- Toolkit::NaviTitleBarStyle titleBarStyle( background, textStyle, textStyle, 720, 111, 68, 48, 34, 16, 11, 45, 63, 26, 14, 22 );
- naviControl.CreateNavigationTitleBar( titleBarStyle, titleBarStyle );
-
Page naviItem = Page::New();
PushButton firstControl = PushButton::New();
int UtcDaliRadioButtonLabelActor(void)
{
- ToolkitTestApplication application;
-
- TextView actor1 = TextView::New( "test actor 1" );
-
- RadioButton radioButton = RadioButton::New( actor1 );
- DALI_TEST_CHECK( actor1 == radioButton.GetLabel() );
-
- TextView actor2 = TextView::New( "test actor 2" );
- radioButton.SetLabel( actor2 );
- DALI_TEST_CHECK( actor2 == radioButton.GetLabel() );
-
+ // TODO
END_TEST;
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali/integration-api/events/key-event-integ.h>
-
-using namespace Dali;
-using namespace Toolkit;
-
-
-int UtcDaliTextInputSetActiveStyle(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of Style to newly added text");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test String<i>ab</i>" ;
- const std::string plainString = "Test String";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Confirm markup text is a plain string ");
- DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
-
- TextStyle style;
- style.SetItalics( true );
-
- tet_infoline("Apply style to TextInput");
- textInput.SetActiveStyle( style );
-
- Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
- Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
-
- application.SendNotification();
- application.Render();
-
- application.ProcessEvent(eventA);
- application.SendNotification();
- application.Render();
-
- application.ProcessEvent(eventB);
- application.SendNotification();
- application.Render();
-
- retreivedMarkupString = textInput.GetMarkupText();
-
- DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputApplyStyleToSelectedText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing application of style to selected text ");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test <i>String</i> to style";
- const std::string plainString = "Test String to style";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Confirm markup text is a plain string ");
- DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
-
- TextStyle style;
- style.SetItalics( true );
-
- textInput.SelectText( 5, 11 );
-
- tet_infoline("Apply style to selected text");
- textInput.ApplyStyle( style );
-
- application.Render();
-
- retreivedMarkupString = textInput.GetMarkupText();
-
- DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputApplyStyleToAll(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing application of style to all text ");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "<i>Test String to style</i>";
- const std::string plainString = "Test String to style";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Confirm markup text is a plain string ");
- DALI_TEST_EQUALS( plainString,textInput.GetText(), TEST_LOCATION);
-
- TextStyle style;
- style.SetItalics( true );
-
- tet_infoline("Apply style to all text");
- textInput.ApplyStyleToAll( style );
-
- application.Render();
-
- retreivedMarkupString = textInput.GetMarkupText();
-
- DALI_TEST_EQUALS( styledString, retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputGetStyleAtCursor(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Test getting style at cursor");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- const std::string styledString = "Test Stringa<i>b</i>" ;
- const std::string plainString = "Test String";
- textInput.SetInitialText( plainString );
-
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable(true);
-
- tet_infoline("Confirm style at cursor is default(plain)");
- TextStyle style;
- Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
- application.ProcessEvent(eventA);
- application.SendNotification();
- application.Render();
-
- TextStyle retreivedStyleAtCursor = textInput.GetStyleAtCursor();
-
- DALI_TEST_CHECK( style == retreivedStyleAtCursor );
- DALI_TEST_CHECK( !retreivedStyleAtCursor.IsItalicsEnabled() );
-
- tet_infoline("Set style before adding new character");
- style.SetItalics( true );
- textInput.SetActiveStyle( style );
-
- Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
- application.ProcessEvent(eventB);
- application.SendNotification();
- application.Render();
-
- tet_infoline("Confirm style at cursor is correct style");
- retreivedStyleAtCursor = textInput.GetStyleAtCursor();
-
- DALI_TEST_CHECK( retreivedStyleAtCursor.IsItalicsEnabled() );
-
- tet_infoline("Confirm style at cursor is not a style that was not set");
- DALI_TEST_CHECK( !retreivedStyleAtCursor.IsUnderlineEnabled() );
-
- tet_infoline("Confirm markup text is correct");
- DALI_TEST_EQUALS( styledString, textInput.GetMarkupText(), TEST_LOCATION);
-
-
-
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetTextAlignment(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
- textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) );
-
- bool result = ( textInput.GetTextAlignment() & Alignment::HorizontalCenter ) ;
-
- DALI_TEST_CHECK( result );
-
- result = ( textInput.GetTextAlignment() & Alignment::HorizontalRight );
-
- DALI_TEST_CHECK( !result );
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetMultilinePolicy(void)
-{
- ToolkitTestApplication application;
-
- const TextView::MultilinePolicy MULTILINE_POLICIES[] = { TextView::SplitByNewLineChar, TextView::SplitByWord, TextView::SplitByChar };
- const unsigned int NUM_MULTILINE_POLICIES = sizeof( MULTILINE_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- Stage::GetCurrent().Add(textInput);
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_MULTILINE_POLICIES; ++epIndex )
- {
- textInput.SetMultilinePolicy( MULTILINE_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetMultilinePolicy(), MULTILINE_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetExceedEnabled(void)
-{
- ToolkitTestApplication application;
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- Stage::GetCurrent().Add(textInput);
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
utc-Dali-ItemLayout.cpp
utc-Dali-ItemView.cpp
utc-Dali-KeyboardFocusManager.cpp
- utc-Dali-MarkupProcessor.cpp
utc-Dali-MaskEffect.cpp
utc-Dali-NinePatchMaskEffect.cpp
utc-Dali-Popup.cpp
utc-Dali-ScrollViewEffect.cpp
utc-Dali-SuperBlurView.cpp
utc-Dali-SwirlEffect.cpp
- utc-Dali-TextInput.cpp
- utc-Dali-TextView.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location);
/**
- * Test whether two UTF32 strings are equal.
- * @param[in] str1 The first string
- * @param[in] str2 The second string
- * @param[in] location The TEST_LOCATION macro should be used here
- */
-template<>
-inline void DALI_TEST_EQUALS<const Integration::TextArray&>( const Integration::TextArray& str1, const Integration::TextArray& str2, const char* location)
-{
- if( !std::equal( str1.Begin(), str1.End(), str2.Begin() ) )
- {
- fprintf(stderr, "%s, checking '", location);
-
- for( unsigned int i = 0; i < str1.Count(); ++i )
- {
- fprintf(stderr, "%c", str1[i]);
- }
-
- fprintf(stderr, "' == '");
-
- for( unsigned int i = 0; i < str2.Count(); ++i )
- {
- fprintf(stderr, "%c", str2[i]);
- }
-
- fprintf(stderr, "'\n");
-
- tet_result(TET_FAIL);
- }
- else
- {
- tet_result(TET_PASS);
- }
-}
-
-/**
* Test whether one unsigned integer value is greater than another.
* Test succeeds if value1 > value2
* @param[in] value1 The first value
mTrace.PushCall("GetClosestImageSize", "");
}
-
/**
* @copydoc PlatformAbstraction::LoadResource()
*/
void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request)
{
std::ostringstream out;
- out << "Type:";
- if( request.GetType()->id == Integration::ResourceText )
- {
- out << "Text";
- }
- else
- {
- out << request.GetType()->id;
- }
- out << ", Path: " << request.GetPath() << std::endl ;
+ out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl;
mTrace.PushCall("LoadResource", out.str());
if(mRequest != NULL)
}
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
- */
-const std::string& TestPlatformAbstraction::GetDefaultFontFamily() const
-{
- mTrace.PushCall("GetDefaultFontFamily", "");
- return mGetDefaultFontFamilyResult;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
-float TestPlatformAbstraction::GetDefaultFontSize() const
-{
- mTrace.PushCall("GetDefaultFontSize", "");
- return mGetDefaultFontSizeResult;
-}
-
-PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const
-{
- mTrace.PushCall("GetFontLineHeightFromCapsHeight", "");
- // LineHeight will be bigger than CapsHeight, so return capsHeight + 1
- return PixelSize(capsHeight + 1);
-}
-
-/**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
-
-Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const
-{
- if( getBitmap )
- {
- mTrace.PushCall("GetGlyphData", "getBitmap:true");
- }
- else
- {
- mTrace.PushCall("GetGlyphData", "getBitmap:false");
- }
-
- // It creates fake metrics for the received characters.
-
- Integration::GlyphSet* set = new Dali::Integration::GlyphSet();
- Integration::BitmapPtr bitmapData;
-
- std::set<uint32_t> characters;
-
- for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it )
- {
- if( characters.find( it->character ) == characters.end() )
- {
- characters.insert( it->character );
- Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
-
- if( getBitmap )
- {
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
- bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
- PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
- memset( pixelBuffer, it->character, 64*64 );
- }
-
- set->AddCharacter(bitmapData, character);
- }
- }
-
- set->mLineHeight = 10.0f;
- set->mAscender = 9.0f;
- set->mUnitsPerEM = 2048.0f/64.0f;
- set->SetAtlasResourceId( textRequest.mTextureAtlasId );
- set->mFontHash = textRequest.mFontHash;
-
- return set;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
-
-Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const
-{
- mTrace.PushCall("GetCachedGlyphData", "");
-
- // It creates fake metrics and bitmap for received numeric characters '0' through '9'.
- Integration::GlyphSet* set = new Dali::Integration::GlyphSet();
- Integration::BitmapPtr bitmapData;
-
- std::set<uint32_t> characters;
-
- for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it )
- {
- if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() )
- {
- characters.insert( it->character );
- Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
-
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
- bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
- PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
- memset( pixelBuffer, it->character, 64*64 );
- set->AddCharacter(bitmapData, character);
- }
- }
-
- set->mLineHeight = 10.0f;
- set->mAscender = 9.0f;
- set->mUnitsPerEM = 2048.0f/64.0f;
- set->SetAtlasResourceId( textRequest.mTextureAtlasId );
- set->mFontHash = textRequest.mFontHash;
-
- return set;
-}
-
-
-/**
- * @copydoc PlatformAbstraction::GetGlobalMetrics()
- */
-void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const
-{
- globalMetrics.lineHeight = 10.0f;
- globalMetrics.ascender = 9.0f;
- globalMetrics.unitsPerEM = 2048.0f/64.0f;
- globalMetrics.underlineThickness = 2.f;
- globalMetrics.underlinePosition = 1.f;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetFontPath()
- */
-std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const
-{
- mTrace.PushCall("GetFontPath", "");
- return mGetFontPathResult;
-
- // Do nothing with arguments
-}
-
-/**
* @copydoc PlatformAbstraction::SetDpi()
*/
void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical)
}
/**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
- */
-const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const
-{
- mTrace.PushCall("GetFontFamilyForChars", "");
- return mGetDefaultFontFamilyResult;
-}
-
-/**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
- */
-bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const
-{
- mTrace.PushCall("AllGlyphsSupported", "");
- return true;
-}
-
-/**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
- */
-bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const
-{
- mTrace.PushCall("ValidateFontFamilyName", "");
- return true;
-}
-
-/**
- * @copydoc PlatformAbstraction::GetFontList()
- */
-void TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode, std::vector<std::string>& fonstList ) const
-{
- mFontListMode = mode;
- mTrace.PushCall("ValidateGetFontList", "");
-}
-
-/**
* @copydoc PlatformAbstraction::LoadFile()
*/
bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const
mTrace.PushCall("JoinLoaderThreads", "");
}
-void TestPlatformAbstraction::UpdateDefaultsFromDevice()
-{
- mTrace.PushCall("UpdateDefaultsFromDevice", "");
- mGetDefaultFontFamilyResult+=1.0f;
-}
-
Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory()
{
mTrace.PushCall("GetDynamicsFactory", "");
return NULL;
}
-bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics )
-{
- mTrace.PushCall("ReadGlobalMetricsFromCacheFile", "");
- globalMetrics = mReadGlobalMetrics; // Want to copy contents...
- return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write)
-}
-
-void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics )
-{
- // Copy so next read uses written values. TODO: Could add method
- // to turn this behaviour off for more extensive testing.
- mReadGlobalMetrics = globalMetrics;
- mReadGlobalMetricsResult = true;
-
- mTrace.PushCall("WriteGlobalMetricsToCacheFile", "");
-}
-
-bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector<Integration::GlyphMetrics>& glyphMetricsContainer )
-{
- mTrace.PushCall("ReadMetricsFromCacheFile", "");
- glyphMetricsContainer = mReadMetrics;
- return mReadMetricsResult; // Default false (will be set to true on subsequent write)
-}
-
-void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet )
-{
- // Copy so next read uses written values. TODO: Could add method
- // to turn this behaviour off for more extensive testing.
- const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList();
- mReadMetrics.clear();
- for(std::size_t i=0, end=charList.size(); i<end; ++i)
- {
- mReadMetrics.push_back(charList[i].second);
- }
- mReadMetricsResult = true;
-
- mTrace.PushCall("WriteMetricsToCacheFile", "");
-}
-
-
-void TestPlatformAbstraction::GetFileNamesFromDirectory( const std::string& directoryName,
- std::vector<std::string>& fileNames )
-{
- fileNames.push_back( std::string( "u1f004.png" ) );
- fileNames.push_back( std::string( "u1f0cf.png" ) );
- fileNames.push_back( std::string( "u1f170.png" ) );
- fileNames.push_back( std::string( "u1f601.png" ) );
-}
-
-
-Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const
-{
- Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
- image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 );
-
- mTrace.PushCall("GetGlyphImage", "");
-
- return image;
-}
-
-
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
mTrace.Reset();
mTrace.Enable(true);
memset(&mResources, 0, sizeof(Resources));
- memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics));
mSeconds=0;
mMicroSeconds=0;
mIsLoadingResult=false;
- mGetDefaultFontFamilyResult = "HelveticaNeue";
- mGetDefaultFontSizeResult=12.0f;
- mGetFontPathResult="helvetica-12";
- mReadMetricsResult=false;
- mReadGlobalMetricsResult=false;
if(mRequest)
{
case CancelLoadFunc: return mTrace.FindMethod("CancelLoad");
case GetResourcesFunc: return mTrace.FindMethod("GetResources");
case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
- case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily");
- case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize");
- case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight");
- case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData");
- case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData");
- case GetFontPathFunc: return mTrace.FindMethod("GetFontPath");
case SetDpiFunc: return mTrace.FindMethod("SetDpi");
case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
- case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars");
- case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported");
- case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName");
- case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice");
case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory");
- case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList");
- case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile");
- case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile");
- case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile");
- case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile");
}
return false;
}
mIsLoadingResult = result;
}
-void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result)
-{
- mGetDefaultFontFamilyResult = result;
-}
-
-void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result)
-{
- mGetDefaultFontSizeResult = result;
-}
-
-void TestPlatformAbstraction::SetGetFontPathResult(std::string& result)
-{
- mGetFontPathResult = result;
-}
-
void TestPlatformAbstraction::ClearReadyResources()
{
memset(&mResources, 0, sizeof(Resources));
mSaveFileResult = result;
}
-Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( )
-{
- return mFontListMode;
-}
-
-void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics )
-{
- mReadGlobalMetricsResult = success;
- mReadGlobalMetrics = globalMetrics;
-}
-
-void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector<Integration::GlyphMetrics>& glyphMetricsContainer )
-{
- mReadMetricsResult = success;
- mReadMetrics = glyphMetricsContainer; // copy
-}
-
} // namespace Dali
#include <dali/public-api/common/set-wrapper.h>
#include <dali/integration-api/platform-abstraction.h>
-#include <dali/integration-api/glyph-set.h>
#include "test-trace-call-stack.h"
virtual bool IsLoading();
/**
- * @copydoc PlatformAbstraction::GetDefaultFontFamily()
- */
- virtual const std::string& GetDefaultFontFamily() const;
-
- /**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
- virtual float GetDefaultFontSize() const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontLineHeightFromCapsHeight()
- */
- virtual Dali::PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const;
-
- /**
- * @copydoc PlatformAbstraction::GetGlyphData()
- */
- virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily,
- bool getBitmap) const;
-
- /**
- * @copydoc PlatformAbstraction::GetCachedGlyphData()
- */
- virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest,
- const std::string& fontFamily ) const;
-
-
- /**
- * @copydoc PlatformAbstraction::GetGlobalMetrics()
- */
- virtual void GetGlobalMetrics( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics ) const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontPath()
- */
- virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const;
-
- /**
* @copydoc PlatformAbstraction::SetDpi()
*/
virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
-
- /**
- * @copydoc PlatformAbstraction::GetFontFamilyForChars()
- */
- virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const;
-
- /**
- * @copydoc PlatformAbstraction::AllGlyphsSupported()
- */
- virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const;
-
- /**
- * @copydoc PlatformAbstraction::ValidateFontFamilyName()
- */
- virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const;
-
- /**
- * @copydoc PlatformAbstraction::GetFontList()
- */
- virtual void GetFontList( PlatformAbstraction::FontListMode mode, std::vector<std::string>& fontList ) const;
-
/**
* @copydoc PlatformAbstraction::LoadFile()
*/
virtual void JoinLoaderThreads();
- virtual void UpdateDefaultsFromDevice();
-
virtual Integration::DynamicsFactory* GetDynamicsFactory();
- virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- Integration::GlobalMetrics& globalMetrics );
-
- virtual void WriteGlobalMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlobalMetrics& globalMetrics );
-
- virtual bool ReadMetricsFromCache( const std::string& fontFamily,
- const std::string& fontStyle,
- std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
- virtual void WriteMetricsToCache( const std::string& fontFamily,
- const std::string& fontStyle,
- const Integration::GlyphSet& glyphSet );
-
-
- virtual void GetFileNamesFromDirectory( const std::string& directoryName,
- std::vector<std::string>& fileNames );
-
- virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const;
-
public: // TEST FUNCTIONS
// Enumeration of Platform Abstraction methods
CancelLoadFunc,
GetResourcesFunc,
IsLoadingFunc,
- GetDefaultFontFamilyFunc,
- GetDefaultFontSizeFunc,
- GetFontLineHeightFromCapsHeightFunc,
- GetGlyphDataFunc,
- GetCachedGlyphDataFunc,
SetDpiFunc,
- GetFontPathFunc,
JoinLoaderThreadsFunc,
- GetFontFamilyForCharsFunc,
- AllGlyphsSupportedFunc,
- ValidateFontFamilyNameFunc,
- UpdateDefaultsFromDeviceFunc,
GetDynamicsFactoryFunc,
- ValidateGetFontListFunc,
- ReadGlobalMetricsFromCacheFileFunc,
- WriteGlobalMetricsToCacheFileFunc,
- ReadMetricsFromCacheFileFunc,
- WriteMetricsToCacheFileFunc,
} TestFuncEnum;
/** Call this every test */
void SetSaveFileResult( bool result );
- PlatformAbstraction::FontListMode GetLastFontListMode( );
-
- void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics );
-
- void SetReadMetricsResult( bool success, std::vector<Integration::GlyphMetrics>& glyphMetricsContainer );
-
-
private:
mutable TraceCallStack mTrace;
size_t mSeconds;
size_t mMicroSeconds;
bool mIsLoadingResult;
- std::string mGetDefaultFontFamilyResult;
- float mGetDefaultFontSizeResult;
- std::string mGetFontPathResult;
Resources mResources;
Integration::ResourceRequest* mRequest;
Vector2 mSize;
Vector2 mClosestSize;
- bool mReadGlobalMetricsResult;
- bool mReadMetricsResult;
- Integration::GlobalMetrics mReadGlobalMetrics;
- std::vector<Integration::GlyphMetrics> mReadMetrics;
LoadFileResult mLoadFileResult;
bool mSaveFileResult;
- mutable FontListMode mFontListMode;
};
} // Dali
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void utc_dali_toolkit_markup_processor_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_markup_processor_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-
-struct MarkupStringTest
-{
- std::string input;
- std::string expectedResult;
-};
-
-bool TestMarkupString( const std::string& input, const std::string& expectedResult, std::string& result )
-{
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( input, styledTextArray, true );
- GetMarkupString( styledTextArray, result );
-
- return expectedResult == result;
-}
-
-} // namespace
-
-
-// Positive test case for a method
-int UtcDaliMarkupProcessor(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliMarkupProcessor ");
-
- const std::string text1( "Text" );
- const std::string text2( "< font face ='FreeSerif' color= 'green' >t< / font >" );
- const std::string text3( "< font face = 'FreeSerif' size= '16' style = 'Bold' color='red'>< i><u >Styled< / u> Text< /i >< / font >< br / >" );
- const std::string text4( "<font face='FreeSerif' size='14' color='0xaadd8744'><b><u>Styled</u> Te<font size='20'>x</font>t</b></font>< br/>" );
- const std::string text5( "< shadow color = 'blue' paramx = '1' paramy = '0.75' >Shadow< / shadow><br />" );
- const std::string text6( "<smooth param= '0.75' >< glow color = 'red' param = '0.1' >Glow</glow></smooth>< br />" );
- const std::string text7( "<font color='green''>< outline color = 'red' paramx = '0.7' paramy = '0.7' >Outline< / outline >< /font >< br / >" );
- const std::string text8( "<smooth param='0.75'>Smooth</smooth>< br / >" );
- const std::string text9( "\\<" );
- const std::string text10( "\\>" );
-
- char crlf[2];
- crlf[0] = 0x0D;
- crlf[1] = 0x0A;
- const std::string text11( crlf, 2 );
-
- const std::string result1( text1 );
- const std::string result2( "<font face='FreeSerif' color='green'>t</font>" );
- const std::string result3( "<font face='FreeSerif' style='Bold' size='16' color='red'><i><u>Styled</u></i></font><font face='FreeSerif' style='Bold' size='16' color='red'><i> Text</i></font><br />" );
- const std::string result4( "<font face='FreeSerif' size='14' color='0xaadd8744'><b><u>Styled</u></b></font><font face='FreeSerif' size='14' color='0xaadd8744'><b> Te</b></font><font face='FreeSerif' size='20' color='0xaadd8744'><b>x</b></font><font face='FreeSerif' size='14' color='0xaadd8744'><b>t</b></font><br />" );
- const std::string result5( "<shadow color='blue' paramx='1' paramy='0.75'>Shadow</shadow><br />" );
- const std::string result6( "<smooth param='0.75'><glow color='red' param='0.1'>Glow</glow></smooth><br />" );
- const std::string result7( "<font color='green'><outline color='red' paramx='0.7' paramy='0.7'>Outline</outline></font><br />" );
- const std::string result8( "<smooth param='0.75'>Smooth</smooth><br />" );
- const std::string result9( text9 );
- const std::string result10( text10 );
- const std::string result11( "<br />" );
-
- std::string markupString;
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( text1, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text2, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result2, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text3, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result3, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text4, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result4, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text5, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result5, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text6, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result6, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text7, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result7, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text8, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result8, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text9, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
- DALI_TEST_EQUALS( result9, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text10, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result10, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text11, styledTextArray, true );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result11, markupString, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliMarkupProcessorSetTextStyle01(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliMarkupProcessorSetTextStyle01 ");
-
- const std::string text1( "Text with no defined style" );
- const std::string result1( "<font color='green'><i>Text with no defined style</i></font>" );
- const std::string result2( "Text with <font color='green'><i>no defined</i></font> style" );
-
- std::string markupString;
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( text1, styledTextArray, true );
-
- TextStyle style;
- style.SetItalics( true );
- style.SetTextColor( Color::GREEN );
-
- SetTextStyle( styledTextArray, style );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- styledTextArray.clear();
- SetTextStyle( text1, styledTextArray, style );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text1, styledTextArray, true );
- SetTextStyleToRange( styledTextArray, style, TextStyle::ALL, 0, text1.size() - 1 );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result1, markupString, TEST_LOCATION );
-
- GetStyledTextArray( text1, styledTextArray, true );
- SetTextStyleToRange( styledTextArray, style, TextStyle::ALL, 10, 19 );
- GetMarkupString( styledTextArray, markupString );
-
- DALI_TEST_EQUALS( result2, markupString, TEST_LOCATION );
-
- std::string plainString;
- GetPlainString( styledTextArray, plainString );
-
- DALI_TEST_EQUALS( text1, plainString, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliMarkupProcessorSetTextStyle02(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliMarkupProcessorSetTextStyle02 ");
-
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- // Test style applied to and empty string doesn't crash
-
- TextStyle style;
- style.SetItalics( true );
- style.SetTextColor( Color::GREEN );
-
- bool fails = false;
- try
- {
- SetTextStyle( styledTextArray, style );
- }
- catch( ... )
- {
- fails = true;
- }
-
- DALI_TEST_CHECK( !fails );
- END_TEST;
-}
-
-int UtcDaliMarkupProcessorTestColors(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliMarkupProcessorTestColors ");
-
- struct MarkupStringTest colorTests[] =
- {
- {
- std::string( "<font color='0xFF000000'>black</font>" ),
- std::string( "<font color='black'>black</font>" )
- },
- {
- std::string( "<font color='0xFFFFFFFF'>white</font>" ),
- std::string( "white" )
- },
- {
- std::string( "<font color='0xFFFF0000'>red</font>" ),
- std::string( "<font color='red'>red</font>" )
- },
- {
- std::string( "<font color='0xFF00FF00'>green</font>" ),
- std::string( "<font color='green'>green</font>" )
- },
- {
- std::string( "<font color='0xFF0000FF'>blue</font>" ),
- std::string( "<font color='blue'>blue</font>" )
- },
- {
- std::string( "<font color='0xFFFFFF00'>yellow</font>" ),
- std::string( "<font color='yellow'>yellow</font>" )
- },
- {
- std::string( "<font color='0xFFFF00FF'>magenta</font>" ),
- std::string( "<font color='magenta'>magenta</font>" )
- },
- {
- std::string( "<font color='0xFF00FFFF'>cyan</font>" ),
- std::string( "<font color='cyan'>cyan</font>" )
- },
- {
- std::string( "<font color='0x00000000'>transparent</font>" ),
- std::string( "<font color='transparent'>transparent</font>" )
- },
- {
- std::string( "<font color='#000000'>black</font>" ),
- std::string( "<font color='black'>black</font>" )
- },
- {
- std::string( "<font color='#FFFFFF'>white</font>" ),
- std::string( "white" )
- },
- {
- std::string( "<font color='#FF0000'>red</font>" ),
- std::string( "<font color='red'>red</font>" )
- },
- {
- std::string( "<font color='#00FF00'>green</font>" ),
- std::string( "<font color='green'>green</font>" )
- },
- {
- std::string( "<font color='#0000FF'>blue</font>" ),
- std::string( "<font color='blue'>blue</font>" )
- },
- {
- std::string( "<font color='#FFFF00'>yellow</font>" ),
- std::string( "<font color='yellow'>yellow</font>" )
- },
- {
- std::string( "<font color='#FF00FF'>magenta</font>" ),
- std::string( "<font color='magenta'>magenta</font>" )
- },
- {
- std::string( "<font color='#00FFFF'>cyan</font>" ),
- std::string( "<font color='cyan'>cyan</font>" )
- },
- {
- std::string( "<font color='#000'>black</font>" ),
- std::string( "<font color='black'>black</font>" )
- },
- {
- std::string( "<font color='#FFF'>white</font>" ),
- std::string( "white" )
- },
- {
- std::string( "<font color='#F00'>red</font>" ),
- std::string( "<font color='red'>red</font>" )
- },
- {
- std::string( "<font color='#0F0'>green</font>" ),
- std::string( "<font color='green'>green</font>" )
- },
- {
- std::string( "<font color='#00F'>blue</font>" ),
- std::string( "<font color='blue'>blue</font>" )
- },
- {
- std::string( "<font color='#FF0'>yellow</font>" ),
- std::string( "<font color='yellow'>yellow</font>" )
- },
- {
- std::string( "<font color='#F0F'>magenta</font>" ),
- std::string( "<font color='magenta'>magenta</font>" )
- },
- {
- std::string( "<font color='#0FF'>cyan</font>" ),
- std::string( "<font color='cyan'>cyan</font>" )
- },
- {
- std::string( "<font color='0x000000'>black</font>" ),
- std::string( "<font color='black'>black</font>" )
- },
- {
- std::string( "<font color='black'>black</font>" ),
- std::string( "<font color='black'>black</font>" )
- },
- {
- std::string( "<font color='white'>white</font>" ),
- std::string( "white" )
- },
- {
- std::string( "<font color='red'>red</font>" ),
- std::string( "<font color='red'>red</font>" )
- },
- {
- std::string( "<font color='0xFF00FF00'>green</font>" ),
- std::string( "<font color='green'>green</font>" )
- },
- {
- std::string( "<font color='blue'>blue</font>" ),
- std::string( "<font color='blue'>blue</font>" )
- },
- {
- std::string( "<font color='yellow'>yellow</font>" ),
- std::string( "<font color='yellow'>yellow</font>" )
- },
- {
- std::string( "<font color='magenta'>magenta</font>" ),
- std::string( "<font color='magenta'>magenta</font>" )
- },
- {
- std::string( "<font color='cyan'>cyan</font>" ),
- std::string( "<font color='cyan'>cyan</font>" )
- },
- {
- std::string( "<font color='transparent'>transparent</font>" ),
- std::string( "<font color='transparent'>transparent</font>" )
- },
- {
- std::string( "<outline color='white'>outline</outline>" ),
- std::string( "<outline color='white'>outline</outline>" )
- },
- };
-
- const std::size_t numberOfTests( 36 );
-
- bool fails = false;
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const MarkupStringTest& test = colorTests[index];
-
- std::string result;
- if( !TestMarkupString( test.input, test.expectedResult, result ) )
- {
- TestMarkupString( test.input, test.expectedResult, result );
- tet_printf( "%s\n input : %s\nexpected result : %s\n result : %s\n", TEST_LOCATION, test.input.c_str(), test.expectedResult.c_str(), result.c_str() );
-
- fails = true;
- }
- }
-
- DALI_TEST_CHECK( !fails );
- END_TEST;
-}
//Test properties
std::string testString = "Hello World";
popup.SetProperty(popup.GetPropertyIndex("title"), testString);
- DALI_TEST_EQUALS( testString, popup.GetTitle().GetText(), TEST_LOCATION );
+ DALI_TEST_EQUALS( testString, popup.GetTitle(), TEST_LOCATION );
END_TEST;
}
int UtcDaliPopupSetTitle(void)
{
- ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
- tet_infoline(" UtcDaliPopupSetTitle");
-
- // Create the Popup actor
- Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
- // Put in show state so it's layer is connected to popup (for ancestor check).
- popup.SetState(Popup::POPUP_SHOW, 0.0f);
-
- TextView titleActor = TextView::New();
- titleActor.SetText("title");
-
- DALI_TEST_CHECK( !popup.GetTitle() );
- popup.SetTitle(titleActor);
- DALI_TEST_CHECK( popup.GetTitle() == titleActor );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "title") );
- // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
- DALI_TEST_CHECK( HasAncestor(titleActor, popup) );
-
- TextView titleActor2 = TextView::New();
- titleActor2.SetText("anothertitle");
- popup.SetTitle(titleActor2);
- DALI_TEST_CHECK( popup.GetTitle() != titleActor );
- DALI_TEST_CHECK( popup.GetTitle() == titleActor2 );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "anothertitle") );
- // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
- DALI_TEST_CHECK( HasAncestor(titleActor2, popup) );
- END_TEST;
-}
-
-int UtcDaliPopupSetTitleText(void)
-{
- ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
- tet_infoline(" UtcDaliPopupSetTitleText");
-
- // Create the Popup actor
- Popup popup = Popup::New();
- Stage::GetCurrent().Add( popup );
- // Put in show state so it's layer is connected to popup (for ancestor check).
- popup.SetState(Popup::POPUP_SHOW, 0.0f);
-
- TextView titleActor = TextView::New();
- titleActor.SetText("title");
-
- DALI_TEST_CHECK( !popup.GetTitle() );
- popup.SetTitle(titleActor);
- DALI_TEST_CHECK( popup.GetTitle() == titleActor );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "title") );
- // verify titleActor is actually inside popup, and not elsewhere on stage, or off even.
- DALI_TEST_CHECK( HasAncestor(titleActor, popup) );
-
- // this text should replace titleImage actor.
- popup.SetTitle("newtext");
- DALI_TEST_CHECK( popup.GetTitle() != titleActor );
- DALI_TEST_CHECK( (popup.GetTitle()) && (popup.GetTitle().GetText() == "newtext") );
- // verify titleActor is no longer inside popup. (been displaced by newtext actor)
- DALI_TEST_CHECK( !HasAncestor(titleActor, popup) );
+ // TODO
END_TEST;
}
application.SendNotification();
application.Render();
- TextView textView;
-
pushButton.SetLabelText( STR );
- textView = TextView::DownCast( pushButton.GetLabelText() );
- DALI_TEST_CHECK( STR == textView.GetText() );
-
- TextView text = TextView::New( STR );
- pushButton.SetLabelText( text );
-
- textView = TextView::DownCast( pushButton.GetLabelText() );
- DALI_TEST_CHECK( STR == textView.GetText() );
END_TEST;
}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-#include <dali/integration-api/events/key-event-integ.h>
-
-using namespace Dali;
-using namespace Toolkit;
-
-void utc_dali_toolkit_text_input_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_text_input_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-static bool gObjectCreatedCallBackCalled;
-
-static void TestCallback(BaseHandle handle)
-{
- Actor actor = Actor::DownCast(handle);
-
- if(actor)
- {
- TextInput handle = TextInput::DownCast(actor);
- if (handle)
- {
- gObjectCreatedCallBackCalled = true;
- }
- }
-}
-
-static bool gHasEndSignalBeenReceived;
-static bool gHasStartSignalBeenReceived;
-
-// Callback test function
-void OnStartInput(TextInput textInput)
-{
- gHasStartSignalBeenReceived = true;
-}
-
-// Callback test function
-void OnEndInput(TextInput textInput)
-{
- gHasEndSignalBeenReceived = true;
-}
-
-}
-
-// Positive test case for a method
-int UtcDaliTextInputConstruction(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing New constructor");
-
- TextInput textInput = TextInput::New();
- DALI_TEST_CHECK(textInput);
-
- //Additional check to ensure object is created by checking if it's registered
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gObjectCreatedCallBackCalled = false;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
- {
- TextInput textInput = TextInput::New();
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
- END_TEST;
-}
-
-
-static bool downCastToTextInput(Dali::Actor actor)
-{
- TextInput handle = TextInput::DownCast(actor);
- if (handle)
- {
- tet_infoline("Downcasted to TextInput");
- return true;
- }
- else
- {
- tet_infoline("Did not downcast to TextInput");
- return false;
- }
-}
-
-// Positive test case for a method
-int UtcDaliTextInputDownCast(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- tet_infoline("Testing Downcasting with a TextInput");
- DALI_TEST_EQUALS(true,downCastToTextInput(textInput), TEST_LOCATION); // downcast a TextInput
-
- Dali::TextActor badHandle = Dali::TextActor::New("test");
-
- tet_infoline("Testing Downcasting with the wrong actor");
- DALI_TEST_EQUALS(false, downCastToTextInput(badHandle), TEST_LOCATION); // downcast a TextActor to TextInput
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliTextInputGetText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing GetText");
-
- const std::string teststring = "test";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); // Get text which should be empty
-
- textInput.SetInitialText(teststring);
-
- DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be test string
-
- END_TEST;
-}
-
-int UtcDaliTextInputGetMarkupText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing retrieval of Markup text after style set");
-
- const std::string markup = "<i>Text with italic style</i>" ;
- const std::string teststring = "Text with italic style";
-
- TextInput textInput = TextInput::New();
-
- tet_infoline("Set initial text");
-
- textInput.SetInitialText( teststring );
-
- tet_infoline("Check initial text");
- DALI_TEST_EQUALS( teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be empty
-
- TextStyle style;
- style.SetItalics( true );
-
- tet_infoline("Apply style to TextInput");
- textInput.ApplyStyleToAll( style );
-
- tet_infoline("Retreive Markup Text");
- const std::string retreivedMarkupString = textInput.GetMarkupText();
-
- tet_infoline("Test Retreived text and Markup text match");
- DALI_TEST_EQUALS( retreivedMarkupString , retreivedMarkupString, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetMaxCharacterLength(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of max characters");
-
- const int maxChars = 4;
- const char* testChar = "v";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetMaxCharacterLength(maxChars);
-
- Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
-
- std::string testString = "";
-
- tet_infoline("Starting editmode");
- textInput.SetEditable( true );
-
- tet_infoline("Sending Key Events");
- // Send max number of characters
- for (int i=0; i < maxChars; i++)
- {
- application.ProcessEvent(event);
- testString.append(testChar);
- }
-
- tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
-
- DALI_TEST_EQUALS(testString, textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Sending Key Event which exceeds max characters");
-
- application.ProcessEvent(event); // try to append additional character
-
- DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Increase max characters limit");
-
- textInput.SetMaxCharacterLength(maxChars+1); // increment max characters by 1
-
- tet_infoline("Send character again which should now fit");
- application.ProcessEvent(event); // append additional character
- testString.append(testChar);
-
- DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliTextInputSetAndGetNumberOfLines(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Ensuring API for setting and getting max number of lines is correct");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- unsigned int numberOfLines = 1;
-
- textInput.SetNumberOfLinesLimit( numberOfLines );
-
- DALI_TEST_EQUALS(numberOfLines ,textInput.GetNumberOfLinesLimit(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputGetNumberOfCharacters(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Getting number of characters");
-
- const std::string initialString = "initial text";
- const std::string newInitialString = "initial text new";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- textInput.SetInitialText( initialString );
-
- tet_infoline("Testing TextInput contains correct number of characters ");
-
- DALI_TEST_EQUALS( initialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
-
- tet_infoline("Testing TextInput contains correct number of characters second phase ");
-
- textInput.SetInitialText( newInitialString );
-
- DALI_TEST_EQUALS( newInitialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetPlaceholderText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of PlaceholderText");
-
- const std::string initialString = "initial text";
- const std::string placeholderString = "placeholder";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- tet_infoline("Testing TextInput is empty at creation ");
-
- DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Set placeholder text");
-
- textInput.SetPlaceholderText( placeholderString );
-
- tet_infoline("Testing TextInput contains placeholder text");
-
- DALI_TEST_EQUALS( placeholderString , textInput.GetPlaceholderText(), TEST_LOCATION);
-
- tet_infoline("Set initial text which should replace placeholder text");
-
- textInput.SetInitialText( initialString );
-
- tet_infoline("Testing TextInput contains initial text when placeholder text set");
-
- DALI_TEST_EQUALS( initialString,textInput.GetText(), TEST_LOCATION);
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliTextInputSetInitialText(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Setting of Initial Text");
-
- const std::string teststring = "test";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- tet_infoline("Testing TextInput is empty at creation ");
-
- DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);
-
- tet_infoline("Set text to TextInput");
-
- textInput.SetInitialText(teststring);
-
- tet_infoline("Test TextInput contains set text");
-
- DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetEditableAndIsEditable(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetEditable And IsEditable");
-
- const std::string initialString = "initial text";
-
- TextInput textInput = TextInput::New(); // create empty TextInput
- textInput.SetInitialText( initialString );
-
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- bool editableStateFalse ( false );
- bool editableStateTrue ( true );
-
- textInput.SetEditable ( editableStateFalse );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( editableStateFalse, textInput.IsEditable() , TEST_LOCATION);
-
- textInput.SetEditable ( editableStateTrue );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( editableStateTrue, textInput.IsEditable() , TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetEditOnTouch(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetEditOnTouch And IsEditOnTouch");
-
- TextInput textInput = TextInput::New();
-
- bool editableOnTouchOn ( true );
- bool editableOnTouchOff( false );
-
- tet_infoline("Testing SetEditOnTouch disabled");
- textInput.SetEditOnTouch ( editableOnTouchOff );
- DALI_TEST_EQUALS( editableOnTouchOff, textInput.IsEditOnTouch() , TEST_LOCATION);
-
- tet_infoline("Testing SetEditOnTouch enabled");
- textInput.SetEditOnTouch ( editableOnTouchOn );
- DALI_TEST_EQUALS( editableOnTouchOn, textInput.IsEditOnTouch() , TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputSetTextSelectable(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetTextSelectable and IsTextSelectable");
-
- const std::string initialString = "initial text";
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( initialString );
-
- tet_infoline("Testing SetTextSelectable");
- textInput.SetTextSelectable();
- DALI_TEST_EQUALS( true, textInput.IsTextSelectable() , TEST_LOCATION);
- textInput.SetTextSelectable( false );
- DALI_TEST_EQUALS( false, textInput.IsTextSelectable() , TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputTextSelection(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Text Selection");
-
- const std::string initialString = "initial text";
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( initialString );
-
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetEditable( true );
-
- tet_infoline("Testing IsTextSelected negative");
- DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
-
- textInput.SelectText(1,7);
- DALI_TEST_EQUALS( true, textInput.IsTextSelected(), TEST_LOCATION);
-
- textInput.DeSelectText();
- DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputEnableGrabHandleAndIsGrabHandleEnabled(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- bool grabHandleState = false;
-
- textInput.EnableGrabHandle( grabHandleState );
-
- DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
-
- grabHandleState = true;
- textInput.EnableGrabHandle( grabHandleState );
-
- DALI_TEST_EQUALS( grabHandleState, textInput.IsGrabHandleEnabled(), TEST_LOCATION);
-
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetBoundingRectangle(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- Stage::GetCurrent().Add(textInput);
- Vector2 stageSize = Stage::GetCurrent().GetSize();
-
- const Rect<float> boundingRectangle( 100.0f, 100.0f, stageSize.width, stageSize.height );
-
- textInput.SetBoundingRectangle( boundingRectangle );
-
- const Rect<float> retreievedBoundingRectangle = textInput.GetBoundingRectangle();
-
- DALI_TEST_EQUALS( boundingRectangle.x, retreievedBoundingRectangle.x, TEST_LOCATION);
- DALI_TEST_EQUALS( boundingRectangle.y, retreievedBoundingRectangle.y, TEST_LOCATION);
- DALI_TEST_EQUALS( boundingRectangle.width, retreievedBoundingRectangle.width, TEST_LOCATION);
- DALI_TEST_EQUALS( boundingRectangle.height, retreievedBoundingRectangle.height, TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliTextInputSetAndGetTextAlignment(void)
-{
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) );
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( static_cast<Alignment::Type>( Alignment::HorizontalCenter) & textInput.GetTextAlignment()) ;
- END_TEST;
-}
-
-
-int UtcDaliTextInputSetSortModifier(void)
-{
- tet_infoline("Testing SetSortModifier does not cause TextInput failure");
-
- ToolkitTestApplication application;
-
- TextInput textInput = TextInput::New();
-
- const float offsetToUse = 1.5f;
-
- textInput.SetSortModifier( offsetToUse );
-
- DALI_TEST_CHECK( textInput );
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetSnapshotModeEnabled(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetSnapshotModeEnabled and IsSnapshotModeEnabled");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
- bool snapshotMode( true );
- textInput.SetSnapshotModeEnabled( snapshotMode );
-
- DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
-
- snapshotMode = false;
- textInput.SetSnapshotModeEnabled( snapshotMode );
-
- DALI_TEST_EQUALS( snapshotMode, textInput.IsSnapshotModeEnabled(), TEST_LOCATION);
- END_TEST;
-}
-
-
-int UtcDaliTextInputEndSignalEmit(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Set editable false emits end signal");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- textInput.InputFinishedSignal().Connect( &OnEndInput );
-
- textInput.SetEditable(true) ;
-
- gHasEndSignalBeenReceived = false;
-
- textInput.SetEditable(false) ;
-
- DALI_TEST_EQUALS(true, gHasEndSignalBeenReceived, TEST_LOCATION);
- END_TEST;
-}
-
-
-
-int UtcDaliTextInputStartSignalEmit(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing SetEditable emits start signal");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
-
- textInput.InputStartedSignal().Connect( &OnStartInput );
-
- gHasStartSignalBeenReceived = false;
-
- textInput.SetEditable(true); // Set editable first time
-
- DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
-
- gHasStartSignalBeenReceived = false;
-
- textInput.SetEditable(true); // Set editable second time, signal should not be sent again.
-
- DALI_TEST_EQUALS(false, gHasStartSignalBeenReceived, TEST_LOCATION);
-
- textInput.SetEditable(false);
-
- gHasStartSignalBeenReceived = false;
-
- textInput.SetEditable(true); // Set editable again
-
- DALI_TEST_EQUALS(true, gHasStartSignalBeenReceived, TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliTextInputExceedMaxCharacters(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("Testing Max characters is obeyed when inputting key events ");
-
- TextInput textInput = TextInput::New(); // create empty TextInput
-
- Stage::GetCurrent().Add(textInput);
- textInput.SetMaxCharacterLength(4);
- textInput.SetInitialText("");
- textInput.SetEditable(true);
-
- application.SendNotification();
- application.Render();
-
- Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
- Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );
-
- application.ProcessEvent(eventA);
- application.ProcessEvent(eventB);
- application.ProcessEvent(eventA);
- application.ProcessEvent(eventB);
-
- application.ProcessEvent(eventA);
- application.ProcessEvent(eventB);
-
- tet_printf( "Get text result : %s\n", textInput.GetText().c_str());
-
- DALI_TEST_EQUALS("abab",textInput.GetText(), TEST_LOCATION); // Get text which should be only 4 characters
- END_TEST;
-}
-
-
-
-int UtcDaliTextInputSetAndGetFadeBoundary(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");
-
- ToolkitTestApplication application;
-
- TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( "Hello world!" );
-
- Stage::GetCurrent().Add(textInput);
- application.SendNotification();
- application.Render();
-
- textInput.SetFadeBoundary( fadeBoundary );
-
- TextView::FadeBoundary fadeBoundary2 = textInput.GetFadeBoundary();
-
- DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetWidthExceedPolicy(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextInputSetAndGetWidthExceedPolicy: ");
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textInput.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextInputSetAndGetHeightExceedPolicy(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextInputSetAndGetHeightExceedPolicy: ");
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextInput textInput = TextInput::New();
- textInput.SetInitialText( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textInput.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textInput.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextInputScroll(void)
-{
- tet_infoline("UtcDaliTextInputScroll: ");
- ToolkitTestApplication application;
-
- // Avoids the frame buffer texture to throw an exception.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- TextInput view = TextInput::New();
- view.SetMultilinePolicy( TextView::SplitByNewLineChar );
- view.SetWidthExceedPolicy( TextView::Original );
- view.SetHeightExceedPolicy( TextView::Original );
- view.SetTextAlignment( static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ) );
- view.SetInitialText( "Hello world! This is a scroll test." );
- view.SetSize( 100.f, 100.f );
- view.SetSnapshotModeEnabled( false );
-
- Stage::GetCurrent().Add( view );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.
-
- view.SetScrollEnabled( true );
-
- DALI_TEST_CHECK( view.IsScrollEnabled() );
- DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.
-
- view.SetScrollPosition( Vector2( 400.f, 400.f ) );
-
- application.SendNotification();
- application.Render();
-
- const Vector2& scrollPosition = view.GetScrollPosition();
- DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-using namespace Toolkit;
-
-void utc_dali_toolkit_text_view_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_text_view_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-namespace
-{
-
-const char* const PROPERTY_TEXT = "text";
-const char* const PROPERTY_MULTILINE_POLICY = "multiline-policy";
-const char* const PROPERTY_WIDTH_EXCEED_POLICY = "width-exceed-policy";
-const char* const PROPERTY_HEIGHT_EXCEED_POLICY = "height-exceed-policy";
-const char* const PROPERTY_LINE_JUSTIFICATION = "line-justification";
-const char* const PROPERTY_FADE_BOUNDARY = "fade-boundary";
-const char* const PROPERTY_LINE_HEIGHT_OFFSET = "line-height-offset";
-const char* const PROPERTY_HORIZONTAL_ALIGNMENT = "horizontal-alignment";
-const char* const PROPERTY_VERTICAL_ALIGNMENT = "vertical-alignment";
-
-bool TestEqual( float x, float y )
-{
- return !( fabsf( x - y ) > Math::MACHINE_EPSILON_1000 );
-}
-
-static bool gObjectCreatedCallBackCalled;
-static unsigned int gNumberObjectCreated;
-
-static void TestCallback(BaseHandle handle)
-{
- gObjectCreatedCallBackCalled = true;
- ++gNumberObjectCreated;
-}
-
-static bool gTextScrolled;
-static Vector2 gScrollDelta;
-static void TestTextScrolled( TextView textView, Vector2 scrollDelta )
-{
- gTextScrolled = true;
- gScrollDelta = scrollDelta;
-}
-
-} // namespace
-
-
-int UtcDaliTextViewNew(void)
-{
- tet_infoline("UtcDaliTextViewNew: ");
- ToolkitTestApplication application;
-
- // Test default constructor.
- TextView view;
-
- DALI_TEST_CHECK( !view );
-
- // Test default initialization.
- view = TextView::New();
-
- DALI_TEST_CHECK( view );
-
- // Test copy constructor and asignment operator.
- TextView viewCopy1;
-
- viewCopy1 = view;
-
- DALI_TEST_CHECK( viewCopy1 );
-
- TextView viewCopy2( view );
-
- DALI_TEST_CHECK( viewCopy2 );
-
- // Test down cast.
- Actor actorView;
-
- actorView = view;
-
- TextView downCastView = TextView::DownCast( actorView );
-
- DALI_TEST_CHECK( downCastView );
-
- // Test constructor with a given text.
-
- const std::string text( "Hello world!" );
-
- const float DESCENDER = 8.0f;
-
- TextView view1 = TextView::New( text );
-
- DALI_TEST_EQUALS( view1.GetText(), text, TEST_LOCATION );
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( text, styledText, true );
-
- TextView view2 = TextView::New( styledText );
-
- DALI_TEST_EQUALS( view2.GetText(), text, TEST_LOCATION );
-
- // Check the default Toolkit::TextView::CharacterLayoutInfo::CharacterLayoutInfo() to increase coverage.
- TextView::CharacterLayoutInfo characterLayoutInfo;
-
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsNewLineChar, false, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsRightToLeftCharacter, false, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsVisible, true, TEST_LOCATION );
-
- TextView::CharacterLayoutInfo characterLayoutInfo2( Size( 2.f, 2.f ),
- Vector3( 3.f, 4.f, 5.f ),
- true,
- true,
- false,
- DESCENDER );
-
- characterLayoutInfo = characterLayoutInfo2;
-
- DALI_TEST_EQUALS( characterLayoutInfo.mSize, Size( 2.f, 2.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mPosition, Vector3( 3.f, 4.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsNewLineChar, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsRightToLeftCharacter, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mIsVisible, false, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mDescender, DESCENDER , TEST_LOCATION );
-
-
- TextView::CharacterLayoutInfo characterLayoutInfo3( characterLayoutInfo );
-
- DALI_TEST_EQUALS( characterLayoutInfo3.mSize, Size( 2.f, 2.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mPosition, Vector3( 3.f, 4.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mIsNewLineChar, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mIsRightToLeftCharacter, true, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo3.mIsVisible, false, TEST_LOCATION );
-
- // Check the default Toolkit::TextView::TextLayoutInfo::TextLayoutInfo() to increase coverage.
-
- TextView::TextLayoutInfo textLayoutInfo;
- DALI_TEST_EQUALS( textLayoutInfo.mCharacterLayoutInfoTable.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mCharacterLogicalToVisualMap.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mCharacterVisualToLogicalMap.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mTextSize, Size::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo.mScrollOffset, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- textLayoutInfo.mCharacterLayoutInfoTable.push_back( characterLayoutInfo );
- textLayoutInfo.mCharacterLogicalToVisualMap.push_back( 1 );
- textLayoutInfo.mCharacterVisualToLogicalMap.push_back( 1 );
- textLayoutInfo.mTextSize = Size( 10.f, 10.f );
- textLayoutInfo.mScrollOffset = Vector2( 5.f, 5.f );
-
- TextView::TextLayoutInfo textLayoutInfo2( textLayoutInfo );
-
- DALI_TEST_EQUALS( textLayoutInfo2.mCharacterLayoutInfoTable.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mCharacterLogicalToVisualMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mCharacterVisualToLogicalMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mTextSize, Size( 10.f, 10.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo2.mScrollOffset, Vector2( 5.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- TextView::TextLayoutInfo textLayoutInfo3;
-
- textLayoutInfo3 = textLayoutInfo2;
-
- DALI_TEST_EQUALS( textLayoutInfo3.mCharacterLayoutInfoTable.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mCharacterLogicalToVisualMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mCharacterVisualToLogicalMap.size(), 1u, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mTextSize, Size( 10.f, 10.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( textLayoutInfo3.mScrollOffset, Vector2( 5.f, 5.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- //Additional check to ensure object is created by checking if it's registered
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gObjectCreatedCallBackCalled = false;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
- {
- TextView view = TextView::New();
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetText(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetText: ");
- ToolkitTestApplication application;
-
- TextView view = TextView::New();
- view.SetSnapshotModeEnabled( false ); // Disables offscreen rendering.
-
- std::string str( "Text with differing aCeNdEr and dEcEnDeR" );
-
- view.SetText( str );
- DALI_TEST_EQUALS( view.GetText(), str, TEST_LOCATION );
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( str, styledText, true );
-
- view.SetText( styledText );
- DALI_TEST_EQUALS( view.GetText(), str, TEST_LOCATION );
-
- // Test the number of text actor created.
-
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gNumberObjectCreated = 0u;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
-
- // Following string should create three text-actors ([Hel], [lo wo] and [rld]).
- std::string text( "Hel<font size='10'>lo wo</font>rld!\n"
- "\n" );
-
- view.SetMarkupProcessingEnabled( true ); // Enables markup processing.
-
- Stage::GetCurrent().Add( view );
- view.SetText( text );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( 3u, gNumberObjectCreated, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSetStyleToCurrentText(void)
-{
- tet_infoline("UtcDaliTextViewSetStyleToCurrentText: ");
- ToolkitTestApplication application;
-
- TextStyle style;
- style.SetItalics( true );
-
- const std::string text( "앞서 농식품부 주이석 검역검사본부\n"
- "동물방역부장을 단장으로 하는\n"
- "민관합동조사단은 지난달 30일부터\n"
- "12일간의 현지 조사활동을 마치고\n"
- "11일 새벽 귀국했습니다." );
- TextView view = TextView::New( text );
-
- bool fail = false;
- try
- {
- view.SetStyleToCurrentText( style );
- }
- catch( ... )
- {
- tet_printf( "Tet case fails\n" );
- fail = true;
- tet_result(TET_FAIL);
- }
-
- DALI_TEST_CHECK( !fail );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetLineHeight(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetLineHeight: ");
-
- ToolkitTestApplication application;
-
- const float lineHeightOffset( 9.f );
-
- TextView textView = TextView::New();
-
- textView.SetLineHeightOffset( PointSize( lineHeightOffset ) );
-
- DALI_TEST_EQUALS( float(textView.GetLineHeightOffset()), lineHeightOffset, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetFadeBoundary(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");
-
- ToolkitTestApplication application;
-
- TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );
-
- TextView textView = TextView::New( "Hello world!" );
-
- textView.SetFadeBoundary( fadeBoundary );
-
- TextView::FadeBoundary fadeBoundary2 = textView.GetFadeBoundary();
-
- DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
- DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetEllipsizeText(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetEllipsizeText: ");
-
- ToolkitTestApplication application;
-
- TextView textView = TextView::New( "Hello world!" );
-
- textView.SetEllipsizeText( std::string( "..." ) );
-
- DALI_TEST_EQUALS( std::string( "..." ), textView.GetEllipsizeText(), TEST_LOCATION );
-
- Toolkit::MarkupProcessor::StyledTextArray styledTextArray;
-
- GetStyledTextArray( std::string( "..." ), styledTextArray, true );
-
- textView.SetEllipsizeText( styledTextArray );
-
- DALI_TEST_EQUALS( std::string( "..." ), textView.GetEllipsizeText(), TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetWidthExceedPolicy(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetWidthExceedPolicy: ");
-
- ToolkitTestApplication application;
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextView textView = TextView::New( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textView.SetWidthExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textView.GetWidthExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliTextViewSetAndGetHeightExceedPolicy(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetHeightExceedPolicy: ");
-
- ToolkitTestApplication application;
-
- const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
- const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );
-
- TextView textView = TextView::New( "Hello world!" );
-
- for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
- {
- textView.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );
-
- DALI_TEST_EQUALS( textView.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
- }
- END_TEST;
-}
-
-/*
-// Re-enable this test case when ALL layout options work in TextView, currently this breaks TCT
-// output because too many warnings/errors are printed out
-//int UtcDaliTextViewTestLayoutOptions01(void)
-{
- tet_infoline("UtcDaliTextViewTestLayoutOptions01: ");
-
- ToolkitTestApplication application;
-
- const std::string text( "앞서 농식품부 주이석 검역검사본부\n"
- "동물방역부장을 단장으로 하는\n"
- "민관합동조사단은 지난달 30일부터\n"
- "12일간의 현지 조사활동을 마치고\n"
- "11일 새벽 귀국했습니다." );
-
- const TextView::MultilinePolicy MULTILINE_POLICIES[] = { TextView::SplitByNewLineChar, TextView::SplitByWord, TextView::SplitByChar };
- const TextView::ExceedPolicy EXCEED_WIDTH_POLICIES[] = { TextView::Original, TextView::Fade, TextView::Split, TextView::ShrinkToFit, TextView::EllipsizeEnd };
- const TextView::ExceedPolicy EXCEED_HEIGHT_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
- const Alignment::Type TEXT_ALIGNMENT[] = { static_cast<Alignment::Type>( Alignment::HorizontalLeft | Alignment::VerticalTop ),
- static_cast<Alignment::Type>( Alignment::HorizontalLeft | Alignment::VerticalCenter ),
- static_cast<Alignment::Type>( Alignment::HorizontalLeft | Alignment::VerticalBottom ),
- static_cast<Alignment::Type>( Alignment::HorizontalCenter | Alignment::VerticalTop ),
- static_cast<Alignment::Type>( Alignment::HorizontalCenter | Alignment::VerticalCenter ),
- static_cast<Alignment::Type>( Alignment::HorizontalCenter | Alignment::VerticalBottom ),
- static_cast<Alignment::Type>( Alignment::HorizontalRight | Alignment::VerticalTop ),
- static_cast<Alignment::Type>( Alignment::HorizontalRight | Alignment::VerticalCenter ),
- static_cast<Alignment::Type>( Alignment::HorizontalRight | Alignment::VerticalBottom ) };
- const TextView::LineJustification LINE_JUSTIFICATION[] = { TextView::Left, TextView::Center, TextView::Right, TextView::Justified };
-
- const unsigned int NUM_MULTILINE_POLICIES = sizeof( MULTILINE_POLICIES ) / sizeof( unsigned int );
- const unsigned int NUM_WIDTH_EXCEED_POLICIES = sizeof( EXCEED_WIDTH_POLICIES ) / sizeof( unsigned int );
- const unsigned int NUM_HEIGHT_EXCEED_POLICIES = sizeof( EXCEED_HEIGHT_POLICIES ) / sizeof( unsigned int );
- const unsigned int NUM_TEXT_ALIGNMENT = sizeof( TEXT_ALIGNMENT ) / sizeof( unsigned int );
- const unsigned int NUM_LINE_JUSTIFICATION = sizeof( LINE_JUSTIFICATION ) / sizeof( unsigned int );
-
- TextView textView = TextView::New( text );
- textView.SetSnapshotModeEnabled( false ); // Disables offscreen rendering.
-
- Stage::GetCurrent().Add( textView );
-
- TextView::TextLayoutInfo textLayoutInfo;
-
- for( unsigned int mlpIndex = 0; mlpIndex < NUM_MULTILINE_POLICIES; ++mlpIndex )
- {
- textView.SetMultilinePolicy( MULTILINE_POLICIES[mlpIndex] );
- for( unsigned int ewpIndex = 0; ewpIndex < NUM_WIDTH_EXCEED_POLICIES; ++ewpIndex )
- {
- textView.SetWidthExceedPolicy( EXCEED_WIDTH_POLICIES[ewpIndex] );
- for( unsigned int ehpIndex = 0; ehpIndex < NUM_HEIGHT_EXCEED_POLICIES; ++ehpIndex )
- {
- textView.SetHeightExceedPolicy( EXCEED_HEIGHT_POLICIES[ehpIndex] );
- for( unsigned int taIndex = 0; taIndex < NUM_TEXT_ALIGNMENT; ++taIndex )
- {
- textView.SetTextAlignment( TEXT_ALIGNMENT[taIndex] );
- for( unsigned int ljIndex = 0; ljIndex < NUM_LINE_JUSTIFICATION; ++ljIndex )
- {
- textView.SetLineJustification( LINE_JUSTIFICATION[ljIndex] );
-
- try
- {
- textView.GetTextLayoutInfo( textLayoutInfo );
-
- application.SendNotification();
- application.Render();
- }
- catch( Dali::DaliException& e )
- {
- DALI_TEST_EQUALS( e.mCondition, "!\"TextView::CombineExceedPolicies() Invalid width and height exceed policies combination\"", TEST_LOCATION );
- }
- catch( ... )
- {
- tet_printf( "Tet case fails\n" );
- tet_printf( " MultilinePolicy : %d\n", MULTILINE_POLICIES[mlpIndex] );
- tet_printf( " Width ExceedPolicy : %d\n", EXCEED_WIDTH_POLICIES[ewpIndex] );
- tet_printf( " Height ExceedPolicy : %d\n", EXCEED_HEIGHT_POLICIES[ehpIndex] );
- tet_printf( " TextAlignment : %d\n", TEXT_ALIGNMENT[taIndex] );
- tet_printf( " LineJustification : %d\n", LINE_JUSTIFICATION[ljIndex] );
- tet_result(TET_FAIL);
- }
-
- DALI_TEST_CHECK( LINE_JUSTIFICATION[ljIndex] == textView.GetLineJustification() );
- }
- DALI_TEST_CHECK( TEXT_ALIGNMENT[taIndex] == textView.GetTextAlignment() );
- }
- DALI_TEST_CHECK( EXCEED_HEIGHT_POLICIES[ehpIndex] == textView.GetHeightExceedPolicy() );
- }
- DALI_TEST_CHECK( EXCEED_WIDTH_POLICIES[ewpIndex] == textView.GetWidthExceedPolicy() );
- }
- DALI_TEST_CHECK( MULTILINE_POLICIES[mlpIndex] == textView.GetMultilinePolicy() );
- }
- END_TEST;
-}
-*/
-
-int UtcDaliTextViewTestLayoutOptions02(void)
-{
- tet_infoline("UtcDaliTextViewTestLayoutOptions02: ");
- ToolkitTestApplication application;
-
- // Check some configurations.
-
- TextView textView = TextView::New();
- textView.SetSnapshotModeEnabled( false ); // Disables offscreen rendering.
- textView.SetMarkupProcessingEnabled( true ); // Enables markup processing.
-
- Stage::GetCurrent().Add( textView );
-
- // SplitByWord and ShrinkToFit.
- // Centered alignment.
- // Centered justification.
- // Don't create a text actor per character.
-
- textView.SetMultilinePolicy( TextView::SplitByWord );
- textView.SetWidthExceedPolicy( TextView::ShrinkToFit );
- textView.SetHeightExceedPolicy( TextView::ShrinkToFit );
- textView.SetTextAlignment( static_cast<Alignment::Type>( Alignment::HorizontalCenter | Alignment::VerticalTop ) );
- textView.SetLineJustification( TextView::Center );
- textView.SetSize( 136.56252f, 100.f );
-
- textView.SetText( "Hel<font color='green'>lo wo</font>rld!" );
-
- application.SendNotification();
- application.Render();
-
- std::vector<Size> sizes;
- sizes.push_back( Size( 34.14063f, 11.380210f ) ); //
- sizes.push_back( Size( 56.90105f, 11.380210f ) ); //
- sizes.push_back( Size( 45.52084f, 11.380210f ) ); // By default characters have width and height values of 11.380210.
- // The result should be a line with the text 'Hello world' as shown below.
- std::vector<Vector3> positions; // ____________
- positions.push_back( Vector3( 0.000008f, 11.380209f, 0.f ) ); // |Hello world!|
- positions.push_back( Vector3( 34.14063f, 11.380209f, 0.f ) ); // ------------
- positions.push_back( Vector3( 91.04168f, 11.380209f, 0.f ) ); //
-
- DALI_TEST_CHECK( positions.size() == textView.GetChildCount() ); // Check text has two text-actors.
-
- for( std::size_t index = 0, num = textView.GetChildCount(); index < num; ++index )
- {
- const Vector3& size = textView.GetChildAt(index).GetCurrentSize();
- const Vector3& position = textView.GetChildAt(index).GetCurrentPosition();
-
- DALI_TEST_EQUALS( size.width, sizes[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, sizes[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.width, positions[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.height, positions[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- }
-
- textView.SetSize( 50.f, 50.f );
- textView.SetTextAlignment( static_cast<Alignment::Type>( Alignment::HorizontalCenter | Alignment::VerticalCenter ) );
- textView.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
- textView.SetLineJustification( Toolkit::TextView::Left );
-
- application.SendNotification();
- application.Render();
-
- sizes.clear();
- sizes.push_back( Size( 24.999999f, 8.333333f ) ); //
- sizes.push_back( Size( 24.999999f, 8.333333f ) ); //
- sizes.push_back( Size( 16.666666f, 8.333333f ) ); // Longest word is 'world!' (6 characters x 11.380210) which doesn't fit in the 50x50 box.
- sizes.push_back( Size( 33.333332f, 8.333333f ) ); // The scale factor is 0.732265339, so the character size is 8.333333.
- // Text should be split in two lines, centered in the vertical dimension and fitted in the horizontal one.
- positions.clear(); // As shown below, the text is two lines and centered in the vertical dimension and
- positions.push_back( Vector3( 0.000008f, 25.223114f, 0.f ) ); // it should start in middle height (~25).
- positions.push_back( Vector3( 24.999999f, 25.223114f, 0.f ) ); // ______
- positions.push_back( Vector3( 0.000006f, 33.556446f, 0.f ) ); // | |
- positions.push_back( Vector3( 16.666666f, 33.556446f, 0.f ) ); // |Hello |
- // |world!|
- // |______|
- //
-
- DALI_TEST_CHECK( positions.size() == textView.GetChildCount() ); // Check text has two text-actors.
-
- for( std::size_t index = 0, num = textView.GetChildCount(); index < num; ++index )
- {
- const Vector3& size = textView.GetChildAt(index).GetCurrentSize();
- const Vector3& position = textView.GetChildAt(index).GetCurrentPosition();
-
- DALI_TEST_EQUALS( size.width, sizes[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, sizes[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.width, positions[index].width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( position.height, positions[index].height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- }
-
- // TODO: Add more tests when TextView implementation is finished.
- END_TEST;
-}
-
-int UtcDaliTextViewInsertRemoveText(void)
-{
- tet_infoline("UtcDaliTextViewInsertRemoveText: ");
- ToolkitTestApplication application;
-
- std::string text("Hello ");
-
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( text, styledText, true );
-
- TextView view = TextView::New( "world!" );
-
- view.InsertTextAt( 0, styledText );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello world!"), TEST_LOCATION );
-
- view.RemoveTextFrom( 4, 5 );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hellld!"), TEST_LOCATION );
-
- view.InsertTextAt( 0, "Hello " );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello Hellld!"), TEST_LOCATION );
-
-
- view.InsertTextAt( 0, "Hello " );
- view.InsertTextAt( 0, "Hello " );
- view.InsertTextAt( 0, "Hello " );
- view.InsertTextAt( 0, "Hello " );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.RemoveTextFrom( 4, 2 );
- view.SetText( "Hello world!" );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello world!"), TEST_LOCATION );
-
- view.ReplaceTextFromTo( 5, 1, "" );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Helloworld!"), TEST_LOCATION );
-
- view.ReplaceTextFromTo( 0, 11, styledText );
-
- DALI_TEST_EQUALS( view.GetText(), std::string("Hello "), TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewSnapshotEnable(void)
-{
- tet_infoline("UtcDaliTextViewSnapshotEnable: ");
- ToolkitTestApplication application;
-
- // Avoids the frame buffer texture to throw an exception.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- TextView view = TextView::New();
- view.SetMarkupProcessingEnabled( true ); // Enables markup processing.
- view.SetText( "Hel<font color='green'>lo world!</font> This <font color='green'>is</font> a sna<font color='green'>psho</font>t test." );
-
- Stage::GetCurrent().Add( view );
-
- view.SetSnapshotModeEnabled( true ); // VCC. By default the snapshot mode should be enabled but it has been temporary disabled.
- // This line should be removed when text-view is set to use the snapshot mode by default.
-
- // Snapshot is enabled by default.
- DALI_TEST_CHECK( view.IsSnapshotModeEnabled() );
-
- application.SendNotification();
- application.Render();
-
- // TextView should have only two actors:
- // the root (Actor) and the image (ImageActor).
-
- DALI_TEST_EQUALS( view.GetChildCount(), 2u, TEST_LOCATION );
-
- view.SetSnapshotModeEnabled( false );
- DALI_TEST_CHECK( !view.IsSnapshotModeEnabled() );
-
- application.SendNotification();
- application.Render();
-
- // TextView should have one text-actor per word.
-
- DALI_TEST_EQUALS( view.GetChildCount(), 7u, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewScroll(void)
-{
- tet_infoline("UtcDaliTextViewScroll: ");
- ToolkitTestApplication application;
-
- // Avoids the frame buffer texture to throw an exception.
- application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
-
- TextView view = TextView::New( "Hello world! This is a scroll test." );
- view.SetSize( 100.f, 100.f );
- view.SetSnapshotModeEnabled( false );
-
- Stage::GetCurrent().Add( view );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.
-
- view.SetScrollEnabled( true );
- view.ScrolledSignal().Connect( &TestTextScrolled );
-
- DALI_TEST_CHECK( view.IsScrollEnabled() );
- DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.
-
- gTextScrolled = false;
- gScrollDelta = Vector2::ZERO;
- view.SetScrollPosition( Vector2( 400.f, 400.f ) );
-
- application.SendNotification();
- application.Render();
-
- const Vector2& scrollPosition = view.GetScrollPosition();
- DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- DALI_TEST_CHECK( gTextScrolled );
- DALI_TEST_EQUALS( gScrollDelta, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
- DALI_TEST_CHECK( view.IsScrollPositionTrimmed() );
- END_TEST;
-}
-
-int UtcDaliTextViewSetProperty(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetText: ");
- ToolkitTestApplication application;
-
- TextView view = TextView::New( "Hello world!" );
- Stage::GetCurrent().Add( view );
-
- //Test multiline policy property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_MULTILINE_POLICY), "SplitByNewLineChar");
- DALI_TEST_CHECK( Toolkit::TextView::SplitByNewLineChar == view.GetMultilinePolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_MULTILINE_POLICY), "SplitByWord");
- DALI_TEST_CHECK( Toolkit::TextView::SplitByWord == view.GetMultilinePolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_MULTILINE_POLICY), "SplitByChar");
- DALI_TEST_CHECK( Toolkit::TextView::SplitByChar == view.GetMultilinePolicy() );
-
- //Test width exceed policy property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_WIDTH_EXCEED_POLICY), "Original");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HEIGHT_EXCEED_POLICY), "Original");
- DALI_TEST_CHECK( Toolkit::TextView::Original == view.GetWidthExceedPolicy() );
- DALI_TEST_CHECK( Toolkit::TextView::Original == view.GetHeightExceedPolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_WIDTH_EXCEED_POLICY), "Fade");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HEIGHT_EXCEED_POLICY), "Fade");
- DALI_TEST_CHECK( Toolkit::TextView::Fade == view.GetWidthExceedPolicy() );
- DALI_TEST_CHECK( Toolkit::TextView::Fade == view.GetHeightExceedPolicy() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_WIDTH_EXCEED_POLICY), "ShrinkToFit");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HEIGHT_EXCEED_POLICY), "ShrinkToFit");
- DALI_TEST_CHECK( Toolkit::TextView::ShrinkToFit == view.GetWidthExceedPolicy() );
- DALI_TEST_CHECK( Toolkit::TextView::ShrinkToFit == view.GetHeightExceedPolicy() );
-
- //Test line justification property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Left");
- DALI_TEST_CHECK( Toolkit::TextView::Left == view.GetLineJustification() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Center");
- DALI_TEST_CHECK( Toolkit::TextView::Center == view.GetLineJustification() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Right");
- DALI_TEST_CHECK( Toolkit::TextView::Right == view.GetLineJustification() );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_JUSTIFICATION), "Justified");
- DALI_TEST_CHECK( Toolkit::TextView::Justified == view.GetLineJustification() );
-
- //Test fade boundary property
- const Vector4 testValue( 23.f, 26.f, 2.f, 11.f );
-
- view.SetProperty(view.GetPropertyIndex(PROPERTY_FADE_BOUNDARY), testValue);
- DALI_TEST_CHECK( testValue.x == view.GetFadeBoundary().mLeft );
- DALI_TEST_CHECK( testValue.y == view.GetFadeBoundary().mRight );
- DALI_TEST_CHECK( testValue.z == view.GetFadeBoundary().mTop );
- DALI_TEST_CHECK( testValue.w == view.GetFadeBoundary().mBottom );
-
- //Test Line height offset property
- float testOffsetValue = 14.04f;
- view.SetProperty(view.GetPropertyIndex(PROPERTY_LINE_HEIGHT_OFFSET), testOffsetValue);
- DALI_TEST_CHECK( PointSize(testOffsetValue) == view.GetLineHeightOffset() );
-
- //Test alignment property
- view.SetProperty(view.GetPropertyIndex(PROPERTY_HORIZONTAL_ALIGNMENT), "HorizontalLeft");
- view.SetProperty(view.GetPropertyIndex(PROPERTY_VERTICAL_ALIGNMENT), "VerticalTop");
- DALI_TEST_CHECK( (Toolkit::Alignment::HorizontalLeft | Toolkit::Alignment::VerticalTop) == view.GetTextAlignment() );
- END_TEST;
-}
-
-int UtcDaliTextViewSetSortModifier(void)
-{
- tet_infoline("UtcDaliTextViewSetAndGetText: ");
- ToolkitTestApplication application;
-
- TextView view = TextView::New( "Hello world!" );
- Stage::GetCurrent().Add( view );
-
- view.SetSortModifier( 10.f );
- view.SetSnapshotModeEnabled( false );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( RenderableActor::DownCast(view.GetChildAt(0)).GetSortModifier(), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliTextViewUnderlineText(void)
-{
- tet_infoline("UtcDaliTextViewUnderlineText: ");
- ToolkitTestApplication application;
-
- TextView textView = TextView::New();
- textView.SetSnapshotModeEnabled( false );
- textView.SetMarkupProcessingEnabled( true );
- textView.SetText( "<u><font size='10'>gg<font size='14'>gg<font size='18'>gg<font size='22'>gg</font>gg</font>gg</font>gg</font></u>" );
-
- textView.SetSize( 150.f, 100.f );
-
- Stage::GetCurrent().Add( textView );
-
- application.SendNotification();
- application.Render();
-
- std::vector<float> positions;
- positions.push_back( 6.448784f );
- positions.push_back( 9.862847f );
- positions.push_back( 13.276909f );
- positions.push_back( 16.690973f );
- positions.push_back( 13.276909f );
- positions.push_back( 9.862847f );
- positions.push_back( 6.448784f );
-
- for( std::size_t index = 0, num = textView.GetChildCount(); index < num; ++index )
- {
- TextStyle style = TextActor::DownCast( textView.GetChildAt(index) ).GetTextStyle();
-
- DALI_TEST_EQUALS( 4.17274f, style.GetUnderlineThickness(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( positions[index], style.GetUnderlinePosition(), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- }
- END_TEST;
-}
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/push-button.h>
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include "push-button-impl.h"
namespace Dali
// INTERNAL INCLUDES
#include "push-button-default-painter-impl.h"
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include <dali-toolkit/internal/controls/relayout-helper.h>
namespace Dali
void PushButton::SetLabelText( const std::string& text )
{
- Toolkit::TextView textView ( Toolkit::TextView::New( text ) );
- textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
- SetLabelText( textView );
+ // TODO
}
void PushButton::SetLabelText( Actor text )
size.height = std::max( size.height, imageSize.height );
}
}
-
- // If label, test against it's size
- Toolkit::TextView textView = Toolkit::TextView::DownCast( mLabel );
- if( textView )
- {
- Vector3 textViewSize = textView.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
- }
- }
}
return size;
#include "radio-button-impl.h"
// EXTERNAL INCLUDES
-#include <dali/public-api/actors/text-actor.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/scripting/scripting.h>
void RadioButton::SetLabel(const std::string& label)
{
- TextActor textActor = TextActor::DownCast( mLabel );
- if( textActor )
- {
- textActor.SetText( label );
- }
- else
- {
- Toolkit::TextView newTextView = Toolkit::TextView::New( label );
- SetLabel( newTextView );
- }
+ // TODO
RelayoutRequest();
}
#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
#include <dali-toolkit/public-api/controls/buttons/radio-button.h>
#include "button-impl.h"
void Popup::SetTitle( const std::string& text )
{
- Toolkit::TextView titleActor = Toolkit::TextView::New();
- titleActor.SetText( text );
- titleActor.SetColor( Color::BLACK );
- titleActor.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- titleActor.SetWidthExceedPolicy( Toolkit::TextView::Split );
- titleActor.SetLineJustification( Toolkit::TextView::Center );
-
- SetTitle( titleActor );
}
-void Popup::SetTitle( Toolkit::TextView titleActor )
+const std::string& Popup::GetTitle() const
{
- // Replaces the current title actor.
- if( mTitle && mPopupBg )
- {
- mPopupBg.Remove( mTitle );
- }
- mTitle = titleActor;
-
- mPopupBg.Add( mTitle );
-
- RelayoutRequest();
-}
-
-Toolkit::TextView Popup::GetTitle() const
-{
- return mTitle;
+ static std::string temp("");
+ return temp;
}
void Popup::AddButton( Toolkit::Button button )
// Relayout title
Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
- if( mTitle )
- {
- Vector2 titleSize;
- titleSize.width = popupSize.width;
- titleSize.height = mTitle.GetHeightForWidth( titleSize.width );
-
- // As the default size policy for text-view is Fixed & Fixed, a size needs to be set.
- // Otherwise size-negotiation algorithm uses the GetNaturalSize() with doesn't take
- // into account the multiline and exceed policies, giving as result a wrong size.
- mTitle.SetSize( titleSize );
- Relayout( mTitle, titleSize, container );
-
- mTitle.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mTitle.SetParentOrigin( ParentOrigin::TOP_CENTER );
- mTitle.SetPosition( positionOffset );
-
- positionOffset.y += titleSize.height + mPopupStyle->margin;
- }
+ // TODO
// Relayout content
if( mContent )
Vector3 Popup::GetNaturalSize()
{
float margin = 2.0f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
- const float maxWidth = Stage::GetCurrent().GetSize().width - margin;
Vector3 naturalSize( 0.0f, 0.0f, 0.0f );
- if ( mTitle )
- {
- Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize();
- // Buffer to avoid errors. The width of the popup could potentially be the width of the title text.
- // It was observed in this case that text wrapping was then inconsistent when seen on device
- const float titleBuffer = 0.5f;
- titleNaturalSize.width += titleBuffer;
-
- // As TextView GetNaturalSize does not take wrapping into account, limit the width
- // to that of the stage
- if( titleNaturalSize.width >= maxWidth)
- {
- naturalSize.width = maxWidth;
- naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width );
- }
- else
- {
- naturalSize += titleNaturalSize;
- }
-
- naturalSize.height += mPopupStyle->margin;
- }
-
if( mContent )
{
Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
float height( 0.0f );
float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) );
- if ( mTitle )
- {
- height += mTitle.GetImplementation().GetHeightForWidth( popupWidth );
- height += mPopupStyle->margin;
- }
-
if( mContent )
{
height += RelayoutHelper::GetHeightForWidth( mContent, popupWidth ) + mPopupStyle->margin;
void SetTitle( const std::string& text );
/**
- * @copydoc Toolkit::Popup::SetTitle( TextView titleActor )
- */
- void SetTitle( Toolkit::TextView titleActor );
-
- /**
* @copydoc Toolkit::Popup::GetTitle
*/
- Toolkit::TextView GetTitle() const;
+ const std::string& GetTitle() const;
/**
* @copydoc Toolkit::Popup::AddButton
Actor mBackgroundImage; ///< Stores the background image.
Actor mButtonAreaImage; ///< Stores the button background image.
- Toolkit::TextView mTitle; ///< Stores the text title.
Actor mContent; ///< Stores popup's content.
Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image.
Actor mTailImage; ///< Stores the tail image
#include <sstream>
#endif // defined(DEBUG_ENABLED)
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
-
namespace Dali
{
#include "dali-toolkit/public-api/controls/control.h"
#include "dali-toolkit/public-api/controls/control-impl.h"
-#include "dali-toolkit/public-api/controls/text-view/text-view.h"
namespace Dali
{
// EXTERNAL INCLUDES
#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/actors/text-actor.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
Image image = imageActor.GetImage();
size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
}
- else
- {
- // Get natural size for TextActor.
- TextActor textActor = TextActor::DownCast( actor );
- if( textActor )
- {
- Font font = textActor.GetFont();
- if( !font )
- {
- font = Font::New();
- }
- size = font.MeasureText( textActor.GetText() );
- size.depth = depth;
- }
- }
}
return size;
}
else
{
- TextActor textActor = TextActor::DownCast( actor );
- if( textActor )
- {
- Font font = textActor.GetFont();
- if( !font )
- {
- font = Font::New();
- }
- size = font.MeasureText( textActor.GetText() );
-
- constrainSize = true;
- }
- else
- {
- size = actor.GetCurrentSize();
- }
+ size = actor.GetCurrentSize();
}
// Scale the actor
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/controls/text-input/text-input-decorator-impl.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/clipboard.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/events/pan-gesture.h>
-#include <dali/public-api/object/property-notification.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/text-input/text-input-handles-impl.h>
-
-using namespace Dali;
-
-namespace
-{
-#if defined(DEBUG_ENABLED)
- Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TEXT_INPUT_DECORATOR");
-#endif
-
-const Vector3 DEFAULT_SELECTION_HANDLE_SIZE( 51.0f, 79.0f, 0.0f );
-const float TOP_HANDLE_TOP_OFFSET(-1.5f); // Offset between top handle and cutCopyPaste pop-up
-const float BOTTOM_HANDLE_BOTTOM_OFFSET(1.5f); // Offset between bottom handle and cutCopyPaste pop-up
-const float UI_Z_OFFSET( 0.2f ); // Text Selection Handles/Cursor z-offset.
-const Vector3 UI_OFFSET(0.0f, 0.0f, UI_Z_OFFSET); // Text Selection Handles/Cursor offset.
-const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" );
-const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f );
-const std::size_t CURSOR_BLINK_INTERVAL = 500; // Cursor blink interval
-const float CURSOR_THICKNESS(6.0f);
-const Degree CURSOR_ANGLE_OFFSET(2.0f); // Offset from the angle
-
-const unsigned int SCROLL_TICK_INTERVAL = 50u;
-const float SCROLL_THRESHOLD = 10.f;
-const float SCROLL_SPEED = 15.f;
-
-/**
- * Whether the given position plus the cursor size offset is inside the given boundary.
- *
- * @param[in] position The given position.
- * @param[in] cursorSize The cursor size.
- * @param[in] controlSize The given boundary.
- * @param[in] threshold imaginary indent around boundary that will trigger the position to be outside of control.
- *
- * @return whether the given position is inside the given boundary.
- */
-bool IsPositionWithinControl( const Vector3& position, const Size& cursorSize, const Vector3& controlSize, const Vector2 threshold = Vector2::ZERO )
-{
- return ( position.x >= -Math::MACHINE_EPSILON_1000 + threshold.x ) &&
- ( position.x <= controlSize.width - threshold.x + Math::MACHINE_EPSILON_1000 ) &&
- ( position.y - cursorSize.height >= -Math::MACHINE_EPSILON_1000 + threshold.y ) &&
- ( position.y <= controlSize.height + Math::MACHINE_EPSILON_1000 - threshold.y);
-}
-
-}
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-Decorator::Decorator( TextViewCharacterPositioning& textViewManager, TextInputTextStyle& textStyle ):
- mTextViewCharacterPositioning( textViewManager ),
- mTextStyle( textStyle ),
- mSelectionHandleOnePosition(0),
- mSelectionHandleTwoPosition(0),
- mGrabHandlePosition(0),
- mCursorPosition( 0 ),
- mTextHighlight( textViewManager ),
- mCursorBlinkStatus( true ),
- mCursorVisibility( true ),
- mCursorRTLEnabled( false ),
- mIsGrabHandleInScrollArea( false ),
- mIsCursorInScrollArea( false ),
- mGrabHandleVisibility( false ),
- mGrabHandleEnabled( true )
-{
-}
-
-Decorator::~Decorator()
-{
-}
-
-/**
- * Bounding Box
- */
-void Decorator::SetBoundingBox( const Rect<float>& boundingRectangle )
-{
- // Convert to world coordinates and store as a Vector4 to be compatible with Property Notifications.
- Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
- const float originX = boundingRectangle.x - 0.5f * stageSize.width;
- const float originY = boundingRectangle.y - 0.5f * stageSize.height;
-
- const Vector4 boundary( originX,
- originY,
- originX + boundingRectangle.width,
- originY + boundingRectangle.height );
-
- mBoundingRectangleWorldCoordinates = boundary;
-}
-
-Vector4 Decorator::GetBoundingBox() const
-{
- return mBoundingRectangleWorldCoordinates;
-}
-
-/**
- * Selection Handles
- */
-void Decorator::OnHandlePan(Actor actor, const PanGesture& gesture)
-{
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- switch (gesture.state)
- {
- case Gesture::Started:
- // fall through so code not duplicated
- case Gesture::Continuing:
- {
- if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() )
- {
- MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement );
- HidePopUp();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() )
- {
- MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement );
- HidePopUp();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() )
- {
- SetCursorVisibility( true );
- ShowGrabHandle( mGrabHandleVisibility && mIsGrabHandleInScrollArea );
- MoveGrabHandle( gesture.displacement );
- HidePopUp(); // Do not show popup while handle is moving
- }
- }
- break;
-
- case Gesture::Finished:
- {
- // Revert back to non-pressed selection handle images
- if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleOne() )
- {
- mSelectionHandleOneActualPosition = MoveSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition, gesture.displacement );
- ShowPopupCutCopyPaste();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetSelectionHandleTwo() )
- {
- mSelectionHandleTwoActualPosition = MoveSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition, gesture.displacement );
- ShowPopupCutCopyPaste();
- }
- else if ( actor.GetParent() == mTextInputHandles.GetGrabHandle() )
- {
- MoveGrabHandle( gesture.displacement );
- SetCursorVisibility( true );
- ShowPopupCutCopyPaste();
- }
- }
- break;
- default:
- break;
- }
-}
-
-void Decorator::CreateSelectionHandles( Actor targetParent )
-{
- if ( !mPanGestureDetector )
- {
- mPanGestureDetector = PanGestureDetector::New();
- mPanGestureDetector.DetectedSignal().Connect(this, &Decorator::OnHandlePan);
- }
-
- if ( !mTextInputHandles.GetSelectionHandleOne() )
- {
- mTextInputHandles.CreateSelectionHandles();
-
- mTextInputHandles.AttachSelectionHandlesToGivenPanGesture( mPanGestureDetector );
-
- targetParent.Add( mTextInputHandles.GetSelectionHandleOne() );
- targetParent.Add( mTextInputHandles.GetSelectionHandleTwo() );
-
- SetUpHandlePropertyNotifications();
- }
-}
-
-void Decorator::RemoveSelectionHandles()
-{
- mTextInputHandles.DestorySelectionHandles();
-}
-
-Vector3 Decorator::GetSelectionHandleSize()
-{
- return DEFAULT_SELECTION_HANDLE_SIZE;
-}
-
-std::size_t Decorator::GetHandleOnePosition() const
-{
- return mSelectionHandleOnePosition;
-}
-
-std::size_t Decorator::GetHandleTwoPosition() const
-{
- return mSelectionHandleTwoPosition;
-}
-
-Vector3 Decorator::PositionSelectionHandle( Actor selectionHandle, std::size_t position )
-{
- bool direction(false);
- Vector3 alternatePosition;
- bool alternatePositionValid(false);
-
- Vector3 actualPositionOfSelectionHandle = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( position, direction, alternatePosition,alternatePositionValid );
-
- return PositionSelectionHandle( selectionHandle, actualPositionOfSelectionHandle, position );
-
-}
-
-Vector3 Decorator::PositionSelectionHandle( Actor selectionHandle, Vector3& actualPosition, std::size_t position )
-{
- const Vector3 DEFAULT_HANDLE_OFFSET(0.0f, -5.0f, 0.0f);
-
- selectionHandle.SetPosition( actualPosition += DEFAULT_HANDLE_OFFSET );
-
- return actualPosition;
-}
-
-void Decorator::SetSelectionHandlesVisibility(bool visible )
-{
- mTextInputHandles.SetSelectionHandleOneVisibility( visible );
- mTextInputHandles.SetSelectionHandleTwoVisibility( visible );
-}
-
-void Decorator::PositionSelectionHandles( std::size_t start, std::size_t end )
-{
- mSelectionHandleOnePosition = start;
- mSelectionHandleTwoPosition = end;
-
- mTextViewCharacterPositioning.UpdateTextLayoutInfo();
-
- mSelectionHandleOneActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleOne(), mSelectionHandleOnePosition );
- mSelectionHandleTwoActualPosition = PositionSelectionHandle( mTextInputHandles.GetSelectionHandleTwo(), mSelectionHandleTwoPosition );
-}
-
-Vector3 Decorator::MoveSelectionHandle( Actor selectionHandle,
- Vector3& actualSelectionHandlePosition,
- std::size_t& currentSelectionHandlePosition,
- const Vector2& displacement )
-{
- Vector3 actualHandlePosition;
- actualSelectionHandlePosition.x += displacement.x * selectionHandle.GetCurrentScale().x;
- actualSelectionHandlePosition.y += displacement.y * selectionHandle.GetCurrentScale().y;
-
- // Selection handles should jump to the nearest character
- std::size_t newHandlePosition = 0;
- newHandlePosition = mTextViewCharacterPositioning.ReturnClosestIndex( actualSelectionHandlePosition.GetVectorXY() );
-
- bool direction(false);
- Vector3 alternatePosition;
- bool alternatePositionValid(false);
- actualHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandlePosition,direction, alternatePosition, alternatePositionValid );
-
- bool handleVisible = true;
-
- if ( handleVisible && // Ensure the handle is visible.
- ( newHandlePosition != currentSelectionHandlePosition ) && // Ensure the handle has moved.
- ( newHandlePosition != mSelectionHandleTwoPosition ) && // Ensure new handle position not the same position as an existing handle.
- ( newHandlePosition != mSelectionHandleOnePosition ) )
- {
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::MoveSelectionHandle Handle visible and moved]\n");
-
- currentSelectionHandlePosition = newHandlePosition;
-
- PositionSelectionHandle( selectionHandle, actualHandlePosition, newHandlePosition );
-
- ShowUpdatedHighlight();
-
- // Set Active Style to that of first character in selection
- std::size_t firstHandleInSelection = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
-
- const TextStyle inputStyle = mTextViewCharacterPositioning.GetStyleAt( firstHandleInSelection );
- mTextStyle.SetInputStyle( inputStyle );
- }
- return actualHandlePosition; // Returns Handle position passed in if new value not assigned.
-}
-
-/**
- * GrabHandle
- */
-void Decorator::PositionGrabHandle( std::size_t positionInText )
-{
- bool direction(false);
- Vector3 alternatePosition;
- bool alternatePositionValid(false);
-
- mGrabHandlePosition = positionInText;
-
- mTextViewCharacterPositioning.UpdateTextLayoutInfo();
- mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( positionInText, direction, alternatePosition,alternatePositionValid );
-
- mTextInputHandles.GetGrabHandle().SetPosition( mActualGrabHandlePosition );
-}
-
-void Decorator::MoveGrabHandle( const Vector2& displacement /*, std::size_t currentHandlePosition */)
-{
- mActualGrabHandlePosition.x += displacement.x;
- mActualGrabHandlePosition.y += displacement.y;
-
- // Grab handle should jump to the nearest character and take cursor with it
- std::size_t newHandlePosition = mTextViewCharacterPositioning.ReturnClosestIndex( mActualGrabHandlePosition.GetVectorXY() );
-
- Vector3 actualHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandlePosition );
-
- bool handleVisible = true;
-
- if( ( newHandlePosition != mGrabHandlePosition ) && // Only redraw cursor and do updates if position changed
- ( handleVisible ) )// and the new position is visible (if scroll is not enabled, it's always true).
- {
- mActualGrabHandlePosition = actualHandlePosition;
- mTextInputHandles.GetGrabHandle().SetPosition( mActualGrabHandlePosition );
-
- //PositionGrabHandle( newHandlePosition );
- mGrabHandlePosition = newHandlePosition;
- SetCurrentCursorPosition( mGrabHandlePosition );
- DrawCursor( mGrabHandlePosition );
-
- const std::size_t cursorPosition = GetCurrentCursorPosition();
-
- // Let keyboard know the new cursor position so can 're-capture' for prediction.
- mCursorRePositionedSignal.Emit();
-
- // Set Input Style to that of cursor position
- if ( !mTextViewCharacterPositioning.IsStyledTextEmpty() && ( cursorPosition > 0 ) )
- {
- DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
- }
- }
-}
-
-void Decorator::ShowGrabHandle( bool visible )
-{
- mGrabHandleVisibility = visible;
- mTextInputHandles.SetGrabHandleVisibility( visible );
-}
-
-void Decorator::CreateGrabHandle( Actor targetParent )
-{
- if ( !mPanGestureDetector )
- {
- mPanGestureDetector = PanGestureDetector::New();
- mPanGestureDetector.DetectedSignal().Connect(this, &Decorator::OnHandlePan);
- }
-
- if ( !mTextInputHandles.GetGrabHandle() )
- {
- mTextInputHandles.CreateGrabHandle();
- mTextInputHandles.AttachGrabHandleToGivenPanGesture( mPanGestureDetector );
- targetParent.Add( mTextInputHandles.GetGrabHandle() );
- }
-}
-
-void Decorator::SetGrabHandleImage( Image image )
-{
- mTextInputHandles.SetGrabHandleImage( image );
-}
-
-void Decorator::EnableGrabHandle( bool toggle)
-{
- // enables grab handle with will in turn de-activate magnifier
- mGrabHandleEnabled = toggle;
-}
-
-bool Decorator::IsGrabHandleEnabled()
-{
- // if false then magnifier will be shown instead.
- return mGrabHandleEnabled;
-}
-
-/**
- * Cursor
- */
-std::size_t Decorator::GetCurrentCursorPosition() const
-{
- return mCursorPosition;
-}
-
-void Decorator::SetCurrentCursorPosition( std::size_t newCursorPosition )
-{
- mCursorPosition = newCursorPosition;
-}
-
-void Decorator::SetCursorVisibility( bool visible )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::SetCursorVisibility[%s]\n", ( visible )?"true":"false");
-
- mCursorVisibility = visible;
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea );
- mCursorRTL.SetVisible( mCursorVisibility && mCursorRTLEnabled );
-}
-
-void Decorator::DrawCursor(const std::size_t nthChar)
-{
- std::size_t cursorPosition = GetCurrentCursorPosition();
-
- // Get height of cursor and set its size
- Size size( CURSOR_THICKNESS, 0.0f );
-
- Vector2 min, max; // out parameters for GetRowRectFromCharacterPosition
- size.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mTextViewCharacterPositioning.GetVisualPosition( cursorPosition ), min, max ).height;
-
- mCursor.SetSize(size);
-
- // If the character is italic then the cursor also tilts.
- if ( !mTextViewCharacterPositioning.IsStyledTextEmpty() && ( cursorPosition > 0 ) )
- {
- DALI_ASSERT_DEBUG( ( 0 <= cursorPosition-1 ) && ( cursorPosition-1 < mTextViewCharacterPositioning.StyledTextSize() ) );
- const TextStyle styleAtCursor = mTextViewCharacterPositioning.GetStyleAt( cursorPosition-1 );
- mCursor.SetRotation( styleAtCursor.IsItalicsEnabled() ? Degree( styleAtCursor.GetItalicsAngle() - CURSOR_ANGLE_OFFSET ) : Degree( 0.f ), Vector3::ZAXIS );
- }
-
- DALI_ASSERT_DEBUG( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() );
- if ( ( cursorPosition <= mTextViewCharacterPositioning.GetNumberOfCharactersInText() ) )
- {
- Vector3 altPosition; // Alternate (i.e. opposite direction) cursor position.
- bool altPositionValid( false ); // Alternate cursor validity flag.
- bool directionRTL( false ); // Need to know direction of primary cursor (in case we have 2 cursors and need to show them differently)
- Vector3 position = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorPosition, directionRTL, altPosition, altPositionValid );
-
- SetAltCursorEnabled( altPositionValid );
-
- mCursor.SetPosition( position + UI_OFFSET );
- }
-}
-
-void Decorator::SetAltCursorEnabled( bool enabled )
-{
- mCursorRTLEnabled = enabled;
- mCursorRTL.SetVisible( mCursorVisibility && mCursorRTLEnabled );
-}
-
-void Decorator::SetCursorImage(Dali::Image image, const Vector4& border )
-{
- DALI_ASSERT_DEBUG ( image && "Create cursor image invalid")
-
- if ( image )
- {
- mCursor.SetImage( image );
- mCursor.SetNinePatchBorder( border );
- }
-}
-
-void Decorator::SetRTLCursorImage( Image image, const Vector4& border )
-{
- DALI_ASSERT_DEBUG ( image && "Create cursor image invalid")
-
- if ( image )
- {
- mCursorRTL.SetImage( image );
- mCursorRTL.SetNinePatchBorder( border );
- }
-}
-
-ImageActor Decorator::CreateCursor( Image cursorImage, const Vector4& border, const std::string& cursorName )
-{
- ImageActor cursor;
-
- if ( cursorImage )
- {
- cursor = ImageActor::New( cursorImage );
- }
- else
- {
- cursor = ImageActor::New( Image::New( DEFAULT_CURSOR ) );
- }
-
- cursor.SetStyle(ImageActor::STYLE_NINE_PATCH);
- cursor.SetNinePatchBorder( border );
- cursor.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER);
- cursor.SetVisible(false);
- cursor.SetName( cursorName );
- return cursor;
-}
-
-void Decorator::CreateCursors( Actor targetParent )
-{
- Image mCursorImage = Image::New( DEFAULT_CURSOR );
- mCursor = CreateCursor (mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER , "mainCursor");
- mCursorRTL = CreateCursor ( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER, "rtlCursor");
- targetParent.Add( mCursor );
- targetParent.Add( mCursorRTL );
-}
-
-Size Decorator::GetCursorSizeAt( std::size_t positionWithinTextToGetCursorSize )
-{
- std::size_t visualPosition = mTextViewCharacterPositioning.GetVisualPosition( positionWithinTextToGetCursorSize );
-
- Vector2 min, max;
-
- const Size cursorSize( CURSOR_THICKNESS,
- mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( visualPosition, min, max ).height );
-
- return cursorSize;
-}
-
-void Decorator::StartCursorBlinkTimer()
-{
- if ( !mCursorBlinkTimer )
- {
- mCursorBlinkTimer = Timer::New( CURSOR_BLINK_INTERVAL );
- mCursorBlinkTimer.TickSignal().Connect( this, &Decorator::OnCursorBlinkTimerTick );
- }
-
- if ( !mCursorBlinkTimer.IsRunning() )
- {
- mCursorBlinkTimer.Start();
- }
-}
-
-void Decorator::StopCursorBlinkTimer()
-{
- if ( mCursorBlinkTimer )
- {
- mCursorBlinkTimer.Stop();
- }
-}
-
-bool Decorator::OnCursorBlinkTimerTick()
-{
- // Cursor blinking
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea && mCursorBlinkStatus );
- if ( mCursorRTLEnabled )
- {
- mCursorRTL.SetVisible( mCursorVisibility && mIsCursorInScrollArea && mCursorBlinkStatus );
- }
- mCursorBlinkStatus = !mCursorBlinkStatus;
-
- return true;
-}
-
-/**
- * Highlight
- */
-void Decorator::ShowUpdatedHighlight()
-{
- Toolkit::TextView::TextLayoutInfo textLayoutInfo = mTextViewCharacterPositioning.GetLayoutInfo();
- TextHighlight::HighlightInfo highlightInfo = mTextHighlight.CalculateHighlightInfo( mSelectionHandleOnePosition, mSelectionHandleTwoPosition, textLayoutInfo );
-
- // Clamp highlightInfo so they don't exceed the boundary of the control.
- const Vector3& controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize();
- highlightInfo.Clamp2D( Vector2::ZERO, Vector2(controlSize.x, controlSize.y) );
-
- mTextHighlight.UpdateHighlight( highlightInfo );
-}
-
-void Decorator::CreateHighlight( Actor parent )
-{
- DALI_ASSERT_DEBUG( parent && "Highlight target parent does not exist" );
-
- if ( !mHighlightMeshActor )
- {
- mHighlightMeshActor = MeshActor::New( mTextHighlight.CreateHighLightMesh() );
- mHighlightMeshActor.SetName( "HighlightMeshActor" );
- mHighlightMeshActor.SetAffectedByLighting(false);
- parent.Add( mHighlightMeshActor );
- }
-}
-
-void Decorator::RemoveHighlight()
-{
- if ( mHighlightMeshActor )
- {
- mHighlightMeshActor.Unparent();
- mHighlightMeshActor.Reset();
- // NOTE: We cannot dereference mHighlightMesh, due to a how the scene-graph MeshRenderer uses the Mesh data.
- }
-}
-
-void Decorator::HighlightVisibility( bool visiblility )
-{
- if ( mHighlightMeshActor )
- {
- mHighlightMeshActor.SetVisible( visiblility );
- }
-}
-
-/**
- * Callbacks connected to be Property notifications for Boundary checking.
- */
-// Note If PropertyNotification signal definition included Actor we would not need to duplicate functions.
-void Decorator::OnHandleOneLeavesBoundary( PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleOne().SetOpacity(0.0f);
-}
-
-void Decorator::OnHandleOneWithinBoundary(PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleOne().SetOpacity(1.0f);
-}
-
-void Decorator::OnHandleTwoLeavesBoundary( PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleTwo().SetOpacity(0.0f);
-}
-
-void Decorator::OnHandleTwoWithinBoundary(PropertyNotification& source)
-{
- mTextInputHandles.GetSelectionHandleTwo().SetOpacity(1.0f);
-}
-
-void Decorator::OnLeftBoundaryExceeded(PropertyNotification& source)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "TextInputDecorationLayouter::OnLeftBoundaryExceeded\n");
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- selectionHandleOne.SetScale( -1.0f, 1.0f, 1.0f );
- selectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_LEFT);
-}
-
-void Decorator::OnReturnToLeftBoundary(PropertyNotification& source)
-{
- DALI_LOG_INFO(gLogFilter, Debug::General, "TextInputDecorationLayouter::OnReturnToLeftBoundary\n");
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- selectionHandleOne.SetScale( 1.0f, 1.0f, 1.0f );
- selectionHandleOne.SetAnchorPoint( AnchorPoint::TOP_RIGHT);
-}
-
-void Decorator::OnRightBoundaryExceeded(PropertyNotification& source)
-{
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
- selectionHandleTwo.SetScale( -1.0f, 1.0f, 1.0f );
- selectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_RIGHT);
-}
-
-void Decorator::OnReturnToRightBoundary(PropertyNotification& source)
-{
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
- selectionHandleTwo.SetScale( 1.0f, 1.0f, 1.0f );
- selectionHandleTwo.SetAnchorPoint( AnchorPoint::TOP_LEFT);
-}
-
-void Decorator::SetUpHandlePropertyNotifications()
-{
- /* Property notifications for handles exceeding the boundary and returning back within boundary */
-
- Vector3 handlesize = GetSelectionHandleSize();
-
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- // Exceeding horizontal boundary
- PropertyNotification leftNotification = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.x + handlesize.x) );
- leftNotification.NotifySignal().Connect( this, &Decorator::OnLeftBoundaryExceeded );
-
- PropertyNotification rightNotification = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.z - handlesize.x ) );
- rightNotification.NotifySignal().Connect( this, &Decorator::OnRightBoundaryExceeded );
-
- // Within horizontal boundary
- PropertyNotification leftLeaveNotification = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_X, GreaterThanCondition( mBoundingRectangleWorldCoordinates.x + 2*handlesize.x ) );
- leftLeaveNotification.NotifySignal().Connect( this, &Decorator::OnReturnToLeftBoundary );
-
- PropertyNotification rightLeaveNotification = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_X, LessThanCondition( mBoundingRectangleWorldCoordinates.z - 2*handlesize.x ) );
- rightLeaveNotification.NotifySignal().Connect( this, &Decorator::OnReturnToRightBoundary );
-
- // Exceeding vertical boundary
- PropertyNotification verticalExceedNotificationOne = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationOne.NotifySignal().Connect( this, &Decorator::OnHandleOneLeavesBoundary );
-
- PropertyNotification verticalExceedNotificationTwo = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalExceedNotificationTwo.NotifySignal().Connect( this, &Decorator::OnHandleTwoLeavesBoundary );
-
- // Within vertical boundary
- PropertyNotification verticalWithinNotificationOne = selectionHandleOne.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationOne.NotifySignal().Connect( this, &Decorator::OnHandleOneWithinBoundary );
-
- PropertyNotification verticalWithinNotificationTwo = selectionHandleTwo.AddPropertyNotification( Actor::WORLD_POSITION_Y,
- InsideCondition( mBoundingRectangleWorldCoordinates.y + handlesize.y,
- mBoundingRectangleWorldCoordinates.w - handlesize.y ) );
- verticalWithinNotificationTwo.NotifySignal().Connect( this, &Decorator::OnHandleTwoWithinBoundary );
-}
-
-/**
- * PopUp
- */
-Vector3 Decorator::PositionOfPopUpRelativeToSelectionHandles()
-{
- Vector3 position;
- Vector2 min, max;
- Vector3 topHandle;
- Size rowSize;
-
- // When text is selected, show popup above top handle (and text), or below bottom handle.
-
- // topHandle: referring to the top most point of the handle or the top line of selection.
- if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y ) // Handle may switch positions so calculate which is top.
- {
- topHandle = mSelectionHandleOneActualPosition;
- rowSize= mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleOnePosition, min, max );
- }
- else
- {
- topHandle = mSelectionHandleTwoActualPosition;
- rowSize = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( mSelectionHandleTwoPosition, min, max );
- }
- topHandle.y += TOP_HANDLE_TOP_OFFSET - rowSize.height;
- position = Vector3(topHandle.x, topHandle.y, 0.0f);
-
- return position;
-}
-
-Vector3 Decorator::AlternatePopUpPositionRelativeToSelectionHandles()
-{
- // alternativePosition: referring to the bottom most point of the handle or the bottom line of selection.
- Vector3 alternativePosition;
- alternativePosition.y = std::max ( mSelectionHandleTwoActualPosition.y , mSelectionHandleOneActualPosition.y );
- alternativePosition.y += GetSelectionHandleSize().y + mPopUpPanel.GetSize().y + BOTTOM_HANDLE_BOTTOM_OFFSET;
-
- return alternativePosition;
-}
-
-Vector3 Decorator::PositionOfPopUpRelativeToCursor()
-{
- // When no text is selected, show PopUp at position of cursor
- Vector3 position;
- Vector2 min, max;
- std::size_t cursorPosition = GetCurrentCursorPosition();
- position = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorPosition );
- const Size rowSize = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( cursorPosition, min, max );
- position.y -= rowSize.height;
-
- return position;
-}
-
-Vector3 Decorator::AlternatePopUpPositionRelativeToCursor()
-{
- std::size_t cursorPosition = GetCurrentCursorPosition();
- Vector3 alternativePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorPosition );
-
- if ( mTextInputHandles.GetGrabHandle() )
- {
- // If grab handle enabled then position pop-up below the grab handle.
- alternativePosition.y += mTextInputHandles.GetGrabHandle().GetCurrentSize().height + mPopUpPanel.GetSize().y + BOTTOM_HANDLE_BOTTOM_OFFSET ;
- }
- else
- {
- alternativePosition.y += mPopUpPanel.GetSize().y;
- }
-
- return alternativePosition;
-
-}
-
-Vector3 Decorator::PositionOfPopUpRelativeToGrabHandle()
-{
- return Vector3::ZERO;
-}
-
-void Decorator::ShowPopUp()
-{
- Vector3 position;
- Vector3 alternativePosition;
- Size rowSize;
-
- DALI_ASSERT_DEBUG( mPopUpTarget && "PopUp Target Actor does not exist" );
-
- if( mHighlightMeshActor ) // Text Selection mode
- {
- position = PositionOfPopUpRelativeToSelectionHandles();
- }
- else // Not in Text Selection mode so position relative to cursor.
- {
- position = PositionOfPopUpRelativeToCursor();
- }
-
- // reposition popup above the desired cursor position.
- mPopUpPanel.Show( mPopUpTarget, true );
- mPopUpPanel.Self().SetPosition( position );
- mPopUpPanel.PressedSignal().Connect( this, &Decorator::OnPopupButtonPressed );
-
- SetUpPopUpPositionNotifications();
- mPopUpPanel.ApplyConfinementConstraint( mBoundingRectangleWorldCoordinates );
-}
-
-void Decorator::ShowPopUp( Actor target )
-{
- mPopUpTarget = target;
- ShowPopupCutCopyPaste();
-}
-
-void Decorator::ShowPopupCutCopyPaste()
-{
- bool isAllTextSelectedAlready = ( mTextViewCharacterPositioning.StyledTextSize() == GetSelectedText().size() );
- bool isTextEmpty = mTextViewCharacterPositioning.IsStyledTextEmpty() ;
- bool isSubsetOfTextAlreadySelected = ( !isAllTextSelectedAlready ) && mHighlightMeshActor;
-
- Clipboard clipboard = Clipboard::Get();
- bool hasClipboardGotContent = clipboard.NumberOfItems();
-
- mPopUpPanel.CreateCutCopyPastePopUp( isAllTextSelectedAlready, isTextEmpty, hasClipboardGotContent, isSubsetOfTextAlreadySelected );
- ShowPopUp();
-}
-
-void Decorator::HidePopUp( bool animate, bool signalFinished )
-{
-}
-
-void Decorator::AddPopupOption(const std::string& name, const std::string& caption, const Image icon, bool finalOption)
-{
- mPopUpPanel.AddButton(name, caption, icon, finalOption);
-}
-
-void Decorator::ClearPopup()
-{
- mPopUpPanel.Clear();
-}
-
-void Decorator::PopUpLeavesVerticalBoundary( PropertyNotification& source)
-{
- Vector3 position, alternativePosition;
-
- if( mHighlightMeshActor ) // Text Selection mode
- {
- alternativePosition = AlternatePopUpPositionRelativeToSelectionHandles();
- }
- else // Not in Text Selection mode
- {
- alternativePosition = AlternatePopUpPositionRelativeToCursor();
- // if can't be positioned above, then position below row.
- }
- // reposition popup above the desired cursor position.
- mPopUpPanel.Self().SetPosition( alternativePosition );
-}
-
-void Decorator::SetUpPopUpPositionNotifications( )
-{
- // Note Property notifications ignore any set anchor point so conditions must allow for this. Default is Top Left.
-
- // Exceeding vertical boundary
- PropertyNotification verticalExceedNotificationOne = mPopUpPanel.Self().AddPropertyNotification( Actor::WORLD_POSITION_Y,
- OutsideCondition( mBoundingRectangleWorldCoordinates.y + mPopUpPanel.GetSize().y/2,
- mBoundingRectangleWorldCoordinates.w - mPopUpPanel.GetSize().y/2 ) );
- verticalExceedNotificationOne.NotifySignal().Connect( this, &Decorator::PopUpLeavesVerticalBoundary );
-}
-
-bool Decorator::OnPopupButtonPressed( Toolkit::Button button )
-{
- mPopUpButtonPressedSignal.Emit( button );
- return false;
-}
-
-Decorator::PressedSignal& Decorator::PopUpButtonPressedSignal()
-{
- return mPopUpButtonPressedSignal;
-}
-
-Decorator::CursorPositionedSignal& Decorator::CursorRePositionedSignal()
-{
- return mCursorRePositionedSignal;
-}
-
-/**
- * Decoration Positioning during Scrolling
- */
-void Decorator::TextViewScrolled( Toolkit::TextView textView, Vector2 scrollPosition )
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::TextViewScrolled\n");
-
- const Vector3& controlSize = mTextViewCharacterPositioning.GetTextView().GetCurrentSize(); // todo Could store size and only update in Control Size change.
- Size cursorSize( CURSOR_THICKNESS, 0.f );
-
- // Updates the cursor and grab handle position and visibility.
- if( mTextInputHandles.GetGrabHandle() || mCursor )
- {
- Vector2 min, max;
- size_t cursorTextPosition = GetCurrentCursorPosition();
- cursorSize.height = mTextViewCharacterPositioning.GetRowRectFromCharacterPosition( cursorTextPosition, min, max ).height;
-
- const Vector3 cursorPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( cursorTextPosition );
-
- bool mIsCursorInScrollArea = IsPositionWithinControl( cursorPosition, cursorSize, controlSize );
- bool mIsGrabHandleInScrollArea = mIsCursorInScrollArea;
-
- Vector2 actualGrabHandlePosition = cursorPosition.GetVectorXY();
-
- if( mTextInputHandles.GetGrabHandle() )
- {
- ShowGrabHandle( mGrabHandleVisibility && mIsGrabHandleInScrollArea );
- PositionGrabHandle( cursorTextPosition );
- }
-
- if( mCursor )
- {
- mCursor.SetVisible( mCursorVisibility && mIsCursorInScrollArea );
- DrawCursor( cursorTextPosition );
- mCursor.SetPosition( Vector3(actualGrabHandlePosition) + UI_OFFSET );
- }
- }
-
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- // Updates the selection handles and highlighted text position and visibility.
- if( mTextInputHandles.GetSelectionHandleOne() && mTextInputHandles.GetSelectionHandleTwo() )
- {
- const Vector3 cursorPositionOne = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition );
- const Vector3 cursorPositionTwo = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition );
-
- Size cursorSize( GetCursorSizeAt( mSelectionHandleOnePosition ) );
- const bool isSelectionHandleOneVisible = IsPositionWithinControl( cursorPositionOne, cursorSize, controlSize );
-
- cursorSize = GetCursorSizeAt( mSelectionHandleTwoPosition );
- const bool isSelectionHandleTwoVisible = IsPositionWithinControl( cursorPositionTwo, cursorSize, controlSize );
-
- mSelectionHandleOneActualPosition = cursorPositionOne.GetVectorXY();
- mSelectionHandleTwoActualPosition = cursorPositionTwo.GetVectorXY();
-
- selectionHandleOne.SetVisible( isSelectionHandleOneVisible );
- selectionHandleTwo.SetVisible( isSelectionHandleTwoVisible );
-
- PositionSelectionHandle( selectionHandleOne, mSelectionHandleOneActualPosition, mSelectionHandleOnePosition );
- PositionSelectionHandle( selectionHandleTwo, mSelectionHandleTwoActualPosition, mSelectionHandleTwoPosition );
-
- if( mHighlightMeshActor )
- {
- mHighlightMeshActor.SetVisible( true );
- ShowUpdatedHighlight();
- }
- }
-}
-
-void Decorator::StartScrollTimer()
-{
- if( !mScrollTimer )
- {
- mScrollTimer = Timer::New( SCROLL_TICK_INTERVAL );
- mScrollTimer.TickSignal().Connect( this, &Decorator::OnScrollTimerTick );
- }
-
- if( !mScrollTimer.IsRunning() )
- {
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::StartScrollTimer\n");
- mScrollTimer.Start();
- }
-}
-
-void Decorator::StopScrollTimer()
-{
- if( mScrollTimer )
- {
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::StopScrollTimer\n");
-
- mScrollTimer.Stop();
- mScrollTimer.Reset();
- }
-}
-
-bool Decorator::OnScrollTimerTick()
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::OnScrollTimerTick\n");
-
- if ( mGrabHandleVisibility && mTextInputHandles.GetGrabHandle() )
- {
- std::size_t newGrabHandlePosition = mTextViewCharacterPositioning.ReturnClosestIndex( mActualGrabHandlePosition.GetVectorXY() );
- if ( mGrabHandlePosition != newGrabHandlePosition )
- {
- Vector2 scrollPosition = mTextViewCharacterPositioning.GetScrollPosition();
- Vector2 scrollDelta = ( mActualGrabHandlePosition - mCurrentHandlePosition ).GetVectorXY();
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextInputDecorationLayouter::OnScrollTimerTick scrollPosition(%f) scrollDelta(%f)\n", scrollPosition.x, scrollDelta.x);
- scrollPosition += scrollDelta;
- mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
-
- mActualGrabHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newGrabHandlePosition ).GetVectorXY();
- }
- }
-
- Actor selectionHandleOne = mTextInputHandles.GetSelectionHandleOne();
- Actor selectionHandleTwo = mTextInputHandles.GetSelectionHandleTwo();
-
- if ( selectionHandleOne && selectionHandleTwo )
- {
- std::size_t newHandleOnePosition = mTextViewCharacterPositioning.ReturnClosestIndex( mSelectionHandleOneActualPosition.GetVectorXY() );
-
- // todo duplicated code should be a function
-
- if ( mSelectionHandleOnePosition != newHandleOnePosition )
- {
- const Vector3 actualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandleOnePosition );
-
- Vector2 scrollDelta = ( actualPosition - mSelectionHandleOneActualPosition ).GetVectorXY();
-
- Vector2 scrollPosition = mTextViewCharacterPositioning.GetScrollPosition();
- scrollPosition += scrollDelta;
- mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
-
- mSelectionHandleOnePosition = newHandleOnePosition;
- mSelectionHandleOneActualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleOnePosition ).GetVectorXY();
- }
- else
- {
- mSelectionHandleOneActualPosition.x += mScrollDisplacement.x;
- mSelectionHandleOneActualPosition.y += mScrollDisplacement.y;
- }
-
- std::size_t newHandleTwoPosition = mTextViewCharacterPositioning.ReturnClosestIndex( mSelectionHandleTwoActualPosition.GetVectorXY() );
-
- if ( mSelectionHandleTwoPosition != newHandleTwoPosition )
- {
- const Vector3 actualPosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( newHandleTwoPosition );
-
- Vector2 scrollDelta = ( actualPosition - mSelectionHandleTwoActualPosition ).GetVectorXY();
-
- Vector2 scrollPosition = mTextViewCharacterPositioning.GetScrollPosition();
- scrollPosition += scrollDelta;
- mTextViewCharacterPositioning.SetScrollPosition( scrollPosition );
-
- mSelectionHandleTwoPosition = newHandleTwoPosition;
- mCurrentHandlePosition = mTextViewCharacterPositioning.GetActualPositionFromCharacterPosition( mSelectionHandleTwoPosition ).GetVectorXY();
-
- }
- else
- {
- mSelectionHandleTwoActualPosition.x += mScrollDisplacement.x;
- mSelectionHandleTwoActualPosition.y += mScrollDisplacement.y;
- }
- }
-
- return true;
-}
-
-/**
- * Text Selection
- */
-MarkupProcessor::StyledTextArray Decorator::GetSelectedText()
-{
- MarkupProcessor::StyledTextArray currentSelectedText;
-
- if ( mHighlightMeshActor ) // Text Selected
- {
- MarkupProcessor::StyledTextArray::iterator it = mTextViewCharacterPositioning.GetStyledTextArray().begin() + std::min(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
- MarkupProcessor::StyledTextArray::iterator end = mTextViewCharacterPositioning.GetStyledTextArray().begin() + std::max(mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
-
- for(; it != end; ++it)
- {
- MarkupProcessor::StyledText& styledText( *it );
- currentSelectedText.push_back( styledText );
- }
- }
- return currentSelectedText;
-}
-
-} // Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_DECORATOR_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_DECORATOR_H__
-
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/adaptor-framework/timer.h>
-#include <dali/public-api/animation/animation.h>
-#include <dali/public-api/common/intrusive-ptr.h>
-#include <dali/public-api/geometry/mesh.h>
-#include <dali/public-api/signals/connection-tracker.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/text-input/textview-character-positions-impl.h>
-#include <dali-toolkit/internal/controls/text-input/text-input-handles-impl.h>
-#include <dali-toolkit/internal/controls/text-input/text-input-text-highlight-impl.h>
-#include <dali-toolkit/internal/controls/text-input/text-input-popup-new-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class Decorator;
-
-typedef IntrusivePtr<Decorator> DecoratorPtr;
-
-/**
- * @brief Decorator Class
- *
- * Decorations are Selection Handles, cursor, grab handle, magnifier the "cut copy paste" PopUp and Selection highlight.
- * The Decorator triggers creation of these decorations and positions them.
- * Decoration positions can be dependent on other decorations like the PopUp on the Selection handles.
- * The decorator maintains a Bounding Box which the decorations have to be positioned within, decorations can be flipped or hidden to obey this Bounding Box.
- * Scrolling of Text can effect positioning of decorations, the decorator repositions decorations in this case.
- */
-
-class Decorator : public ConnectionTracker
-{
-
-public:
-
- /**
- * @brief Constructor
- *
- * @param[in] textviewManager TextViewManager to be used
- */
- Decorator( TextViewCharacterPositioning& textviewManager, TextInputTextStyle& textStyle);
-
- /**
- * @brief Default destructor
- */
- ~Decorator();
-
- /**
- * @brief Set the dimensions of the bounding rectangle for decorations to obey.
- *
- * @param[in] boundingRectangle
- */
- void SetBoundingBox( const Rect<float>& boundingRectangle );
-
- /**
- * @brief Get the bounding dimensions of the bounding box
- *
- * @return dimensions of the bounding box from world origin. (x, y, w, z )
- *
- * -----------------
- * | ^ |
- * | | |
- * | y |
- * | | |
- * | v |
- * |<--x--> o <--z-->|
- * | ^ |
- * | | |
- * | w |
- * | | |
- * | v |
- * -----------------
- */
- Vector4 GetBoundingBox() const;
-
- /**
- * @brief Callback when a handle is panned/moved, either selection handles or grab handle
- *
- * @param actor Handle of the selection or grab handle.
- * @param gesture Data structure with the parameters of the gesture.
- */
- void OnHandlePan(Actor actor, const PanGesture& gesture);
-
- // Selection Handles
-
- /**
- * @brief Create a left and right selection handle and parent both to the provided actor
- * @param[in] parent actor in which the handles should be added to.
- */
- void CreateSelectionHandles( Actor parent );
-
- /**
- * @brief Remove selection handles from their parent
- */
- void RemoveSelectionHandles();
-
- /**
- * @brief Get size of Selection handles
- *
- * @return size of a selection handle
- */
- Vector3 GetSelectionHandleSize();
-
- /**
- * @brief Get position of Selection handle within text
- *
- * @return character position of a selection handle one
- */
- std::size_t GetHandleOnePosition() const;
-
- /**
- * @brief Get position of Selection handle within text
- *
- * @return character position of a selection handle two
- */
- std::size_t GetHandleTwoPosition() const;
-
- /**
- * @brief Position Selection a single handle at given positions within the text string.
- *
- * @param[in] selectionHandle handle to be positioned
- * @param[in] position where to place handle
- * @return Vector3 Position of handle as a coordinate.
- */
- Vector3 PositionSelectionHandle( Actor selectionHandle, std::size_t position );
-
- /**
- * @brief Position Selection a single handle at given coordinates
- *
- * @param[in] selectionHandle handle to be positioned
- * @param[in] actualPosition coordinates to position handle
- * @param[in] position where to place handle
- * @return Vector3 Position of handle as a coordinate.
- */
- Vector3 PositionSelectionHandle( Actor selectionHandle, Vector3& actualPosition, std::size_t position );
-
- /**
- * @brief Make both selection handle visible or invisible
- * @param[in] visible true to make visible, false to fine
- */
- void SetSelectionHandlesVisibility( bool visible );
-
- /**
- * @brief Position Selection handles at given positions within the text string.
- *
- * @param[in] start where to place first handle
- * @param[in] end where to place second handle
- */
- void PositionSelectionHandles( std::size_t start, std::size_t end );
-
- /**
- * @brief Move selection handle by the given displacement.
- *
- * @param[in] selectionHandle Actor to move
- * @param[in] actualSelectionHandlePosition actual current position of the handle in x y z
- * @param[in] currentSelectionHandlePosition current position along the string
- * @param[in] displacement the x y displacement
- */
- Vector3 MoveSelectionHandle( Actor selectionHandle,
- Vector3& actualSelectionHandlePosition,
- std::size_t& currentSelectionHandlePosition,
- const Vector2& displacement );
-
- /* Grab Handle */
-
- /**
- * @brief Position GrabHandlewith depending on the the character in the text it should be placed at
- * @param[in] positonInText the character position within the text the handle should be at
- */
- void PositionGrabHandle( std::size_t positionInText );
-
- /**
- * @brief Move grab handle to the required position within the text
- *
- * @param[in] displacement Displacement of the grab handle in actor coordinates.
- */
- void MoveGrabHandle( const Vector2& displacement );
-
-&nbs