diff --git a/common/include/input_hub.cpp b/common/include/input_hub.cpp index 8c1b0ffcb7aa113e6273c582f82c8d7d8ed70fe9..6ef5d72329340eda9c2bd94ed99189c4cbbcb73e 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 029aaedee301148cf3767ed8ed09a840eed6f6ef..eca804d931ce015fcee9a0df16992627e5246626 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 206089754f93a9731447a64351dabe0cbbd54e15..f23ce61105ef0c2433078f4576730da68010ddca 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 e48f8790f5165dde9b00655b5152e317a2e1ac74..ed3dff1d5b9283de249d18c2b7142cf3fa78d898 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 4abf0486a0111a0a6fc343dc82bea669f88fdd6f..b730a3c857f6ef312835d15ffad2d953aae70fdc 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 05c4750510a32f6d56bb8535bddbcec7bfb55a72..e5796b31aa82072091ba5cafa366c6a9bf264de5 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 bedd63b185526603b35c518f1e8e7b572c3f203f..edc00ae99ac919a4fce2358e67c8c3f1df4ae4c3 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 46d44bc0faeaf274b60d154505eafc6b7ddb0b51..22e6a735f116c3bac4eb72422ba6c34108abeae6 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 c97fab483a88e4a8a53392c2544eac1bcdcef7c9..3f59f4a40a41bbe730893239b8fd343a8da32538 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 c47d5e0981e5ca0cba7fe60b6e2baf601d990f0c..d1001d322b75000669d1e93f7711fc1996c0cc38 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 7b4428805d3cc5013ecc36da94b8b3ef7ac38e2d..eaa0fa2fd233956053a8e2450b758140d75369e4 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 0a3577b64b72da5379a72673ca684c9bff43e5f2..c69afe2b4d71c1c776125f86f47e8385688b50eb 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 9060f8344c6465e89b1abe25863a3ad574ad78f5..105e0b6abfef84d4fe48b09b9868472621e84a79 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 0a471de69a24d9736e5bdb7242bb672ffb906fad..d8d53700aba77767b35a62eb0bd10265b75409ed 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