Merge "DALi Version 1.0.44" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 11 Jun 2015 10:19:42 +0000 (03:19 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 11 Jun 2015 10:19:42 +0000 (03:19 -0700)
automated-tests/src/dali-toolkit/utc-Dali-BloomView.cpp
automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp
dali-toolkit/internal/controls/table-view/table-view-impl.cpp
dali-toolkit/internal/text/multi-language-support-impl.cpp

index c35269a..fa3f10c 100644 (file)
@@ -164,3 +164,63 @@ int UtcDaliBloomActivateDeactivate(void)
   DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
   END_TEST;
 }
+
+int UtcDaliBloomCopyAndAssignment(void)
+{
+  ToolkitTestApplication application;
+
+  BloomView view = Toolkit::BloomView::New();
+  DALI_TEST_CHECK( view );
+
+  BloomView copy( view );
+  DALI_TEST_CHECK( view == copy );
+
+  BloomView assign;
+  DALI_TEST_CHECK( ! assign );
+
+  assign = copy;
+  DALI_TEST_CHECK( assign == view );
+
+  END_TEST;
+}
+
+int UtcDaliBloomTypeRegistry(void)
+{
+  ToolkitTestApplication application;
+
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+  DALI_TEST_CHECK( typeRegistry );
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "BloomView" );
+  DALI_TEST_CHECK( typeInfo );
+
+  BaseHandle handle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle );
+
+  BloomView view = BloomView::DownCast( handle );
+  DALI_TEST_CHECK( view );
+
+  END_TEST;
+}
+
+int UtcDaliBloomOnSizeSet(void)
+{
+  ToolkitTestApplication application;
+
+  BloomView view = Toolkit::BloomView::New();
+
+  Stage::GetCurrent().Add( view );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector3 size( 200.0f, 300.0f, 200.0f );
+  view.SetSize( size );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( view.GetCurrentSize(), size, TEST_LOCATION );
+
+  END_TEST;
+}
index 8e6bffa..9985106 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <iostream>
 #include <stdlib.h>
+#include <sstream>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 
@@ -719,3 +720,178 @@ int UtcDaliTableViewCustomProperties(void)
 
   END_TEST;
 }
