(Automated Tests) Added widget test cases to increase line/function coverage 78/284878/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 29 Nov 2022 16:45:17 +0000 (16:45 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 29 Nov 2022 16:45:30 +0000 (16:45 +0000)
Change-Id: Iafe78701c47e61a39bd727e8b14410d4954e3ab3

automated-tests/src/dali-adaptor/CMakeLists.txt
automated-tests/src/dali-adaptor/utc-Dali-Application.cpp
automated-tests/src/dali-adaptor/utc-Dali-Widget.cpp [new file with mode: 0644]
automated-tests/src/dali-adaptor/utc-Dali-WidgetApplication.cpp [new file with mode: 0644]

index e41f1c8..d4fa455 100644 (file)
@@ -10,6 +10,7 @@ SET(TC_SOURCES
     utc-Dali-Capture.cpp
     utc-Dali-FileLoader.cpp
     utc-Dali-GifLoading.cpp
+    utc-Dali-Gl-Window.cpp
     utc-Dali-ImageLoading.cpp
     utc-Dali-Key.cpp
     utc-Dali-NativeImageSource.cpp
@@ -17,8 +18,9 @@ SET(TC_SOURCES
     utc-Dali-TextScript.cpp
     utc-Dali-Timer.cpp
     utc-Dali-TtsPlayer.cpp
+    utc-Dali-WidgetApplication.cpp
+    utc-Dali-Widget.cpp
     utc-Dali-Window.cpp
-    utc-Dali-Gl-Window.cpp
 )
 
 LIST(APPEND TC_SOURCES
index 48d11de..d2ec99d 100644 (file)
@@ -634,3 +634,139 @@ int UtcDaliApplicationDownCastN(void)
   DALI_TEST_CHECK(!application);
   END_TEST;
 }
+
+int UtcDaliApplicationTaskInitSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskInitSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskTerminateSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskTerminateSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskAppControlSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskAppControlSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskLanguageChangedSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskLanguageChangedSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskRegionChangedSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskRegionChangedSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskLowBatterySignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskLowBatterySignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskLowMemorySignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskLowMemorySignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
+
+int UtcDaliApplicationTaskDeviceOrientationChangedSignalN(void)
+{
+  Application application;
+
+  try
+  {
+    application.TaskDeviceOrientationChangedSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true);
+  }
+
+  END_TEST;
+}
\ No newline at end of file
diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Widget.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Widget.cpp
new file mode 100644 (file)
index 0000000..94430b7
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2022 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 <dali-test-suite-utils.h>
+#include <dali/dali.h>
+#include <dali/public-api/adaptor-framework/widget-impl.h>
+#include <dali/public-api/adaptor-framework/widget.h>
+
+using namespace Dali;
+
+void utc_dali_widget_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_widget_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliWidgetConstructorsP(void)
+{
+  Widget widget1 = Widget::New();
+  DALI_TEST_CHECK(widget1);
+
+  // copy constructor
+  Widget widget2 = Widget(widget1);
+  DALI_TEST_CHECK(widget1 == widget2);
+
+  // copy assignment
+  widget1.Reset();
+  DALI_TEST_CHECK(!widget1);
+  DALI_TEST_CHECK(widget1 != widget2);
+  widget1 = widget2;
+  DALI_TEST_CHECK(widget1 == widget2);
+
+  // move constructor
+  Widget widget3 = Widget(std::move(widget1));
+  DALI_TEST_CHECK(widget3);
+
+  // move assignemnt
+  widget2.Reset();
+  DALI_TEST_CHECK(!widget2);
+  widget2 = std::move(widget3);
+  DALI_TEST_CHECK(widget2);
+
+  Widget widget4;
+  DALI_TEST_CHECK(!widget4);
+  widget4 = Widget::New();
+  DALI_TEST_CHECK(widget4);
+
+  END_TEST;
+}
+
+int UtcDaliWidgetImplOnMethodsP(void)
+{
+  /// No real test in this function, purely for function and line coverage
+
+  Widget widget = Widget::New();
+  DALI_TEST_CHECK(widget);
+  Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
+
+  try
+  {
+    widgetImpl.OnCreate(std::string(), Dali::Window());
+    widgetImpl.OnTerminate(std::string(), Dali::Widget::Termination::PERMANENT);
+    widgetImpl.OnPause();
+    widgetImpl.OnResume();
+    widgetImpl.OnResize(Dali::Window());
+    widgetImpl.OnUpdate(std::string(), 1);
+    DALI_TEST_CHECK(true);
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(false); // Should not come here
+  }
+
+  END_TEST;
+}
+
+int UtcDaliWidgetImplSetContentInfoP(void)
+{
+  Widget                     widget     = Widget::New();
+  Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
+
+  try
+  {
+    widgetImpl.SetContentInfo(std::string());
+    DALI_TEST_CHECK(true);
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(false); // Should not come here
+  }
+
+  END_TEST;
+}
+
+int UtcDaliWidgetImplKeyEventUsingP(void)
+{
+  Widget                     widget     = Widget::New();
+  Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
+
+  DALI_TEST_CHECK(!widgetImpl.IsKeyEventUsing());
+  widgetImpl.SetUsingKeyEvent(true);
+  DALI_TEST_CHECK(!widgetImpl.IsKeyEventUsing()); // Still false as Impl is not set WidgetImpl
+
+  END_TEST;
+}
+
+int UtcDaliWidgetImplSetInformationP(void)
+{
+  Widget                     widget     = Widget::New();
+  Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
+
+  try
+  {
+    widgetImpl.SetInformation(Dali::Window(), std::string());
+    DALI_TEST_CHECK(true);
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(false); // Should not come here
+  }
+
+  END_TEST;
+}
+
+int UtcDaliWidgetImplGetWindowP(void)
+{
+  const Widget                     widget     = Widget::New();
+  const Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
+
+  DALI_TEST_CHECK(!widgetImpl.GetWindow());
+
+  END_TEST;
+}
+
+int UtcDaliWidgetImplGetWidgetIdP(void)
+{
+  const Widget                     widget     = Widget::New();
+  const Internal::Adaptor::Widget& widgetImpl = Internal::Adaptor::GetImplementation(widget);
+
+  DALI_TEST_CHECK(widgetImpl.GetWidgetId().empty());
+
+  END_TEST;
+}
diff --git a/automated-tests/src/dali-adaptor/utc-Dali-WidgetApplication.cpp b/automated-tests/src/dali-adaptor/utc-Dali-WidgetApplication.cpp
new file mode 100644 (file)
index 0000000..719053d
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2022 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 <dali-test-suite-utils.h>
+#include <dali/dali.h>
+#include <dali/public-api/adaptor-framework/widget-application.h>
+#include <dali/public-api/adaptor-framework/widget.h>
+
+using namespace Dali;
+
+void utc_dali_widget_application_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_widget_application_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+namespace
+{
+Widget CreateWidgetFunction(const std::string&)
+{
+  return Dali::Widget();
+}
+} // namespace
+
+int UtcDaliWidgetApplicationRegisterWidgetCreatingFunctionNegative(void)
+{
+  Dali::WidgetApplication instance;
+  try
+  {
+    std::string arg1;
+    instance.RegisterWidgetCreatingFunction(arg1, &CreateWidgetFunction);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliWidgetApplicationConstructorsPositive(void)
+{
+  WidgetApplication widget1;
+
+  // copy constructor
+  WidgetApplication widget2 = WidgetApplication(widget1);
+
+  // copy assignment
+  widget1 = widget2;
+
+  // move constructor
+  WidgetApplication widget3 = WidgetApplication(std::move(widget1));
+
+  // move assignemnt
+  widget2 = std::move(widget3);
+
+  DALI_TEST_CHECK(!widget1);
+  DALI_TEST_CHECK(!widget2);
+  DALI_TEST_CHECK(!widget3);
+
+  END_TEST;
+}