From 2c9099d827fb6421ceab8486f694cace81da5c3e Mon Sep 17 00:00:00 2001 From: li-tiangang4 Date: Tue, 19 Mar 2024 15:23:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-tiangang4 --- common/include/input_hub.cpp | 4 ++-- common/include/test/whitelistunittest/white_list_test.h | 6 +++--- .../test/unittest/distributed_input_inner_test.h | 6 +++--- .../distributed_input_collector_test.h | 8 +++----- .../distributed_input_sinkmanager_test.h | 6 +++--- .../test/sinkmanagerunittest/mock/mock_process.cpp | 6 +++--- .../transport/src/distributed_input_sink_transport.cpp | 2 +- .../sinktransunittest/distributed_input_sinktrans_test.h | 4 ++-- .../distributed_input_sourceinject_test.h | 4 ++-- .../distributed_input_sourcemanager_test.h | 6 +++--- .../distributed_input_sourcetrans_test.h | 6 +++--- .../test/unittest/distributed_input_sinkhandler_test.h | 6 +++--- .../test/unittest/distributed_input_sourcehandler_test.h | 6 +++--- utils/test/unittest/dinput_context_test.h | 6 +++--- 14 files changed, 37 insertions(+), 39 deletions(-) diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 8c1b0ff..6ef5d72 100644 --- a/common/include/input_hub.cpp +++ b/common/include/input_hub.cpp @@ -42,6 +42,7 @@ namespace DistributedInput { namespace { const uint32_t SLEEP_TIME_US = 100 * 1000; const std::string MOUSE_NODE_KEY = "mouse"; +const int32_t SPACE_LENGTH = 1024; } InputHub::InputHub(bool isPluginMonitor) : epollFd_(-1), iNotifyFd_(-1), inputWd_(-1), @@ -914,8 +915,7 @@ int32_t InputHub::QueryLocalTouchScreenInfo(int fd, std::unique_ptr &dev std::string InputHub::StringPrintf(const char *format, ...) const { - static const int kSpaceLength = 1024; - char space[kSpaceLength]; + char space[SPACE_LENGTH] = {0}; va_list ap; va_start(ap, format); diff --git a/common/include/test/whitelistunittest/white_list_test.h b/common/include/test/whitelistunittest/white_list_test.h index 029aaed..eca804d 100644 --- a/common/include/test/whitelistunittest/white_list_test.h +++ b/common/include/test/whitelistunittest/white_list_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -25,8 +25,8 @@ class WhiteListTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h index 2060897..f23ce61 100644 --- a/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h +++ b/interfaces/inner_kits/test/unittest/distributed_input_inner_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -46,8 +46,8 @@ class DistributedInputInnerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; int CheckSourceProxy() const; int CheckSinkProxy() const; diff --git a/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.h b/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.h index e48f879..ed3dff1 100644 --- a/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.h +++ b/services/sink/inputcollector/test/sinkcollectorunittest/distributed_input_collector_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -19,9 +19,7 @@ #include #include "constants_dinput.h" -#define private public #include "distributed_input_collector.h" -#undef private namespace OHOS { namespace DistributedHardware { @@ -30,8 +28,8 @@ class DistributedInputCollectorTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; class DInputSinkCollectorEventHandler : public AppExecFwk::EventHandler { public: diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.h b/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.h index 4abf048..b730a3c 100644 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.h +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/distributed_input_sinkmanager_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -36,8 +36,8 @@ class DistributedInputSinkManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; class TestGetSinkScreenInfosCb : public OHOS::DistributedHardware::DistributedInput::GetSinkScreenInfosCallbackStub { diff --git a/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp b/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp index 05c4750..e5796b3 100644 --- a/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp +++ b/services/sink/sinkmanager/test/sinkmanagerunittest/mock/mock_process.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -23,7 +23,7 @@ namespace DistributedHardware { namespace DistributedInput { void MockProcess::MockDinputProcess(const char* processName) { - static const char *PERMS[] = { + static const char *perms[] = { "ohos.permission.DISTRIBUTED_DATASYNC" }; uint64_t tokenId; @@ -32,7 +32,7 @@ void MockProcess::MockDinputProcess(const char* processName) .permsNum = 1, .aclsNum = 0, .dcaps = nullptr, - .perms = PERMS, + .perms = perms, .acls = nullptr, .processName = processName, .aplStr = "system_core", diff --git a/services/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index bedd63b..edc00ae 100644 --- a/services/sink/transport/src/distributed_input_sink_transport.cpp +++ b/services/sink/transport/src/distributed_input_sink_transport.cpp @@ -253,7 +253,7 @@ void DistributedInputSinkTransport::SendKeyStateNodeMsgBatch(const int32_t sessi void DistributedInputSinkTransport::DoSendMsgBatch(const int32_t sessionId, const std::vector &events) { - int64_t currentTimeNs = GetCurrentTimeUs() * 1000LL; + int64_t currentTimeNs = *(reinterpret_cast(GetCurrentTimeUs())) * 1000LL; std::shared_ptr eventsJsonArr = std::make_shared(); for (const auto &ev : events) { nlohmann::json tmpJson; diff --git a/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.h b/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.h index 46d44bc..22e6a73 100644 --- a/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.h +++ b/services/sink/transport/test/sinktransunittest/distributed_input_sinktrans_test.h @@ -33,8 +33,8 @@ class DistributedInputSinkTransTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; private: nlohmann::json jsonStr_; nlohmann::json jsonStr1_; diff --git a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.h b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.h index c97fab4..3f59f4a 100644 --- a/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.h +++ b/services/source/inputinject/test/sourceinjectunittest/distributed_input_sourceinject_test.h @@ -36,8 +36,8 @@ class DistributedInputSourceInjectTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; class TestInputNodeListener : public OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub { public: TestInputNodeListener() = default; diff --git a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h index c47d5e0..d1001d3 100644 --- a/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h +++ b/services/source/sourcemanager/test/sourcemanagerunittest/distributed_input_sourcemanager_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -48,8 +48,8 @@ class DistributedInputSourceManagerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; class TestPrepareDInputCallback : public OHOS::DistributedHardware::DistributedInput::PrepareDInputCallbackStub { diff --git a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.h b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.h index 7b44288..eaa0fa2 100644 --- a/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.h +++ b/services/source/transport/test/sourcetransunittest/distributed_input_sourcetrans_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -33,8 +33,8 @@ class DistributedInputSourceTransTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; }; } // namespace DistributedInput } // namespace DistributedHardware diff --git a/sinkhandler/test/unittest/distributed_input_sinkhandler_test.h b/sinkhandler/test/unittest/distributed_input_sinkhandler_test.h index 0a3577b..c69afe2 100644 --- a/sinkhandler/test/unittest/distributed_input_sinkhandler_test.h +++ b/sinkhandler/test/unittest/distributed_input_sinkhandler_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -35,8 +35,8 @@ class DistributedInputSinkHandlerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; int32_t CheckSystemAbility(); }; } // namespace DistributedInput diff --git a/sourcehandler/test/unittest/distributed_input_sourcehandler_test.h b/sourcehandler/test/unittest/distributed_input_sourcehandler_test.h index 9060f83..105e0b6 100644 --- a/sourcehandler/test/unittest/distributed_input_sourcehandler_test.h +++ b/sourcehandler/test/unittest/distributed_input_sourcehandler_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 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 @@ -40,8 +40,8 @@ class DistributedInputSourceHandlerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; int32_t CheckSystemAbility(); class TestRegisterDInputCallback : public OHOS::DistributedHardware::RegisterCallback { diff --git a/utils/test/unittest/dinput_context_test.h b/utils/test/unittest/dinput_context_test.h index 0a471de..d8d5370 100644 --- a/utils/test/unittest/dinput_context_test.h +++ b/utils/test/unittest/dinput_context_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 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 @@ -25,8 +25,8 @@ class DInputContextTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - virtual void SetUp() override; - virtual void TearDown() override; + void SetUp() override; + void TearDown() override; }; } // namespace DistributedInput } // namespace DistributedHardware -- Gitee