+++ /dev/null
-!Makefile
-tet_captured
-results-desktop
-results-target
-results
-rules.mk
-dali.info
+++ /dev/null
-export ARCH=desktop
-
-
-if [ -z "$DESKTOP_PREFIX" ] ; then
- if [ -z "$PREFIX" ] ; then
- echo "####################################################"
- echo "# DESKTOP_PREFIX is not set. Recommend running #"
- echo "# dali_env -s to create setenv script #"
- echo "####################################################"
- else
- echo "####################################################"
- echo "# DESKTOP_PREFIX is not set. Using PREFIX instead. #"
- echo "# #"
- echo "# Warning, PREFIX is deprecated, please use #"
- echo "# dali_env to set up your environment. #"
- echo "####################################################"
- export DESKTOP_PREFIX=$PREFIX
- fi
-fi
-
-export TET_INSTALL_PATH=$HOME/Packages/tetware-desktop # Your tetware root path
-export PATH=$TET_INSTALL_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$TET_INSTALL_PATH/lib/tet3:$LD_LIBRARY_PATH
-export TET_ROOT=$TET_INSTALL_PATH
-export DALI_IMAGE_DIR=$DESKTOP_PREFIX/share/app.dalimenu/images/
-export DALI_MODEL_DIR=$DESKTOP_PREFIX/share/app.dalimenu/models/
-export DALI_STYLE_DIR=$DESKTOP_PREFIX/share/themes/dali/
-
-set $(pwd)
-export TET_SUITE_ROOT=$1
-
-set $(date +%s)
-FILE_NAME_EXTENSION=$1
+++ /dev/null
-export ARCH=target
-
-export TET_INSTALL_PATH=/scratchbox/TETware # tetware root path
-export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path
-export PATH=$TET_TARGET_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
-export DALI_IMAGE_DIR=/opt/share/app.dalimenu/images/
-export DALI_MODEL_DIR=/opt/share/app.dalimenu/models/
-export DALI_STYLE_DIR=/opt/share/themes/dali/
-
-export TET_ROOT=$TET_TARGET_PATH
-
-set $(pwd)
-export TET_SUITE_ROOT=$1
-
-set $(date +%s)
-FILE_NAME_EXTENSION=$1
+++ /dev/null
-export ARCH=target
-
-export TET_INSTALL_PATH=$HOME/git/TETware # tetware root path
-export TET_TARGET_PATH=$TET_INSTALL_PATH
-export PATH=$TET_TARGET_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
-export DALI_IMAGE_DIR=/opt/share/app.dalimenu/images/
-export DALI_MODEL_DIR=/opt/share/app.dalimenu/models/
-export DALI_STYLE_DIR=/opt/share/themes/dali/
-
-export TET_ROOT=$TET_TARGET_PATH
-
-set $(pwd)
-export TET_SUITE_ROOT=$1
-
-set $(date +%s)
-FILE_NAME_EXTENSION=$1
+++ /dev/null
-export ARCH=target
-
-export TET_INSTALL_PATH=/mnt/nfs/git/TETware # path to mount
-export TET_TARGET_PATH=$TET_INSTALL_PATH
-export PATH=$TET_TARGET_PATH/bin:$PATH
-export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
-export DALI_IMAGE_DIR=/opt/share/app.dalimenu/images/
-export DALI_MODEL_DIR=/opt/share/app.dalimenu/models/
-export DALI_STYLE_DIR=/opt/share/themes/dali/
-
-export TET_ROOT=$TET_TARGET_PATH
-
-set $(pwd)
-export TET_SUITE_ROOT=$1
-
-set $(date +%s)
-FILE_NAME_EXTENSION=$1
+++ /dev/null
-#!/bin/bash
-
-TEMP=`getopt -o 2vds: --long 2,verbose,desktop,scenario: \
- -n 'build_out.sh' -- "$@"`
-
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
-
-# Note the quotes around `$TEMP': they are essential!
-eval set -- "$TEMP"
-
-scenario=all
-opt_verbose=0
-opt_env=scratchbox
-
-while true ; do
- case "$1" in
- -d|--desktop) opt_env=desktop ; shift ;;
- -s|--scenario) scenario="$2" ; shift 2 ;;
- -v|--verbose) opt_verbose=1 ; shift ;;
- -2|--2) opt_env=sbs ; shift ;;
- --) shift ; break ;;
- *) echo "Internal error!" ; exit 1 ;;
- esac
-done
-
-
-case "$opt_env" in
- desktop)
- . _export_desktop.sh
- cat <<EOF > coverage.mk
-LDFLAGS += --coverage
-EOF
- ;;
- scratchbox)
- . _export_env.sh
- cat <<EOF > coverage.mk
-LDFLAGS +=
-EOF
- ;;
- sbs)
- . _export_sbs.sh
- cat <<EOF > coverage.mk
-LDFLAGS +=
-EOF
- ;;
-esac
-
-
-echo PATH=$PATH
-echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-echo TET_ROOT=$TET_ROOT
-echo TET_SUITE_ROOT=$TET_SUITE_ROOT
-echo ARCH=$ARCH
-
-RESULT_DIR=results-$ARCH
-HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
-JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
-
-# Faster cleanup.
-find . -name Makefile -execdir make -f {} clean \;
-
-mkdir -p $RESULT_DIR
-if [ $opt_verbose -eq 1 ] ; then
- tcc -b -j - ./ $scenario | tee $JOURNAL_RESULT
-else
- tcc -b -j $JOURNAL_RESULT -p ./ $scenario
-fi
-./tbp.pl $JOURNAL_RESULT
-
-
+++ /dev/null
-#!/bin/bash
-
-./build.sh -v $*
+++ /dev/null
-LDFLAGS += --coverage
+++ /dev/null
-#!/bin/bash
-
-( cd ../build/slp ; make cov_data )
-
-for i in `find . -name Makefile` ; do
- (
- cd $(dirname $i)
- echo `pwd`
- covs=( `ls *.gcda 2>/dev/null` )
- if [[ $? -eq 0 ]]
- then
- make coverage
- fi
- )
-done
-
-(
- cd .. ;
- genhtml -o build/slp/doc/coverage `find . -name dali.info`
-)
-
-
+++ /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.
-#
-
-CC = g++
-
-TARGETS =
-include file.list
-
-PKGS = dali-core dali dali-toolkit dali-test-suite-utils
-include ../../rules.mk
-include ../../coverage.mk
-
-TOOLKIT_TEST_UTILS_DIR=../../dali-toolkit-test-utils/
-
-CXXFLAGS += -I$(TOOLKIT_TEST_UTILS_DIR)
-
-TOOLKIT_TEST_UTILS_SRC_FILES = \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-application.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-adaptor.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-clipboard-event-notifier.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-accessibility-manager.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-physical-keyboard.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-style-monitor.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-timer.cpp \
- $(TOOLKIT_TEST_UTILS_DIR)/toolkit-orientation.cpp
-
-all: $(TARGETS)
-
-%: %.cpp $(TOOLKIT_TEST_UTILS_SRC_FILES)
- $(CC) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
-
-clean:
- @rm -f $(notdir $(TARGETS))
- @rm -f tet_captured
- @rm -f *~
- @rm -f *.gcda *.gcno
-
-coverage:
- @lcov --directory . -c -o dali.info
- @lcov --remove dali.info "*boost*" "/usr/include/*" "*/automated-tests/*" -o dali.info
+++ /dev/null
-../dali-test-suite/tc-gen.sh
\ No newline at end of file
+++ /dev/null
-utc-Dali-TextInput
+++ /dev/null
-../master-makefile.mk
\ No newline at end of file
+++ /dev/null
-TARGETS += \
- utc-Dali-TextInput \
+++ /dev/null
-/dali-internal-test-suite/text-input/utc-Dali-TextInput
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali/integration-api/events/key-event-integ.h>
-
-// Internal includes
-#include <dali-toolkit/internal/controls/text-input/text-input-impl.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliInternalTextInputTextSelection, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextInputSetGetExceedEnabled, POSITIVE_TC_IDX );
-// TEST_FUNCTION( UtcDaliTextInputMethod02, NEGATIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-
-/**
- * Test: Selected is replaced by new input text.
- **/
-static void UtcDaliInternalTextInputTextSelection()
-{
- const char* testChar = "v";
-
- ToolkitTestApplication application;
-
- tet_infoline("Testing Text Selection with replace.");
-
- Toolkit::TextInput textInput = Toolkit::TextInput::New();
-
- DALI_TEST_CHECK(textInput);
-
- Stage::GetCurrent().Add(textInput);
-
- textInput.SetInitialText("Test String");
-
- std::string initialText = textInput.GetText();
-
- tet_printf("Set Initial text: %s\n", initialText.c_str() );
-
- textInput.SetKeyInputFocus();
-
- GetImpl(textInput).SelectText(0,11);
-
- tet_printf("Select all of Initial text\n");
-
- Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );
-
- application.ProcessEvent( event );
-
- tet_printf("Simulate pressing of a key: %s\n", testChar );
-
- std::string newText = textInput.GetText();
-
- tet_printf("Check current text (%s) is the new text \n", newText.c_str() );
-
- DALI_TEST_EQUALS("v",textInput.GetText(), TEST_LOCATION);
-}
-
-static void UtcDaliTextInputSetGetExceedEnabled()
-{
- tet_infoline("UtcDaliTextInputSetGetExceedEnabled: ");
-
- ToolkitTestApplication application;
-
- Toolkit::TextInput textInput = Toolkit::TextInput::New();
- textInput.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
- textInput.SetWidthExceedPolicy( Toolkit::TextView::Split );
- textInput.SetHeightExceedPolicy( Toolkit::TextView::Original );
-
- DALI_TEST_CHECK( textInput.GetExceedEnabled() );
-
- Toolkit::Internal::TextInput& textInputImpl = static_cast<Toolkit::Internal::TextInput&>( textInput.GetImplementation() );
-
- textInput.SetSize( 50.f, 50.f );
- textInput.SetExceedEnabled( false );
-
- DALI_TEST_CHECK( !textInput.GetExceedEnabled() );
-
-
- textInputImpl.InsertAt( Text("He"), 0 );
-
- DALI_TEST_EQUALS("He",textInput.GetText(), TEST_LOCATION);
-
- textInputImpl.InsertAt( Text("llo"), 2 );
-
- DALI_TEST_EQUALS("Hello",textInput.GetText(), TEST_LOCATION);
-
- textInputImpl.InsertAt( Text(" world! hello world hello world hello world"), 5 ); // Doesn't fit so is not added.
-
- DALI_TEST_EQUALS("Hello",textInput.GetText(), TEST_LOCATION);
-}
+++ /dev/null
-utc-Dali-TextView
-utc-Dali-TextView-HelperAndDebug
-utc-Dali-TextView-Processor
-utc-Dali-TextView-Processor-Types
-utc-Dali-TextView-Relayout-Utilities
+++ /dev/null
-../master-makefile.mk
\ No newline at end of file
+++ /dev/null
-TARGETS += \
- utc-Dali-TextView \
- utc-Dali-TextView-HelperAndDebug \
- utc-Dali-TextView-Processor \
- utc-Dali-TextView-Processor-Types \
- utc-Dali-TextView-Relayout-Utilities \
\ No newline at end of file
+++ /dev/null
-/dali-internal-test-suite/text-view/utc-Dali-TextView
-/dali-internal-test-suite/text-view/utc-Dali-TextView-Processor
-/dali-internal-test-suite/text-view/utc-Dali-TextView-Processor-Types
-/dali-internal-test-suite/text-view/utc-Dali-TextView-Relayout-Utilities
-/dali-internal-test-suite/text-view/utc-Dali-TextView-HelperAndDebug
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.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;
-
-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 lineIndex;
- std::size_t groupIndex;
- std::size_t wordIndex;
- std::size_t characterIndex;
-};
-
-/**
- * Gets the line, group, 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 resultLineIndex Index to the line where the character is located.
- * @param resultGroupIndex Index to the group within the line where the character is located.
- * @param resultWordIndex Index to the word within the group 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 resultLineIndex,
- const std::size_t resultGroupIndex,
- 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.mLineIndex != resultLineIndex )
- {
- tet_printf( "Fail. different line index. %s", location );
- return false;
- }
- if( indices.mGroupIndex != resultGroupIndex )
- {
- tet_printf( "Fail. different group 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
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliTextViewGetIndicesFromGlobalCharacterIndex, POSITIVE_TC_IDX ); // Tests correctness when indices to lines, groups, words and characters are worked out from a given global position.
-TEST_FUNCTION( UtcDaliTextViewDebugCouts, POSITIVE_TC_IDX ); // Tests debug functions just to not to penalize the coverage.
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliTextViewGetIndicesFromGlobalCharacterIndex()
-{
- 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,
- 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,
- 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,
- 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,
- 1,
- 0,
- 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,
- 0,
- 3
- },
- /* TODO Check for mixed RTL and LTR text.
- {
- std::string( "Test position 33. (end of the second word of the second line)" ),
- 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,
- 0,
- 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,
- 1,
- 3,
- 3
- },
- */
- };
- const std::size_t numberOfTests( 5 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const GetIndicesFromGlobalCharacterIndexTest& test = getIndicesFromGlobalCharacterIndexTests[index];
-
- if( !TestGetIndicesFromGlobalCharacterIndex( test.description, test.input, test.position, test.lineIndex, test.groupIndex, test.wordIndex, test.characterIndex, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewDebugCouts()
-{
- /////////////////////////////////////////////////////
- // 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 );
-}
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.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;
-
-namespace
-{
-// Data structures used to create an 'experiment' in TET cases
-
-//////////////////////////////////////////////////////////////////
-} // namespace
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliTextViewDefaultConstructorDestructor, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextViewCopyConstructorOperator, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextViewEqualityOperator, POSITIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliTextViewDefaultConstructorDestructor()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
-
- TextViewProcessor::TextInfoIndices indices;
- DALI_TEST_EQUALS( indices.mLineIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( indices.mGroupIndex, 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.mHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mAdvance, 0.f, 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.mSize, 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_CHECK( characterLayoutInfo.mStyledText.mText.IsEmpty() );
- DALI_TEST_EQUALS( characterLayoutInfo.mColorAlpha, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mGradientColor, Vector4::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mStartPoint, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo.mEndPoint, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- 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::WordGroupLayoutInfo wordGroupLayoutInfo;
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mDirection, TextViewProcessor::LTR, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mWordsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mNumberOfCharacters, 0u, TEST_LOCATION );
-
- TextViewProcessor::LineLayoutInfo lineLayoutInfo;
- DALI_TEST_EQUALS( lineLayoutInfo.mSize, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mLineHeightOffset, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.mWordGroupsLayoutInfo.size(), 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo.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.mLinesLayoutInfo.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 );
-}
-
-static void UtcDaliTextViewCopyConstructorOperator()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCopyConstructorOperator : ");
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo;
- characterLayoutInfo.mHeight = 1.f;
- characterLayoutInfo.mAdvance = 1.f;
- characterLayoutInfo.mBearing = 1.f;
- characterLayoutInfo.mPosition = Vector3( 1.f, 1.f, 1.f );
- characterLayoutInfo.mOffset = Vector2( 1.f, 1.f );
- characterLayoutInfo.mSize = Vector2( 1.f, 1.f );
- characterLayoutInfo.mAscender = 1.f;
- characterLayoutInfo.mUnderlineThickness = 1.f;
- characterLayoutInfo.mUnderlinePosition = 1.f;
-
- characterLayoutInfo.mGlyphActor = TextActor::New( "Hello" );
- characterLayoutInfo.mStyledText.mText = Text( "Hello" );
-
- characterLayoutInfo.mColorAlpha = 0.f;
- characterLayoutInfo.mGradientColor = Vector4( 1.f, 1.f, 1.f, 1.f );
- characterLayoutInfo.mStartPoint = Vector2( 1.f, 1.f );
- characterLayoutInfo.mEndPoint = Vector2( 1.f, 1.f );
- characterLayoutInfo.mIsVisible = false;
- characterLayoutInfo.mSetText = false;
- characterLayoutInfo.mSetStyle = false;
-
- TextViewProcessor::CharacterLayoutInfo characterLayoutInfo1;
- characterLayoutInfo1 = characterLayoutInfo;
-
- DALI_TEST_EQUALS( characterLayoutInfo1.mHeight, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mAdvance, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- 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.mStyledText.mText.GetLength(), 5u, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo1.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.mHeight, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mAdvance, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- 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.mStyledText.mText.GetLength(), 5u, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mColorAlpha, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mGradientColor, Vector4( 1.f, 1.f, 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.mStartPoint, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( characterLayoutInfo2.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::LineSeparator;
-
- 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::LineSeparator, 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::LineSeparator, TEST_LOCATION );
-
-
- TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo;
- wordGroupLayoutInfo.mSize = Vector2( 1.f, 1.f );
- wordGroupLayoutInfo.mAscender = 1.f;
- wordGroupLayoutInfo.mDirection = TextViewProcessor::RTL;
- wordGroupLayoutInfo.mNumberOfCharacters = 1u;
-
- TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo1;
- wordGroupLayoutInfo1 = wordGroupLayoutInfo;
-
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mDirection, TextViewProcessor::RTL, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mNumberOfCharacters, 1u, TEST_LOCATION );
-
- TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo2( wordGroupLayoutInfo );
-
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mDirection, TextViewProcessor::RTL, TEST_LOCATION );
- DALI_TEST_EQUALS( wordGroupLayoutInfo.mNumberOfCharacters, 1u, TEST_LOCATION );
-
-
- TextViewProcessor::LineLayoutInfo lineLayoutInfo;
- lineLayoutInfo.mSize = Vector2( 1.f, 1.f );
- lineLayoutInfo.mAscender = 1.f;
- lineLayoutInfo.mLineHeightOffset = 1.f;
- lineLayoutInfo.mNumberOfCharacters = 1u;
-
- TextViewProcessor::LineLayoutInfo lineLayoutInfo1;
- lineLayoutInfo1 = lineLayoutInfo;
-
- DALI_TEST_EQUALS( lineLayoutInfo1.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo1.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo1.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo1.mNumberOfCharacters, 1u, TEST_LOCATION );
-
- TextViewProcessor::LineLayoutInfo lineLayoutInfo2( lineLayoutInfo );
-
- DALI_TEST_EQUALS( lineLayoutInfo2.mSize, Vector2( 1.f, 1.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo2.mAscender, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo2.mLineHeightOffset, 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( lineLayoutInfo2.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 );
-}
-
-static void UtcDaliTextViewEqualityOperator()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewEqualityOperator : ");
-
- TextViewProcessor::TextInfoIndices indices;
- TextViewProcessor::TextInfoIndices indices1( 1u, 1u, 1u, 1u );
-
- DALI_TEST_CHECK( !( indices == indices1 ) );
-
- indices = indices1;
-
- DALI_TEST_CHECK( indices == indices1 );
-}
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.h>
-
-// Internal headers are allowed here
-#include <dali-toolkit/internal/controls/text-view/text-processor.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-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 styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( input, styledText, true );
-
- const bool ret = ( result == TextProcessor::BeginsRightToLeftCharacter( styledText ) );
-
- 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 styled text with the markup or plain string.
- MarkupProcessor::StyledTextArray styledText;
- MarkupProcessor::GetStyledTextArray( input, styledText, true );
-
- const bool ret = ( result == TextProcessor::ContainsRightToLeftCharacter( styledText ) );
-
- 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 SplitInLinesTest
-{
- std::string inputText;
-
- std::size_t resultNumberOfLines;
-};
-
-bool TestSplitInLines( const SplitInLinesTest& 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;
-
- TextProcessor::SplitInLines( styledText,
- lines );
-
- if( lines.size() != test.resultNumberOfLines )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Different number of lines, result %d, expected result %d", lines.size(), test.resultNumberOfLines );
-
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-struct SplitInWordsTest
-{
- std::string inputText;
-
- std::size_t resultNumberOfWords;
-};
-
-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 );
-
- std::vector<MarkupProcessor::StyledTextArray> words;
-
- TextProcessor::SplitInWords( styledText,
- words );
-
- if( words.size() != test.resultNumberOfWords )
- {
- tet_printf( "Fail. %s", location );
- tet_printf( "Different number of words, result %d, expected result %d", words.size(), test.resultNumberOfWords );
-
- return false;
- }
-
- return true;
-}
-
-//////////////////////////////////////////////////////////////////
-
-} // namespace
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliTextViewSplitInLines, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextViewSplitInWords, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextViewBeginsRightToLeftCharacter, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextViewContainsRightToLeftCharacter, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliTextViewFindNearestWord, POSITIVE_TC_IDX );
-// TEST_FUNCTION( , POSITIVE_TC_IDX );
-// TEST_FUNCTION( , NEGATIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliTextViewSplitInLines()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitInLines : ");
-
- struct SplitInLinesTest splitInLinesTest[] =
- {
- {
- 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 SplitInLinesTest& test = splitInLinesTest[index];
-
- if( !TestSplitInLines( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewSplitInWords()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitInWords : ");
-
- struct SplitInWordsTest splitInWordsTest[] =
- {
- {
- std::string( "Hello world, hello word!" ),
- 7
- },
- };
- const std::size_t numberOfTests( 1 );
-
- 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 );
-}
-
-static void UtcDaliTextViewBeginsRightToLeftCharacter()
-{
- 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 );
-}
-
-static void UtcDaliTextViewContainsRightToLeftCharacter()
-{
- 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 );
-}
-
-static void UtcDaliTextViewFindNearestWord()
-{
- 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 );
-}
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.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;
-
-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 CalculateSubLineLayoutTest
-{
- std::string description;
- std::string inputLine;
- float parentWidth;
- std::size_t groupIndex;
- std::size_t wordIndex;
- std::size_t characterIndex;
- TextViewRelayout::HorizontalWrapType splitPolicy;
- float shrinkFactor;
-
- float resultLineLength;
- float resultMaxCharHeight;
- float resultMaxAscender;
-};
-
-bool TestCalculateSubLineLayout( const CalculateSubLineLayoutTest& test, const char* location )
-{
- tet_printf( "%s", test.description.c_str() );
-
- // Create styled text.
- MarkupProcessor::StyledTextArray inputStyledText;
- MarkupProcessor::GetStyledTextArray( test.inputLine, 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( 0, test.groupIndex, test.wordIndex, test.characterIndex );
-
- // Get the input line.
- TextViewProcessor::LineLayoutInfo inputLineLayout;
-
- if( !relayoutData.mTextLayoutInfo.mLinesLayoutInfo.empty() )
- {
- inputLineLayout = *relayoutData.mTextLayoutInfo.mLinesLayoutInfo.begin();
- }
-
- // Result struct.
- TextViewRelayout::SubLineLayoutInfo resultLayoutInfo;
-
- CalculateSubLineLayout( test.parentWidth,
- indices,
- inputLineLayout,
- 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
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliTextViewDefaultConstructorDestructor, POSITIVE_TC_IDX ); // Calls structs's default constructor and destructors and checks their default values.
-TEST_FUNCTION( UtcDaliTextViewCalculateSubLineLayout, POSITIVE_TC_IDX ); // Checks the function which calculates the layout info of the portion of the line which fits on the text-view width.
-TEST_FUNCTION( UtcDaliTextViewCalculateAlignmentOffsets, POSITIVE_TC_IDX ); // Checks the horizontal and vertical alignaments (for the whole text).
-TEST_FUNCTION( UtcDaliTextViewCalculateJustificationOffsets, POSITIVE_TC_IDX ); // Checks the justification alignment (line per line).
-TEST_FUNCTION( UtcDaliTextViewCalculateVisibility, POSITIVE_TC_IDX ); // Checks the text-actor visibility within the text-view with a rectangle intersection test.
-
-TEST_FUNCTION( UtcDaliTextViewMiscelaneousAsserts, NEGATIVE_TC_IDX ); // Tests some strange asserts.
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliTextViewDefaultConstructorDestructor()
-{
- 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.mLineSize, 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.mLineIndex, 0u, TEST_LOCATION );
- DALI_TEST_EQUALS( relayoutParameters.mIndices.mGroupIndex, 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.mIsNewLineCharacter );
- 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 SubLineLayoutInfo defaults
- TextViewRelayout::SubLineLayoutInfo subLineLayoutInfo;
-
- DALI_TEST_EQUALS( subLineLayoutInfo.mLineLength, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( subLineLayoutInfo.mMaxCharHeight, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
- DALI_TEST_EQUALS( subLineLayoutInfo.mMaxAscender, 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-}
-
-static void UtcDaliTextViewCalculateSubLineLayout()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewCalculateSubLineLayout : ");
-
- struct CalculateSubLineLayoutTest calculateSubLineLayoutTest[] =
- {
- //WrapByCharacter
- {
- "The line is wraped by character. All characters have the same size.",
- "Hello world", // input line
- 100.f, // parent width
- 0,
- 0, // indices
- 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 line is wraped by character. There are characters with different sizes.",
- "Hello <font size='14'>world</font>", // input line
- 100.f, // parent width
- 0,
- 0, // indices
- 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 line 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 line
- 100.f, // parent width
- 0,
- 2, // indices. The third character of the third word starts in a new line.
- 2,
- 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 line 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 line
- 100.f, // parent width
- 0,
- 4, // indices. The fifth character of the fifth word starts in a new line.
- 4,
- 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 line is wraped by word. All characters have the same size.",
- "Hello world", // input line
- 100.f, // parent width
- 0,
- 0, // indices. It shouldn't use the index character so 9999999 shouldn't make it crash.
- 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 line is wraped by word. There are characters with different sizes.",
- "Hell<font size='14'>o</font> world", // input line
- 100.f, // parent width
- 0,
- 0, // indices.
- 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 line 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 line
- 100.f, // parent width
- 0,
- 2, // indices. The third word starts in a new line.
- 0,
- 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 line is wraped by word. The word doen't fit.",
- "Hello world", // input line
- 40.f, // parent width
- 0,
- 0, // indices. The third word starts in a new line.
- 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 line is wraped by word and by character. All characters have the same size. There is not a long word.",
- "Hello world hello world", // input line
- 100.f, // parent width
- 0,
- 0, // indices.
- 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 line is wraped by word and by character. All characters have the same size. There is a long word.",
- "Helloooooooo world", // input line
- 100.f, // parent width
- 0,
- 0, // indices.
- 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 line is wraped by word and by character. There are characters with different sizes. There is a long word. It calculates the layout for the second line.",
- "Helloooooooo <font size='14'>world</font>", // input line
- 100.f, // parent width
- 0,
- 0, // indices.
- 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 line 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 line
- 100.f, // parent width
- 0,
- 0, // indices.
- 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
- },
-
- //WrapByLineAndSplit
- {
- "The line is wraped by end of line and by character. All characters have the same size.",
- "Hello world", // input line
- 100.f, // parent width
- 0,
- 0, // indices
- 0,
- TextViewRelayout::WrapByLineAndSplit, // 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 line fits in the width.",
- "Hello", // input line
- 100.f, // parent width
- 0,
- 0, // indices
- 0,
- TextViewRelayout::WrapByLineAndSplit, // 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 line is wraped by end of line and by character. All characters have the same size. It calculates the layout for the second line.",
- "Hello world, hello world", // input line
- 100.f, // parent width
- 0,
- 2, // indices
- 2,
- TextViewRelayout::WrapByLineAndSplit, // 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 CalculateSubLineLayoutTest& test = calculateSubLineLayoutTest[index];
-
- if( !TestCalculateSubLineLayout( test, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewCalculateAlignmentOffsets()
-{
- 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 );
-}
-
-static void UtcDaliTextViewCalculateJustificationOffsets()
-{
- 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 );
-}
-
-
-static void UtcDaliTextViewCalculateVisibility()
-{
- 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 );
-}
-
-static void UtcDaliTextViewMiscelaneousAsserts()
-{
- 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 );
-
-}
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.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-line-processor.h>
-#include <dali-toolkit/internal/controls/text-view/text-view-word-group-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;
-
-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 SplitWordGroupTest
-{
- std::string description;
- std::string input;
- std::size_t wordPosition;
- std::size_t position;
- std::string firstResult;
- std::string lastResult;
-};
-
-struct SplitLineTest
-{
- std::string description;
- std::string input;
- std::size_t groupPosition;
- std::size_t wordPosition;
- std::size_t position;
- float lineHeightOffset;
- std::string firstResult;
- std::string lastResult;
-};
-
-struct MergeWordsTest
-{
- std::string description;
- std::string inputFirst;
- std::string inputLast;
- std::string result;
-};
-
-struct MergeWordGroupsTest
-{
- std::string description;
- std::string inputFirst;
- std::string inputLast;
- std::string result;
-};
-
-struct MergeLinesTest
-{
- 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 RemoveWordsFromGroupTest
-{
- std::string description;
- std::string input;
- std::size_t wordIndex;
- std::size_t numberOfWords;
- std::string result;
-};
-
-struct RemoveGroupsFromLineTest
-{
- std::string description;
- std::string input;
- std::size_t groupIndex;
- std::size_t numberOfGroups;
- 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.mHeight << std::endl;
- std::cout << " advance : " << character.mAdvance << std::endl;
- std::cout << " bearing : " << character.mBearing << std::endl;
- std::cout << " mPosition : " << character.mPosition << std::endl;
- std::cout << " mSize : " << character.mSize << std::endl;
- std::cout << " mAscender : " << character.mAscender << std::endl;
-
- TextActor textActor = TextActor::DownCast( character.mGlyphActor );
- if( textActor )
- {
- std::cout << "[" << textActor.GetText() << "]";
- }
- else
- {
- std::cout << "{" << character.mStyledText.mText.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::WordGroupLayoutInfo& wordGroup )
-{
- std::cout << "(";
- std::cout << " mSize : " << wordGroup.mSize << std::endl;
- std::cout << " mAscender : " << wordGroup.mAscender << std::endl;
- std::cout << " mDirection : " << wordGroup.mDirection << std::endl;
- std::cout << "mNumberOfCharacters : " << wordGroup.mNumberOfCharacters << std::endl;
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it = wordGroup.mWordsLayoutInfo.begin(), endIt = wordGroup.mWordsLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << ")"; std::cout << std::endl;
-}
-
-void Print( const TextViewProcessor::LineLayoutInfo& line )
-{
- std::cout << "<";
- std::cout << " mSize : " << line.mSize << std::endl;
- std::cout << " mAscender : " << line.mAscender << std::endl;
- std::cout << "mNumberOfCharacters : " << line.mNumberOfCharacters << std::endl;
- for( TextViewProcessor::WordGroupLayoutInfoContainer::const_iterator it = line.mWordGroupsLayoutInfo.begin(), endIt = line.mWordGroupsLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << ">" << std::endl;
-}
-
-void Print( const TextViewProcessor::TextLayoutInfo& text )
-{
- std::cout << "||";
- for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it = text.mLinesLayoutInfo.begin(), endIt = text.mLinesLayoutInfo.end(); it != endIt; ++it )
- {
- Print( *it );
- }
- std::cout << "||" << std::endl;
-}
-
-void Print( const TextStyle& style )
-{
- std::cout << " font name : " << style.GetFontName() << std::endl;
- std::cout << " : " << style.GetFontStyle() << std::endl;
- std::cout << " : " << style.GetFontPointSize() << std::endl;
- std::cout << " : " << style.GetWeight() << std::endl;
- std::cout << " : " << style.GetTextColor() << std::endl;
- std::cout << " : " << style.GetItalics() << std::endl;
- std::cout << " : " << style.GetUnderline() << std::endl;
- std::cout << " : " << style.GetShadow() << std::endl;
- std::cout << " : " << style.GetShadowColor() << std::endl;
- std::cout << " : " << style.GetShadowOffset() << std::endl;
- std::cout << " : " << style.GetGlow() << std::endl;
- std::cout << " : " << style.GetGlowColor() << std::endl;
- std::cout << " : " << style.GetGlowIntensity() << std::endl;
- std::cout << " : " << style.GetSmoothEdge() << std::endl;
- std::cout << " : " << style.GetOutline() << std::endl;
- std::cout << " : " << style.GetOutlineThickness() << std::endl;
-}
-
-// Test functions used to check if two data structures are equal.
-
-bool TestEqual( float x, float y )
-{
- return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
-}
-
-bool TestEqual( const TextViewProcessor::CharacterLayoutInfo& character1,
- const TextViewProcessor::CharacterLayoutInfo& character2 )
-{
- if( !TestEqual( character1.mHeight, character2.mHeight ) )
- {
- return false;
- }
- if( !TestEqual( character1.mAdvance, character2.mAdvance ) )
- {
- 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.mSize.x, character2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( character1.mSize.y, character2.mSize.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;
- }
-
- text1 = character1.mStyledText.mText.GetText();
- style1 = character1.mStyledText.mStyle;
-
- text2 = character2.mStyledText.mText.GetText();
- style2 = character2.mStyledText.mStyle;
-
- 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::WordGroupLayoutInfo& group1,
- const TextViewProcessor::WordGroupLayoutInfo& group2 )
-{
-
- if( group1.mNumberOfCharacters != group2.mNumberOfCharacters )
- {
- return false;
- }
-
- if( group1.mWordsLayoutInfo.size() != group2.mWordsLayoutInfo.size() )
- {
- return false;
- }
-
- if( !TestEqual( group1.mSize.x, group2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( group1.mSize.y, group2.mSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( group1.mAscender, group2.mAscender ) )
- {
- return false;
- }
-
- if( group1.mDirection != group2.mDirection )
- {
- return false;
- }
-
- for( TextViewProcessor::WordLayoutInfoContainer::const_iterator it1 = group1.mWordsLayoutInfo.begin(), endIt1 = group1.mWordsLayoutInfo.end(),
- it2 = group2.mWordsLayoutInfo.begin(), endIt2 = group2.mWordsLayoutInfo.end();
- ( it1 != endIt1 ) && ( it2 != endIt2 );
- ++it1, ++it2 )
- {
- if( !TestEqual( *it1, *it2 ) )
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TestEqual( const TextViewProcessor::LineLayoutInfo& line1,
- const TextViewProcessor::LineLayoutInfo& line2 )
-{
- if( !TestEqual( line1.mSize.x, line2.mSize.x ) )
- {
- return false;
- }
- if( !TestEqual( line1.mSize.y, line2.mSize.y ) )
- {
- return false;
- }
-
- if( !TestEqual( line1.mAscender, line2.mAscender ) )
- {
- return false;
- }
-
- if( line1.mNumberOfCharacters != line2.mNumberOfCharacters )
- {
- return false;
- }
-
- if( line1.mWordGroupsLayoutInfo.size() != line2.mWordGroupsLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::WordGroupLayoutInfoContainer::const_iterator it1 = line1.mWordGroupsLayoutInfo.begin(), endIt1 = line1.mWordGroupsLayoutInfo.end(),
- it2 = line2.mWordGroupsLayoutInfo.begin(), endIt2 = line2.mWordGroupsLayoutInfo.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.mLinesLayoutInfo.size() != text2.mLinesLayoutInfo.size() )
- {
- return false;
- }
-
- for( TextViewProcessor::LineLayoutInfoContainer::const_iterator it1 = text1.mLinesLayoutInfo.begin(), endIt1 = text1.mLinesLayoutInfo.end(),
- it2 = text2.mLinesLayoutInfo.begin(), endIt2 = text2.mLinesLayoutInfo.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", 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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- firstResultWordLayout = *( *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- lastResultWordLayout = *( *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.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", location );
- return false;
- }
-
- if( !TestEqual( lastWordLayoutInfo, lastResultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Splits the \e input group of words in two by the given \e wordPosition and \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 group of words from the beginning. (wordPosition 0 and position 0)".
- * @param input The input word.
- * @param wordPosition Index to the word within the group where to split the group.
- * @param position Where to split the word.
- * @param firstResult First part of the split group of words.
- * @param lastResult Last part of the split group of words.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestSplitWordGroup( const std::string& description,
- const std::string& input,
- const size_t wordPosition,
- const size_t position,
- const std::string& firstResult,
- const std::string& lastResult,
- const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create layout info for the input group of words.
- 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 group of words
- TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
-
- if( !inputLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the first part of the result (after split the group of words)
-
- 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 group of words
- TextViewProcessor::WordGroupLayoutInfo firstResultWordGroupLayout;
-
- if( !firstResultLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *firstResultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- firstResultWordGroupLayout = *( *firstResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the last part of the result (after split the group of words)
-
- 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 group of words
- TextViewProcessor::WordGroupLayoutInfo lastResultWordGroupLayout;
-
- if( !lastResultLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *lastResultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- lastResultWordGroupLayout = *( *lastResultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- // Split the group of words.
-
- TextViewProcessor::WordGroupLayoutInfo lastWordGroupLayoutInfo;
-
- TextViewProcessor::TextInfoIndices indices( 0, 0, wordPosition, position );
- SplitWordGroup( indices,
- inputWordGroupLayout,
- lastWordGroupLayoutInfo );
-
- // Test results
- if( !TestEqual( inputWordGroupLayout, firstResultWordGroupLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- if( !TestEqual( lastWordGroupLayoutInfo, lastResultWordGroupLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Splits the \e input line in two by the given \e groupPosition, \e wordPosition and \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 line from the beginning. (groupPosition 0, wordPosition 0 and position 0)".
- * @param input The input word.
- * @param groupPosition Index to the group of words within the line where to split the line.
- * @param wordPosition Index to the word within the group where to split the group.
- * @param position Where to split the word.
- * @param lineHeightOffset Offset between lines.
- * @param firstResult First part of the split line.
- * @param lastResult Last part of the split line.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestSplitLine( const std::string& description,
- const std::string& input,
- const size_t groupPosition,
- const size_t wordPosition,
- const size_t position,
- const float lineHeightOffset,
- const std::string& firstResult,
- const std::string& lastResult,
- const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create layout info for the input line.
- 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 ),
- std::string( "..." ),
- true ),
- relayoutData );
-
- // Get the input line
- TextViewProcessor::LineLayoutInfo inputLineLayout;
-
- if( !inputLayout.mLinesLayoutInfo.empty() )
- {
- inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
- }
-
- // Create layout info for the first part of the result (after split the line)
-
- 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 ),
- std::string( "..." ),
- true ),
- firstRelayoutData );
-
- // Get the first result line
- TextViewProcessor::LineLayoutInfo firstResultLineLayout;
-
- if( !firstResultLayout.mLinesLayoutInfo.empty() )
- {
- firstResultLineLayout = *firstResultLayout.mLinesLayoutInfo.begin();
- }
-
- // Create layout info for the last part of the result (after split the line)
-
- 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 ),
- std::string( "..."),
- true ),
- lastRelayoutData );
-
- // Get the last result line
- TextViewProcessor::LineLayoutInfo lastResultLineLayout;
-
- if( !lastResultLayout.mLinesLayoutInfo.empty() )
- {
- lastResultLineLayout = *lastResultLayout.mLinesLayoutInfo.begin();
- }
-
- // Split the line.
-
- TextViewProcessor::LineLayoutInfo lastLineLayoutInfo;
-
- TextViewProcessor::TextInfoIndices indices( 0, groupPosition, wordPosition, position );
- SplitLine( indices,
- PointSize( lineHeightOffset ),
- inputLineLayout,
- lastLineLayoutInfo );
-
- // Test results
- if( !TestEqual( inputLineLayout, firstResultLineLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- if( !TestEqual( lastLineLayoutInfo, lastResultLineLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", 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", 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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- inputFirstWordLayout = *( *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- inputLastWordLayout = *( *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
- }
-
- MergeWord( inputFirstWordLayout,
- inputLastWordLayout );
-
- if( !TestEqual( inputFirstWordLayout, resultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Merges the \e inputFirst group of words and the \e inputLast group of words, 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 group of words.
- * @param inputLast The last part of the group of words.
- * @param result The merged group of word.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestMergeGroupsOfWords( const std::string& description, const std::string& inputFirst, const std::string& inputLast, const std::string& result, const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create layout info for the inputFirst group of 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 group of words.
- TextViewProcessor::WordGroupLayoutInfo inputFirstWordGroupLayout;
-
- if( !inputFirstLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputFirstLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- inputFirstWordGroupLayout = *( *inputFirstLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the inputLast group of words.
- 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 group of words
- TextViewProcessor::WordGroupLayoutInfo inputLastWordGroupLayout;
-
- if( !inputLastLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputLastLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- inputLastWordGroupLayout = *( *inputLastLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the result group of words.
- 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::WordGroupLayoutInfo resultWordGroupLayout;
-
- if( !resultLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- MergeWordGroup( inputFirstWordGroupLayout,
- inputLastWordGroupLayout );
-
- if( !TestEqual( inputFirstWordGroupLayout, resultWordGroupLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Merges the \e inputFirst line and the \e inputLast line, 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 line.
- * @param inputLast The last part of the line.
- * @param lineHeightOffset Offset between lines.
- * @param result The merged line.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestMergeLines( 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", description.c_str() );
-
- // Create layout info for the inputFirst line.
- 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 ),
- std::string( "..." ),
- true ),
- firstRelayoutData );
-
- // Get the input word
- TextViewProcessor::LineLayoutInfo inputFirstLineLayout;
-
- if( !inputFirstLayout.mLinesLayoutInfo.empty() )
- {
- inputFirstLineLayout = *inputFirstLayout.mLinesLayoutInfo.begin();
- }
-
- // Create layout info for the inputLast line.
- 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 ),
- std::string( "..." ),
- true ),
- lastRelayoutData );
-
- // Get the input word
- TextViewProcessor::LineLayoutInfo inputLastLineLayout;
-
- if( !inputLastLayout.mLinesLayoutInfo.empty() )
- {
- inputLastLineLayout = *inputLastLayout.mLinesLayoutInfo.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 ),
- std::string( "..." ),
- true ),
- resultRelayoutData );
-
- // Get the result word
- TextViewProcessor::LineLayoutInfo resultLineLayout;
-
- if( !resultLayout.mLinesLayoutInfo.empty() )
- {
- resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
- }
-
- MergeLine( inputFirstLineLayout,
- inputLastLineLayout );
-
- if( !TestEqual( inputFirstLineLayout, resultLineLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", 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 group of characters. 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", 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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- inputWordLayout = *( *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.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.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- const TextViewProcessor::WordGroupLayoutInfo& group( *line.mWordGroupsLayoutInfo.begin() );
- if( !group.mWordsLayoutInfo.empty() )
- {
- resultWordLayout = *( *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
- }
- }
- }
-
- RemoveCharactersFromWord( position,
- numberOfCharacters,
- inputWordLayout );
-
- if( !TestEqual( inputWordLayout, resultWordLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- return true;
-}
-
-/**
- * Removes from the \e input group of words 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 group of words.
- * @param wordIndex Where to start to remove words.
- * @param numberOfWords The number of words to remove.
- * @param result The group of words 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 TestRemoveWordsFromGroup( const std::string& description, const std::string& input, const std::size_t wordIndex, const std::size_t numberOfWords, const std::string& result, const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create layout info for the input group of words.
- 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 group of words
- TextViewProcessor::WordGroupLayoutInfo inputWordGroupLayout;
-
- if( !inputLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *inputLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- inputWordGroupLayout = *( *inputLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- // Create layout info for the result group of words.
- 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 group of words.
- TextViewProcessor::WordGroupLayoutInfo resultWordGroupLayout;
-
- if( !resultLayout.mLinesLayoutInfo.empty() )
- {
- const TextViewProcessor::LineLayoutInfo& line( *resultLayout.mLinesLayoutInfo.begin() );
- if( !line.mWordGroupsLayoutInfo.empty() )
- {
- resultWordGroupLayout = *( *resultLayout.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
- }
- }
-
- RemoveWordsFromWordGroup( wordIndex,
- numberOfWords,
- inputWordGroupLayout );
-
- if( !TestEqual( inputWordGroupLayout, resultWordGroupLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- return false;
- }
-
- return true;
-}
-
-
-/**
- * Removes from the \e input line the \e numberOfGroups groups of words starting from the given \e groupIndex 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 line.
- * @param groupIndex Where to start to remove groups of words
- * @param numberOfGroups The number of groups of words to remove.
- * @param lineHeightOffset Offset between lines.
- * @param result The line without the removed groups of words.
- * @param location Where this function has been called.
- *
- * @return \e true if the experiment is successful. Otherwise returns \e false.
- */
-bool TestRemoveGroupsFromLine( const std::string& description, const std::string& input, const std::size_t groupIndex, const std::size_t numberOfGroups, const float lineHeightOffset, const std::string& result, const char* location )
-{
- tet_printf( "%s", description.c_str() );
-
- // Create layout info for the input line.
- 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 ),
- std::string( "..." ),
- true ),
- relayoutData );
-
- // Get the input line
- TextViewProcessor::LineLayoutInfo inputLineLayout;
-
- if( !inputLayout.mLinesLayoutInfo.empty() )
- {
- inputLineLayout = *inputLayout.mLinesLayoutInfo.begin();
- }
-
- // Create layout info for the result line.
- 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 ),
- std::string( "..." ),
- true ),
- resultRelayoutData );
-
- // Get the result line
- TextViewProcessor::LineLayoutInfo resultLineLayout;
-
- if( !resultLayout.mLinesLayoutInfo.empty() )
- {
- resultLineLayout = *resultLayout.mLinesLayoutInfo.begin();
- }
-
- RemoveWordGroupsFromLine( groupIndex,
- numberOfGroups,
- PointSize( lineHeightOffset ),
- inputLineLayout );
-
- if( !TestEqual( inputLineLayout, resultLineLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
- 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,
- const UpdateTextInfoOperation operation,
- const std::string& input,
- const std::size_t position,
- const std::size_t numberOfCharacters,
- const std::string& inputText,
- const float lineHeightOffset,
- const std::string& result,
- const char* location )
-{
- tet_printf( "%s", 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 ),
- std::string( "..." ),
- 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 ),
- std::string( "..." ),
- 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 ),
- std::string( "..." ),
- 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", location );
- return false;
- }
- }
-
- if( !TestEqual( inputLayout, resultLayout ) )
- {
- tet_printf( "Fail. different layout info. %s", location );
-
- std::cout << " result : "; Print( inputLayout );
- std::cout << " expected result : "; Print( resultLayout );
- return false;
- }
-
- return true;
-}
-
-} // namespace
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliTextViewCreateTextInfo, POSITIVE_TC_IDX ); // Tests data structures are built well.
-TEST_FUNCTION( UtcDaliTextViewUpdateTextInfo, POSITIVE_TC_IDX ); // Tests update operations within a whole text (insert, remove, replace).
-TEST_FUNCTION( UtcDaliTextViewSplitWord, POSITIVE_TC_IDX ); // Tests the split word operation.
-TEST_FUNCTION( UtcDaliTextViewSplitWordGroup, POSITIVE_TC_IDX ); // Tests the split group of words operation.
-TEST_FUNCTION( UtcDaliTextViewSplitLine, POSITIVE_TC_IDX ); // Tests the split line operation.
-TEST_FUNCTION( UtcDaliTextViewMergeWord01, POSITIVE_TC_IDX ); // Tests the merge word operation.
-TEST_FUNCTION( UtcDaliTextViewMergeWord02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge word operation.
-TEST_FUNCTION( UtcDaliTextViewMergeGroup01, POSITIVE_TC_IDX ); // Tests the merge group of words operation.
-TEST_FUNCTION( UtcDaliTextViewMergeGroup02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge group of words operation.
-TEST_FUNCTION( UtcDaliTextViewMergeLine01, POSITIVE_TC_IDX ); // Tests the merge line operation.
-TEST_FUNCTION( UtcDaliTextViewMergeLine02, NEGATIVE_TC_IDX ); // Tests invalid inputs in the merge line operation.
-TEST_FUNCTION( UtcDaliTextViewRemoveCharactersFromWord, POSITIVE_TC_IDX ); // Tests the remove characters from a word operation.
-TEST_FUNCTION( UtcDaliTextViewRemoveWordsFromGroup, POSITIVE_TC_IDX ); // Tests the remove words from a group of words operation.
-TEST_FUNCTION( UtcDaliTextViewRemoveGroupsFromLine, POSITIVE_TC_IDX ); // Tests the remove groups of words from a line operation.
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliTextViewCreateTextInfo()
-{
- 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 WIDTH_10( 9.48351f );
- 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 WIDTH_12( 11.3802f );
- 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.mHeight = HEIGHT_10;
- layoutInfo10.mAdvance = ADVANCE_10;
- layoutInfo10.mBearing = BEARING_10;
- layoutInfo10.mSize = Size( WIDTH_10, HEIGHT_10 );
- layoutInfo10.mAscender = ASCENDER_10;
- TextViewProcessor::CharacterLayoutInfo layoutInfo12; // ( [Hel], [rld!] and [CR])
- layoutInfo12.mHeight = HEIGHT_12;
- layoutInfo12.mAdvance = ADVANCE_12;
- layoutInfo12.mBearing = BEARING_12;
- layoutInfo12.mSize = Size( WIDTH_12, HEIGHT_12 );
- layoutInfo12.mAscender = ASCENDER_12;
-
- TextStyle style10;
- style10.SetFontPointSize( PointSize( 10.f ) );
- TextStyle style12;
- style12.SetFontPointSize( PointSize( 0.f ) ); // point size is set to zero because is a default point size.
-
- layoutInfo12.mStyledText.mStyle = style12;
- layoutInfo10.mStyledText.mStyle = style10;
-
- // Words
-
- TextViewProcessor::WordLayoutInfo wordLayout1, wordLayout2, wordLayout3, wordLayout4;
-
- // Hello
- wordLayout1.mSize = Size( 3.f * WIDTH_12 + 2.f * WIDTH_10, HEIGHT_12 );
- wordLayout1.mAscender = ASCENDER_12;
- wordLayout1.mType = TextViewProcessor::NoSeparator;
-
- layoutInfo12.mStyledText.mText = Text( "H" );
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // H
- layoutInfo12.mStyledText.mText = Text( "e" );
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // e
- layoutInfo12.mStyledText.mText = Text( "l" );
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- layoutInfo10.mStyledText.mText = Text( "l" );
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // l
- layoutInfo10.mStyledText.mText = Text( "o" );
- wordLayout1.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
-
- // (white space)
- wordLayout2.mSize = Size( WIDTH_10, HEIGHT_10 );
- wordLayout2.mAscender = ASCENDER_10;
- wordLayout2.mType = TextViewProcessor::WordSeparator;
- layoutInfo10.mStyledText.mText = Text( " " );
- wordLayout2.mCharactersLayoutInfo.push_back( layoutInfo10 ); // (white space)
-
- // world!
- wordLayout3.mSize = Size( 2.f * WIDTH_10 + 4.f * WIDTH_12, HEIGHT_12 );
- wordLayout3.mAscender = ASCENDER_12;
- wordLayout3.mType = TextViewProcessor::NoSeparator;
- layoutInfo10.mStyledText.mText = Text( "w" );
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // w
- layoutInfo10.mStyledText.mText = Text( "o" );
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo10 ); // o
- layoutInfo12.mStyledText.mText = Text( "r" );
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // r
- layoutInfo12.mStyledText.mText = Text( "l" );
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // l
- layoutInfo12.mStyledText.mText = Text( "d" );
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // d
- layoutInfo12.mStyledText.mText = Text( "!" );
- wordLayout3.mCharactersLayoutInfo.push_back( layoutInfo12 ); // !
-
- // (new line character)
- wordLayout4.mSize = Size( 0.f, HEIGHT_12 );
- wordLayout4.mAscender = ASCENDER_12;
- wordLayout4.mType = TextViewProcessor::LineSeparator;
- layoutInfo12.mStyledText.mText = Text( "\n" );
- layoutInfo12.mSize.width = 0.f;
- wordLayout4.mCharactersLayoutInfo.push_back( layoutInfo12 ); // (new line char)
-
- // Groups
-
- TextViewProcessor::WordGroupLayoutInfo groupLayout1, groupLayout2;
-
- groupLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
- groupLayout1.mAscender = ASCENDER_12;
- groupLayout1.mDirection = TextViewProcessor::LTR;
- groupLayout1.mNumberOfCharacters = 13;
- groupLayout1.mWordsLayoutInfo.push_back( wordLayout1 );
- groupLayout1.mWordsLayoutInfo.push_back( wordLayout2 );
- groupLayout1.mWordsLayoutInfo.push_back( wordLayout3 );
- groupLayout1.mWordsLayoutInfo.push_back( wordLayout4 );
-
- groupLayout2.mSize = Size( 0.f, HEIGHT_12 );
- groupLayout2.mAscender = ASCENDER_12;
- groupLayout2.mDirection = TextViewProcessor::LTR;
- groupLayout2.mNumberOfCharacters = 1;
- groupLayout2.mWordsLayoutInfo.push_back( wordLayout4 );
-
- // Lines
-
- TextViewProcessor::LineLayoutInfo lineLayout1, lineLayout2, lineLayout3;
-
- lineLayout1.mSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, HEIGHT_12 );
- lineLayout1.mAscender = ASCENDER_12;
- lineLayout1.mNumberOfCharacters = 13;
- lineLayout1.mWordGroupsLayoutInfo.push_back( groupLayout1 );
-
- lineLayout2.mSize = Size( 0.f, HEIGHT_12 );
- lineLayout2.mAscender = ASCENDER_12;
- lineLayout2.mNumberOfCharacters = 1;
- lineLayout2.mWordGroupsLayoutInfo.push_back( groupLayout2 );
-
- lineLayout3.mSize = Size( 0.f, HEIGHT_12 );
-
- // Text (layout)
- TextViewProcessor::TextLayoutInfo textLayout;
-
- textLayout.mWholeTextSize = Size( 5.f * WIDTH_10 + 7.f * WIDTH_12, 3.f * HEIGHT_12 );
- textLayout.mMaxWordWidth = 2.f * WIDTH_10 + 4.f * WIDTH_12;
- textLayout.mNumberOfCharacters = 14;
- textLayout.mLinesLayoutInfo.push_back( lineLayout1 );
- textLayout.mLinesLayoutInfo.push_back( lineLayout2 );
- textLayout.mLinesLayoutInfo.push_back( lineLayout3 );
-
- 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 ) );
-}
-
-static void UtcDaliTextViewSplitWord()
-{
- 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( 5 );
-
- for( std::size_t index = 0; 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 );
-}
-
-static void UtcDaliTextViewUpdateTextInfo()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewUpdateTextInfo : ");
-
- struct UpdateTextInfoTest updateTextInfoTest[] =
- {
- // Remove operations
-
- {
- std::string( "Remove from new line character to first character next line." ),
- Remove,
- std::string("Hello world\nhello world."),
- 11,
- 2,
- std::string(""),
- 0.f,
- std::string("Hello worldello world."),
- },
- {
- std::string( "Replace style from new line character to first character next line." ),
- 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.
- {
- std::string( "Remove within the same word, within the same group of characters" ),
- 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 lines)
- {
- std::string( "Remove within the same word, whole word (merge lines)" ),
- 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 whole group of words
- /* TODO check this when RTL text is working
- {
- std::string( "Remove within the same line, whole group of words (merge groups)" ),
- Remove,
- std::string("Hello world, שלום עולם, hello world"),
- 10,
- 15,
- std::string(), // Not used.
- 0.f,
- std::string( "Hello worlello world" )
- },
- */
- // * Remove whole line
- {
- std::string( "Remove whole line" ),
- 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 line" ),
- 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( 21 );
-
- for( std::size_t index = 0; 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 );
-}
-
-static void UtcDaliTextViewSplitWordGroup()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitWordGroup : ");
-
- struct SplitWordGroupTest splitWordGroupTests[] =
- {
- {
- std::string( "Split word group, wordPosition 0, position 0." ),
- std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
- 0,
- 0,
- std::string( "" ),
- std::string( "<u><font size='10'>He<font size='12'>ll</font>oooo wooorld</font></u>" ),
- },
- {
- std::string( "Split word group, wordPosition 2, position 8." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
- 2,
- 7,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
- std::string( "" ),
- },
- {
- std::string( "Split word group, wordPosition 0, position 2." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
- 0,
- 2,
- std::string( "<font size='10'>He</font>" ),
- std::string( "<font size='12'>ll</font><font size='10'>oooo wooorld</font>" ),
- },
- {
- std::string( "Split word group, wordPosition 0, position 3." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
- 0,
- 3,
- std::string( "<font size='10'>He</font><font size='12'>l</font>" ),
- std::string( "<font size='12'>l</font><font size='10'>oooo wooorld</font>" ),
- },
- {
- std::string( "Split word group, wordPosition 0, position 4." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
- 0,
- 4,
- std::string( "<font size='10'>He</font><font size='12'>ll</font>" ),
- std::string( "<font size='10'>oooo wooorld</font>" ),
- },
- {
- std::string( "Split word group, wordPosition 1, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font>" ),
- 1,
- 0,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo</font>" ),
- std::string( "<font size='10'> wooorld</font>" ),
- },
- };
- const std::size_t numberOfTests( 6 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const SplitWordGroupTest& test = splitWordGroupTests[index];
-
- if( !TestSplitWordGroup( test.description, test.input, test.wordPosition, test.position, test.firstResult, test.lastResult, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewSplitLine()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewSplitLine : ");
-
- struct SplitLineTest splitLineTests[] =
- {
- {
- std::string( "Split line, groupPosition 0, 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 line, groupPosition 2, wordPosition 2, position 4." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 2,
- 2,
- 4,
- 0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- std::string( "" ),
- },
- /* TODO check when RTL is working.
- {
- std::string( "Split line, groupPosition 1, wordPosition 2, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 1,
- 2,
- 0,
- 0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום" ),
- std::string( " עולם text text" ),
- },
- {
- std::string( "Split line, groupPosition 1, wordPosition 0, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 1,
- 0,
- 0,
- 0.f,
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> " ),
- std::string( "שלום עולם text text" ),
- },
- */
- {
- std::string( "Split line, groupPosition 2, wordPosition 0, position 0." ),
- std::string( "<font size='10'>He<font size='12'>ll</font>oooo wooorld</font> שלום עולם text text" ),
- 2,
- 0,
- 0,
- 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( 3 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const SplitLineTest& test = splitLineTests[index];
-
- if( !TestSplitLine( test.description, test.input, test.groupPosition, test.wordPosition, test.position, test.lineHeightOffset, test.firstResult, test.lastResult, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewMergeWord01()
-{
- 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( 2 );
-
- for( std::size_t index = 0; 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 );
-}
-
-static void UtcDaliTextViewMergeWord02()
-{
- // Negative test.
- // It test white spaces and new line 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.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo02;
-
- wordLayoutInfo02 = *( *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText03,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData03 );
-
- TextViewProcessor::WordLayoutInfo wordLayoutInfo03;
-
- wordLayoutInfo03 = *( *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin() ).mWordsLayoutInfo.begin();
-
- // Test MergeWord() asserts if white spaces or new line 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 line 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 line 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 line 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 line 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 line 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 line 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 );
- }
-}
-
-static void UtcDaliTextViewMergeGroup01()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeGroup01 : ");
-
- struct MergeWordGroupsTest mergeWordGroupssTests[] =
- {
- {
- std::string( "Merge a void first group." ),
- std::string( "" ),
- std::string( "Hello world" ),
- std::string( "Hello world" ),
- },
- {
- std::string( "Merge a void last group." ),
- std::string( "Hello world" ),
- std::string( "" ),
- std::string( "Hello world" ),
- },
- {
- std::string( "Merge groups and merge last and first words." ),
- std::string( "Hello wor" ),
- std::string( "ld, hello world" ),
- std::string( "Hello world, hello world" ),
- },
- {
- std::string( "Merge groups and don't merge last and first words." ),
- std::string( "Hello world, " ),
- std::string( "hello world" ),
- std::string( "Hello world, hello world" )
- },
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const MergeWordGroupsTest& test = mergeWordGroupssTests[index];
-
- if( !TestMergeGroupsOfWords( test.description, test.inputFirst, test.inputLast, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result(TET_PASS);
-}
-
-static void UtcDaliTextViewMergeGroup02()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeGroup02 : ");
-
- 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( "Hello \n" );
- std::string text02( "world" );
- std::string text03( "السلام عليكم" );
- 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::WordGroupLayoutInfo wordGroupLayoutInfo01;
-
- wordGroupLayoutInfo01 = *( *textLayoutInfo01.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo02;
-
- wordGroupLayoutInfo02 = *( *textLayoutInfo02.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText03,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData03 );
-
- TextViewProcessor::WordGroupLayoutInfo wordGroupLayoutInfo03;
-
- wordGroupLayoutInfo03 = *( *textLayoutInfo03.mLinesLayoutInfo.begin() ).mWordGroupsLayoutInfo.begin();
-
- bool assert1 = false;
- bool assert2 = false;
-
- try
- {
- MergeWordGroup( wordGroupLayoutInfo01,
- wordGroupLayoutInfo02 );
- }
- 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::MergeWordGroup(). ERROR: A group of words can't be merged to another group which finishes with a new line character.\"", TEST_LOCATION );
- assert1 = true;
- }
-
- try
- {
- MergeWordGroup( wordGroupLayoutInfo03,
- wordGroupLayoutInfo02 );
- }
- 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::MergeWordGroup(). ERROR: groups with different direction can't be merged.\"", TEST_LOCATION );
- assert2 = true;
- }
-
- if( assert1 && assert2 )
- {
- tet_result( TET_PASS );
- }
- else
- {
- tet_result( TET_FAIL );
- }
-}
-
-static void UtcDaliTextViewMergeLine01()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeLine01 : ");
-
- struct MergeLinesTest mergeLinesTests[] =
- {
- {
- std::string( "Merge a void first line." ),
- std::string( "" ),
- std::string( "Hello world, this is a whole line" ),
- 2.f,
- std::string( "Hello world, this is a whole line" )
- },
- {
- std::string( "Merge a void last line." ),
- std::string( "Hello world, this is a whole line" ),
- std::string( "" ),
- 0.f,
- std::string( "Hello world, this is a whole line" )
- },
- /* TODO: check when RTL text is working.
- {
- std::string( "Merge lines and merge last and first groups" ),
- std::string( "Hello world, שלום" ),
- std::string( " עולם, hello world." ),
- 6.f,
- std::string( "Hello world, שלום עולם, hello world." )
- },
- {
- std::string( "Merge lines 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 lines. Don't merge words" ),
- std::string( "Hello world," ),
- std::string( " this is a whole line" ),
- 0.f,
- std::string( "Hello world, this is a whole line" )
- },
- {
- std::string( "Merge lines. Merge words" ),
- std::string( "Hello world, th" ),
- std::string( "is is a whole line" ),
- 0.f,
- std::string( "Hello world, this is a whole line" )
- },
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const MergeLinesTest& test = mergeLinesTests[index];
-
- if( !TestMergeLines( test.description, test.inputFirst, test.inputLast, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewMergeLine02()
-{
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewMergeLine02 : ");
-
- 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::LineLayoutInfo lineLayoutInfo01;
-
- lineLayoutInfo01 = *textLayoutInfo01.mLinesLayoutInfo.begin();
-
- TextViewProcessor::CreateTextInfo( styledText02,
- DEFAULT_LAYOUT_PARAMETERS,
- relayoutData02 );
-
- TextViewProcessor::LineLayoutInfo lineLayoutInfo02;
-
- lineLayoutInfo02 = *textLayoutInfo02.mLinesLayoutInfo.begin();
-
- bool assert1 = false;
-
- try
- {
- MergeLine( lineLayoutInfo01,
- lineLayoutInfo02 );
- }
- 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::MergeLine(). ERROR: A line can't be merged to another line which finishes with a new line character.\"", TEST_LOCATION );
- assert1 = true;
- }
-
- if( assert1 )
- {
- tet_result( TET_PASS );
- }
- else
- {
- tet_result( TET_FAIL );
- }
-}
-
-void UtcDaliTextViewRemoveCharactersFromWord()
-{
- 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( 11 );
-
- for( std::size_t index = 0; 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 );
-}
-
-static void UtcDaliTextViewRemoveWordsFromGroup()
-{
- // Note: Currently RemoveWordsFromWordGroup() function is only used to remove a number of words from the beginning, or
- // from a given index to the end. RemoveWordsFromWordGroup() doesn't merge words (if a white space is removed) so
- // tehere isn't any TET case to cover these cases. To be done if needed.
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewRemoveWordsFromGroup : ");
- struct RemoveWordsFromGroupTest removeWordsFromGroupTests[] =
- {
- {
- std::string( "Delete 0 words." ),
- std::string( "Hello world, hello world" ),
- 3,
- 0,
- std::string( "Hello world, hello world" ),
- },
- {
- std::string( "Delete some words in the middle. Don't merge words" ),
- std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
- 1,
- 4,
- std::string( "<font size='10'>Hel</font><font size='20'>lo</font><font size='30'> world</font>" ),
- },
- {
- std::string( "Delete words up to the end" ),
- std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello world</font>" ),
- 5,
- 2,
- std::string( "<font size='10'>Hel</font><font size='20'>lo wo</font><font size='30'>rld, hello</font>" ),
- },
- {
- std::string( "Delete words from the beginning." ),
- std::string( "Hello world, hello world" ),
- 0,
- 3,
- std::string( " hello world" ),
- },
- };
- const std::size_t numberOfTests( 4 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const RemoveWordsFromGroupTest& test = removeWordsFromGroupTests[index];
-
- if( !TestRemoveWordsFromGroup( test.description, test.input, test.wordIndex, test.numberOfWords, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
-
-static void UtcDaliTextViewRemoveGroupsFromLine()
-{
- // Note: Currently RemoveWordGroupsFromLine() function is only used to remove a number of group of words from the beginning, or
- // from a given index to the end. RemoveWordGroupsFromLine() doesn't merge groups of words (if a whole group of words is removed) so
- // tehere isn't any TET case to cover these cases. To be done if needed.
-
- ToolkitTestApplication application;
-
- tet_infoline("UtcDaliTextViewRemoveGroupsFromLine : ");
- struct RemoveGroupsFromLineTest removeGroupsFromLineTests[] =
- {
- {
- std::string( "Delete 0 groups of words." ),
- std::string( "Hello hello, שלום עולם hello hello" ),
- 1,
- 0,
- 2.f,
- std::string( "Hello hello, שלום עולם hello hello" ),
- },
- {
- std::string( "Delete from the middle to the end." ),
- std::string( "Hello hello, שלום עולם hello hello" ),
- 1,
- 2,
- 0.f,
- std::string( "Hello hello, " ),
- },
- {
- std::string( "Delete from the beginning to the middle." ),
- std::string( "Hello hello, שלום עולם hello hello" ),
- 0,
- 2,
- 6.f,
- std::string( "hello hello" ),
- },
- };
- const std::size_t numberOfTests( 3 );
-
- for( std::size_t index = 0; index < numberOfTests; ++index )
- {
- const RemoveGroupsFromLineTest& test = removeGroupsFromLineTests[index];
-
- if( !TestRemoveGroupsFromLine( test.description, test.input, test.groupIndex, test.numberOfGroups, test.lineHeightOffset, test.result, TEST_LOCATION ) )
- {
- tet_result( TET_FAIL );
- }
- }
-
- tet_result( TET_PASS );
-}
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.h>
-
-// Internal headers are allowed here
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-using namespace Dali::Toolkit::Internal;
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( Utc@MODULE@@CLASS@Method01, POSITIVE_TC_IDX );
-TEST_FUNCTION( Utc@MODULE@@CLASS@Method02, NEGATIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-
-// Positive test case for a method
-static void Utc@MODULE@@CLASS@Method01()
-{
- ToolkitTestApplication application;
-
- tet_infoline("Journaled printf Output");
- tet_result(TET_FAIL);
-#if 0
- tet_result(TET_PASS);
-#endif
-}
-
-
-// Negative test case for a method
-static void Utc@MODULE@@CLASS@Method02()
-{
- ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
-
- try
- {
- /* My test code and results */
- DALI_TEST_EQUALS(myVar, expectedValue, TEST_LOCATION);
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
- DALI_TEST_EQUALS(e.mCondition, "assert conditional", TEST_LOCATION);
- }
-}
-
+++ /dev/null
-utc-Dali-ScrollViewEffect
+++ /dev/null
-utc-Dali-Alignment
+++ /dev/null
-../master-makefile.mk
\ No newline at end of file
+++ /dev/null
-TARGETS += \
- utc-Dali-Alignment \
+++ /dev/null
-/dali-test-suite/alignment/utc-Dali-Alignment
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-static void Startup();
-static void Cleanup();
-
-namespace
-{
-static bool gObjectCreatedCallBackCalled;
-
-static void TestCallback(BaseHandle handle)
-{
- gObjectCreatedCallBackCalled = true;
-}
-} // namespace
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliAlignmentConstructorNegative, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentConstructorPositive, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentConstructorRegister, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypePositiveOffStage, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypePositiveOnStage, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentSetAlignmentTypeNegative, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentGetAlignmentType, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentSetScaling, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentGetScaling, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentSetPaddingPositive, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentSetPaddingNegative, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentGetPadding, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentChildAddAndRemove, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentOnSizeSet, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentOnTouchEvent, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentOnKeyEvent, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentOnSizeAnimation, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliAlignmentCopyAndAssignment, POSITIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliAlignmentConstructorNegative()
-{
- ToolkitTestApplication application;
-
- Alignment alignment;
-
- try
- {
- Alignment::Padding padding;
- alignment.SetPadding(padding);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "alignment")
- {
- tet_result(TET_PASS);
- }
- }
-}
-
-static void UtcDaliAlignmentConstructorPositive()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
-
- try
- {
- Alignment::Padding padding;
- alignment.SetPadding(padding);
- tet_result(TET_PASS);
- }
- catch (DaliException& exception)
- {
- tet_result(TET_FAIL);
- }
-
- Actor actor = alignment;
- alignment = Alignment::DownCast( actor );
-
- DALI_TEST_CHECK( alignment );
-}
-
-static void UtcDaliAlignmentConstructorRegister()
-{
- ToolkitTestApplication application;
-
- //Te ensure the object is registered after creation
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK( registry );
-
- gObjectCreatedCallBackCalled = false;
- registry.ObjectCreatedSignal().Connect(&TestCallback);
- {
- Alignment alignment = Alignment::New();
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
-}
-
-static void UtcDaliAlignmentSetAlignmentTypePositiveOffStage()
-{
- ToolkitTestApplication application;
-
- // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalLeft, VerticalCenter
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::HorizontalLeft);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalRight, VerticalCenter
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::HorizontalRight);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalLeft, VerticalTop
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalCenter, VerticalTop
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::VerticalTop);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalRight, VerticalTop
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalLeft, VerticalBottom
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalCenter, VerticalBottom
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::VerticalBottom);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-
- // HorizontalRight, VerticalBottom
- {
- Alignment alignment = Alignment::New();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
- }
-}
-
-static void UtcDaliAlignmentSetAlignmentTypePositiveOnStage()
-{
- ToolkitTestApplication application;
-
- // Default, HorizontalCenter, VerticalCenter - Ensure they do not change!
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::VerticalCenter));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalLeft, VerticalCenter
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::HorizontalLeft);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalRight, VerticalCenter
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::HorizontalRight);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalLeft, VerticalTop
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalTop));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalCenter, VerticalTop
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::VerticalTop);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalRight, VerticalTop
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalTop));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalLeft, VerticalBottom
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::VerticalBottom));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalCenter, VerticalBottom
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::VerticalBottom);
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalRight, VerticalBottom
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- // Check default values
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
-
- Alignment::Type type(Alignment::Type(Alignment::HorizontalRight | Alignment::VerticalBottom));
- alignment.SetAlignmentType(type);
- DALI_TEST_CHECK(alignment.GetAlignmentType() & type);
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-}
-
-static void UtcDaliAlignmentSetAlignmentTypeNegative()
-{
- ToolkitTestApplication application;
-
- // Setting HorizontalLeft, HorizontalCenter
- {
- Alignment alignment = Alignment::New();
- Alignment::Type type(Alignment::Type(Alignment::HorizontalLeft | Alignment::HorizontalCenter));
-
- try
- {
- alignment.SetAlignmentType(type);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "!horizontalSet")
- {
- tet_result(TET_PASS);
- }
- }
- }
-
- // Setting HorizontalCenter, HorizontalRight
- {
- Alignment alignment = Alignment::New();
- Alignment::Type type(Alignment::Type(Alignment::HorizontalCenter | Alignment::HorizontalRight));
-
- try
- {
- alignment.SetAlignmentType(type);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "!horizontalSet")
- {
- tet_result(TET_PASS);
- }
- }
- }
-
- // Setting VerticalTop, VerticalCenter
- {
- Alignment alignment = Alignment::New();
- Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalCenter));
-
- try
- {
- alignment.SetAlignmentType(type);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "!verticalSet")
- {
- tet_result(TET_PASS);
- }
- }
- }
-
- // Setting VerticalCenter, VerticalBottom
- {
- Alignment alignment = Alignment::New();
- Alignment::Type type(Alignment::Type(Alignment::VerticalTop | Alignment::VerticalBottom));
-
- try
- {
- alignment.SetAlignmentType(type);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "!veritcalSet")
- {
- tet_result(TET_PASS);
- }
- }
- }
-}
-
-static void UtcDaliAlignmentGetAlignmentType()
-{
- ToolkitTestApplication application;
-
- // Default, HorizonalCenter, VerticalCenter
- {
- Alignment alignment = Alignment::New();
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalLeft, VerticalCenter
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalLeft);
- DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalRight, VerticalCenter
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalRight);
- DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalCenter, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalLeft, VerticalTop
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalTop);
- DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalCenter, VerticalTop
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalTop);
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalRight, VerticalTop
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalTop);
- DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalTop, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalLeft, VerticalBottom
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalLeft, Alignment::VerticalBottom);
- DALI_TEST_EQUALS(Alignment::HorizontalLeft | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalCenter, VerticalBottom
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalCenter, Alignment::VerticalBottom);
- DALI_TEST_EQUALS(Alignment::HorizontalCenter | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // HorizontalRight, VerticalBottom
- {
- Alignment alignment = Alignment::New(Alignment::HorizontalRight, Alignment::VerticalBottom);
- DALI_TEST_EQUALS(Alignment::HorizontalRight | Alignment::VerticalBottom, alignment.GetAlignmentType(), TEST_LOCATION);
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-}
-
-static void UtcDaliAlignmentSetScaling()
-{
- ToolkitTestApplication application;
-
- // ScaleToFill
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
- alignment.SetScaling(Alignment::ScaleToFill);
- DALI_TEST_EQUALS(Alignment::ScaleToFill, alignment.GetScaling(), TEST_LOCATION);
- application.Render();
- application.SendNotification();
-
- // For complete line coverage
- alignment.SetAlignmentType(Alignment::HorizontalLeft);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::HorizontalRight);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalTop);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalBottom);
- application.Render();
- application.SendNotification();
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // ScaleToFitKeepAspect
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
- alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
- DALI_TEST_EQUALS(Alignment::ScaleToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
- application.Render();
- application.SendNotification();
-
- // For complete line coverage
- alignment.SetAlignmentType(Alignment::HorizontalLeft);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::HorizontalRight);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalTop);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalBottom);
- application.Render();
- application.SendNotification();
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // ScaleToFillKeepAspect
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
- alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
- DALI_TEST_EQUALS(Alignment::ScaleToFillKeepAspect, alignment.GetScaling(), TEST_LOCATION);
- application.Render();
- application.SendNotification();
-
- // For complete line coverage
- alignment.SetAlignmentType(Alignment::HorizontalLeft);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::HorizontalRight);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalTop);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalBottom);
- application.Render();
- application.SendNotification();
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // ShrinkToFit
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
- alignment.SetScaling(Alignment::ShrinkToFit);
- DALI_TEST_EQUALS(Alignment::ShrinkToFit, alignment.GetScaling(), TEST_LOCATION);
- application.Render();
- application.SendNotification();
-
- // For complete line coverage
- alignment.SetAlignmentType(Alignment::HorizontalLeft);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::HorizontalRight);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalTop);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalBottom);
- application.Render();
- application.SendNotification();
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-
- // ShrinkToFitKeepAspect
- {
- Alignment alignment = Alignment::New();
- alignment.Add(RenderableActor::New());
- Stage::GetCurrent().Add(alignment);
- application.Render();
- application.SendNotification();
-
- DALI_TEST_EQUALS(Alignment::ScaleNone, alignment.GetScaling(), TEST_LOCATION);
- alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
- DALI_TEST_EQUALS(Alignment::ShrinkToFitKeepAspect, alignment.GetScaling(), TEST_LOCATION);
- application.Render();
- application.SendNotification();
-
- // For complete line coverage
- alignment.SetAlignmentType(Alignment::HorizontalLeft);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::HorizontalRight);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalTop);
- application.Render();
- application.SendNotification();
- alignment.SetAlignmentType(Alignment::VerticalBottom);
- application.Render();
- application.SendNotification();
-
- Stage::GetCurrent().Remove(alignment);
- application.Render();
- application.SendNotification();
- }
-}
-
-static void UtcDaliAlignmentGetScaling()
-{
- ToolkitTestApplication application;
-
- // ScaleToFill
- {
- Alignment alignment = Alignment::New();
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
-
- alignment.SetScaling(Alignment::ScaleToFill);
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFill);
- }
-
- // ScaleToFitKeepAspect
- {
- Alignment alignment = Alignment::New();
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
-
- alignment.SetScaling(Alignment::ScaleToFitKeepAspect);
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFitKeepAspect);
- }
-
- // ScaleToFillKeepAspect
- {
- Alignment alignment = Alignment::New();
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
-
- alignment.SetScaling(Alignment::ScaleToFillKeepAspect);
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleToFillKeepAspect);
- }
-
- // ShrinkToFit
- {
- Alignment alignment = Alignment::New();
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
-
- alignment.SetScaling(Alignment::ShrinkToFit);
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFit);
- }
-
- // ShrinkToFitKeepAspect
- {
- Alignment alignment = Alignment::New();
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ScaleNone);
-
- alignment.SetScaling(Alignment::ShrinkToFitKeepAspect);
- DALI_TEST_CHECK(alignment.GetScaling() == Alignment::ShrinkToFitKeepAspect);
- }
-
-}
-
-static void UtcDaliAlignmentSetPaddingPositive()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
-
- Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.5f);
- DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) > GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
- DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) > GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
- DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) > GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
- DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) > GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
-
- alignment.SetPadding(padding);
- DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
- DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
- DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
- DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
-}
-
-static void UtcDaliAlignmentSetPaddingNegative()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
-
- try
- {
- Alignment::Padding padding(-1.0f, 1.5f, 2.f, 0.f);
- alignment.SetPadding(padding);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
- {
- tet_result(TET_PASS);
- }
- }
-
- try
- {
- Alignment::Padding padding(1.0f, 1.5f, -2.f, 0.f);
- alignment.SetPadding(padding);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
- {
- tet_result(TET_PASS);
- }
- }
-
- try
- {
- Alignment::Padding padding(1.0f, 1.5f, 2.f, -1.f);
- alignment.SetPadding(padding);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
- {
- tet_result(TET_PASS);
- }
- }
-
- try
- {
- Alignment::Padding padding(1.0f, -1.5f, 2.f, 0.f);
- alignment.SetPadding(padding);
- tet_result(TET_FAIL);
- }
- catch (DaliException& exception)
- {
- if (exception.mCondition == "( padding.left >= 0.f ) && ( padding.top >= 0.f ) && ( padding.right >= 0.f ) && ( padding.bottom >= 0.f )")
- {
- tet_result(TET_PASS);
- }
- }
-}
-
-static void UtcDaliAlignmentGetPadding()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- DALI_TEST_CHECK( fabs( alignment.GetPadding().left ) < GetRangedEpsilon( 0.f, alignment.GetPadding().left ) );
- DALI_TEST_CHECK( fabs( alignment.GetPadding().right ) < GetRangedEpsilon( 0.f, alignment.GetPadding().right ) );
- DALI_TEST_CHECK( fabs( alignment.GetPadding().top ) < GetRangedEpsilon( 0.f, alignment.GetPadding().top ) );
- DALI_TEST_CHECK( fabs( alignment.GetPadding().bottom ) < GetRangedEpsilon( 0.f, alignment.GetPadding().bottom ) );
-
- Alignment::Padding padding(1.0f, 1.5f, 2.f, 0.f);
- alignment.SetPadding(padding);
- DALI_TEST_CHECK( fabs( padding.left - alignment.GetPadding().left ) < GetRangedEpsilon( padding.left, alignment.GetPadding().left ) );
- DALI_TEST_CHECK( fabs( padding.right - alignment.GetPadding().right ) < GetRangedEpsilon( padding.right, alignment.GetPadding().right ) );
- DALI_TEST_CHECK( fabs( padding.top - alignment.GetPadding().top ) < GetRangedEpsilon( padding.top, alignment.GetPadding().top ) );
- DALI_TEST_CHECK( fabs( padding.bottom - alignment.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignment.GetPadding().bottom ) );
-}
-
-static void UtcDaliAlignmentChildAddAndRemove()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- Stage::GetCurrent().Add(alignment);
-
- application.Render();
- application.SendNotification();
-
- Actor actor = RenderableActor::New();
- alignment.Add(actor);
-
- DALI_TEST_EQUALS(alignment.GetChildCount(), 1u, TEST_LOCATION);
-
- application.Render();
- application.SendNotification();
-
- alignment.Remove(actor);
-
- DALI_TEST_EQUALS(alignment.GetChildCount(), 0u, TEST_LOCATION);
-
- application.Render();
- application.SendNotification();
-
- Stage::GetCurrent().Remove(alignment);
-}
-
-static void UtcDaliAlignmentOnSizeSet()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- Stage::GetCurrent().Add(alignment);
-
- application.Render();
- application.SendNotification();
-
- Vector3 size(100.0f, 200.0f, 0.0f);
- alignment.SetSize(size);
-
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
-
- DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
-
- Stage::GetCurrent().Remove(alignment);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-static bool TouchEventCallback(Actor actor, const TouchEvent& event)
-{
- return false;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static void UtcDaliAlignmentOnTouchEvent()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- alignment.SetSize(100.0f, 100.0f);
- alignment.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- Stage::GetCurrent().Add(alignment);
-
- alignment.TouchedSignal().Connect(&TouchEventCallback);
-
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
-
- Integration::TouchEvent touchEvent(1);
- TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
- touchEvent.AddPoint(point);
- application.ProcessEvent(touchEvent);
-
- tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
-}
-
-static void UtcDaliAlignmentOnKeyEvent()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- Stage::GetCurrent().Add(alignment);
-
- alignment.SetKeyInputFocus();
-
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
-
- Integration::KeyEvent keyEvent;
- application.ProcessEvent(keyEvent);
-
- tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
-}
-
-static void UtcDaliAlignmentOnSizeAnimation()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- Stage::GetCurrent().Add(alignment);
-
- Animation animation = Animation::New(100.0f);
- animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
- animation.Play();
-
- application.Render();
- application.SendNotification();
- application.Render();
- application.SendNotification();
-
- tet_result(TET_PASS); // For line coverage, as long as there are no exceptions, we assume passed.
-}
-
-static void UtcDaliAlignmentCopyAndAssignment()
-{
- ToolkitTestApplication application;
-
- Alignment alignment = Alignment::New();
- Alignment emptyAlignment;
-
- Alignment::Padding padding(100.0f, 150.0f, 200.f, 0.f);
- alignment.SetPadding(padding);
-
- Alignment alignmentCopy(alignment);
- DALI_TEST_CHECK( fabs( padding.left - alignmentCopy.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentCopy.GetPadding().left ) );
- DALI_TEST_CHECK( fabs( padding.right - alignmentCopy.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentCopy.GetPadding().right ) );
- DALI_TEST_CHECK( fabs( padding.top - alignmentCopy.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentCopy.GetPadding().top ) );
- DALI_TEST_CHECK( fabs( padding.bottom - alignmentCopy.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentCopy.GetPadding().bottom ) );
-
- Alignment alignmentEmptyCopy(emptyAlignment);
- DALI_TEST_CHECK(emptyAlignment == alignmentEmptyCopy);
-
- Alignment alignmentEquals;
- alignmentEquals = alignment;
- DALI_TEST_CHECK( fabs( padding.left - alignmentEquals.GetPadding().left ) < GetRangedEpsilon( padding.left, alignmentEquals.GetPadding().left ) );
- DALI_TEST_CHECK( fabs( padding.right - alignmentEquals.GetPadding().right ) < GetRangedEpsilon( padding.right, alignmentEquals.GetPadding().right ) );
- DALI_TEST_CHECK( fabs( padding.top - alignmentEquals.GetPadding().top ) < GetRangedEpsilon( padding.top, alignmentEquals.GetPadding().top ) );
- DALI_TEST_CHECK( fabs( padding.bottom - alignmentEquals.GetPadding().bottom ) < GetRangedEpsilon( padding.bottom, alignmentEquals.GetPadding().bottom ) );
-
- Alignment alignmentEmptyEquals;
- alignmentEmptyEquals = emptyAlignment;
- DALI_TEST_CHECK(emptyAlignment == alignmentEmptyEquals);
-
- // Self assignment
- alignment = alignment;
- DALI_TEST_CHECK(alignment == alignmentCopy);
-}
+++ /dev/null
-utc-Dali-BubbleEmitter
+++ /dev/null
-../master-makefile.mk
\ No newline at end of file
+++ /dev/null
-TARGETS += \
- utc-Dali-BubbleEmitter \
+++ /dev/null
-/dali-test-suite/bubble-emitter/utc-Dali-BubbleEmitter
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-#include <dali-toolkit-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const int RENDER_FRAME_INTERVAL = 16;
-
-static bool gObjectCreatedCallBackCalled;
-static void TestCallback(BaseHandle handle)
-{
- gObjectCreatedCallBackCalled = true;
-}
-
-/*
- * Simulate time passed by.
- *
- * @note this will always process at least 1 frame (1/60 sec)
- *
- * @param application Test application instance
- * @param duration Time to pass in milliseconds.
- * @return The actual time passed in milliseconds
- */
-int Wait(ToolkitTestApplication& application, int duration = 0)
-{
- int time = 0;
-
- for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
- {
- application.SendNotification();
- application.Render(RENDER_FRAME_INTERVAL);
- time += RENDER_FRAME_INTERVAL;
- }
-
- return time;
-}
-
-Image CreateSolidColorImage( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
-{
- BitmapImage imageData = BitmapImage::New( width, height, Pixel::RGBA8888 );
-
- // Create the image
- PixelBuffer* pixbuf = imageData.GetBuffer();
- unsigned int size = width * height;
-
- for( size_t i = 0; i < size; i++ )
- {
- pixbuf[i*4+0] = 0xFF * color.r;
- pixbuf[i*4+1] = 0xFF * color.g;
- pixbuf[i*4+2] = 0xFF * color.b;
- pixbuf[i*4+3] = 0xFF * color.a;
- }
- imageData.Update();
-
- application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- application.SendNotification();
- application.Render(RENDER_FRAME_INTERVAL);
- application.Render(RENDER_FRAME_INTERVAL);
- application.SendNotification();
-
- return imageData;
-}
-}//namespace
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-// Add test functionality for all APIs in the class (Positive and Negative)
-TEST_FUNCTION( UtcDaliBubbleEmitterNew, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterGetRootActor, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterSetBackground, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterSetShapeImage, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterSetBubbleScale, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterSetBubbleDensity01, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterSetBubbleDensity02, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterSetBlendMode, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterEmitBubble, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterStartExplosion, POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBubbleEmitterRestore, POSITIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliBubbleEmitterNew()
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBubbleEmitterNew ");
-
- // Test default constructor
- BubbleEmitter emitter;
- DALI_TEST_CHECK( !emitter );
-
- // Test object creation
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
- DALI_TEST_CHECK( emitter );
-
- // 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 );
- {
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
-
- // Test copy constructor
- BubbleEmitter emitterCopy( emitter );
- DALI_TEST_CHECK( emitterCopy );
-
- // Test down cast
- Handle handleEmitter;
- handleEmitter = emitter;
- BubbleEmitter downCastEmitter = BubbleEmitter::DownCast( handleEmitter );
- DALI_TEST_CHECK( downCastEmitter );
-}
-
-static void UtcDaliBubbleEmitterGetRootActor()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterGetRootActor " );
-
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
-
- Actor root = emitter.GetRootActor();
- DALI_TEST_CHECK( root );
- DALI_TEST_CHECK( root.GetChildCount() == 3 );
-}
-
-static void UtcDaliBubbleEmitterSetBackground()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBackground " );
-
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 200, Vector2( 5.f, 10.f ));
-
- RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
- unsigned int taskCount = taskList.GetTaskCount();
-
- Image bgImage = CreateSolidColorImage( application, Color::RED, 50, 50 );
- emitter.SetBackground( bgImage, Vector3(0.f, 0.f, 0.5f) );
-
- DALI_TEST_CHECK( taskList.GetTaskCount() == taskCount+1 );
-
- Wait(application, 500);
- DALI_TEST_CHECK( taskList.GetTaskCount() == taskCount );
-}
-
-static void UtcDaliBubbleEmitterSetShapeImage()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetShapeImage " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
-
- Actor root = emitter.GetRootActor();
- MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
- Material material = bubbleMesh.GetMaterial();
-
- DALI_TEST_CHECK( material.GetDiffuseTexture() == shapeImage1 );
-
- Image shapeImage2 = CreateSolidColorImage( application, Color::RED, 8, 8 );
- emitter.SetShapeImage( shapeImage2 );
-
- DALI_TEST_CHECK( material.GetDiffuseTexture() == shapeImage2 );
-}
-
-static void UtcDaliBubbleEmitterSetBubbleScale()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBubbleScale " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
-
- Actor root = emitter.GetRootActor();
- MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
- ShaderEffect effect = bubbleMesh.GetShaderEffect();
- DALI_TEST_CHECK( effect );
-
- Property::Index scalePropertyIndex = effect.GetPropertyIndex( "uDynamicScale" );
- float scaleValue;
- (effect.GetProperty(scalePropertyIndex)).Get( scaleValue );
- DALI_TEST_EQUALS(scaleValue, 1.f, TEST_LOCATION );
-
- emitter.SetBubbleScale( 2.f );
- application.SendNotification();
- application.Render();
- (effect.GetProperty(scalePropertyIndex)).Get( scaleValue );
- DALI_TEST_EQUALS(scaleValue, 2.f, TEST_LOCATION );
-
- emitter.SetBubbleScale( 0.5f );
- application.SendNotification();
- application.Render();
- (effect.GetProperty(scalePropertyIndex)).Get( scaleValue );
- DALI_TEST_EQUALS(scaleValue, 0.5f, TEST_LOCATION );
-}
-
-static void UtcDaliBubbleEmitterSetBubbleDensity01()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBubbleDensity " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
-
- try
- {
- emitter.SetBubbleDensity( 3.f );
- DALI_TEST_CHECK(true);
- }
- catch(Dali::DaliException& e)
- {
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
- DALI_TEST_ASSERT(e, "density>0 && density<=9", TEST_LOCATION );
- }
-}
-
-static void UtcDaliBubbleEmitterSetBubbleDensity02()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBubbleDensity " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
-
- try
- {
- emitter.SetBubbleDensity( 10.f );
- }
- catch(Dali::DaliException& e)
- {
- tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
- DALI_TEST_ASSERT(e, "density>0 && density<=9", TEST_LOCATION );
- }
-}
-
-static void UtcDaliBubbleEmitterSetBlendMode()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBlendMode " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
-
- Actor root = emitter.GetRootActor();
- MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
-
- BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
-
- emitter.SetBlendMode( true );
- bubbleMesh.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
- DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE );
- DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ZERO );
- DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE );
-
- emitter.SetBlendMode( false );
- bubbleMesh.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
- DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
- DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
- DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
- DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE_MINUS_SRC_ALPHA );
-}
-
-static void UtcDaliBubbleEmitterEmitBubble()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterEmitBubble " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
-
- Actor root = emitter.GetRootActor();
- MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
- ShaderEffect effect = bubbleMesh.GetShaderEffect();
- DALI_TEST_CHECK( effect );
-
- Property::Index propertyIndex0 = effect.GetPropertyIndex( "uPercentage[0]" );
- Property::Index propertyIndex1 = effect.GetPropertyIndex( "uPercentage[1]" );
- float value0, value1;
-
- Animation animation = Animation::New( 0.5f );
- emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) );
- emitter.EmitBubble( animation, Vector2(10.f,10.f), Vector2(5.f,5.f), Vector2(30.f,30.f) );
- (effect.GetProperty(propertyIndex0)).Get( value0 );
- (effect.GetProperty(propertyIndex1)).Get( value1 );
- DALI_TEST_EQUALS(value0, 0.f, TEST_LOCATION );
- DALI_TEST_EQUALS(value1, 0.f, TEST_LOCATION );
-
- animation.Play();
-
- Wait(application, 300);
- (effect.GetProperty(propertyIndex0)).Get( value0 );
- (effect.GetProperty(propertyIndex1)).Get( value1 );
- DALI_TEST_CHECK( value0 >= 0.6f );
- DALI_TEST_CHECK( value1 >= 0.6f );
-
- Wait(application, 600);
- (effect.GetProperty(propertyIndex0)).Get( value0 );
- (effect.GetProperty(propertyIndex1)).Get( value1 );
- DALI_TEST_EQUALS(value0, 1.f, TEST_LOCATION );
- DALI_TEST_EQUALS(value1, 1.f, TEST_LOCATION );
-}
-
-static void UtcDaliBubbleEmitterStartExplosion()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterStartExplosion " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
- Actor root = emitter.GetRootActor();
- MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
- ShaderEffect effect = bubbleMesh.GetShaderEffect();
- DALI_TEST_CHECK( effect );
-
- Property::Index propertyIndex = effect.GetPropertyIndex( "uMagnification" );
- float value;
- (effect.GetProperty(propertyIndex)).Get( value );
- DALI_TEST_EQUALS(value, 1.f, TEST_LOCATION );
-
- emitter.StartExplosion( 0.4, 4.f );
-
- Wait(application, 200); // 0.2s
- (effect.GetProperty(propertyIndex)).Get( value );
- DALI_TEST_CHECK( value >= 2.f );
-
- Wait(application, 100); // 0.3s
- (effect.GetProperty(propertyIndex)).Get( value );
- DALI_TEST_CHECK( value >= 3.f );
-
- Wait(application, 100); // 0.4s
- (effect.GetProperty(propertyIndex)).Get( value );
- DALI_TEST_EQUALS(value, 1.f, TEST_LOCATION );
-}
-
-static void UtcDaliBubbleEmitterRestore()
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterRestore " );
-
- Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f ));
- Actor root = emitter.GetRootActor();
- MeshActor bubbleMesh = MeshActor::DownCast( root.GetChildAt( 0 ) );
- ShaderEffect effect = bubbleMesh.GetShaderEffect();
- DALI_TEST_CHECK( effect );
-
- Property::Index percentagePropertyIndex = effect.GetPropertyIndex( "uPercentage[0]" );
- float percentage;
-
- Animation animation = Animation::New( 0.5f );
- emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) );
- (effect.GetProperty(percentagePropertyIndex)).Get( percentage );
- DALI_TEST_EQUALS(percentage, 0.f, TEST_LOCATION );
-
- animation.Play();
- Wait(application, 200);
- animation.Clear();
-
- (effect.GetProperty(percentagePropertyIndex)).Get( percentage );
- DALI_TEST_CHECK( percentage < 0.5f && percentage >= 0.4);
-
- emitter.Restore();
- application.SendNotification();
- application.Render();
-
- (effect.GetProperty(percentagePropertyIndex)).Get( percentage );
- DALI_TEST_EQUALS(percentage, 1.f, TEST_LOCATION );
-}
+++ /dev/null
-utc-Dali-Builder
-utc-Dali-JsonParser
+++ /dev/null
-../master-makefile.mk
\ No newline at end of file
+++ /dev/null
-TARGETS += \
- Dali/utc-Dali-Builder \
- Dali/utc-Dali-JsonParser \
+++ /dev/null
-/dali-test-suite/builder/utc-Dali-Builder
-/dali-test-suite/builder/utc-Dali-JsonParser
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/public-api/builder/builder.h>
-#include <dali-toolkit-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Toolkit;
-
-namespace
-{
-//
-// Note: To avoid escaping double quotes single quotes are used and then replaced
-// before parsing. JSON uses double quotes
-//
- std::string JSON_TEXTSTYLE_ONLY("\
-{ \
- 'text-styles': \
- { \
- 'title-text-style':{'font-name': 'Vera', \
- 'font-style': 'Bold', \
- 'point-size': 12.0, \
- 'weight': 'light', \
- 'text-color': [0.0,0.5,0.5,1], \
- 'italic': false, \
- 'underline': false, \
- 'shadow': true, \
- 'glow': true, \
- 'outline': true, \
- 'shadow-color': [0.0,1.0,0.0,1.0], \
- 'shadow-offset': [3.0,2.0], \
- 'shadow-size': 2.0, \
- 'glow-color': [0.9,0.6,0.3,1.0], \
- 'glow-intensity':0.1, \
- 'smooth-edge': 0.45, \
- 'outline-color': [1.0,0.5,0.0,1.0], \
- 'outline-thickness': [0.7,0.6] \
- } \
- } \
-} \
-");
-
- std::string JSON_TEXT_ACTOR("\
-{ \
- 'styles': \
- { \
- 'basic-text': \
- { \
- 'type':'TextActor', \
- '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("\
-{ \
- 'styles': \
- { \
- '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] \
- }, \
- '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 JSON_CONSTANTS("\
-{ \
- 'constants': \
- { \
- 'HELLO':'Hello World', \
- 'HELLO2':'Hello {WORLD}' \
- }, \
- 'styles': \
- { \
- 'basic-text': { \
- 'type':'TextActor', \
- 'text':'{HELLO2}' \
- } \
- }, \
- 'animations': \
- { \
- 'rotate': \
- { \
- 'duration': 10, \
- 'properties': \
- [ \
- { \
- 'actor':'{ACTOR}', \
- 'property':'rotation', \
- 'value':[0, 3, 0, 0], \
- 'alpha-function': 'EASE_IN_OUT', \
- 'time-period': {'delay': 0, 'duration': 3 } \
- } \
- ] \
- } \
- }, \
- 'stage': \
- [ \
- {'name':'txt1', \
- 'type':'TextActor', \
- 'text':'{HELLO}' \
- } \
- ] \
-} \
-");
-
-
- std::string ReplaceQuotes(const std::string &in_s)
- {
- std::string s(in_s);
- // wrong as no embedded quote but had regex link problems
- std::replace(s.begin(), s.end(), '\'', '"');
- return s;
- }
-
-} // namespace
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-static void UtcDaliBuilderConstants();
-static void UtcDaliBuilderTextActorCreateFromStyle();
-static void UtcDaliBuilderTextActorCreateAnimation();
-static void UtcDaliBuilderTextActorApplyFromStyle();
-static void UtcDaliBuilderStyles();
-static void UtcDaliBuilderAddActorsOther();
-static void UtcDaliBuilderAddActors();
-static void UtcDaliBuilderSetProperty();
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-TEST_FUNCTION( UtcDaliBuilderConstants , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderTextActorCreateFromStyle , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderTextActorCreateAnimation , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderTextActorApplyFromStyle , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderStyles , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderAddActorsOther , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderAddActors , POSITIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliBuilderSetProperty , POSITIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-static void UtcDaliBuilderConstants()
-{
- ToolkitTestApplication application;
- Stage stage = Stage::GetCurrent();
-
- tet_infoline(" UtcDaliBuilderConstants");
-
- Builder builder = Builder::New();
-
- PropertyValueMap userMap;
- userMap["WORLD"] = "World";
- builder.AddConstants(userMap);
-
- builder.LoadFromString( ReplaceQuotes(JSON_CONSTANTS) );
-
- // constants in json
- Layer layer = stage.GetRootLayer();
- size_t count = layer.GetChildCount();
-
- builder.AddActors( layer );
- DALI_TEST_CHECK( layer.GetChildCount() == count + 1 );
-
- TextActor actor = TextActor::DownCast( layer.GetChildAt( count ) );
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == std::string("Hello World") );
-
- // global constants
- PropertyValueMap map;
- map["HELLO2"] = "Hi";
-
- builder.AddConstants( map );
-
- actor = TextActor::DownCast( builder.CreateFromStyle("basic-text") );
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == std::string("Hi") );
-
- // user overriding
- userMap["HELLO2"] = "Hello Dali";
- actor = TextActor::DownCast( builder.CreateFromStyle("basic-text", userMap) );
- DALI_TEST_CHECK( actor );
- DALI_TEST_CHECK( actor.GetText() == std::string("Hello Dali") );
-
- // animation constants
- actor = TextActor::DownCast( layer.GetChildAt( count ) );
- actor.SetName("rotate-me");
- userMap["ACTOR"] = actor.GetName();
-
- Animation anim = builder.CreateAnimation("rotate", userMap);
- DALI_TEST_CHECK( anim );
- DALI_TEST_CHECK( 10.0f == anim.GetDuration() );
-
-}
-
-static void UtcDaliBuilderTextActorCreateFromStyle()
-{
- ToolkitTestApplication application;
- Stage stage = Stage::GetCurrent();
-
- tet_infoline(" UtcDaliBuilderTextActorCreateFromStyle");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_TEXT_ACTOR));
-
- TextActor actor( TextActor::DownCast( builder.CreateFromStyle("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() == "Hello");
-
- actor = TextActor::DownCast( builder.CreateFromStyle("*(&^") );
- DALI_TEST_CHECK(!actor);
-
-}
-
-static void UtcDaliBuilderTextActorCreateAnimation()
-{
- 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() );
-
-}
-
-static void UtcDaliBuilderTextActorApplyFromStyle()
-{
- 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");
-
-}
-
-static void UtcDaliBuilderAddActors()
-{
- 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");
-
-}
-
-static void UtcDaliBuilderAddActorsOther()
-{
- 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");
-
-}
-
-
-static void UtcDaliBuilderStyles()
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliBuilderStyles");
-
- Builder builder = Builder::New();
-
- builder.LoadFromString(ReplaceQuotes(JSON_CORE_ACTOR_TREE));
-
- BaseHandle handle = builder.CreateFromStyle("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.CreateFromStyle("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>() );
-
-}
-
-static void UtcDaliBuilderSetProperty()
-{
- 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" );
-
-}
+++ /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 <tet_api.h>
-
-#include <dali/public-api/dali-core.h>
-#include <dali-toolkit/public-api/builder/json-parser.h>
-
-#include <dali-toolkit-test-suite-utils.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-static void Startup();
-static void Cleanup();
-
-extern "C" {
- void (*tet_startup)() = Startup;
- void (*tet_cleanup)() = Cleanup;
-}
-
-enum {
- POSITIVE_TC_IDX = 0x01,
- NEGATIVE_TC_IDX,
-};
-
-#define MAX_NUMBER_OF_TESTS 10000
-extern "C" {
- struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
-}
-
-TEST_FUNCTION( UtcDaliJsonParserMethod01, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod02, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod03, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod04, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod05, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod06, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod07, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod08, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod09, NEGATIVE_TC_IDX );
-TEST_FUNCTION( UtcDaliJsonParserMethod10, NEGATIVE_TC_IDX );
-
-// Called only once before first test is run.
-static void Startup()
-{
-}
-
-// Called only once after last test is run
-static void Cleanup()
-{
-}
-
-std::string ReplaceQuotes(const std::string &in_s)
-{
- std::string s(in_s);
- // wrong as no embedded quote but had regex link problems
- std::replace(s.begin(), s.end(), '\'', '"');
- return s;
-}
-
-
-static void UtcDaliJsonParserMethod01()
-{
- ToolkitTestApplication application;
-
- tet_infoline("JSON basic test");
-
- std::string s1( ReplaceQuotes("\
-{ \
- 'string':'value2', \
- 'integer':2, \
- 'float':2.0, \
- 'boolean':true, \
- 'nil':null, \
- 'array':[1,2,3], \
- 'object':{'key':'value'} \
-} \
-"));
-
- JsonParser parser = JsonParser::New();
-
- parser.Parse( s1 );
-
- if(parser.ParseError())
- {
- std::cout << "Error: " << parser.GetErrorDescription() << std::endl;
- std::cout << " at: " << parser.GetErrorLineNumber() << "(" << parser.GetErrorPosition() << ")" << std::endl;
- }
-
- DALI_TEST_CHECK(!parser.ParseError());
-
- const TreeNode* root = parser.GetRoot();
-
- DALI_TEST_CHECK(root);
-
- DALI_TEST_CHECK(root->Size());
-
- TreeNode::ConstIterator iter = root->CBegin();
- DALI_TEST_CHECK(iter != root->CEnd());
-
- const TreeNode* node = NULL;
-
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::STRING);
- DALI_TEST_CHECK(std::string((*iter).first) == std::string("string"));
- DALI_TEST_CHECK(std::string(node->GetString()) == std::string("value2"));
-
- ++iter;
- DALI_TEST_CHECK(iter != root->CEnd());
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::INTEGER);
- DALI_TEST_CHECK(std::string((*iter).first) == std::string("integer"));
- DALI_TEST_CHECK(node->GetInteger() == 2);
-
- ++iter;
- DALI_TEST_CHECK(iter != root->CEnd());
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::FLOAT);
- DALI_TEST_CHECK(std::string((*iter).first) == std::string("float"));
- DALI_TEST_CHECK(node->GetFloat() == 2.0);
-
- ++iter;
- DALI_TEST_CHECK(iter != root->CEnd());
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::BOOLEAN);
- DALI_TEST_CHECK(std::string((*iter).first) == std::string("boolean"));
- DALI_TEST_CHECK(node->GetBoolean());
-
- ++iter;
- DALI_TEST_CHECK(iter != root->CEnd());
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::IS_NULL);
- DALI_TEST_CHECK(std::string((*iter).first) == std::string("nil"));
-
- ++iter;
- DALI_TEST_CHECK(iter != root->CEnd());
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::ARRAY);
- DALI_TEST_CHECK(node->Size() == 3);
- TreeNode::ConstIterator iterArray = node->CBegin();
-
- DALI_TEST_CHECK(iterArray != node->CEnd());
- DALI_TEST_CHECK( ((*iterArray).second).GetType() == TreeNode::INTEGER);
- DALI_TEST_CHECK( (*iterArray).first == NULL );
- DALI_TEST_CHECK( ((*iterArray).second).GetInteger() == 1);
-
- ++iterArray;
- DALI_TEST_CHECK(iterArray != node->CEnd());
- DALI_TEST_CHECK( ((*iterArray).second).GetType() == TreeNode::INTEGER);
- DALI_TEST_CHECK( (*iterArray).first == NULL );
- DALI_TEST_CHECK( ((*iterArray).second).GetInteger() == 2);
-
- ++iterArray;
- DALI_TEST_CHECK(iterArray != node->CEnd());
- DALI_TEST_CHECK( ((*iterArray).second).GetType() == TreeNode::INTEGER);
- DALI_TEST_CHECK( (*iterArray).first == NULL );
- DALI_TEST_CHECK( ((*iterArray).second).GetInteger() == 3);
-
- ++iter;
- DALI_TEST_CHECK(iter != root->CEnd());
- node = &((*iter).second);
- DALI_TEST_CHECK(node);
- DALI_TEST_CHECK(node->GetType() == TreeNode::OBJECT);
- DALI_TEST_CHECK(node->Size() == 1);
-
- TreeNode::ConstIterator iterObject = node->CBegin();
- DALI_TEST_CHECK(iterObject != node->CEnd());
- DALI_TEST_CHECK( ((*iterObject).second).GetType() == TreeNode::STRING);
- DALI_TEST_CHECK( std::string((*iterObject).first) == std::string("key" ));
- DALI_TEST_CHECK( std::string(((*iterObject).second).GetString()) == std::string("value"));
-
- tet_result(TET_PASS);
-}
-
-static void UtcDaliJsonParserMethod02()
-{
- ToolkitTestApplication application;
-
- tet_infoline("JSON Comments");
-
- std::string s1( ReplaceQuotes(" \
-// some comments with empty line above \n\
-{ \
- // inline comments \n\
- 'key':'value', // endline comments \n\
- // more inline comments \n\
- 'key2':'value2' \
-} \
-"));
-
- JsonParser parser = JsonParser::New();
-
- parser.Parse( s1 );
-
- if(parser.ParseError())
- {
- std::cout << "Error: " << parser.GetErrorDescription() << std::endl;
- std::cout << " at: " << parser.GetErrorLineNumber() <&l