Update UTC for ItemView, ScrollView and FocusManager 27/39927/1
authorRichard Huang <r.huang@samsung.com>
Tue, 26 May 2015 13:20:34 +0000 (14:20 +0100)
committerRichard Huang <r.huang@samsung.com>
Tue, 26 May 2015 13:20:34 +0000 (14:20 +0100)
Change-Id: I90ccadcba919af94d41d56d0a830db8568aa34f7

automated-tests/src/dali-toolkit/utc-Dali-FocusManager.cpp
automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp
automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp

index ae74364..b26edb0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -114,6 +114,20 @@ public:
   Toolkit::FocusManager::FocusOvershotDirection mFocusOvershotDirection;
 };
 
+// Functor to test whether focused actor activated signal is emitted.
+class FocusedActorActivatedCallback : public Dali::ConnectionTracker
+{
+public:
+  FocusedActorActivatedCallback()
+  {
+  }
+
+  void Callback(Actor activatedActor)
+  {
+    tet_infoline("Verifying FocusedActorActivatedCallback()");
+  }
+};
+
 } // namespace
 
 
@@ -1051,3 +1065,19 @@ int UtcDaliFocusManagerSignalFocusOvershot(void)
   DALI_TEST_CHECK(signalVerified);
   END_TEST;
 }
+
+int UtcDaliFocusManagerSignalFocusedActorActivated(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline(" UtcDaliFocusManagerSignalFocusedActorActivated");
+
+  FocusManager manager = FocusManager::Get();
+  DALI_TEST_CHECK(manager);
+
+  FocusedActorActivatedCallback callback;
+  manager.FocusedActorActivatedSignal().Connect(&callback, &FocusedActorActivatedCallback::Callback);
+  DALI_TEST_CHECK(true);
+
+  END_TEST;
+}
index d9e52fd..8dd9e24 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
@@ -47,6 +47,13 @@ public:
   {
   }
 
+  /**
+   * Virtual destructor.
+   */
+  virtual ~TestItemFactory()
+  {
+  }
+
 public: // From ItemFactory
 
   /**
@@ -72,6 +79,186 @@ public: // From ItemFactory
     return actor;
   }
 };
+
+class TestItemLayout;
+
+typedef IntrusivePtr<TestItemLayout> TestItemLayoutPtr;
+
+// Implementation of ItemLayout
+class TestItemLayout : public ItemLayout
+{
+public:
+
+  /**
+   * Constructor
+   */
+  TestItemLayout()
+  {
+  }
+
+  /**
+   * Virtual destructor.
+   */
+  virtual ~TestItemLayout()
+  {
+  }
+
+  /**
+   * Create a new grid layout.
+   */
+  static TestItemLayoutPtr New()
+  {
+    return TestItemLayoutPtr(new TestItemLayout());
+  }
+
+public: // From ItemLayout
+
+  /**
+   * Query the minimum valid layout position; this is a negative value.
+   *
+   * When scrolling, the first item will move within the range 0 to GetMinimumLayoutPosition().
+   * @param[in] numberOfItems The current number of items in the layout.
+   * @param[in] layoutSize The size of the layout area.
+   * @return The minimum layout position.
+   */
+  virtual float GetMinimumLayoutPosition(unsigned int numberOfItems, Vector3 layoutSize) const
+  {
+    return 0.0f;
+  }
+
+  /**
+   * Query the closest anchor position for the given layout position.
+   *
+   * This anchor position is the position where all the items in the layout are aligned to
+   * their rounded layout positions in integer.
+   * @param[in] layoutPosition The layout position.
+   * @return The closest anchor position for the given layout position.
+   */
+  virtual float GetClosestAnchorPosition(float layoutPosition) const
+  {
+    return 0.0f;
+  }
+
+  /**
+   * Query the layout position for the first item in the layout to move to when the layout
+   * needs to scroll to a particular item.
+   *
+   * @param[in] itemId The ID of an item in the layout.
+   * @return The layout position for the first item in the layout to move to.
+   */
+  virtual float GetItemScrollToPosition(unsigned int itemId) const
+  {
+    return 0.0f;
+  }
+
+  /**
+   * Query the items within a given layout-area.
+   *
+   * @param[in] firstItemPosition The layout-position of the first item in the layout.
+   * @param[in] layoutSize The size of the layout area.
+   * @return The ID of the first & last visible item.
+   */
+  virtual ItemRange GetItemsWithinArea(float firstItemPosition, Vector3 layoutSize) const
+  {
+    return ItemRange(0, 10);
+  }
+
+  /**
+   * Query the number of items that should be reserved, for scrolling purposes.
+   *
+   * @param[in] layoutSize The size of the layout area.
+   * @return The number of extra items.
+   */
+  virtual unsigned int GetReserveItemCount(Vector3 layoutSize) const
+  {
+    return 0;
+  }
+
+  /**
+   * Retrieve the default size of an item in the layout.
+   *
+   * @param[in] itemId The ID of an item in the layout.
+   * @param[in] layoutSize The layout size
+   * @param[out] itemSize The target size of an item.
+   */
+  virtual void GetDefaultItemSize( unsigned int itemId, const Vector3& layoutSize, Vector3& itemSize ) const
+  {
+  }
+
+  /**
+   * Retrieve the resize animation in the layout.
+   *
+   * @param[in] animation The resize animation, not owned by the layout
+   * @param[in] actor The actor to animate
+   * @param [in] size The target size.
+   * @param [in] durationSeconds The duration of the resizing.
+   */
+  virtual void GetResizeAnimation(Animation& animation, Actor actor, Vector3 size, float durationSeconds) const
+  {
+  }
+
+  /**
+   * @brief Query the scroll direction of the layout.
+   * @return The scroll direction in degrees.
+   */
+  virtual Degree GetScrollDirection() const
+  {
+    return Degree( 0.0f );
+  }
+
+  /**
+   * @brief Query the scroll speed factor of the layout while dragging.
+   * @return The scroll speed factor of the layout.
+   */
+  virtual float GetScrollSpeedFactor() const
+  {
+    return 0;
+  }
+
+  /**
+   * @brief Query the maximum swipe speed in pixels per second.
+   * @return speed The maximum swipe speed.
+   */
+  virtual float GetMaximumSwipeSpeed() const
+  {
+    return 0;
+  }
+
+  /**
+   * @brief Get the duration of the flick animation in second.
+   * @return The duration of the flick animation.
+   */
+  virtual float GetItemFlickAnimationDuration() const
+  {
+    return 0;
+  }
+
+  /*
+   * @brief Applies constraints defined by the layout to an actor.
+   *
+   * @param[in] actor The actor to constrain.
+   * @param[in] itemId The ID of the item represented by the actor.
+   * @param[in] layoutSize the current size of the item view instance.
+   * @param[in] itemViewActor The item view instance which requests the application of constraints.
+   */
+  virtual void ApplyConstraints( Actor& actor, const int itemId, const Vector3& layoutSize, const Actor& itemViewActor )
+  {
+  }
+
+  /**
+   * @brief Gets the position of a given item
+   *
+   * @param[in] itemID id of the item we want to get its position
+   * @param[in] currentLayoutPosition the current layout position of the item view instance
+   * @param[in] layoutSize the current size of the item view instance
+   * @return The item position (x,y,z)
+   */
+  virtual Vector3 GetItemPosition(int itemID, float currentLayoutPosition, const Vector3& layoutSize) const
+  {
+    return Vector3::ZERO;
+  }
+};
+
 } // namespace
 
 int UtcDaliItemLayoutSetAndGetOrientation(void)
