--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(tct_coreapi_utc)
+
+INCLUDE(FindPkgConfig)
+SET(BIN_DIR "/opt/usr/bin")
+
+INCLUDE_DIRECTORIES(
+ src/common
+)
+
+ADD_SUBDIRECTORY(src)
--- /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
+
+( 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
+#!/bin/bash
+
+TEMP=`getopt -o ds: --long 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
+env=./_export_env.sh
+
+while true ; do
+ case "$1" in
+ -d|--desktop) env=./_export_desktop.sh ; shift ;;
+ -s|--scenario) scenario="$2" ; shift 2 ;;
+ --) shift ; break ;;
+ *) echo "Internal error!" ; exit 1 ;;
+ esac
+done
+
+
+# Source correct environment
+. $env
+
+
+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/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./ $scenario
+./tbp.pl $JOURNAL_RESULT
+
#!/bin/bash
-TEMP=`getopt -o 2vds: --long 2,verbose,desktop,scenario: \
- -n 'build_out.sh' -- "$@"`
+rm -rf build
+mkdir build
-if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+function build
+{
+ (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ (cd build ; cmake .. -DMODULE=$1 ; make -j7 )
+}
-# Note the quotes around `$TEMP': they are essential!
-eval set -- "$TEMP"
+if [ -n "$1" ] ; then
+ echo BUILDING ONLY $1
+ build $1
-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
+ for mod in `ls -1 src/ | grep -v CMakeList `
+ do
+ if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
+ echo BUILDING $mod
+ build $mod
+ fi
+ done
fi
-./tbp.pl $JOURNAL_RESULT
-
-
( cd ../build/slp ; make cov_data )
-for i in `find . -name Makefile` ; do
+
+for i in `find . -name "*.dir"` ; do
(
- cd $(dirname $i)
+ cd $i
echo `pwd`
covs=( `ls *.gcda 2>/dev/null` )
if [[ $? -eq 0 ]]
then
- make coverage
+ lcov --directory . -c -o dali.info
+ lcov --remove dali.info "*boost*" "/usr/include/*" "*/automated-tests/*" -o dali.info
fi
)
done
cd .. ;
genhtml -o build/slp/doc/coverage `find . -name dali.info`
)
-
-
#!/bin/bash
-TEMP=`getopt -o ds: --long 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
-env=./_export_env.sh
-
-while true ; do
- case "$1" in
- -d|--desktop) env=./_export_desktop.sh ; shift ;;
- -s|--scenario) scenario="$2" ; shift 2 ;;
- --) shift ; break ;;
- *) echo "Internal error!" ; exit 1 ;;
- esac
-done
-
-
-# Source correct environment
-. $env
-
-
-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/exec-tar-result-$FILE_NAME_EXTENSION.html
-JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
-
-mkdir -p $RESULT_DIR
-
-tcc -e -j $JOURNAL_RESULT -p ./ $scenario
-./tbp.pl $JOURNAL_RESULT
-
+function execute
+{
+ scripts/tctestsgen.sh $1 `pwd` desktop
+ testkit-lite -f `pwd`/tests.xml -o tct-${1}-core-tests.xml -A --comm localhost
+ scripts/add_style.pl $1
+}
+
+# Clean up old test results
+rm -f tct*core-tests.xml
+
+if [ -n "$1" ] ; then
+ echo EXECUTING ONLY $1
+ execute $1
+
+else
+ for mod in `ls -1 src/ | grep -v CMakeList `
+ do
+ if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
+ echo EXECUTING $mod
+ execute $mod
+ fi
+ done
+fi
+
+scripts/summarize.pl
--- /dev/null
+%define MODULE_NAME dali-toolkit
+%define MODULE_LIBNAME dali-toolkit
+Name: core-%{MODULE_NAME}-tests
+Summary: Core API unit TC (%{name})
+Version: 0.1
+Release: 0
+Group: Development/Tools
+License: Apache License, Version 2.0, Samsung Properietary
+Source0: %{name}-%{version}.tar.gz
+Requires: dali
+Requires: dali-adaptor
+Requires: dali-toolkit
+BuildRequires: dali-integration-devel
+BuildRequires: pkgconfig(dali-core)
+BuildRequires: pkgconfig(dali)
+BuildRequires: pkgconfig(dali-toolkit)
+BuildRequires: libxml2-devel
+BuildRequires: cmake
+
+%description
+Core API unit TC (%{name})
+
+%prep
+%setup -q
+
+%build
+
+%define PREFIX "%{_libdir}/%{name}"
+
+export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed"
+cd automated-tests
+cmake . -DMODULE="%{MODULE_NAME}" -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+cd automated-tests
+%make_install
+mkdir -p %{buildroot}/opt/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/opt/usr/share/license/%{name}
+mkdir -p %{buildroot}/tmp/
+cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/add_all_smack_rule.sh %{buildroot}/tmp/
+cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/all_smack.rule %{buildroot}/tmp/
+
+%post
+
+%postun
+
+
+%files
+/opt/usr/bin/*
+/opt/usr/share/license/%{name}
+/tmp/add_all_smack_rule.sh
+/tmp/all_smack.rule
--- /dev/null
+%define MODULE_NAME dali-toolkit-unmanaged
+%define MODULE_LIBNAME dali-toolkit-unmanaged
+Name: core-%{MODULE_NAME}-tests
+Summary: Core API unit TC (%{name})
+Version: 0.1
+Release: 0
+Group: Development/Tools
+License: Apache License, Version 2.0, Samsung Properietary
+Source0: %{name}-%{version}.tar.gz
+Requires: dali
+Requires: dali-adaptor
+Requires: dali-toolkit
+BuildRequires: dali-integration-devel
+BuildRequires: pkgconfig(dali-core)
+BuildRequires: pkgconfig(dali)
+BuildRequires: pkgconfig(dali-toolkit)
+BuildRequires: libxml2-devel
+BuildRequires: cmake
+
+%description
+Core API unit TC (%{name})
+
+%prep
+%setup -q
+
+%build
+
+%define PREFIX "%{_libdir}/%{name}"
+
+export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed"
+cd automated-tests
+cmake . -DMODULE="%{MODULE_NAME}" -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+cd automated-tests
+%make_install
+mkdir -p %{buildroot}/opt/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/opt/usr/share/license/%{name}
+mkdir -p %{buildroot}/tmp/
+cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/add_all_smack_rule.sh %{buildroot}/tmp/
+cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/all_smack.rule %{buildroot}/tmp/
+
+%post
+
+%postun
+
+
+%files
+/opt/usr/bin/*
+/opt/usr/share/license/%{name}
+/tmp/add_all_smack_rule.sh
+/tmp/all_smack.rule
--- /dev/null
+%define MODULE_NAME dali-unmanaged
+%define MODULE_LIBNAME dali-unmanaged
+Name: core-%{MODULE_NAME}-tests
+Summary: Core API unit TC (%{name})
+Version: 0.1
+Release: 0
+Group: Development/Tools
+License: Apache License, Version 2.0, Samsung Properietary
+Source0: %{name}-%{version}.tar.gz
+Requires: dali
+BuildRequires: dali-devel
+BuildRequires: dali-integration-devel
+BuildRequires: pkgconfig(dali-core)
+BuildRequires: pkgconfig(dali)
+BuildRequires: libxml2-devel
+BuildRequires: cmake
+
+%description
+Core API unit TC (%{name})
+
+%prep
+%setup -q
+
+%build
+
+%define PREFIX "%{_libdir}/%{name}"
+
+export LDFLAGS+="-Wl,--rpath=%{PREFIX} -Wl,--as-needed"
+cd automated-tests
+cmake . -DMODULE="%{MODULE_NAME}" -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+cd automated-tests
+%make_install
+mkdir -p %{buildroot}/opt/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/opt/usr/share/license/%{name}
+mkdir -p %{buildroot}/tmp/
+cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/add_all_smack_rule.sh %{buildroot}/tmp/
+cp %{_builddir}/%{name}-%{version}/automated-tests/scripts/all_smack.rule %{buildroot}/tmp/
+
+%post
+
+%postun
+
+
+%files
+/opt/usr/bin/*
+/opt/usr/share/license/%{name}
+/tmp/add_all_smack_rule.sh
+/tmp/all_smack.rule
--- /dev/null
+#!/bin/sh
+
+SCRIPTDIR=`dirname $(readlink -f $0)`
+SMACK_FILE=$SCRIPTDIR/all_smack.rule
+
+echo ""
+echo "Add smack rule in $SMACK_FILE"
+echo "==================================================="
+echo ""
+
+while read rule; do
+ NO_BLANK=$(echo $rule | sed 's/ //g' | sed 's/ //g')
+ if [ ${#NO_BLANK} -lt 1 ]; then
+ echo "Blank"
+ continue
+ elif [ `echo $NO_BLANK|cut -c1-1` = '#' ]; then
+ echo "Comment"
+ continue
+ fi
+
+ echo "echo \"$rule\" > /smack/load2"
+ echo "$rule" > /smack/load2
+done < $SMACK_FILE
+
+echo "==================================================="
+echo ""
--- /dev/null
+#!/bin/sh
+
+SCRIPTDIR=`dirname $(readlink -f $0)`
+SMACK_FILE=$SCRIPTDIR/all_smack.rule
+
+echo ""
+echo "Add smack rule in $SMACK_FILE"
+echo "==================================================="
+
+echo "sdb root on"
+sdb root on
+
+while read rule; do
+ NO_BLANK=$(echo $rule | sed 's/ //g' | sed 's/ //g')
+ if [ ${#NO_BLANK} -lt 1 ]; then
+ #echo "Blank"
+ continue
+ elif [ `echo $NO_BLANK|cut -c1-1` = '#' ]; then
+ #echo "Comment"
+ continue
+ fi
+
+ echo "sdb shell \"echo $rule > /smack/load2\""
+ sdb shell "echo $rule > /smack/load2"
+done < $SMACK_FILE
+
+echo "==================================================="
+echo ""
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use Encode;
+use Getopt::Long;
+use Cwd;
+
+my $pwd = getcwd;
+my $MOD_NAME = $ARGV[0];
+my $results_xml = "tct-$MOD_NAME-core-tests.xml";
+my $results_out = "results_xml.$$";
+
+# Copy $results_xml, writing new stylesheet line:
+# Write <?xml-stylesheet type="text/xsl" href="./style/testresult.xsl"?> as second line
+open RESULTS, "<$results_xml" || die "Can't open $results_xml for reading:$!\n";
+open RESULTS_OUT, ">$results_out" || die "Can't open $results_out for writing:$!\n";
+my $fline = readline RESULTS;
+print RESULTS_OUT $fline;
+print RESULTS_OUT "<?xml-stylesheet type=\"text/xsl\" href=\"./style/testresult.xsl\"?>\n";
+while(<RESULTS>)
+{
+ print RESULTS_OUT $_;
+}
+close RESULTS_OUT;
+close RESULTS;
+unlink $results_xml;
+print `mv $results_out $results_xml`;
--- /dev/null
+# calendar-service
+_ calendar-service::svc rwx
+
+# capi-appfw-application
+_ alarm-server::alarm rw
+_ aul::launch x
+_ aul::terminate x
+
+# capi-network-bluetooth
+_ bt-service::admin w
+_ bt-service::manager w
+_ bt-service::gap w
+_ bt-service::spp w
+_ bt:service::opp w
+
+# capi-network-nfc
+_ nfc-manager rwx
+_ nfc-manager::tag rwx
+_ nfc-manager::p2p rwx
+_ nfc-manager::admin rwx
+_ nfc-manager::common rwx
+
+# capi-location-*
+_ location::maps rw
+_ location::client rw
+
+# libmdm
+_ mdm-server::eas rw
--- /dev/null
+#!/bin/bash
+if [ -z "$TC_PROJECT_DIR" ]; then
+ echo "CoreAPI project directory can't be found. `basename $0` exitting..."
+ exit 1
+fi
+
+_tcbuild () {
+ local cur
+ cur=${COMP_WORDS[$COMP_CWORD]}
+ if [ $COMP_CWORD -eq 1 ]; then
+ COMPREPLY=( $( compgen -W "addmod build install rmmod" -- $cur ) )
+ else #if [ $COMP_CWORD -eq 2 ]; then
+ COMPREPLY=( $( cd $TC_PROJECT_DIR/src; compgen -d -X "common" -- $cur ) )
+ fi
+ return 0
+}
+
+complete -F _tcbuild tcbuild
--- /dev/null
+#!/bin/bash
+
+PROJECT_DIR="$(cd "$(dirname $0)" && cd .. && pwd)"
+
+ln -s $PROJECT_DIR/scripts/tcbuild.sh $PROJECT_DIR/tcbuild
+
+echo "" >> $HOME/.bashrc
+echo "# CoreAPI-tests convenience helpers" >> $HOME/.bashrc
+echo "export TC_PROJECT_DIR=\"$PROJECT_DIR\"" >> $HOME/.bashrc
+echo "source $PROJECT_DIR/scripts/autocompletion.sh" >> $HOME/.bashrc
--- /dev/null
+#!/bin/bash
+
+USAGE=$(cat <<EOF
+Usage note: retriever.sh [option] [directory]
+Options:
+ none retrieve TC names with corresponding startup and cleanup functions
+ -f retrieveve TC name with corresponding "set" and "purpose" clauses
+ -anum retrieve automatic TC number
+ -mnum retrieve manual TC number
+
+In case of TC in form of "int tc_name()" script will abort.
+("int tc_name(void)" is a proper function signature)
+EOF
+)
+
+function get_tc_files {
+ CMAKE_FILE="$DIR/CMakeLists.txt"
+ if [ ! -e $CMAKE_FILE ]; then
+ echo "File $CMAKE_FILE not found. Aborting..."
+ exit 1
+ fi
+
+ TC_FILES=$(cat $CMAKE_FILE | awk -vDIR="$DIR" '
+ BEGIN {
+ flag = 0;
+ files = "";
+ }
+ /^SET\(TC_SOURCES/ {
+ flag = 1;
+ next;
+ }
+ /\)/ {
+ if (flag == 1)
+ exit;
+ }
+ !/^ *#/ {
+ if (flag == 1) {
+ if (files == "")
+ files = DIR "/" $1;
+ else
+ files = files " " DIR "/" $1;
+ }
+ }
+ END {
+ print files;
+ }')
+}
+
+function tc_names {
+ if [[ -z "$1" ]]; then
+ exit
+ fi
+
+ awk '
+ BEGIN {
+ OFS = ",";
+ start_fun = "NULL";
+ clean_fun = "NULL";
+ err_flag = 0;
+ tc_list = "";
+ }
+ /^void .*startup\(void\)/ {
+ gsub(/^void /, "");
+ gsub(/\(void\)$/,"");
+ start_fun = $0
+ }
+ /^void .*cleanup\(void\)/ {
+ gsub(/^void /, "");
+ gsub(/\(void\)$/,"");
+ clean_fun = $0
+ }
+ /^int .*\(\)/ {
+ print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
+ err_flag = 1;
+ }
+ /^int .*\(void\)/ {
+ gsub(/^int /, "");
+ gsub(/\(void\).*/,"");
+ if (tc_list != "") tc_list = tc_list "\n";
+ tc_list = tc_list $0 OFS start_fun OFS clean_fun
+ }
+ END {
+ if (err_flag) {
+ exit 1
+ } else {
+ print tc_list
+ }
+ }
+ ' $*
+}
+
+function tc_anum {
+ awk '
+ BEGIN {
+ count = 0;
+ err_flag = 0;
+ }
+ /^int .*\(\)/ {
+ print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
+ err_flag = 1;
+ }
+ /^int .*\(void\)$/ {
+ count++;
+ }
+ END {
+ if (err_flag) {
+ exit 1
+ } else {
+ print count
+ }
+ }
+ ' $*
+}
+
+function tc_mnum {
+ # TODO: fix this hardcoded value
+ echo 0
+}
+
+function tc_fullinfo {
+ awk '
+ BEGIN {
+ OFS=",";
+ purpose = "";
+ set = "default";
+ err_flag = 0;
+ tc_list = "";
+ }
+ /^\/\/& set:/ {
+ set = $3;
+ next;
+ }
+ /^\/\/& purpose:/ {
+ purpose = $3;
+ for (i = 4; i <= NF; i++) {
+ purpose = purpose " " $i;
+ }
+ next;
+ }
+ /^int .*\(\)/ {
+ print "Warning: function with empty argument list -- \"" $0 "\" in " FILENAME ":" FNR;
+ err_flag = 1;
+ }
+ /^int .*\(void\)$/ {
+ gsub(/^int /, "");
+ gsub(/\(void\)$/,"");
+ if (tc_list != "") tc_list = tc_list "\n";
+ tc_list = tc_list $0 OFS set OFS purpose;
+ purpose = "";
+ next
+ }
+ END {
+ if (err_flag) {
+ exit 1
+ } else {
+ print tc_list
+ }
+ }
+ ' $*
+}
+
+
+# usage note and exit:
+# - argument begin with '-' but is not recognised or number of arguments is > 2,
+# - argument doesn't begin with '-' and number of arguments is > 1
+if [[ ( "$1" == -* && ( ! "$1" =~ ^-(anum|mnum|f)$ || $# > 2 ) ) || ( "$1" != -* && $# > 1 ) ]]; then
+ echo -e "$USAGE"
+ exit 1
+fi
+
+
+# get directory from last argument (or assume current one)
+if [[ ! "$1" =~ ^-(anum|mnum|f)$ ]]; then
+ DIR=${1:-.}
+else
+ DIR=${2:-.}
+fi
+
+
+# populate $TC_FILES with files declared in CMakeLists.txt
+get_tc_files $DIR
+if [ $? != 0 ]; then
+ exit 1
+fi
+
+
+# run appropriate subcommand
+case "$1" in
+ -anum)
+ tc_anum $TC_FILES ;;
+ -mnum)
+ tc_mnum $TC_FILES ;;
+ -f)
+ tc_fullinfo $TC_FILES ;;
+ *)
+ tc_names $TC_FILES ;;
+esac
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use XML::Parser;
+use Encode;
+use Getopt::Long;
+use Cwd;
+
+my $pwd = getcwd;
+my $num_tests=0;
+my $num_passes=0;
+my $num_actual_passes=0;
+my $text = "";
+
+sub handle_start
+{
+ my ($p, $elt, %attrs) = @_;
+
+ if($elt =~ /testcase/)
+ {
+ $num_tests++;
+ if($attrs{"result"} eq "PASS")
+ {
+ $num_passes++;
+ }
+ }
+ if($elt =~ /actual_result/)
+ {
+ $text = "";
+ }
+}
+
+sub handle_end
+{
+ my ($p, $elt) = @_;
+ if($elt =~ /actual_result/)
+ {
+ if($text eq "PASS")
+ {
+ $num_actual_passes++;
+ }
+ $text = "";
+ }
+}
+
+sub handle_char
+{
+ my ($p, $str) = @_;
+ $text .= $str;
+}
+
+my($parser) = new XML::Parser(Handlers => {Start => \&handle_start,
+ End => \&handle_end,
+ Char => \&handle_char});
+
+
+# Write summary.xml:
+open SUMMARY, ">summary.xml" || die "Can't open summary.xml for writing:$!\n";
+print SUMMARY << "EOS";
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="./style/summary.xsl"?>
+<result_summary plan_name="Core">
+ <other xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" />
+ <summary test_plan_name="Empty test_plan_name">
+ <start_at>2014-03-21_18_52_41</start_at>
+ <end_at>2014-03-21_18_57_54</end_at>
+ </summary>
+EOS
+
+print "\n\nSummary of all tests:\n";
+my $output_files = `ls tct*core-tests.xml`;
+my $file;
+foreach $file (split /\s+/, $output_files )
+{
+ $num_tests=0;
+ $num_passes=0;
+ $num_actual_passes=0;
+ $text = "";
+
+ $parser->parsefile($file);
+
+ my $pass_rate = sprintf("%5.2f", $num_passes * 100.0 / $num_tests);
+ my $num_fails = $num_tests - $num_passes;
+ my $fail_rate = sprintf("%5.2f", $num_fails * 100.0 / $num_tests);
+
+ my $suite_name = $file;
+ $suite_name =~ s/\.xml$//;
+
+ print "$suite_name: $num_passes tests passed out of $num_tests ( $pass_rate% )\n";
+
+print SUMMARY << "EOS2";
+ <suite name="$suite_name">
+ <total_case>$num_tests</total_case>
+ <pass_case>$num_passes</pass_case>
+ <pass_rate>$pass_rate</pass_rate>
+ <fail_case>$num_fails</fail_case>
+ <fail_rate>$fail_rate</fail_rate>
+ <block_case>0</block_case>
+ <block_rate>0.00</block_rate>
+ <na_case>0</na_case>
+ <na_rate>0.00</na_rate>
+ </suite>
+EOS2
+}
+
+print SUMMARY "</result_summary>\n";
+close SUMMARY;
+
+print "Summary of results written to summary.xml\n";
--- /dev/null
+#!/bin/bash
+
+#---------- DEBUG_BEGIN ----------
+#ARG="-d" # debug-on flag, might be set as $1
+# keyprompt "introductory message" -- wait until any key pressed
+function keyprompt { echo -ne "\n\e[1;31m$1 -- " && read -n 1 && echo -e "\n\e[0m"; }
+# d_bp -- breakpoint at which user need to press any key to proceed
+function d_bp { if [[ "$ARG" == "-d" ]]; then keyprompt "d >> Press any key"; fi }
+# d_showVar VARNAME -- print bash variable name
+function d_showVar { if [ "$ARG" == "-d" -a -n "$1" ]; then echo "d >> ${1} = ${!1}"; fi }
+# d_print "message" -- print a debug message
+function d_print { if [ "$ARG" == "-d" -a -n "$1" ]; then echo -e "d >> $1"; fi }
+#---------- DEBUG_END ----------
+
+PROJECT_DIR="$(cd "$(dirname $0)" && pwd)"
+d_showVar PROJECT_DIR
+
+function gbs_profile {
+perl -e "
+use Config::Tiny;
+my \$Config = Config::Tiny->read( \"\$ENV{HOME}/.gbs.conf\" );
+my \$profile = \$Config->{general}->{profile};
+\$profile =~ s/profile.//;
+print \$profile;"
+}
+
+PROFILE=`gbs_profile`
+RPM_DIR="$HOME/GBS-ROOT/local/repos/$PROFILE/armv7l/RPMS"
+d_showVar RPM_DIR
+
+function add_module {
+ # argument check
+ if [ -z "$1" ]; then echo "Usage: `basename $0` addmod <module_name> [module_lib_name]"; exit 1; fi
+
+ MODULE_NAME=$1
+ d_showVar MODULE_NAME
+ MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/')
+ d_showVar MODULE_NAME_C
+ MODULE_NAME_U=$(echo $MODULE_NAME | sed -e 's/-/_/')
+ d_showVar MODULE_NAME_U
+# MODULE_LIBNAME=${2:-capi-$MODULE_NAME}
+ MODULE_LIBNAME=$1
+ d_showVar MODULE_LIBNAME
+
+ echo "Adding $MODULE_NAME module to project..."
+ d_bp
+ cd $PROJECT_DIR
+ # prepare .spec file
+ echo "-- Generating packaging/core-$MODULE_NAME-tests.spec file"
+ if [ ! -d packaging ]; then mkdir packaging; fi
+ sed -e "s:\[MODULE_NAME\]:$MODULE_NAME:g" -e "s:\[MODULE_LIBNAME\]:$MODULE_LIBNAME:g" \
+ templates/core-\[module_name\]-tests.spec > packaging/core-$MODULE_NAME-tests.spec
+ # prepare src directory
+ mkdir src/$MODULE_NAME
+ echo "-- Generating src/$MODULE_NAME/CMakeLists.txt file"
+ sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" -e "s:%{MODULE_LIBNAME}:$MODULE_LIBNAME:g" \
+ templates/src-directory/CMakeLists.txt > src/$MODULE_NAME/CMakeLists.txt
+ echo "-- Generating src/$MODULE_NAME/tct-$MODULE_NAME-core.c file"
+ sed -e "s:%{MODULE_NAME}:$MODULE_NAME:g" \
+ templates/src-directory/tct-\[module_name\]-core.c > src/$MODULE_NAME/tct-$MODULE_NAME-core.c
+ echo "-- Generating src/$MODULE_NAME/utc-$MODULE_NAME.c file"
+ sed -e "s:%{MODULE_NAME_U}:$MODULE_NAME_U:g" -e "s:%{MODULE_NAME_C}:$MODULE_NAME_C:g" \
+ templates/src-directory/utc-\[module_name\].c > src/$MODULE_NAME/utc-$MODULE_NAME.c
+ echo "Task finished successfully"
+}
+
+function rm_module {
+ # argument check
+ if [ -z "$1" ]; then echo "Usage: `basename $0` rmmod <module_name>"; exit 1; fi
+
+ MODULE_NAME=$1
+ d_showVar MODULE_NAME
+
+ echo "Removing $MODULE_NAME module from project..."
+ d_bp
+ echo "---- Updating /opt/tct/packages/package_list.xml"
+ scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/packages/package_list.xml 1
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # echo "---- Updating test plans"
+ # scripts/tcpackageslistsgen.sh $MODULE_NAME /opt/tct/manager/plan/*.xml 1
+ # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+
+ cd $PROJECT_DIR
+ echo "-- Removing packaging/core-$MODULE_NAME-tests.spec file"
+ rm packaging/core-$MODULE_NAME-tests.spec
+ echo "-- Removing src/$MODULE_NAME directory"
+ rm -r src/$MODULE_NAME
+ echo "Task finished successfully"
+}
+
+function build {
+ if [ -n "$1" ]; then
+ (cd src/$1; ../../scripts/tcheadgen.sh tct-$1-core.h)
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ cp packaging/core-$1-tests.spec ../packaging
+ gbs build -A armv7l --spec core-$1-tests.spec --include-all --keep-packs | \
+ tee build.log | stdbuf -o0 sed -e 's/error:/\x1b[1;91m&\x1b[0m/' \
+ -e 's/warning:/\x1b[93m&\x1b[0m/'
+ rm ../packaging/core-$1-tests.spec
+ else
+ echo "Build requires a module name"
+ exit 1
+ fi
+}
+
+function inst {
+ if [ -z "$1" ]
+ then
+ for mod in `ls -1 src/ | grep -v CMakeLists`
+ do
+
+ if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
+
+ PKG_NAME="core-$mod-tests"
+ d_showVar PKG_NAME
+ VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
+ d_showVar VER
+ PKG_VNAME="$PKG_NAME-$VER"
+ d_showVar PKG_VNAME
+ PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
+ d_showVar PKG_FNAME
+
+ if [ -f "$RPM_DIR/$PKG_FNAME" ]
+ then
+ inst $mod
+ echo ""
+ fi
+ fi
+ done
+ else
+ cd $PROJECT_DIR
+ # setting variables
+ MOD_NAME="$1"
+ d_showVar MOD_NAME
+ PKG_NAME="core-$MOD_NAME-tests"
+ d_showVar PKG_NAME
+ VER=$(cat packaging/$PKG_NAME.spec | awk '/^Version:/ { print $2; exit; }')
+ d_showVar VER
+ PKG_VNAME="$PKG_NAME-$VER"
+ d_showVar PKG_VNAME
+ PKG_FNAME="$PKG_VNAME-0.armv7l.rpm"
+ d_showVar PKG_FNAME
+ TCT_DIR="opt/tct-$MOD_NAME-core-tests"
+ d_showVar TCT_DIR
+
+ echo "Deploying $MOD_NAME suite to tct-mgr..."
+ d_bp
+ # prepare tct directory and files
+ echo "-- Preparing suite .zip file..."
+ echo "---- Creating /tmp/$TCT_DIR directory"
+ rm -r /tmp/opt > /dev/null 2>&1
+ mkdir -p /tmp/$TCT_DIR
+ # README
+ echo "---- Copying /tmp/$TCT_DIR"
+ cp templates/tct-package/README /tmp/$TCT_DIR
+ # rpm
+ echo "---- Copying /tmp/$TCT_DIR package"
+ cp $RPM_DIR/$PKG_FNAME /tmp/$TCT_DIR
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # inst.sh
+ echo "---- Generating /tmp/$TCT_DIR/inst.sh file"
+ sed -e "s:%{PKG_NAME}:\"$PKG_NAME\":g" -e "s:%{PKG_FULLNAME}:\"$PKG_FNAME\":g" \
+ -e "s:%{PKG_DIR}:\"/opt/usr/media/tct/$TCT_DIR\":g" \
+ templates/tct-package/inst.sh > /tmp/$TCT_DIR/inst.sh
+ chmod a+x /tmp/$TCT_DIR/inst.sh
+ # tests.xml
+ echo "---- Generating /tmp/$TCT_DIR"
+ scripts/tctestsgen.sh $MOD_NAME /tmp/$TCT_DIR target
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # zip
+ echo "---- Preparing /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip file"
+ # clear old zips
+ rm -r /tmp/tct/packages > /dev/null 2>&1
+ mkdir -p /tmp/tct/packages
+ # create new zip
+ ( cd /tmp; zip -r /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip opt > /dev/null 2>&1; )
+ # deployment
+ echo "-- Suite deployment..."
+ echo "---- Copying /opt/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip"
+ cp /tmp/tct/packages/tct-$MOD_NAME-core-tests-2.2.1-1.zip /opt/tct/packages/
+ echo "---- Updating /opt/tct/packages/package_list.xml"
+ scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/packages/package_list.xml 0
+ if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ # echo "---- Updating test plans"
+ # for file in `grep -r tct-$MOD_NAME-core-tests /opt/tct/manager/plan/ | cut -d: -f1 | uniq`
+ # do
+ # scripts/tcpackageslistsgen.sh $MOD_NAME $file
+ # done
+ # scripts/tcpackageslistsgen.sh $MOD_NAME /opt/tct/manager/plan/Full_test.xml
+ # if [ $? -ne 0 ]; then echo "Aborting..."; exit 1; fi
+ echo "Task finished successfully"
+ fi
+}
+
+if [ -z "$1" ]; then
+ # usage note
+ echo "Usage: `basename $0` <addmod|rmmod|build|install> <module_name> [module_lib_name]"
+ exit 1
+elif [ "addmod" == "$1" ]; then
+ # add new module
+ add_module $2 $3
+elif [ "rmmod" == "$1" ]; then
+ # remove module
+ rm_module $2
+elif [ "build" == "$1" ]; then
+ # build the binary
+ build $2
+elif [ "install" == "$1" ]; then
+ # install
+ inst $2
+else
+ echo "Invalid subcommand: $1"
+fi
--- /dev/null
+#!/bin/bash
+
+if [[ -z $1 ]]; then
+ echo "Usage note: tcheadgen.sh <header_filename.h>"
+ exit 1
+fi
+
+FILE="$PWD/$1"
+TFILE="/tmp/retr.csv"
+HEADER_NAME=$(echo $1 | tr '[:lower:]' '[:upper:]' | sed -e 's/-/_/g' -e 's/\./_/')
+SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
+
+$SCRIPT_DIR/retriever.sh > $TFILE
+if [ $? -ne 0 ]; then cat $TFILE; exit 1; fi
+awk -F',' -v HEADER_NAME="$HEADER_NAME" '
+ BEGIN {
+ OFS = ", ";
+
+ startup_counter = 0;
+ startup_list[0] = "";
+
+ cleanup_counter = 0;
+ cleanup_list[0] = "";
+
+ testcase_counter = 0;
+ testcase_list[0] = "";
+
+ tc_array_counter = 0;
+ tc_array_list[0] = "";
+
+print "#ifndef __" HEADER_NAME "__"
+print "#define __" HEADER_NAME "__"
+print ""
+print "#include \"testcase.h\""
+print ""
+ }
+ {
+ testcase_list[testcase_counter++] = $1;
+
+ if (startup_counter == 0 || startup_list[startup_counter-1] != $2)
+ startup_list[startup_counter++] = $2;
+
+ if (startup_counter == 0 || cleanup_list[cleanup_counter-1] != $3)
+ cleanup_list[cleanup_counter++] = $3;
+
+ tc_array_list[tc_array_counter++] = "\"" $1 "\", " $1 ", " $2 ", " $3;
+ }
+ END {
+ sc_count = (startup_counter > cleanup_counter) ? startup_counter : cleanup_counter;
+ for (i = 0; i < sc_count; i++) {
+ if (i < startup_counter && startup_list[i] != "NULL")
+print "extern void " startup_list[i] "(void);"
+ if (i < cleanup_counter && cleanup_list[i] != "NULL")
+print "extern void " cleanup_list[i] "(void);"
+ }
+
+print ""
+ for (i = 0; i < testcase_counter; i++)
+print "extern int " testcase_list[i] "(void);"
+
+print ""
+print "testcase tc_array[] = {"
+
+ for (i = 0; i < tc_array_counter; i++)
+print " {" tc_array_list[i] "},"
+
+print " {NULL, NULL}"
+print "};"
+print ""
+print "#endif // __" HEADER_NAME "__"
+}' $TFILE > $FILE
--- /dev/null
+#!/bin/bash
+
+if [ -z $1 -o -z $2 ]; then
+ echo "Usage note: tcpackageslistsgen.sh <module_name> <output_file.xml>"
+ exit 1
+fi
+
+MODULE_NAME=$1
+FILE=$2
+if [ ! -f $FILE ]; then
+ echo "No such file: $2"
+ exit
+fi
+SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
+AUTO_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh -anum src/$MODULE_NAME)
+if [ $? -ne 0 ]; then echo $AUTO_NUM; exit 1; fi
+MAN_NUM=$(cd $SCRIPT_DIR/..; scripts/retriever.sh -mnum src/$MODULE_NAME)
+if [ $? -ne 0 ]; then echo $MAN_NUM; exit 1; fi
+
+TFILE="/tmp/tempfile.xml"
+if [ -f $TFILE ]; then
+ rm $TFILE
+fi
+
+function regen {
+ awk -v RS='\r\n' -v ORS='\r\n' -v MODULE_NAME=$MODULE_NAME -v AUTO_NUM=$AUTO_NUM -v MAN_NUM=$MAN_NUM '
+ BEGIN {
+ found = 0;
+ replaced = 0;
+ }
+ $0 ~ "<suite name=\"tct-" MODULE_NAME "-core-tests\" category=\"Core APIs\">" {
+ found = 1;
+ next
+ }
+ /<\/suite>/ {
+ if (found == 1) {
+print " <suite name=\"tct-" MODULE_NAME "-core-tests\" category=\"Core APIs\">";
+print " <auto_tcn>" AUTO_NUM "</auto_tcn>";
+print " <manual_tcn>" MAN_NUM "</manual_tcn>";
+print " <total_tcn>" AUTO_NUM+MAN_NUM "</total_tcn>";
+print " <pkg_name>tct-" MODULE_NAME "-core-tests-2.2.1-1.zip</pkg_name>";
+print " </suite>";
+ found = 0;
+ replaced = 1;
+ } else {
+ print $0;
+ }
+ next
+ }
+ /<\/ns3:testplan>/ {
+ if (replaced == 0) {
+print " <suite name=\"tct-" MODULE_NAME "-core-tests\" category=\"Core APIs\">";
+print " <auto_tcn>" AUTO_NUM "</auto_tcn>";
+print " <manual_tcn>" MAN_NUM "</manual_tcn>";
+print " <total_tcn>" AUTO_NUM+MAN_NUM "</total_tcn>";
+print " <pkg_name>tct-" MODULE_NAME "-core-tests-2.2.1-1.zip</pkg_name>";
+print " </suite>";
+print $0
+ } else {
+ print $0
+ }
+ next
+ }
+ {
+ if (found == 0) {
+ print $0;
+ }
+ }' $FILE > $TFILE
+ cat $TFILE > $FILE
+}
+
+regen
--- /dev/null
+#!/bin/bash
+
+if [[ -z $1 ]]; then
+ echo "Usage note: tctestsgen.sh <module_name>"
+ exit 1
+fi
+
+MODULE_NAME=$1
+MODULE_NAME_C=$(echo $MODULE_NAME | sed -e 's/-\([a-z]\)/\U\1/' -e 's/^\([a-z]\)/\U\1/')
+SCRIPT_DIR="$(cd "$(dirname $0)" && pwd)"
+TC_DIR="/opt/usr/bin/tct-$1-core"
+if [[ $3 == "desktop" ]] ; then
+ TC_DIR="build/src/$1"
+fi
+
+FILE="$2/tests.xml"
+if [ -a $FILE ]; then
+ rm $FILE
+fi
+TFILE="/tmp/tcs.csv"
+if [ -a $TFILE ]; then
+ rm $TFILE
+fi
+
+function gen {
+ awk -F',' -v MODULE_NAME=$MODULE_NAME -v MODULE_NAME_C=$MODULE_NAME_C -v TC_DIR=$TC_DIR '
+ BEGIN {
+ set = ""
+print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+print " <?xml-stylesheet type=\"text/xsl\" href=\"./testcase.xsl\"?>";
+print "<test_definition>";
+print " <suite name=\"tct-"MODULE_NAME"-core-tests\" category=\"Core APIs\">";
+ }
+ {
+ if (set != "" && set != $2) {
+print " </set>"
+ }
+
+ if (set != $2) {
+ set = $2;
+print " <set name=\"" set "\">";
+ }
+
+ tcname = $1;
+ tcpurpose = $3
+
+print " <testcase component=\"CoreAPI/" MODULE_NAME_C "/" set "\" execution_type=\"auto\" id=\"" tcname "\" purpose=\"" tcpurpose "\">";
+print " <description>";
+
+print " <test_script_entry test_script_expected_result=\"0\">" TC_DIR "/tct-" MODULE_NAME "-core " tcname "</test_script_entry>";
+print " </description>";
+print " </testcase>";
+ }
+ END {
+ if (set != "") {
+print " </set>"
+ }
+print " </suite>"
+print "</test_definition>"
+ }' $TFILE > $FILE
+}
+
+(cd $SCRIPT_DIR/..; scripts/retriever.sh -f src/$MODULE_NAME > ${TFILE}_pre)
+if [ $? -ne 0 ]; then cat ${TFILE}_pre; exit 1; fi
+cat ${TFILE}_pre | sort -t',' -k2,2 -s > $TFILE
+gen
--- /dev/null
+IF( DEFINED MODULE )
+ MESSAGE(STATUS "Building: ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE}")
+ ADD_SUBDIRECTORY(${MODULE})
+ELSE( DEFINED MODULE )
+ MESSAGE(FATAL_ERROR "No module selected to build. Aborting...")
+ENDIF( DEFINED MODULE )
--- /dev/null
+#ifndef _ASSERT_H_
+#define _ASSERT_H_
+#include <stdio.h>
+#include <stdlib.h>
+
+#define assert(exp) \
+ if (!(exp)) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Following expression is not true:\n" \
+ "%s\n", #exp); \
+ return 1; \
+ }
+
+#define assert_eq(var, ref) \
+ if (var != ref) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Values \"%s\" and \"%s\" are not equal:\n" \
+ "%s == %d, %s == %d\n", \
+ #var, #ref, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ }
+
+#define assert_neq(var, ref) \
+ if (var == ref) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Values \"%s\" and \"%s\" are equal:\n" \
+ "%s == %s == %d\n", \
+ #var, #ref, #var, #ref, (int)ref); \
+ return 1; \
+ }
+
+#define assert_gt(var, ref) \
+ if (var <= ref) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Value \"%s\" is not greater than \"%s\":\n" \
+ "%s == %d, %s == %d\n", \
+ #var, #ref, #var, var, #ref, ref); \
+ return 1; \
+ }
+
+#define assert_geq(var, ref) \
+ if (var < ref) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Value \"%s\" is not greater or equal to \"%s\":\n" \
+ "%s == %d, %s == %d\n", \
+ #var, #ref, #var, var, #ref, ref); \
+ return 1; \
+ }
+
+#define assert_lt(var, ref) \
+ if (var >= ref) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Value \"%s\" is not lower than \"%s\":\n" \
+ "%s == %d, %s == %d\n", \
+ #var, #ref, #var, var, #ref, ref); \
+ return 1; \
+ }
+
+#define assert_leq(var, ref) \
+ if (var > ref) { \
+ fprintf(stderr, \
+ "Assert fail in %s:%d\n", __FILE__, __LINE__); \
+ fprintf(stderr, \
+ "Value \"%s\" is not lower or equal to \"%s\":\n" \
+ "%s == %d, %s == %d\n", \
+ #var, #ref, #var, var, #ref, ref); \
+ return 1; \
+ }
+
+#endif // _ASSERT_H_
--- /dev/null
+#ifndef _TESTCASE_H_
+#define _TESTCASE_H_
+
+/* pointer to startup/cleanup functions */
+typedef void (*void_fun_ptr)(void);
+
+/* pointer to testcase functions */
+typedef int (*tc_fun_ptr)(void);
+
+/* struct describing specific testcase */
+typedef struct testcase_s {
+ const char* name;
+ tc_fun_ptr function;
+ void_fun_ptr startup;
+ void_fun_ptr cleanup;
+} testcase;
+
+#endif // _TESTCASE_H_
--- /dev/null
+SET(PKG_NAME "dali-toolkit-internal")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+SET(RPM_NAME "core-${PKG_NAME}-tests")
+
+SET(CAPI_LIB "dali-toolkit-internal")
+
+# List of test case sources (Only these get parsed for test cases)
+SET(TC_SOURCES
+ utc-Dali-PushButton.cpp
+ utc-Dali-TextView-HelperAndDebug.cpp
+ utc-Dali-TextView-Processor-Types.cpp
+ utc-Dali-TextView-Processor.cpp
+ utc-Dali-TextView-Relayout-Utilities.cpp
+ utc-Dali-TextView.cpp
+)
+
+# Append list of test harness files (Won't get parsed for test cases)
+LIST(APPEND TC_SOURCES
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-manager.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-imf-manager.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-orientation.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-physical-keyboard.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-timer.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard-event-notifier.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-application.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp
+ ../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
+)
+
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+ dali-core
+ dali
+ dali-toolkit
+)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb --coverage -Wall -Werror=return-type")
+
+FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
+ SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
+ENDFOREACH(directory ${CAPI_LIB_LIBRARY_DIRS})
+
+INCLUDE_DIRECTORIES(
+ ${${CAPI_LIB}_INCLUDE_DIRS}
+ ../dali-toolkit/dali-toolkit-test-utils
+ ../../..
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp ${TC_SOURCES})
+TARGET_LINK_LIBRARIES(${EXEC_NAME}
+ ${${CAPI_LIB}_LIBRARIES}
+)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+ DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "tct-dali-toolkit-internal-core.h"
+
+int main(int argc, const char *argv[])
+{
+ int result = -1;
+ int i;
+
+ if (argc != 2) {
+ printf("Usage: %s <testcase name>\n", argv[0]);
+ return 2;
+ }
+
+ for (i = 0; tc_array[i].name; i++) {
+ if (!strcmp(argv[1], tc_array[i].name)) {
+ if (tc_array[i].startup)
+ tc_array[i].startup();
+
+ result = tc_array[i].function();
+
+ if (tc_array[i].cleanup)
+ tc_array[i].cleanup();
+
+ return result;
+ }
+ }
+
+ printf("Unknown testcase name: \"%s\"\n", argv[1]);
+ return 2;
+}
--- /dev/null
+#ifndef __TCT_DALI_TOOLKIT_INTERNAL_CORE_H__
+#define __TCT_DALI_TOOLKIT_INTERNAL_CORE_H__
+
+#include "testcase.h"
+
+extern void dali_text_view_helper_and_debug_startup(void);
+extern void dali_text_view_helper_and_debug_cleanup(void);
+extern void dali_text_view_processor_types_startup(void);
+extern void dali_text_view_processor_types_cleanup(void);
+extern void dali_text_view_processor_startup(void);
+extern void dali_text_view_processor_cleanup(void);
+extern void dali_text_view_relayout_utils_startup(void);
+extern void dali_text_view_relayout_utils_cleanup(void);
+extern void dali_text_view_startup(void);
+extern void dali_text_view_cleanup(void);
+
+extern int UtcDaliPushButtonInterruptEventWhenInsensitive(void);
+extern int UtcDaliPushButtonInterruptEventWhenNonVisible(void);
+extern int UtcDaliPushButtonProperties(void);
+extern int UtcDaliTextViewGetIndicesFromGlobalCharacterIndex(void);
+extern int UtcDaliTextViewDebugCouts(void);
+extern int UtcDaliTextViewDefaultConstructorDestructor_PT(void);
+extern int UtcDaliTextViewCopyConstructorOperator(void);
+extern int UtcDaliTextViewEqualityOperator(void);
+extern int UtcDaliTextViewSplitInLines(void);
+extern int UtcDaliTextViewSplitInWords(void);
+extern int UtcDaliTextViewBeginsRightToLeftCharacter(void);
+extern int UtcDaliTextViewContainsRightToLeftCharacter(void);
+extern int UtcDaliTextViewFindNearestWord(void);
+extern int UtcDaliTextViewDefaultConstructorDestructor_RU(void);
+extern int UtcDaliTextViewCalculateSubLineLayout(void);
+extern int UtcDaliTextViewCalculateAlignmentOffsets(void);
+extern int UtcDaliTextViewCalculateJustificationOffsets(void);
+extern int UtcDaliTextViewCalculateVisibility(void);
+extern int UtcDaliTextViewMiscelaneousAsserts(void);
+extern int UtcDaliTextViewCreateTextInfo(void);
+extern int UtcDaliTextViewSplitWord(void);
+extern int UtcDaliTextViewUpdateTextInfo(void);
+extern int UtcDaliTextViewSplitWordGroup(void);
+extern int UtcDaliTextViewSplitLine(void);
+extern int UtcDaliTextViewMergeWord01(void);
+extern int UtcDaliTextViewMergeWord02(void);
+extern int UtcDaliTextViewMergeGroup01(void);
+extern int UtcDaliTextViewMergeGroup02(void);
+extern int UtcDaliTextViewMergeLine01(void);
+extern int UtcDaliTextViewMergeLine02(void);
+extern int UtcDaliTextViewRemoveCharactersFromWord(void);
+extern int UtcDaliTextViewRemoveWordsFromGroup(void);
+extern int UtcDaliTextViewRemoveGroupsFromLine(void);
+
+testcase tc_array[] = {
+ {"UtcDaliPushButtonInterruptEventWhenInsensitive", UtcDaliPushButtonInterruptEventWhenInsensitive, NULL, NULL},
+ {"UtcDaliPushButtonInterruptEventWhenNonVisible", UtcDaliPushButtonInterruptEventWhenNonVisible, NULL, NULL},
+ {"UtcDaliPushButtonProperties", UtcDaliPushButtonProperties, NULL, NULL},
+ {"UtcDaliTextViewGetIndicesFromGlobalCharacterIndex", UtcDaliTextViewGetIndicesFromGlobalCharacterIndex, dali_text_view_helper_and_debug_startup, dali_text_view_helper_and_debug_cleanup},
+ {"UtcDaliTextViewDebugCouts", UtcDaliTextViewDebugCouts, dali_text_view_helper_and_debug_startup, dali_text_view_helper_and_debug_cleanup},
+ {"UtcDaliTextViewDefaultConstructorDestructor_PT", UtcDaliTextViewDefaultConstructorDestructor_PT, dali_text_view_processor_types_startup, dali_text_view_processor_types_cleanup},
+ {"UtcDaliTextViewCopyConstructorOperator", UtcDaliTextViewCopyConstructorOperator, dali_text_view_processor_types_startup, dali_text_view_processor_types_cleanup},
+ {"UtcDaliTextViewEqualityOperator", UtcDaliTextViewEqualityOperator, dali_text_view_processor_types_startup, dali_text_view_processor_types_cleanup},
+ {"UtcDaliTextViewSplitInLines", UtcDaliTextViewSplitInLines, dali_text_view_processor_startup, dali_text_view_processor_cleanup},
+ {"UtcDaliTextViewSplitInWords", UtcDaliTextViewSplitInWords, dali_text_view_processor_startup, dali_text_view_processor_cleanup},
+ {"UtcDaliTextViewBeginsRightToLeftCharacter", UtcDaliTextViewBeginsRightToLeftCharacter, dali_text_view_processor_startup, dali_text_view_processor_cleanup},
+ {"UtcDaliTextViewContainsRightToLeftCharacter", UtcDaliTextViewContainsRightToLeftCharacter, dali_text_view_processor_startup, dali_text_view_processor_cleanup},
+ {"UtcDaliTextViewFindNearestWord", UtcDaliTextViewFindNearestWord, dali_text_view_processor_startup, dali_text_view_processor_cleanup},
+ {"UtcDaliTextViewDefaultConstructorDestructor_RU", UtcDaliTextViewDefaultConstructorDestructor_RU, dali_text_view_relayout_utils_startup, dali_text_view_relayout_utils_cleanup},
+ {"UtcDaliTextViewCalculateSubLineLayout", UtcDaliTextViewCalculateSubLineLayout, dali_text_view_relayout_utils_startup, dali_text_view_relayout_utils_cleanup},
+ {"UtcDaliTextViewCalculateAlignmentOffsets", UtcDaliTextViewCalculateAlignmentOffsets, dali_text_view_relayout_utils_startup, dali_text_view_relayout_utils_cleanup},
+ {"UtcDaliTextViewCalculateJustificationOffsets", UtcDaliTextViewCalculateJustificationOffsets, dali_text_view_relayout_utils_startup, dali_text_view_relayout_utils_cleanup},
+ {"UtcDaliTextViewCalculateVisibility", UtcDaliTextViewCalculateVisibility, dali_text_view_relayout_utils_startup, dali_text_view_relayout_utils_cleanup},
+ {"UtcDaliTextViewMiscelaneousAsserts", UtcDaliTextViewMiscelaneousAsserts, dali_text_view_relayout_utils_startup, dali_text_view_relayout_utils_cleanup},
+ {"UtcDaliTextViewCreateTextInfo", UtcDaliTextViewCreateTextInfo, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewSplitWord", UtcDaliTextViewSplitWord, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewUpdateTextInfo", UtcDaliTextViewUpdateTextInfo, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewSplitWordGroup", UtcDaliTextViewSplitWordGroup, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewSplitLine", UtcDaliTextViewSplitLine, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewMergeWord01", UtcDaliTextViewMergeWord01, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewMergeWord02", UtcDaliTextViewMergeWord02, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewMergeGroup01", UtcDaliTextViewMergeGroup01, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewMergeGroup02", UtcDaliTextViewMergeGroup02, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewMergeLine01", UtcDaliTextViewMergeLine01, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewMergeLine02", UtcDaliTextViewMergeLine02, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewRemoveCharactersFromWord", UtcDaliTextViewRemoveCharactersFromWord, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewRemoveWordsFromGroup", UtcDaliTextViewRemoveWordsFromGroup, dali_text_view_startup, dali_text_view_cleanup},
+ {"UtcDaliTextViewRemoveGroupsFromLine", UtcDaliTextViewRemoveGroupsFromLine, dali_text_view_startup, dali_text_view_cleanup},
+ {NULL, NULL}
+};
+
+#endif // __TCT_DALI_TOOLKIT_INTERNAL_CORE_H__
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/internal/controls/buttons/button-impl.h>
+
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+
+static bool gPushButtonToggleState = false;
+bool PushButtonToggled( Button button, bool toggled )
+{
+ gPushButtonToggleState = toggled && ( toggled == static_cast<PushButton&>( button ).IsToggled() );
+ return true;
+}
+
+
+const Dali::TouchPoint pointDownInside( 0, TouchPoint::Down, 240, 400 );
+const Dali::TouchPoint pointUpInside( 0, TouchPoint::Up, 240, 400 );
+const Dali::TouchPoint pointLeave( 0, TouchPoint::Leave, 240, 400 );
+const Dali::TouchPoint pointEnter( 0, TouchPoint::Motion, 240, 400 );
+const Dali::TouchPoint pointMotionOut( 0, TouchPoint::Motion, 10, 10 );
+const Dali::TouchPoint pointDownOutside( 0, TouchPoint::Down, 10, 10 );
+const Dali::TouchPoint pointUpOutside( 0, TouchPoint::Up, 10, 10 );
+} // namespace
+
+
+//////////////////////////////////////////////////////////
+
+namespace
+{
+static bool gOnTouchPointInterrupted = false;
+} //namespace
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+class TETButton;
+}
+
+/**
+ * Creates a Button to test if interrupt events are handled correctly.
+ */
+class TETButton : public Button
+{
+public:
+ // PushButton Pressed
+ typedef SignalV2< bool ( Button ) > PressedSignalV2;
+
+ PressedSignalV2& PressedSignal();
+
+ /**
+ * Default constructor.
+ */
+ TETButton();
+
+ /**
+ * Copy constructor.
+ */
+ TETButton( const Button& button );
+
+ /**
+ * Assignment operator.
+ */
+ TETButton& operator=( const TETButton& button );
+
+ /**
+ * Creates and initializes a new button.
+ */
+ static TETButton New();
+
+ /**
+ * Down cast to TETButton.
+ */
+ static TETButton DownCast( BaseHandle handle );
+
+ /**
+ * Creates a handle using the Toolkit::Internal implementation.
+ * @param[in] implementation The Control implementation.
+ */
+ TETButton( Internal::TETButton& implementation );
+
+ /**
+ * Allows the creation of this Control from an Internal::CustomActor pointer.
+ * @param[in] internal A pointer to the internal CustomActor.
+ */
+ TETButton( Dali::Internal::CustomActor* internal );
+};
+
+namespace Internal
+{
+
+/**
+ * Internal implementation
+ */
+class TETButton : public Button
+{
+public:
+ /**
+ * Construct a new Button.
+ */
+ TETButton();
+
+ /**
+ * A reference counted object may only be deleted by calling Unreference()
+ */
+ virtual ~TETButton();
+
+ /**
+ * Creates an internal button.
+ */
+ static Toolkit::TETButton New();
+
+ /**
+ * @return the pressed signal.
+ */
+ Toolkit::TETButton::PressedSignalV2& PressedSignal();
+
+ /**
+ * Callback called when an interrupt events is received.
+ */
+ void OnTouchPointInterrupted();
+
+ /**
+ * Callback received when a down event is received.
+ */
+ void OnButtonDown();
+
+ Toolkit::TETButton::PressedSignalV2 mPressedSignal; ///< Signal emitted when the button is pressed.
+};
+
+} // namespace Internal
+
+TETButton::TETButton()
+{
+}
+
+TETButton::TETButton( const Button& button )
+: Button( button )
+{
+}
+
+TETButton& TETButton::operator=( const TETButton& button )
+{
+ if( &button != this )
+ {
+ Button::operator=( button );
+ }
+ return *this;
+}
+
+TETButton TETButton::New()
+{
+ return Internal::TETButton::New();
+}
+
+TETButton TETButton::DownCast( BaseHandle handle )
+{
+ return Control::DownCast<TETButton, Internal::TETButton>(handle);
+}
+
+TETButton::PressedSignalV2& TETButton::PressedSignal()
+{
+ TETButton button( *this );
+ DALI_ASSERT_ALWAYS( button );
+
+ Dali::RefObject& handle = button.GetImplementation();
+
+ return static_cast<Toolkit::Internal::TETButton&>( handle ).PressedSignal();
+}
+
+TETButton::TETButton( Internal::TETButton& implementation )
+: Button( implementation )
+{}
+
+TETButton::TETButton( Dali::Internal::CustomActor* internal )
+: Button( internal )
+{
+ VerifyCustomActorPointer<Internal::TETButton>(internal);
+}
+
+namespace Internal
+{
+
+TETButton::TETButton()
+: Button(),
+ mPressedSignal()
+{
+}
+
+TETButton::~TETButton()
+{
+}
+
+Toolkit::TETButton TETButton::New()
+{
+ // Create the implementation, temporarily owned on stack
+ IntrusivePtr< TETButton > internalTETButton = new TETButton();
+
+ // Pass ownership to CustomActor
+ Dali::Toolkit::TETButton tetButton( *internalTETButton );
+
+ // Second-phase init of the implementation
+ // This can only be done after the CustomActor connection has been made...
+ internalTETButton->Initialize();
+
+ return tetButton;
+}
+
+Toolkit::TETButton::PressedSignalV2& TETButton::PressedSignal()
+{
+ return mPressedSignal;
+}
+
+void TETButton::OnButtonDown()
+{
+ Toolkit::TETButton handle( GetOwner() );
+
+ //Emit signal.
+ mPressedSignal.Emit( handle );
+}
+
+void TETButton::OnTouchPointInterrupted()
+{
+ gOnTouchPointInterrupted = true;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+namespace
+{
+
+class TETButtonPressed : public Dali::ConnectionTracker
+{
+public:
+ enum Test
+ {
+ SENSITIVENESS,
+ VISIBILITY
+ };
+
+ TETButtonPressed( Actor actor, Test test )
+ : mActor( actor ),
+ mTest( test )
+ {
+ }
+
+ bool Callback( Button button )
+ {
+ switch( mTest )
+ {
+ case SENSITIVENESS:
+ {
+ mActor.SetSensitive( false );
+ break;
+ }
+ case VISIBILITY:
+ {
+ std::cout <<"VISIBILITY false" << std::endl;
+ mActor.SetVisible( false );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ return true;
+ }
+
+ Actor mActor;
+ Test mTest;
+};
+
+static bool TestCallback(Actor actor, const TouchEvent& event)
+{
+ return true;
+}
+
+} // namespace
+
+//////////////////////////////////////////////////////////
+
+
+int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliPushButtonInterruptEventWhenInsensitive");
+
+ // * Creates an actor which contains a button.
+ // * The size of the actor is bigger than the button.
+ // * The button's boundary is contained in the actor's one.
+ Actor actor = Actor::New();
+ TETButton tetButton= Toolkit::TETButton::New();
+
+ actor.SetName( "Actor" );
+ tetButton.SetName( "TETButton" );
+
+ actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ actor.SetPosition( 0, 0 );
+ actor.SetSize( 400, 800 );
+
+ tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ tetButton.SetPosition( 240, 400 );
+ tetButton.SetSize( 100, 100 );
+
+ actor.Add( tetButton );
+ Stage::GetCurrent().Add( actor );
+
+ // * Actor's touch event is connected to a callback function
+ // and this callback function consumes the event.
+ actor.TouchedSignal().Connect( &TestCallback );
+
+ // * Button's pressed signal is connected to a callback function
+ // which also consumes the event.
+ // * Changes the sensitiveness of the button to false.
+ TETButtonPressed tetButtonPressed( actor, TETButtonPressed::SENSITIVENESS );
+ tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );
+
+ // Initializes TET state.
+ gOnTouchPointInterrupted = false;
+ tetButton.SetSensitive( true );
+
+ Dali::Integration::TouchEvent event;
+
+ // TET starts.
+
+ // Test a down point inside the button which is also consumed by the actor, and an up point
+ // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
+ // interrupt event.
+
+ application.SendNotification();
+ application.Render();
+
+ // A down event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointDownInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ // An up event is sent outside the button's boundary but inside the actor's one.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointUpOutside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( gOnTouchPointInterrupted );
+
+ // Test a down point inside the button which is also consumed by the actor, and a motion point
+ // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
+ // interrupt event.
+
+ // Initializes TET state.
+ gOnTouchPointInterrupted = false;
+ actor.SetSensitive( true );
+ tetButton.SetSensitive( true );
+
+ application.SendNotification();
+ application.Render();
+
+ // A down event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointDownInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ // A motion event is sent outside the button's boundary but inside the actor's one.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointMotionOut );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( gOnTouchPointInterrupted );
+
+ // Test a down point inside the button which is also consumed by the actor, and an up point
+ // also inside the button and consumed by the actor. gOnTouchPointInterrupted should be false.
+
+ // Initializes TET state.
+ gOnTouchPointInterrupted = false;
+ actor.SetSensitive( true );
+ tetButton.SetSensitive( true );
+
+ // A down event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointDownInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ actor.SetSensitive( true );
+ // An up event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointUpInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( !gOnTouchPointInterrupted );
+ END_TEST;
+}
+
+int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliPushButtonInterruptEventWhenNonVisible");
+
+ // Does same test as above but changing the visibility instead the sensitiveness.
+
+ // * Creates an actor which contains a button.
+ // * The size of the actor is bigger than the button.
+ // * The button's boundary is contained in the actor's one.
+ Actor actor = Actor::New();
+ TETButton tetButton = Toolkit::TETButton::New();
+
+ actor.SetName( "Actor" );
+ tetButton.SetName( "TETButton" );
+
+ actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ actor.SetPosition( 0, 0 );
+ actor.SetSize( 400, 800 );
+
+ tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ tetButton.SetPosition( 240, 400 );
+ tetButton.SetSize( 100, 100 );
+
+ actor.Add( tetButton );
+ Stage::GetCurrent().Add( actor );
+
+ // * Actor's touch event is connected to a callback function
+ // and this callback function consumes the event.
+ actor.TouchedSignal().Connect( &TestCallback );
+
+ // * Button's pressed signal is connected to a callback function
+ // which also consumes the event.
+ // * Changes the visibility of the button to false.
+ TETButtonPressed tetButtonPressed( tetButton, TETButtonPressed::VISIBILITY );
+ tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );
+
+ // Initializes TET state.
+ gOnTouchPointInterrupted = false;
+ tetButton.SetVisible( true );
+
+ Dali::Integration::TouchEvent event;
+
+ // TET starts.
+
+ // Test a down point inside the button which is also consumed by the actor, and an up point
+ // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
+ // interrupt event.
+
+ application.SendNotification();
+ application.Render();
+
+ // A down event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointDownInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ // More renders are needed in order to allow the node of the actor to become invisible.
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // An up event is sent outside the button's boundary but inside the actor's one.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointUpOutside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( gOnTouchPointInterrupted );
+
+ // Test a down point inside the button which is also consumed by the actor, and a motion point
+ // consumed only by the actor. gOnTouchPointInterrupted should be true (Button receives an
+ // interrupt event.
+
+ // Initializes TET state.
+ gOnTouchPointInterrupted = false;
+ tetButton.SetVisible( true );
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // A down event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointDownInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ // More renders are needed in order to allow the node of the actor to become invisible.
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // A motion event is sent outside the button's boundary but inside the actor's one.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointMotionOut );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( gOnTouchPointInterrupted );
+
+ // Test a down point inside the button which is also consumed by the actor, and an up point
+ // also inside the button and consumed by the actor. gOnTouchPointInterrupted should be false.
+
+ // Initializes TET state.
+ gOnTouchPointInterrupted = false;
+ tetButton.SetVisible( true );
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // A down event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointDownInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ tetButton.SetVisible( true );
+
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // An up event is sent inside the button's boundary.
+
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( pointUpInside );
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+ application.ProcessEvent( event );
+
+ DALI_TEST_CHECK( !gOnTouchPointInterrupted );
+ END_TEST;
+}
+
+int UtcDaliPushButtonProperties(void)
+{
+ ToolkitTestApplication application;
+
+ PushButton button = PushButton::New();
+ Stage::GetCurrent().Add( button );
+
+ // PushButton::PROPERTY_AUTO_REPEATING
+ button.SetAutoRepeating( false );
+ DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_AUTO_REPEATING ) );
+ button.SetProperty( PushButton::PROPERTY_AUTO_REPEATING, true );
+ DALI_TEST_CHECK( button.IsAutoRepeating() ) ;
+ DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_AUTO_REPEATING ) );
+
+ // PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY
+ button.SetInitialAutoRepeatingDelay( 10.0f );
+ DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION );
+ button.SetProperty( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, 25.0f );
+ DALI_TEST_EQUALS( 25.0f, button.GetInitialAutoRepeatingDelay(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION );
+
+ // PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY
+ button.SetNextAutoRepeatingDelay( 3.0f );
+ DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION );
+ button.SetProperty( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY, 4.0f );
+ DALI_TEST_EQUALS( 4.0f, button.GetNextAutoRepeatingDelay(), TEST_LOCATION );
+ DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION );
+
+ // PushButton::PROPERTY_TOGGLABLE
+ button.SetToggleButton( false );
+ DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_TOGGLABLE ) );
+ button.SetProperty( PushButton::PROPERTY_TOGGLABLE, true );
+ DALI_TEST_CHECK( button.IsToggleButton() ) ;
+ DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_TOGGLABLE ) );
+
+ // PushButton::PROPERTY_TOGGLE
+ button.SetToggled( false );
+ DALI_TEST_CHECK( ! button.GetProperty< bool >( PushButton::PROPERTY_TOGGLE ) );
+ button.SetProperty( PushButton::PROPERTY_TOGGLE, true );
+ DALI_TEST_CHECK( button.IsToggled() ) ;
+ DALI_TEST_CHECK( button.GetProperty< bool >( PushButton::PROPERTY_TOGGLE ) );
+
+ // PushButton::PROPERTY_NORMAL_STATE_ACTOR
+ {
+ button.SetButtonImage( Image::New( "IMAGE_PATH_1") );
+ DALI_TEST_EQUALS( "IMAGE_PATH_1", button.GetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "ImageActor" ) );
+
+ button.SetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR, map );
+ DALI_TEST_EQUALS( "ImageActor", button.GetProperty( PushButton::PROPERTY_NORMAL_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
+ }
+
+ // PushButton::PROPERTY_PRESSED_IMAGE
+ {
+ button.SetPressedImage( Image::New( "IMAGE_PATH_2") );
+ DALI_TEST_EQUALS( "IMAGE_PATH_2", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "TextActor" ) );
+
+ button.SetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR, map );
+ DALI_TEST_EQUALS( "TextActor", button.GetProperty( PushButton::PROPERTY_PRESSED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
+ }
+
+ // PushButton::PROPERTY_DIMMED_STATE_ACTOR
+ {
+ button.SetDimmedImage( Image::New( "IMAGE_PATH_3") );
+ DALI_TEST_EQUALS( "IMAGE_PATH_3", button.GetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR ).GetValue( "image" ).GetValue( "filename" ).Get< std::string >(), TEST_LOCATION );
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "Actor" ) );
+
+ button.SetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR, map );
+ DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_DIMMED_STATE_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
+ }
+
+ // PushButton::PROPERTY_LABEL_ACTOR
+ {
+ button.SetLabelText( "LABEL_TEXT_CUSTOM" );
+ DALI_TEST_EQUALS( "TextView", button.GetProperty( PushButton::PROPERTY_LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
+
+ Property::Map map;
+ map.push_back( Property::StringValuePair( "type", "Actor" ) );
+
+ button.SetProperty( PushButton::PROPERTY_LABEL_ACTOR, map );
+ DALI_TEST_EQUALS( "Actor", button.GetProperty( PushButton::PROPERTY_LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION );
+ }
+ END_TEST;
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+// Internal headers are allowed here
+#include <dali-toolkit/internal/controls/text-view/split-by-new-line-char-policies.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-impl.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-helper-functions.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-dbg.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace Dali::Toolkit::Internal;
+
+void dali_text_view_helper_and_debug_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_text_view_helper_and_debug_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+
+namespace
+{
+// Data structures used to create an 'experiment' in TET cases
+
+const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
+const Toolkit::Internal::TextView::VisualParameters DEFAULT_VISUAL_PARAMETERS;
+
+struct GetIndicesFromGlobalCharacterIndexTest
+{
+ std::string description;
+ std::string input;
+ std::size_t position;
+ std::size_t 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
+
+
+int UtcDaliTextViewGetIndicesFromGlobalCharacterIndex(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewGetIndicesFromGlobalCharacterIndex : ");
+ struct GetIndicesFromGlobalCharacterIndexTest getIndicesFromGlobalCharacterIndexTests[] =
+ {
+ {
+ std::string( "Test position 0" ),
+ std::string( "text te<font size='30'>xt text te</font>xt text\n"
+ "text t<font size='30'>ext טקסט טקסט te</font>xt\n"
+ "text text text text text\n"
+ "\n" ),
+ 0,
+ 0,
+ 0,
+ 0,
+ 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 );
+ END_TEST;
+}
+
+int UtcDaliTextViewDebugCouts(void)
+{
+ /////////////////////////////////////////////////////
+ // Text debug functions to not to penalize coverage
+ /////////////////////////////////////////////////////
+
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewDebugCouts : ");
+
+ Toolkit::Internal::TextView::RelayoutData relayoutData;
+
+ MarkupProcessor::StyledTextArray inputStyledText;
+ MarkupProcessor::GetStyledTextArray( std::string( "Hello world\nhello world" ), inputStyledText, true );
+
+ TextViewProcessor::CreateTextInfo( inputStyledText,
+ DEFAULT_LAYOUT_PARAMETERS,
+ relayoutData );
+
+ Actor dummy = Actor::New();
+ Toolkit::Internal::SplitByNewLineChar::Relayout( dummy,
+ Toolkit::Internal::TextView::RELAYOUT_ALL,
+ DEFAULT_LAYOUT_PARAMETERS,
+ DEFAULT_VISUAL_PARAMETERS,
+ relayoutData );
+
+ TextViewProcessor::dbgPrint( relayoutData.mTextLayoutInfo );
+
+ TextStyle textStyle;
+ TextViewProcessor::dbgPrint( textStyle );
+
+ TextViewProcessor::TextInfoIndices indices;
+ TextViewProcessor::dbgPrint( indices );
+
+ TextViewProcessor::dbgPrint( inputStyledText );
+
+ tet_result( TET_PASS );
+ END_TEST;
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+
+// Internal headers are allowed here
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-types.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace Dali::Toolkit::Internal;
+
+void dali_text_view_processor_types_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_text_view_processor_types_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+
+namespace
+{
+// Data structures used to create an 'experiment' in TET cases
+
+//////////////////////////////////////////////////////////////////
+} // namespace
+
+
+int UtcDaliTextViewDefaultConstructorDestructor_PT(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
+
+ TextViewProcessor::TextInfoIndices indices;
+ DALI_TEST_EQUALS( indices.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 );
+ END_TEST;
+}
+
+int UtcDaliTextViewCopyConstructorOperator(void)
+{
+ 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 );
+ END_TEST;
+}
+
+int UtcDaliTextViewEqualityOperator(void)
+{
+ 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 );
+ END_TEST;
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+// Internal headers are allowed here
+#include <dali-toolkit/internal/controls/text-view/text-processor.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace Dali::Toolkit::Internal;
+
+void dali_text_view_processor_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_text_view_processor_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+
+namespace
+{
+// Data structures used to create an 'experiment' in TET cases
+
+//////////////////////////////////////////////////////////////////
+
+struct BeginsRightToLeftCharacterTest
+{
+ std::string description;
+ std::string input;
+ bool result;
+};
+
+bool TestBeginsRightToLeftCharacter( const std::string& description, const std::string& input, const bool result, const char* location )
+{
+ // Creates a 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
+
+
+int UtcDaliTextViewSplitInLines(void)
+{
+ 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 );
+ END_TEST;
+}
+
+int UtcDaliTextViewSplitInWords(void)
+{
+ 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 );
+ END_TEST;
+}
+
+int UtcDaliTextViewBeginsRightToLeftCharacter(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewBeginsRightToLeftCharacter : ");
+
+ struct BeginsRightToLeftCharacterTest beginsRightToLeftCharacterTest[] =
+ {
+ {
+ std::string( "Test if it begins with a right to left character. Should return false." ),
+ std::string( "Hello world مرحبا العالم." ),
+ false
+ },
+ {
+ std::string( "Test if it begins with a right to left character. Should return true." ),
+ std::string( "مرحبا العالم Hola mundo." ),
+ true
+ }
+ };
+ const std::size_t numberOfTests( 2 );
+
+ for( std::size_t index = 0; index < numberOfTests; ++index )
+ {
+ const BeginsRightToLeftCharacterTest& test = beginsRightToLeftCharacterTest[index];
+
+ if( !TestBeginsRightToLeftCharacter( test.description, test.input, test.result, TEST_LOCATION ) )
+ {
+ tet_result( TET_FAIL );
+ }
+ }
+
+ tet_result( TET_PASS );
+ END_TEST;
+}
+
+int UtcDaliTextViewContainsRightToLeftCharacter(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewContainsRightToLeftCharacter : ");
+
+ struct ContainsRightToLeftCharacterTest containsRightToLeftCharacterTest[] =
+ {
+ {
+ std::string( "Test if it contains a right to left character. Should return true." ),
+ std::string( "Hello world مرحبا العالم." ),
+ true
+ },
+ {
+ std::string( "Test if it contains a right to left character. Should return true." ),
+ std::string( "مرحبا العالم Hola mundo." ),
+ true
+ },
+ {
+ std::string( "Test if it contains a right to left character. Should return false." ),
+ std::string( "Hello world." ),
+ false
+ },
+ {
+ std::string( "Test if it contains a right to left character. Should return true." ),
+ std::string( "مرحبا العالم." ),
+ true
+ }
+ };
+ const std::size_t numberOfTests( 4 );
+
+ for( std::size_t index = 0; index < numberOfTests; ++index )
+ {
+ const ContainsRightToLeftCharacterTest& test = containsRightToLeftCharacterTest[index];
+
+ if( !TestContainsRightToLeftCharacter( test.description, test.input, test.result, TEST_LOCATION ) )
+ {
+ tet_result( TET_FAIL );
+ }
+ }
+
+ tet_result( TET_PASS );
+ END_TEST;
+}
+
+int UtcDaliTextViewFindNearestWord(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewFindNearestWord : ");
+
+ struct FindNearestWordTest findNearestWordTest[] =
+ {
+ {
+ std::string( "" ),
+ std::string( "Hello world, hola mundo" ),
+ 0u,
+ 0u,
+ 5u
+ },
+ {
+ std::string( "" ),
+ std::string( "Hello world, hola mundo" ),
+ 7u,
+ 6u,
+ 12u
+ },
+ {
+ std::string( "" ),
+ std::string( "Hello world, hola mundo" ),
+ 11u,
+ 6u,
+ 12u
+ },
+ {
+ std::string( "" ),
+ std::string( "Hello world, hola mundo" ),
+ 23u,
+ 18u,
+ 23u
+ },
+ {
+ std::string( "" ),
+ std::string( "Hello world, hola mundo" ),
+ 5u,
+ 0u,
+ 5u
+ },
+ {
+ std::string( "" ),
+ std::string( "Hello world, hola mundo مرحبا العالم" ),
+ 24u,
+ 25u,
+ 30u
+ }
+ };
+
+ const std::size_t numberOfTests( 6 );
+
+ for( std::size_t index = 0; index < numberOfTests; ++index )
+ {
+ const FindNearestWordTest& test = findNearestWordTest[index];
+
+ if( !TestFindNearestWord( test.description, test.input, test.offset, test.start, test.end, TEST_LOCATION ) )
+ {
+ tet_result( TET_FAIL );
+ }
+ }
+
+ tet_result( TET_PASS );
+ END_TEST;
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+// Internal headers are allowed here
+#include <dali-toolkit/internal/controls/text-view/relayout-utilities.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-processor.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using namespace Dali::Toolkit::Internal;
+
+void dali_text_view_relayout_utils_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_text_view_relayout_utils_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+const Toolkit::Internal::TextView::LayoutParameters DEFAULT_LAYOUT_PARAMETERS;
+
+// Data structures used to create an 'experiment' in TET cases
+
+
+bool TestEqual( float x, float y )
+{
+ return ( fabsf( x - y ) < Math::MACHINE_EPSILON_1000 );
+}
+
+//////////////////////////////////////////////////////////////////
+
+struct 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
+
+
+int UtcDaliTextViewDefaultConstructorDestructor_RU(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline("UtcDaliTextViewDefaultConstructorDestructor : ");
+
+ // Test RelayoutParameters defaults.
+ TextViewRelayout::RelayoutParameters relayoutParameters;
+
+ DALI_TEST_EQUALS( relayoutParameters.mPositionOffset, Vector3::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ DALI_TEST_EQUALS( relayoutParameters.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 );
+ END_TEST;
+}
+
+int UtcDaliTextViewCalculateSubLineLayout(void)
+{
+ 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&