+
+int UtcDaliTableViewGetChildAtN(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(10,10);
+
+  Actor actor = tableView.GetChildAt( TableView::CellPosition( 200, 200 ) );
+  DALI_TEST_CHECK( !actor );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewAddChildN(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(10,10);
+  DALI_TEST_CHECK( tableView.AddChild( Actor::New(), TableView::CellPosition( 0, 0 ) ) );
+  DALI_TEST_CHECK( ! tableView.AddChild( Actor::New(), TableView::CellPosition( 0, 0 ) ) );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewInsertRowAtZero(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(10,10);
+  DALI_TEST_CHECK( tableView.AddChild( Actor::New(), TableView::CellPosition( 0, 0 , 10, 10 ) ) );
+  tableView.InsertRow(0);
+
+  DALI_TEST_CHECK( tableView.GetRows() == 11 );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewDeleteRowAtZero(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(10,10);
+  DALI_TEST_CHECK( tableView.AddChild( Actor::New(), TableView::CellPosition( 0, 0 , 10, 10 ) ) );
+  tableView.DeleteRow(0);
+
+  DALI_TEST_CHECK( tableView.GetRows() == 9 );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewInsertColumnAtZero(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(10,10);
+  DALI_TEST_CHECK( tableView.AddChild( Actor::New(), TableView::CellPosition( 0, 0 , 10, 10 ) ) );
+  tableView.InsertColumn(0);
+
+  DALI_TEST_CHECK( tableView.GetColumns() == 11 );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewDeleteColumnAtZero(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(10,10);
+  DALI_TEST_CHECK( tableView.AddChild( Actor::New(), TableView::CellPosition( 0, 0 , 10, 10 ) ) );
+  tableView.DeleteColumn(0);
+
+  DALI_TEST_CHECK( tableView.GetColumns() == 9 );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewTypeRegistry(void)
+{
+  ToolkitTestApplication application;
+
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+  DALI_TEST_CHECK( typeRegistry );
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "TableView" );
+  DALI_TEST_CHECK( typeInfo );
+
+  BaseHandle handle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle );
+
+  TableView view = TableView::DownCast( handle );
+  DALI_TEST_CHECK( view );
+
+  END_TEST;
+}
+
+int UtcDaliTableViewKeyboardFocus(void)
+{
+  ToolkitTestApplication application;
+
+  TableView tableView = TableView::New(4,4);
+  tableView.SetKeyboardFocusable( true );
+  tableView.SetName( "TableView");
+
+  for ( int row = 0; row < 4; ++row )
+  {
+    for ( int col = 0; col < 4; ++col )
+    {
+      Control control = Control::New();
+      std::ostringstream str;
+      str << row << "-" << col;
+      control.SetName( str.str() );
+      control.SetKeyboardFocusable( true );
+      tableView.AddChild( control, TableView::CellPosition( row, col ) );
+    }
+  }
+
+  Stage::GetCurrent().Add( tableView );
+
+  application.SendNotification();
+  application.Render();
+
+  Actor firstFocusActor = Toolkit::Internal::GetImplementation( tableView ).GetNextKeyboardFocusableActor( Actor(), Control::KeyboardFocus::RIGHT, true );
+  DALI_TEST_CHECK( firstFocusActor );
+  DALI_TEST_CHECK( firstFocusActor.GetName() == "0-0" );
+
+  KeyboardFocusManager manager = KeyboardFocusManager::Get();
+  manager.SetFocusGroupLoop( true );
+  manager.SetCurrentFocusActor( firstFocusActor );
+
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-0" );
+  manager.MoveFocus( Control::KeyboardFocus::RIGHT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-1" );
+  manager.MoveFocus( Control::KeyboardFocus::RIGHT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-2" );
+  manager.MoveFocus( Control::KeyboardFocus::RIGHT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-3" );
+  manager.MoveFocus( Control::KeyboardFocus::RIGHT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "1-0" );
+
+  manager.MoveFocus( Control::KeyboardFocus::LEFT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-3" );
+  manager.MoveFocus( Control::KeyboardFocus::LEFT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-2" );
+  manager.MoveFocus( Control::KeyboardFocus::LEFT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-1" );
+  manager.MoveFocus( Control::KeyboardFocus::LEFT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-0" );
+  manager.MoveFocus( Control::KeyboardFocus::LEFT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "3-3" );
+
+  manager.MoveFocus( Control::KeyboardFocus::RIGHT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-0" );
+  manager.MoveFocus( Control::KeyboardFocus::RIGHT );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-1" );
+
+  manager.MoveFocus( Control::KeyboardFocus::DOWN );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "1-1" );
+  manager.MoveFocus( Control::KeyboardFocus::DOWN );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "2-1" );
+  manager.MoveFocus( Control::KeyboardFocus::DOWN );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "3-1" );
+  manager.MoveFocus( Control::KeyboardFocus::DOWN );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-1" );
+
+  manager.MoveFocus( Control::KeyboardFocus::UP );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "3-1" );
+  manager.MoveFocus( Control::KeyboardFocus::UP );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "2-1" );
+  manager.MoveFocus( Control::KeyboardFocus::UP );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "1-1" );
+  manager.MoveFocus( Control::KeyboardFocus::UP );
+  DALI_TEST_CHECK( manager.GetCurrentFocusActor().GetName() == "0-1" );
+
+  END_TEST;
+}
index bd96f77..3e9eaf1 100644 (file)
@@ -49,7 +49,9 @@ bool FitToChild( Actor actor, Dimension::Type dimension )
 
 #define TABLEVIEW_TAG "DALI Toolkit::TableView "
 #define TV_LOG(fmt, args...) Debug::LogMessage(Debug::DebugInfo, TABLEVIEW_TAG fmt, ## args)
+//#define TABLEVIEW_DEBUG 1
 
+#if defined(TABLEVIEW_DEBUG)
 void PrintArray( Array2d<Dali::Toolkit::Internal::TableView::CellData>& array )
 {
   TV_LOG( "Array2d<CellData> size [%d,%d] \n", array.GetRows(), array.GetColumns() );
@@ -101,6 +103,7 @@ void PrintVector( std::vector<float>& array )
   }
   TV_LOG( "\n" );
 }
+#endif // defined(TABLEVIEW_DEBUG)
 #endif // defined(DEBUG_ENABLED)
 
 } // namespace
index 47db1e2..2d2352e 100644 (file)
@@ -126,24 +126,6 @@ Script GetScript( Length index,
   return script;
 }
 
-/**
- * @brief Whether the character is valid for all scripts. i.e. the white space.
- *
- * @param[in] character The character.
- *
- * @return @e true if the character is valid for all scripts.
- */
-bool IsValidForAllScripts( Character character )
-{
-  return ( TextAbstraction::IsWhiteSpace( character )         ||
-           TextAbstraction::IsZeroWidthNonJoiner( character ) ||
-           TextAbstraction::IsZeroWidthJoiner( character )    ||
-           TextAbstraction::IsZeroWidthSpace( character )     ||
-           TextAbstraction::IsLeftToRightMark( character )    ||
-           TextAbstraction::IsRightToLeftMark( character )    ||
-           TextAbstraction::IsThinSpace( character ) );
-}
-
 bool ValidateFontsPerScript::FindValidFont( FontId fontId ) const
 {
   for( Vector<FontId>::ConstIterator it = mValidFonts.Begin(),
@@ -262,7 +244,7 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
     // Skip those characters valid for many scripts like white spaces or '\n'.
     bool endOfText = index == numberOfCharacters;
     while( !endOfText &&
-           IsValidForAllScripts( character ) )
+           TextAbstraction::IsCommonScript( character ) )
     {
       // Count all these characters to be added into a script.
       ++numberOfAllScriptCharacters;
@@ -374,10 +356,12 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
                                           const Vector<ScriptRun>& scripts,
                                           Vector<FontRun>& fonts )
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "-->MultilanguageSupport::ValidateFonts\n" );
   const Length numberOfCharacters = text.Count();
 
   if( 0u == numberOfCharacters )
   {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--MultilanguageSupport::ValidateFonts\n" );
     // Nothing to do if there are no characters.
     return;
   }
@@ -427,6 +411,20 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
                                scriptRunIt,
                                scriptRunEndIt );
 
+#ifdef DEBUG_ENABLED
+    {
+      Dali::TextAbstraction::FontDescription description;
+      fontClient.GetDescription( fontId, description );
+
+      DALI_LOG_INFO( gLogFilter,
+                     Debug::Verbose,
+                     "  Initial font set\n  Character : %x, Script : %s, Font : %s \n",
+                     character,
+                     Dali::TextAbstraction::ScriptName[script],
+                     description.path.c_str() );
+    }
+#endif
+
     if( TextAbstraction::UNKNOWN == script )
     {
       DALI_LOG_WARNING( "MultilanguageSupport::ValidateFonts. Unknown script!" );
@@ -436,6 +434,11 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
     // Whether the font being validated is a default one not set by the user.
     const bool isDefault = ( 0u == fontId );
 
+    DALI_LOG_INFO( gLogFilter,
+                   Debug::Verbose,
+                   "  Is a default font : %s\n",
+                   ( isDefault ? "true" : "false" ) );
+
     // The default font point size.
     PointSize26Dot6 pointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
 
@@ -488,6 +491,26 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
             else
             {
               // Add the font to the valid font cache.
+
+              //   At this point the validated font supports the given character. However, characters
+              // common for all scripts, like white spaces or new paragraph characters, need to be
+              // processed differently.
+              //
+              //   i.e. A white space can have assigned a DEVANAGARI script but the font assigned may not
+              // support none of the DEVANAGARI glyphs. This font can't be added to the cache as a valid
+              // font for the DEVANAGARI script but the COMMON one.
+              if( TextAbstraction::IsCommonScript( character ) )
+              {
+                validateFontsPerScript = *( validFontsPerScriptCacheBuffer + TextAbstraction::COMMON );
+
+                if( NULL == validateFontsPerScript )
+                {
+                  validateFontsPerScript = new ValidateFontsPerScript();
+
+                  *( validFontsPerScriptCacheBuffer + TextAbstraction::COMMON ) = validateFontsPerScript;
+                }
+              }
+
               validateFontsPerScript->mValidFonts.PushBack( fontId );
             }
           }
@@ -520,16 +543,24 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           fontId = fontClient.FindDefaultFont( UTF32_A, pointSize );
         }
 
-#ifdef DEBUG_ENABLED
-        Dali::TextAbstraction::FontDescription description;
-        fontClient.GetDescription( fontId, description );
-        DALI_LOG_INFO( gLogFilter, Debug::Concise, "Script: %s; Selected font: %s\n", Dali::TextAbstraction::ScriptName[script], description.path.c_str() );
-#endif
         // Cache the font.
         *( defaultFontPerScriptCacheBuffer + script ) = fontId;
       }
     }
 
+#ifdef DEBUG_ENABLED
+    {
+      Dali::TextAbstraction::FontDescription description;
+      fontClient.GetDescription( fontId, description );
+      DALI_LOG_INFO( gLogFilter,
+                     Debug::Verbose,
+                     "  Validated font set\n  Character : %x, Script : %s, Font : %s \n",
+                     character,
+                     Dali::TextAbstraction::ScriptName[script],
+                     description.path.c_str() );
+    }
+#endif
+
     // The font is now validated.
 
     if( ( fontId != currentFontRun.fontId ) ||
@@ -559,6 +590,7 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
     // Store the last run.
     fonts.PushBack( currentFontRun );
   }
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--MultilanguageSupport::ValidateFonts\n" );
 }
 
 void MultilanguageSupport::ValidateFonts( LogicalModel& model,