@@ -135,3 +322,39 @@ int UtcDaliItemLayoutSetAndGetOrientation(void)
   DALI_TEST_CHECK(spiralLayout == layout);
   END_TEST;
 }
+
+int UtcDaliItemLayoutGetExtension(void)
+{
+  ToolkitTestApplication application;
+
+  ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID );
+  DALI_TEST_CHECK( gridLayout );
+  DALI_TEST_CHECK( !gridLayout->GetExtension() );
+
+  END_TEST;
+}
+
+int UtcDaliItemLayoutGetClosestOnScreenLayoutPosition(void)
+{
+  ToolkitTestApplication application;
+
+  TestItemLayoutPtr layout = TestItemLayout::New();
+  DALI_TEST_CHECK( layout );
+  DALI_TEST_EQUALS(layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3::ZERO), 0.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS(layout->GetClosestOnScreenLayoutPosition(0, 0.0f, Vector3(-800.0f, -1200.0f, 0.0f)), 0.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliItemLayoutGetNextFocusItemID(void)
+{
+  ToolkitTestApplication application;
+
+  TestItemLayoutPtr layout = TestItemLayout::New();
+  DALI_TEST_CHECK( layout );
+  DALI_TEST_EQUALS(layout->GetNextFocusItemID(0, 100, Control::Left, true), 99, TEST_LOCATION );
+  DALI_TEST_EQUALS(layout->GetNextFocusItemID(110, 100, Control::Right, true), 0, TEST_LOCATION );
+
+  END_TEST;
+}
+
index fd01efe..6d38d5e 100644 (file)
@@ -685,6 +685,9 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void)
   ScrollView scrollView = ScrollView::New();
   Stage::GetCurrent().Add( scrollView );
 
+  Actor actor = Actor::New();
+  scrollView.Add( actor );
+
   // Position rulers. 4x4 grid.
   RulerPtr rulerX = new FixedRuler(50.0f);
   RulerPtr rulerY = new FixedRuler(50.0f);
@@ -697,7 +700,10 @@ int UtcDaliToolkitScrollViewSetWrapModeP(void)
   scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
   Wait(application);
   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION );
+
   scrollView.SetWrapMode(true);
+  scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
+  Wait(application);
   DALI_TEST_EQUALS( static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION );
   END_TEST;
 }
@@ -2006,6 +2012,18 @@ int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
   position = rulerNormal->GetPositionFromPage(2, volume, true);
   DALI_TEST_EQUALS( position, 60.0f, TEST_LOCATION );
   DALI_TEST_EQUALS( volume, 0u, TEST_LOCATION );
+
+  // Disable the ruler
+  rulerNormal->Disable();
+
+  position = rulerNormal->GetPositionFromPage(1, volume, true);
+  DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( volume, 1u, TEST_LOCATION );
+
+  position = rulerNormal->GetPositionFromPage(2, volume, true);
+  DALI_TEST_EQUALS( position, 10.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( volume, 2u, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -2103,6 +2121,21 @@ int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
   DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
 
+  // Set domain size to be smaller than the ruler space
+  fixedRuler->SetDomain( RulerDomain(0.0f, 50.0f, true) );
+
+  fixedRuler->Enable();
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
+
+  fixedRuler->Disable();
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS( fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
+
   END_TEST;
 }