From 4e8d24b9a833448ba4d98f19de30a84daa5b35fe Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Thu, 9 Nov 2023 09:22:19 +0800 Subject: [PATCH 1/2] updata 1109 Signed-off-by: redking-zhong --- window_scene/test/unittest/BUILD.gn | 28 +++++++++++ .../test/unittest/screen_property_test.cpp | 17 +++++++ .../test/unittest/session_permission_test.cpp | 38 ++++++++++++++ .../test/unittest/task_scheduler_test.cpp | 50 +++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 window_scene/test/unittest/task_scheduler_test.cpp diff --git a/window_scene/test/unittest/BUILD.gn b/window_scene/test/unittest/BUILD.gn index 66ba03acbe..6cf4a8fcda 100644 --- a/window_scene/test/unittest/BUILD.gn +++ b/window_scene/test/unittest/BUILD.gn @@ -45,11 +45,13 @@ group("unittest") { ":ws_session_display_power_controller_test", ":ws_session_listener_controller_test", ":ws_session_manager_agent_controller_test", + ":ws_session_permission_test", ":ws_session_proxy_test", ":ws_session_stage_proxy_test", ":ws_session_stage_stub_test", ":ws_session_stub_test", ":ws_session_test", + ":ws_task_scheduler_test", ":ws_timer_manager_test", ":ws_window_event_channel_proxy_test", ":ws_window_event_channel_stub_test", @@ -72,6 +74,32 @@ ohos_unittest("ws_dual_display_device_policy_test") { ] } +ohos_unittest("ws_task_scheduler_test") { + module_out_path = module_out_path + + sources = [ "task_scheduler_test.cpp" ] + + deps = [ ":ws_unittest_common" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] +} + +ohos_unittest("ws_session_permission_test") { + module_out_path = module_out_path + + sources = [ "session_permission_test.cpp" ] + + deps = [ ":ws_unittest_common" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + ] +} + ohos_unittest("ws_session_listener_controller_test") { module_out_path = module_out_path diff --git a/window_scene/test/unittest/screen_property_test.cpp b/window_scene/test/unittest/screen_property_test.cpp index 6ee22cc676..c7eab30eca 100644 --- a/window_scene/test/unittest/screen_property_test.cpp +++ b/window_scene/test/unittest/screen_property_test.cpp @@ -205,6 +205,23 @@ HWTEST_F(ScreenPropertyTest, SetScreenRequestedOrientation, Function | SmallTest delete property; GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenRequestedOrientation end"; } + +/** + * @tc.name: GetPhyHeight + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(ScreenPropertyTest, GetPhyHeight, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhyHeight start"; + ScreenProperty* property = new(std::nothrow) ScreenProperty(); + uint32_t phyHeight = 1; + property->SetPhyHeight(phyHeight); + int32_t ret = property->GetPhyHeight(); + ASSERT_EQ(ret, phyHeight); + delete property; + GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhyHeight end"; +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/session_permission_test.cpp b/window_scene/test/unittest/session_permission_test.cpp index 6c96427685..1db994569f 100644 --- a/window_scene/test/unittest/session_permission_test.cpp +++ b/window_scene/test/unittest/session_permission_test.cpp @@ -140,6 +140,44 @@ HWTEST_F(SessionPermissionTest, IsStartedByInputMethod, Function | SmallTest | L ASSERT_EQ(false, result); } +/** + * @tc.name: session_permission_test001 + * @tc.desc: test function : session_permission_test001 + * @tc.type: FUNC +*/ +HWTEST_F(SessionPermissionTest, session_permission_test001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test001 start"; + bool result = SessionPermission::IsStartByHdcd(); + ASSERT_EQ(result, true); + GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test001 end"; +} + +/** + * @tc.name: session_permission_test002 + * @tc.desc: test function : session_permission_test002 + * @tc.type: FUNC +*/ +HWTEST_F(SessionPermissionTest, session_permission_test002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test002 start"; + bool result = SessionPermission::IsStartedByInputMethod(); + ASSERT_EQ(result, false); + GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test002 end"; +} + +/** + * @tc.name: session_permission_test003 + * @tc.desc: test function : session_permission_test003 + * @tc.type: FUNC +*/ +HWTEST_F(SessionPermissionTest, session_permission_test003, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test003 start"; + bool result = SessionPermission::IsStartedByInputMethod(); + ASSERT_EQ(result, false); + GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test003 end"; +} } // namespacecd } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/task_scheduler_test.cpp b/window_scene/test/unittest/task_scheduler_test.cpp new file mode 100644 index 0000000000..6dd97700a6 --- /dev/null +++ b/window_scene/test/unittest/task_scheduler_test.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2023 Huawei Device 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 "common/include/task_scheduler.h" +#include + +// using namespace FRAME_TRACE; +using namespace testing; +using namespace testing::ext; +namespace OHOS { +namespace Rosen { +class TaskSchedulerText : public testing::Test { + public: + TaskSchedulerText() {} + ~TaskSchedulerText() {} +}; + +namespace { +/** + * @tc.name: task_scheduler_test001 + * @tc.desc: normal function + * @tc.type: FUNC + */ +HWTEST_F(TaskSchedulerText, task_scheduler_test001, Function | SmallTest | Level2) +{ + GTEST_LOG_(INFO) << "TaskSchedulerText: task_scheduler_test001 start"; + std::string threadName = "threadName"; + std::string name = "name"; + TaskScheduler* taskScheduler = new(std::nothrow) TaskScheduler(threadName); + int res = 0; + taskScheduler->RemoveTask(name); + ASSERT_EQ(res, 0); + delete taskScheduler; + GTEST_LOG_(INFO) << "TaskSchedulerText: task_scheduler_test001 end"; +} +} // namespace +} // namespace Rosen +} // namespace OHOS -- Gitee From cd66269d322bf85d955207a9556e291482f93c0c Mon Sep 17 00:00:00 2001 From: redking-zhong Date: Thu, 9 Nov 2023 11:13:42 +0800 Subject: [PATCH 2/2] updata tdd Signed-off-by: redking-zhong --- .../test/unittest/session_permission_test.cpp | 13 ------------- window_scene/test/unittest/task_scheduler_test.cpp | 1 - 2 files changed, 14 deletions(-) diff --git a/window_scene/test/unittest/session_permission_test.cpp b/window_scene/test/unittest/session_permission_test.cpp index 1db994569f..ff9f79db8e 100644 --- a/window_scene/test/unittest/session_permission_test.cpp +++ b/window_scene/test/unittest/session_permission_test.cpp @@ -165,19 +165,6 @@ HWTEST_F(SessionPermissionTest, session_permission_test002, Function | SmallTest ASSERT_EQ(result, false); GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test002 end"; } - -/** - * @tc.name: session_permission_test003 - * @tc.desc: test function : session_permission_test003 - * @tc.type: FUNC -*/ -HWTEST_F(SessionPermissionTest, session_permission_test003, Function | SmallTest | Level1) -{ - GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test003 start"; - bool result = SessionPermission::IsStartedByInputMethod(); - ASSERT_EQ(result, false); - GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test003 end"; -} } // namespacecd } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/task_scheduler_test.cpp b/window_scene/test/unittest/task_scheduler_test.cpp index 6dd97700a6..f9c83bc810 100644 --- a/window_scene/test/unittest/task_scheduler_test.cpp +++ b/window_scene/test/unittest/task_scheduler_test.cpp @@ -16,7 +16,6 @@ #include "common/include/task_scheduler.h" #include -// using namespace FRAME_TRACE; using namespace testing; using namespace testing::ext; namespace OHOS { -- Gitee