-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * 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>
// 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;
bool TestBeginsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( input, styledText, true );
+ // Creates a text with the string.
+ Text text( input );
- const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( styledText ) );
+ const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( text ) );
if( !ret )
{
bool TestContainsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( input, styledText, true );
+ // Creates a text with the string.
+ Text text( input );
- const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( styledText ) );
+ const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( text ) );
if( !ret )
{
//////////////////////////////////////////////////////////////////
-struct SplitInLinesTest
+struct SplitInParagraphsTest
{
std::string inputText;
- std::size_t resultNumberOfLines;
+ std::size_t resultNumberOfParagraphs;
};
-bool TestSplitInLines( const SplitInLinesTest& test, const char* location )
+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<MarkupProcessor::StyledTextArray> lines;
+ std::vector<Text> paragraphs;
+ std::vector< Vector<TextStyle*> > styles;
- TextProcessor::SplitInLines( styledText,
- lines );
+ TextProcessor::SplitInParagraphs( styledText,
+ paragraphs,
+ styles );
- if( lines.size() != test.resultNumberOfLines )
+ if( paragraphs.size() != test.resultNumberOfParagraphs )
{
tet_printf( "Fail. %s", location );
- tet_printf( "Different number of lines, result %d, expected result %d", lines.size(), test.resultNumberOfLines );
+ tet_printf( "Different number of paragraphs, result %d, expected result %d", paragraphs.size(), test.resultNumberOfParagraphs );
return false;
}
{
std::string inputText;
- std::size_t resultNumberOfWords;
+ std::size_t resultNumberOfSeparators;
};
bool TestSplitInWords( const SplitInWordsTest& test, const char* location )
{
- // Creates a styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( test.inputText, styledText, true );
+ // Creates a text with the string.
+ Text text( test.inputText );
- std::vector<MarkupProcessor::StyledTextArray> words;
+ Vector<std::size_t> positions;
- TextProcessor::SplitInWords( styledText,
- words );
+ TextProcessor::SplitInWords( text,
+ positions );
- if( words.size() != test.resultNumberOfWords )
+ if( positions.Count() != test.resultNumberOfSeparators )
{
tet_printf( "Fail. %s", location );
- tet_printf( "Different number of words, result %d, expected result %d", words.size(), test.resultNumberOfWords );
+ tet_printf( "Different number of separators, result %d, expected result %d", positions.Count(), test.resultNumberOfSeparators );
return false;
}
} // namespace
-int UtcDaliTextViewSplitInLines(void)
+int UtcDaliTextViewSplitInParagraphs(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliTextViewSplitInLines : ");
+ tet_infoline("UtcDaliTextViewSplitInParagraphs : ");
- struct SplitInLinesTest splitInLinesTest[] =
+ struct SplitInParagraphsTest splitInParagraphsTest[] =
{
{
std::string( "Hello world\nhello world." ),
for( std::size_t index = 0; index < numberOfTests; ++index )
{
- const SplitInLinesTest& test = splitInLinesTest[index];
+ const SplitInParagraphsTest& test = splitInParagraphsTest[index];
- if( !TestSplitInLines( test, TEST_LOCATION ) )
+ if( !TestSplitInParagraphs( test, TEST_LOCATION ) )
{
tet_result( TET_FAIL );
}
{
{
std::string( "Hello world, hello word!" ),
- 7
+ 3u
},
+ {
+ std::string( "Hello world\n" ),
+ 2u
+ }
};
- const std::size_t numberOfTests( 1 );
+ const std::size_t numberOfTests( 2u );
for( std::size_t index = 0; index < numberOfTests; ++index )
{