Fix bug that the properties of layouts are set after the call of ItemView::ActivateLa... 36/110336/1
authorFeng Jin <feng16.jin@samsung.com>
Sun, 15 Jan 2017 23:07:40 +0000 (07:07 +0800)
committerFeng Jin <feng16.jin@samsung.com>
Sun, 15 Jan 2017 23:20:14 +0000 (07:20 +0800)
Change-Id: I91e424b86c0e13125e5cd3b2b9fb0138f798b77d
Signed-off-by: Feng Jin <feng16.jin@samsung.com>
automated-tests/src/dali-toolkit-internal/CMakeLists.txt [changed mode: 0644->0755]
automated-tests/src/dali-toolkit-internal/utc-Dali-ItemView-internal.cpp [new file with mode: 0755]
automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp
dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp
dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp
dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
dali-toolkit/internal/controls/scrollable/item-view/spiral-layout.cpp
dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp
dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h

old mode 100644 (file)
new mode 100755 (executable)
index fc24948..4e3e0ff
@@ -22,6 +22,7 @@ SET(TC_SOURCES
  utc-Dali-Text-Typesetter.cpp
  utc-Dali-Text-ViewModel.cpp
  utc-Dali-DebugRendering.cpp
+ utc-Dali-ItemView-internal.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-ItemView-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-ItemView-internal.cpp
new file mode 100755 (executable)
index 0000000..1ee8077
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+
+// Need to override adaptor classes for toolkit test harness, so include
+// test harness headers before dali headers.
+#include <dali-toolkit-test-suite-utils.h>
+
+#include <dali.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/scrollable/item-view/default-item-layout-property.h>
+
+#include <dali-toolkit/internal/controls/scrollable/item-view/grid-layout.h>
+#include <dali-toolkit/devel-api/controls/scrollable/item-view/item-view-devel.h>
+
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+const unsigned int TOTAL_ITEM_NUMBER = 200;
+const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
+
+
+// Implementation of ItemFactory for providing actors to ItemView
+class TestItemFactory : public ItemFactory
+{
+public:
+
+  /**
+   * Constructor
+   * @param application class, stored as reference
+   */
+  TestItemFactory()
+  {
+  }
+
+  /**
+   * Virtual destructor.
+   */
+  virtual ~TestItemFactory()
+  {
+  }
+
+public: // From ItemFactory
+
+  /**
+   * Query the number of items available from the factory.
+   * The maximum available item has an ID of GetNumberOfItems() - 1.
+   */
+  virtual unsigned int GetNumberOfItems()
+  {
+    return TOTAL_ITEM_NUMBER;
+  }
+
+  /**
+   * Create an Actor to represent a visible item.
+   * @param itemId
+   * @return the created actor.
+   */
+  virtual Actor NewItem(unsigned int itemId)
+  {
+    // Create a renderable actor for this item
+    Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+    Actor actor = CreateRenderableActor(image);
+
+    return actor;
+  }
+};
+
+}
+
+int UtcDaliItemLayoutCheckPropertiesSetBeforeActivateLayout(void)
+{
+  ToolkitTestApplication application;
+
+  TestItemFactory factory;
+  ItemView view = ItemView::New(factory);
+
+  Property::Map gridLayoutProperty;
+  gridLayoutProperty.Insert( DefaultItemLayoutProperty::TYPE, Dali::Property::Value((int)DefaultItemLayout::GRID) );
+
+  //Set the column of grid-layout.
+  gridLayoutProperty.Insert( DefaultItemLayoutProperty::GRID_COLUMN_NUMBER, Dali::Property::Value(6) );
+
+  Property::Array layoutArray;
+
+  layoutArray.PushBack(gridLayoutProperty);
+
+  view.SetProperty( DevelItemView::Property::LAYOUT, layoutArray);
+
+  Dali::Toolkit::Internal::GridLayout* gridLayout = dynamic_cast<Dali::Toolkit::Internal::GridLayout*>(view.GetLayout(0).Get());
+
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+  Vector3 stageSize(stage.GetSize());
+
+  //Check if the number of columns is equals to 6 which is set before.
+  DALI_TEST_EQUALS(gridLayout->GetNumberOfColumns(), 6, TEST_LOCATION );
+  view.ActivateLayout(0, stageSize, 0.0f);
+  END_TEST;
+
+}
index da05a53..77321db 100755 (executable)
@@ -601,18 +601,6 @@ int UtcDaliItemLayoutSetAndGetLayoutProperties(void)
 
 }
 
-int UtcDaliItemLayoutSetandGetLayoutChangedFlag(void)
-{
-  ToolkitTestApplication application;
-
-  TestItemLayoutPtr layout = TestItemLayout::New();
-  DALI_TEST_CHECK( layout );
-  layout->ResetLayoutChangedFlag();
-  DALI_TEST_CHECK(layout->HasLayoutChanged() == false);
-
-  END_TEST;
-}
-
 int UtcDaliItemRangeIntersection(void)
 {
   ToolkitTestApplication application;
index 3b53bac..4cb2043 100755 (executable)
@@ -447,10 +447,6 @@ Degree DepthLayout::GetScrollDirection() const
 void DepthLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor )
 {
 
-  if(HasLayoutChanged())
-  {
-    SetDepthLayoutProperties(GetLayoutProperties());
-  }
   Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor );
   if( itemView )
   {
@@ -559,7 +555,6 @@ void DepthLayout::SetDepthLayoutProperties(const Property::Map& properties)
       }
     }
   }
