Merge "Add UTCs for public-api" into devel/master
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Tue, 21 Jul 2015 14:36:38 +0000 (07:36 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Tue, 21 Jul 2015 14:36:38 +0000 (07:36 -0700)
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/utc-Dali-GaussianBlurView.cpp
automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp
automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp
automated-tests/src/dali-toolkit/utc-Dali-Toolkit.cpp [new file with mode: 0644]

index c75e082..2b1858e 100644 (file)
@@ -46,6 +46,7 @@ SET(TC_SOURCES
    utc-Dali-ScrollViewEffect.cpp
    utc-Dali-StyleManager.cpp
    utc-Dali-SuperBlurView.cpp
+   utc-Dali-Toolkit.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
index 2028c6c..f3f6f77 100644 (file)
@@ -38,7 +38,28 @@ void utc_gaussian_blur_view_cleanup(void)
   test_return_value = TET_PASS;
 }
 
+class TestCallback : public ConnectionTracker
+{
+public:
+  TestCallback( Dali::Toolkit::GaussianBlurView& blurView )
+  : mBlurView( blurView )
+  {
+    mFinished = false;
+  }
 
+  void Connect()
+  {
+    mBlurView.FinishedSignal().Connect( this, &TestCallback::OnFinished );
+  }
+
+  void OnFinished( Dali::Toolkit::GaussianBlurView source )
+  {
+    mFinished = true;
+  }
+
+  bool mFinished;
+  Dali::Toolkit::GaussianBlurView& mBlurView;
+};
 
 // Negative test case for a method
 int UtcDaliGaussianBlurViewUninitialized(void)
@@ -199,3 +220,55 @@ int UtcDaliGaussianBlurViewSetGetRenderTarget(void)
   DALI_TEST_CHECK( view.GetBlurredRenderTarget() == renderTarget );
   END_TEST;
 }
+
+int UtcDaliGaussianBlurViewActivateOnce(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliGaussianBlurActivateOnce");
+
+  Toolkit::GaussianBlurView view = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, true);
+  DALI_TEST_CHECK( view );
+
+  RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+  DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
+
+  view.SetParentOrigin(ParentOrigin::CENTER);
+  view.SetSize(Stage::GetCurrent().GetSize());
+  view.Add(Actor::New());
+  Stage::GetCurrent().Add(view);
+  view.ActivateOnce();
+
+  RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
+  DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
+  application.Render();
+
+  END_TEST;
+}
+
+int UtcDaliGaussianBlurViewFinishedSignalN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliGaussianBlurViewSetGetRenderTarget");
+
+  Toolkit::GaussianBlurView view = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, true);
+  DALI_TEST_CHECK( view );
+
+  view.SetParentOrigin(ParentOrigin::CENTER);
+  view.SetSize(Stage::GetCurrent().GetSize());
+  view.Add(Actor::New());
+  Stage::GetCurrent().Add(view);
+  view.Activate();
+
+  TestCallback callback( view );
+  DALI_TEST_CHECK( callback.mFinished == false );
+
+  callback.Connect();
+
+  view.Deactivate();
+  application.SendNotification();
+
+  // FinishedSignal is only for ActivateOnce()
+  DALI_TEST_CHECK( callback.mFinished == false );
+
+  END_TEST;
+}
index 68938b9..c85bffd 100644 (file)
@@ -346,3 +346,24 @@ int UtcDaliItemLayoutGetNextFocusItemID(void)
   END_TEST;
 }
 
+int UtcDaliItemRangeIntersection(void)
+{
+  ToolkitTestApplication application;
+
+  unsigned int uBeginItemFirst = 100u, uEndItemFirst = 300u;
+  unsigned int uBeginItemSecond = 290u, uEndItemSecond = 400;
+  unsigned int uInterBeginCheck=290u , uInterEndCheck=301u;
+  bool bIsInThisRange = false, bOutOfThisRange = false;
+
+  Toolkit::ItemRange objItemRangeFirst(uBeginItemFirst, uEndItemFirst);
+  Toolkit::ItemRange objItemRangeSecond(uBeginItemSecond, uEndItemSecond);
+  ItemRange itmInterSect = objItemRangeFirst.Intersection(objItemRangeSecond);
+
+  bIsInThisRange = itmInterSect.Within(uInterBeginCheck);
+  DALI_TEST_EQUALS(bIsInThisRange, true, TEST_LOCATION );
+
+  bOutOfThisRange = itmInterSect.Within(uInterEndCheck);
+  DALI_TEST_EQUALS(bOutOfThisRange, false, TEST_LOCATION );
+
+  END_TEST;
+}
index f2f0461..d5baabb 100644 (file)
@@ -2186,6 +2186,97 @@ int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
   END_TEST;
 }
 
