ScrollView: Avoid unintentional contraints on X/Y properties
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Control.cpp
index 5c3daac..e816ff6 100644 (file)
@@ -1,19 +1,18 @@
-/*
- * Copyright (c) 2014 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.
- *
- */
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.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://floralicense.org/license/
+//
+// 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>
@@ -201,7 +200,7 @@ int UtcDaliControlGetImplementation(void)
   {
     try
     {
-      ControlImpl& controlImpl = control.GetImplementation();
+      Toolkit::Internal::Control& controlImpl = control.GetImplementation();
       (void)controlImpl; // Avoid unused warning
       tet_result(TET_FAIL);
     }
@@ -216,7 +215,7 @@ int UtcDaliControlGetImplementation(void)
     try
     {
       const DummyControl constControl(control);
-      const ControlImpl& controlImpl = constControl.GetImplementation();
+      const Toolkit::Internal::Control& controlImpl = constControl.GetImplementation();
       (void)controlImpl; // Avoid unused warning
       tet_result(TET_FAIL);
     }
@@ -232,7 +231,7 @@ int UtcDaliControlGetImplementation(void)
   {
     try
     {
-      ControlImpl& controlImpl = control.GetImplementation();
+      Toolkit::Internal::Control& controlImpl = control.GetImplementation();
       (void)controlImpl; // Avoid unused warning
       tet_result(TET_PASS);
     }
@@ -247,7 +246,7 @@ int UtcDaliControlGetImplementation(void)
     try
     {
       const DummyControl constControl(control);
-      const ControlImpl& controlImpl = constControl.GetImplementation();
+      const Toolkit::Internal::Control& controlImpl = constControl.GetImplementation();
       (void)controlImpl; // Avoid unused warning
       tet_result(TET_PASS);
     }
@@ -435,3 +434,74 @@ int UtcDaliControlBackgroundProperties(void)
 
   END_TEST;
 }
+
+int UtcDaliControlSizePolicyProperties(void)
+{
+  ToolkitTestApplication application;
+
+  Control control = Control::New();
+
+  Control::SizePolicy widthPolicy( Control::Fixed );
+  Control::SizePolicy heightPolicy( Control::Fixed );
+
+  control.GetSizePolicy( widthPolicy, heightPolicy );
+  DALI_TEST_EQUALS( "FIXED", control.GetProperty( Control::PROPERTY_WIDTH_POLICY ).Get< std::string >(), TEST_LOCATION );
+  DALI_TEST_EQUALS( "FIXED", control.GetProperty( Control::PROPERTY_HEIGHT_POLICY ).Get< std::string >(), TEST_LOCATION );
+
+  control.SetSizePolicy( Control::Flexible, Control::Range );
+  DALI_TEST_EQUALS( "FLEXIBLE", control.GetProperty( Control::PROPERTY_WIDTH_POLICY ).Get< std::string >(), TEST_LOCATION );
+  DALI_TEST_EQUALS( "RANGE", control.GetProperty( Control::PROPERTY_HEIGHT_POLICY ).Get< std::string >(), TEST_LOCATION );
+
+  control.SetProperty( Control::PROPERTY_WIDTH_POLICY, "MAXIMUM" );
+  control.SetProperty( Control::PROPERTY_HEIGHT_POLICY, "MINIMUM" );
+  control.GetSizePolicy( widthPolicy, heightPolicy );
+  DALI_TEST_EQUALS( Control::Maximum, widthPolicy, TEST_LOCATION );
+  DALI_TEST_EQUALS( Control::Minimum, heightPolicy, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliControlSizeProperties(void)
+{
+  ToolkitTestApplication application;
+
+  Control control = Control::New();
+
+  DALI_TEST_EQUALS( control.GetMinimumSize(), control.GetProperty( Control::PROPERTY_MINIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
+  DALI_TEST_EQUALS( control.GetMaximumSize(), control.GetProperty( Control::PROPERTY_MAXIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
+
+  control.SetMinimumSize( Vector3( 100.0f, 200.0f, 300.0f ) );
+  DALI_TEST_EQUALS( Vector3( 100.0f, 200.0f, 300.0f ), control.GetProperty( Control::PROPERTY_MINIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
+
+
+  control.SetMaximumSize( Vector3( 200.0f, 250.0f, 800.0f ) );
+  DALI_TEST_EQUALS( Vector3( 200.0f, 250.0f, 800.0f ), control.GetProperty( Control::PROPERTY_MAXIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
+
+  control.SetProperty( Control::PROPERTY_MINIMUM_SIZE, Vector3( 1.0f, 2.0f, 3.0f ) );
+  control.SetProperty( Control::PROPERTY_MAXIMUM_SIZE, Vector3( 10.0f, 20.0f, 30.0f ) );
+  DALI_TEST_EQUALS( control.GetMinimumSize(), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
+  DALI_TEST_EQUALS( control.GetMaximumSize(), Vector3( 10.0f, 20.0f, 30.0f ), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliControlKeyProperties(void)
+{
+  ToolkitTestApplication application;
+
+  Control control = Control::New();
+  Stage::GetCurrent().Add( control );
+
+  DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::PROPERTY_KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
+
+  control.SetKeyInputFocus();
+  DALI_TEST_EQUALS( true, control.GetProperty( Control::PROPERTY_KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
+
+  control.ClearKeyInputFocus();
+  DALI_TEST_EQUALS( false, control.GetProperty( Control::PROPERTY_KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
+
+  control.SetProperty( Control::PROPERTY_KEY_INPUT_FOCUS, true );
+  DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
+
+  END_TEST;
+}