From cd68e141305c0a57d14dbcfcb5cb2073add6add7 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Wed, 10 Jun 2015 16:10:56 +0100 Subject: [PATCH] Increased Line/Function Coverage for BloomView & TableView Change-Id: I440954500f6e338728e85ac01aa95d1b65a630cc --- .../src/dali-toolkit/utc-Dali-BloomView.cpp | 60 +++++++ .../src/dali-toolkit/utc-Dali-TableView.cpp | 176 +++++++++++++++++++++ .../controls/table-view/table-view-impl.cpp | 3 + 3 files changed, 239 insertions(+) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-BloomView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-BloomView.cpp index c35269a..fa3f10c 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-BloomView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-BloomView.cpp @@ -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; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp index 8e6bffa..9985106 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -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; +} diff --git a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp index bd96f77..3e9eaf1 100644 --- a/dali-toolkit/internal/controls/table-view/table-view-impl.cpp +++ b/dali-toolkit/internal/controls/table-view/table-view-impl.cpp @@ -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& array ) { TV_LOG( "Array2d size [%d,%d] \n", array.GetRows(), array.GetColumns() ); @@ -101,6 +103,7 @@ void PrintVector( std::vector& array ) } TV_LOG( "\n" ); } +#endif // defined(TABLEVIEW_DEBUG) #endif // defined(DEBUG_ENABLED) } // namespace -- 2.7.4