--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(device-haltests C CXX)
+
+SET(HALAPI_LIBRARY "hal-api-device")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${INC_DIR})
+
+SET(REQUIRES_LIST ${REQUIRES_LIST}
+ capi-system-info
+ hal-api-common
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+)
+
+FIND_LIBRARY(
+ HALAPI_LIBRARY
+ NAMES libhal-api-device.so
+ HINTS /usr/lib/hal /usr/lib64/hal
+ REQUIRED)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(gtest_pkgs REQUIRED ${REQUIRES_LIST})
+
+FOREACH(flag ${gtest_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+SET(src ${CMAKE_SOURCE_DIR}/haltest/main.cpp
+ ${CMAKE_SOURCE_DIR}/haltest/display.cpp)
+ADD_EXECUTABLE(${PROJECT_NAME} ${src})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest_LDFLAGS} ${gtest_pkgs_LDFLAGS} -ldl ${HALAPI_LIBRARY})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/hal)
--- /dev/null
+
+#include <iostream>
+#include <gtest/gtest.h>
+#include <system_info.h>
+#include "haltest.h"
+#include "hal-display.h"
+
+using namespace std;
+
+/* Define Classes */
+class DISPLAY : public testing::Test
+{
+ public:
+ virtual void SetUp()
+ {
+ int ret;
+
+ ret = system_info_get_platform_bool(FEATURE_DISPLAY, &supported);
+ EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
+
+ }
+
+ virtual void TearDown()
+ {
+
+ }
+};
+
+/*
+ * Testcase for Display
+ */
+TEST_F(DISPLAY, GetBackendP)
+{
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_backend();
+ EXPECT_EQ(ret, 0) << "Fail to get display device (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetMaxBrightnessP)
+{
+ int ret;
+ int max;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_max_brightness(&max);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get max brightness (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetBrightnessP)
+{
+ int ret;
+ int brt;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_brightness(&brt);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get brightness (" << ret << ")";
+}
+
+TEST_F(DISPLAY, SetBrightnessP)
+{
+ int ret;
+ int max = 100;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_set_brightness(max);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to set_brightness (" << ret << ")";
+}
+
+TEST_F(DISPLAY, SetMultiBrightnessP)
+{
+ int ret;
+ int brt = 50, step = 5, delay = 10000;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_set_multi_brightness(brt, step, delay);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to set multi brightness (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetAutoBrightnessP)
+{
+ int ret;
+ int brt;
+ float lmax = 0, lmin = 0, light = 0;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &brt);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get auto brightness (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetStateP)
+{
+ int ret;
+ enum display_state state;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_state(&state);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get state (" << ret << ")";
+}
+
+TEST_F(DISPLAY, SetStateP)
+{
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_set_state(DISPLAY_ON);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to set state (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetImageEffectP)
+{
+ enum display_image_effect effect;
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_image_effect(&effect);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get image effect (" << ret << ")";
+}
+
+TEST_F(DISPLAY, SetImageEffectP)
+{
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_set_image_effect(DISPLAY_IMAGE_EFFECT_GREY);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to set image effect (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetPanelModeP)
+{
+ enum display_panel_mode mode;
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_panel_mode(&mode);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get panel mode (" << ret << ")";
+}
+
+TEST_F(DISPLAY, SetPanelModeP)
+{
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_set_panel_mode(DISPLAY_PANEL_MODE_LOWPOWER);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to set panel mode (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetAodModeP)
+{
+ enum display_aod_mode mode;
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_aod_mode(&mode);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get aod mode (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetAodBrightnessP)
+{
+ int max, normal, min, charging;
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_aod_brightness(&max, &normal, &min, &charging);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_EQ(ret, 0) << "Fail to get aod brightness (" << ret << ")";
+}
+
+
+TEST_F(DISPLAY, GetMaxFrameRateP)
+{
+ int ret;
+ int max;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_max_frame_rate(&max);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_GE(ret, 0) << "Fail to get max frame_rate (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetMinFrameRateP)
+{
+ int ret;
+ int min;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_min_frame_rate(&min);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_GE(ret, 0) << "Fail to get min frame rate (" << ret << ")";
+}
+
+TEST_F(DISPLAY, GetFrameRateP)
+{
+ int ret, rate;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_frame_rate(&rate);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_GE(ret, 0) << "Fail to get frame rate (" << ret << ")";
+}
+
+TEST_F(DISPLAY, SetFrameRateP)
+{
+ int ret, fmax;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_get_max_frame_rate(&fmax);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_GE(ret, 0) << "Fail to get max frame rate (" << ret << ")";
+
+ ret = hal_device_display_set_frame_rate(fmax);
+ if (ret == -ENODEV)
+ return;
+
+ EXPECT_GE(ret, 0) << "Fail to set frame rate (" << ret << ")";
+}
+
+TEST_F(DISPLAY, DeinitP)
+{
+ int ret;
+
+ if (!supported)
+ return;
+
+ ret = hal_device_display_put_backend();
+ EXPECT_GE(ret, 0) << "Fail to close display device (" << ret << ")";
+}
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __HALTEST_H__
+#define __HALTEST_H__
+
+#include <glib.h>
+
+#define FEATURE_BATTERY "http://tizen.org/feature/battery"
+#define FEATURE_DISPLAY "http://tizen.org/feature/display"
+#define FEATURE_LED "http://tizen.org/feature/led"
+#define FEATURE_IR "http://tizen.org/feature/consumer_ir"
+#define FEATURE_THERMISTOR "http://tizen.org/feature/thermistor.ap"
+#define FEATURE_BEZEL "http://tizen.org/feature/input.rotating_bezel"
+
+
+bool supported;
+
+#endif /* __HALTEST_H__ */
Source1: hal-api-device.manifest
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(capi-system-info)
%description
API library for HAL device modules
%description devel
API library for HAL device modules (Development package)
+%package -n device-haltests
+Summary: Device HAL(Hardware Abstraction Layer) Test Cases
+Requires: %{name} = %{version}-%{release}
+
+%description -n device-haltests
+Device HAL(Hardware Abstraction Layer) Test Cases
+
%prep
%setup -q
cp %{SOURCE1} .
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
%cmake . -DFULLVER=%{version} \
- -DMAJORVER=${MAJORVER}
+ -DMAJORVER=${MAJORVER} \
+ -DHALTEST=on
%__make %{?jobs:-j%jobs}
%{_includedir}/hal/device/hal-*.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/hal/libhal-api-device.so
+
+%files -n device-haltests
+%manifest %{name}.manifest
+%license LICENSE.Apache-2.0
+%{_bindir}/hal/device-haltests