-  ResetLayoutChangedFlag();
 }
 
 Vector3 DepthLayout::GetItemPosition( int itemID, float currentLayoutPosition, const Vector3& layoutSize ) const
index e002245..d362f05 100755 (executable)
@@ -534,10 +534,6 @@ Degree GridLayout::GetScrollDirection() const
 
 void GridLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor )
 {
-  if(HasLayoutChanged())
-  {
-    SetGridLayoutProperties(GetLayoutProperties());
-  }
   // This just implements the default behaviour of constraint application.
   // Custom layouts can override this function to apply their custom constraints.
   Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor );
@@ -685,7 +681,6 @@ void GridLayout::SetGridLayoutProperties(const Property::Map& properties)
       }
     }
   }
-  ResetLayoutChangedFlag();
 }
 
 Vector3 GridLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const
index a5741ab..1724f83 100755 (executable)
@@ -1800,6 +1800,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts )
               {
                 Internal::DepthLayoutPtr depthLayout = Internal::DepthLayout::New();
                 (*depthLayout).SetLayoutProperties(*layout);
+                (*depthLayout).SetDepthLayoutProperties(*layout);
                 AddLayout(*depthLayout);
                 break;
               }
@@ -1807,6 +1808,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts )
               {
                 Internal::GridLayoutPtr gridLayout = Internal::GridLayout::New();
                 (*gridLayout).SetLayoutProperties(*layout);
+                (*gridLayout).SetGridLayoutProperties(*layout);
                 AddLayout(*gridLayout);
                 break;
               }
@@ -1815,6 +1817,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts )
                 Internal::GridLayoutPtr listLayout = Internal::GridLayout::New();
                 listLayout->SetNumberOfColumns( 1 );
                 (*listLayout).SetLayoutProperties(*layout);
+                (*listLayout).SetGridLayoutProperties(*layout);
                 AddLayout(*listLayout);
                 break;
               }
@@ -1822,6 +1825,7 @@ void ItemView::SetLayoutArray( const Property::Array& layouts )
               {
                 Internal::SpiralLayoutPtr spiralLayout = Internal::SpiralLayout::New();
                 (*spiralLayout).SetLayoutProperties(*layout);
+                (*spiralLayout).SetSpiralLayoutProperties(*layout);
                 AddLayout(*spiralLayout);
                 break;
               }
index 9e8db62..e320fe1 100755 (executable)
@@ -426,10 +426,6 @@ Degree SpiralLayout::GetScrollDirection() const
 void SpiralLayout::ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor )
 {
 
-  if(HasLayoutChanged())
-  {
-    SetSpiralLayoutProperties(GetLayoutProperties());
-  }
   // This just implements the default behaviour of constraint application.
   // Custom layouts can override this function to apply their custom constraints.
   Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast( itemViewActor );
@@ -548,7 +544,6 @@ void SpiralLayout::SetSpiralLayoutProperties(const Property::Map& properties)
       }
     }
   }
-  ResetLayoutChangedFlag();
 }
 
 Vector3 SpiralLayout::GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const
index a9f2769..017ac53 100755 (executable)
@@ -38,7 +38,6 @@ struct ItemLayout::Impl
   Vector3 mItemSize;                              ///< The size of an item in the layout
   ControlOrientation::Type mOrientation;          ///< the orientation of the layout.
   Property::Map mProperties;
-  bool mHasLayoutChanged;
 };
 
 ItemLayout::ItemLayout()
@@ -156,7 +155,6 @@ void ItemLayout::SetLayoutProperties(const Property::Map& properties)
       }
     }
   }
-  mImpl->mHasLayoutChanged = true;
   mImpl->mProperties = properties;
 }
 
@@ -165,16 +163,6 @@ Property::Map ItemLayout::GetLayoutProperties()
   return mImpl->mProperties;
 }
 
-bool ItemLayout::HasLayoutChanged()
-{
-  return mImpl->mHasLayoutChanged;
-}
-
-void ItemLayout::ResetLayoutChangedFlag()
-{
-  mImpl->mHasLayoutChanged = false;
-}
-
 } // namespace Toolkit
 
 } // namespace Dali
index 97af2df..4d91ef5 100755 (executable)
@@ -181,19 +181,6 @@ public:
   Property::Map GetLayoutProperties();
 
   /**
-   * @brief Check if the Property has been changed.
-   * @SINCE_1_2.20
-   * @return whether the layout has been changed or not.if changed, return true.
-   */
-  bool HasLayoutChanged();
-
-  /**
-   * @brief Set the layout changed flag to false.
-   * @SINCE_1_2.20
-   */
-  void ResetLayoutChangedFlag();
-
-  /**
    * @brief Retrieve the target size of an item in the layout.
    *
    * This will return the default size for the layout unless overridden by calling SetItemSize().