+int UtcDaliToolkitScrollViewConstraintsMove(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
+
+  // Set up a scrollView...
+  ScrollView scrollView = ScrollView::New();
+  Stage::GetCurrent().Add( scrollView );
+  Vector2 stageSize = Stage::GetCurrent().GetSize();
+  scrollView.SetSize(stageSize);
+  scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+
+  // Position rulers.
+  RulerPtr rulerX = new DefaultRuler();
+  RulerPtr rulerY = new DefaultRuler();
+  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
+  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
+  scrollView.SetRulerX(rulerX);
+  scrollView.SetRulerY(rulerY);
+
+  // Add an Actor to ScrollView,
+  Actor a = Actor::New();
+  scrollView.Add(a);
+  a.SetPosition( TEST_ACTOR_POSITION );
+  Wait(application);
 
+  const Vector2 target = Vector2(100.0f, 100.0f);
+  const Vector2 target2 = Vector2(200.0f, 200.0f);
 
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
+  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
+  constraint.SetRemoveAction(Constraint::Discard);
+  scrollView.ApplyConstraintToChildren(constraint);
 
+  scrollView.ScrollTo( target, 0.0f );
+  Wait(application);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
+  scrollView.ScrollTo( target2 );
+  Wait(application, RENDER_DELAY_SCROLL);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliToolkitScrollViewConstraintsWrap(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
+
+  // Set up a scrollView...
+  ScrollView scrollView = ScrollView::New();
+  Stage::GetCurrent().Add( scrollView );
+  Vector2 stageSize = Stage::GetCurrent().GetSize();
+  scrollView.SetSize(stageSize);
+  scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+
+  // Position rulers.
+  RulerPtr rulerX = new DefaultRuler();
+  RulerPtr rulerY = new DefaultRuler();
+  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
+  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
+  scrollView.SetRulerX(rulerX);
+  scrollView.SetRulerY(rulerY);
+
+  // Add an Actor to ScrollView,
+  Actor a = Actor::New();
+  scrollView.Add(a);
+  a.SetPosition( TEST_ACTOR_POSITION );
+  Wait(application);
+
+  const Vector2 target = Vector2(100.0f, 100.0f);
+  const Vector2 target2 = Vector2(200.0f, 200.0f);
+
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
+  constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+  constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
+  constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+  constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+  constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+  constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
+  constraint.SetRemoveAction(Constraint::Discard);
+  scrollView.ApplyConstraintToChildren(constraint);
+
+  scrollView.ScrollTo( target, 0.0f );
+  Wait(application);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
+  scrollView.ScrollTo( target2 );
+  Wait(application, RENDER_DELAY_SCROLL);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
+
+  END_TEST;
+}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Toolkit.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Toolkit.cpp
new file mode 100644 (file)
index 0000000..bf75f39
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ * 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>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+void dali_toolkit_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void dali_toolkit_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcToolkitIsVertical(void)
+{
+  ToolkitTestApplication application;
+
+  bool bRet = false;
+
+  tet_infoline(" UtcToolkitIsVertical");
+  bRet = IsVertical(ControlOrientation::Up);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  bRet = IsVertical(ControlOrientation::Down);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcToolkitIsHorizontal(void)
+{
+  ToolkitTestApplication application;
+
+  bool bRet = false;
+
+  tet_infoline(" UtcToolkitIsHorizontal");
+  bRet = IsHorizontal(ControlOrientation::Left);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  bRet = IsHorizontal(ControlOrientation::Right);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  END_TEST;
+}
+