已合并
Remove empty WantSenderStub and inherit IRemoteStub directly #20319
m0_65533854创建于 14 天前
Remove empty WantSenderStub and inherit IRemoteStub directly #20319
已合并
共 23 个文件变更+4-548
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | -#include "want_sender_stub.h" | 31 | +#include "want_sender_interface.h" |
| 32 | 32 | ||
| 33 | namespace OHOS::AbilityRuntime::WantAgent { | 33 | namespace OHOS::AbilityRuntime::WantAgent { |
| 34 | class PendingWant final : public std::enable_shared_from_this<PendingWant>, public Parcelable { | 34 | class PendingWant final : public std::enable_shared_from_this<PendingWant>, public Parcelable { |
| @@ -21,15 +21,16 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | + | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | 27 | ||
| 27 | -#include "want_sender_stub.h" | 28 | +#include "want_sender_interface.h" |
| 28 | 29 | ||
| 29 | namespace OHOS { | 30 | namespace OHOS { |
| 30 | namespace AAFwk { | 31 | namespace AAFwk { |
| 31 | class PendingWantManager; | 32 | class PendingWantManager; |
| 32 | -class PendingWantRecord : public WantSenderStub { | 33 | +class PendingWantRecord : public IRemoteStub<IWantSender> { |
| 33 | public: | 34 | public: |
| 34 | 35 | ||
| 35 | PendingWantRecord(); | 36 | PendingWantRecord(); |
| @@ -1,34 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2021 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | -namespace OHOS { | ||
| 26 | -namespace AAFwk { | ||
| 27 | -class WantSenderStub : public IRemoteStub<IWantSender> { | ||
| 28 | -public: | ||
| 29 | - WantSenderStub() = default; | ||
| 30 | - virtual ~WantSenderStub() = default; | ||
| 31 | -}; | ||
| 32 | -} // namespace AAFwk | ||
| 33 | -} // namespace OHOS | ||
| 34 | - | ||
| @@ -108,7 +108,6 @@ | |||
| 108 | *WantReceiverStub*; | 108 | *WantReceiverStub*; |
| 109 | *WantReceiverProxy*; | 109 | *WantReceiverProxy*; |
| 110 | *WantSenderProxy*; | 110 | *WantSenderProxy*; |
| 111 | - *WantSenderStub*; | ||
| 112 | *WantUtils*; | 111 | *WantUtils*; |
| 113 | *WindowOptionsUtils*; | 112 | *WindowOptionsUtils*; |
| 114 | }; | 113 | }; |
| @@ -563,7 +563,6 @@ group("fuzztest") { | |||
| 563 | "usercontrollerfourth_fuzzer:fuzztest", | 563 | "usercontrollerfourth_fuzzer:fuzztest", |
| 564 | "wantagenthelperstring_fuzzer:fuzztest", | 564 | "wantagenthelperstring_fuzzer:fuzztest", |
| 565 | "wantagenthelpertrigger_fuzzer:fuzztest", | 565 | "wantagenthelpertrigger_fuzzer:fuzztest", |
| 566 | - "wantsenderstub_fuzzer:fuzztest", | ||
| 567 | "wantutils_fuzzer:fuzztest", | 566 | "wantutils_fuzzer:fuzztest", |
| 568 | "windowoptionsutils_fuzzer:fuzztest", | 567 | "windowoptionsutils_fuzzer:fuzztest", |
| 569 | ] | 568 | ] |
| @@ -1,77 +0,0 @@ | |||
| 1 | -# Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 2 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 3 | -# you may not use this file except in compliance with the License. | ||
| 4 | -# You may obtain a copy of the License at | ||
| 5 | -# | ||
| 6 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 7 | -# | ||
| 8 | -# Unless required by applicable law or agreed to in writing, software | ||
| 9 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 10 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 11 | -# See the License for the specific language governing permissions and | ||
| 12 | -# limitations under the License. | ||
| 13 | - | ||
| 14 | -#####################hydra-fuzz################### | ||
| 15 | -import("//build/config/features.gni") | ||
| 16 | -import("//build/ohos.gni") | ||
| 17 | -import("//build/test.gni") | ||
| 18 | -import("//foundation/ability/ability_runtime/ability_runtime.gni") | ||
| 19 | -module_output_path = "ability_runtime/abilitymgr" | ||
| 20 | - | ||
| 21 | -##############################fuzztest########################################## | ||
| 22 | -ohos_fuzztest("WantSenderStubFuzzTest") { | ||
| 23 | - module_out_path = module_output_path | ||
| 24 | - | ||
| 25 | - fuzz_config_file = | ||
| 26 | - "${ability_runtime_test_path}/fuzztest/wantsenderstub_fuzzer" | ||
| 27 | - include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ] | ||
| 28 | - cflags = [ | ||
| 29 | - "-g", | ||
| 30 | - "-O0", | ||
| 31 | - "-Wno-unused-variable", | ||
| 32 | - "-fno-omit-frame-pointer", | ||
| 33 | - ] | ||
| 34 | - sources = [ "wantsenderstub_fuzzer.cpp" ] | ||
| 35 | - | ||
| 36 | - configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ] | ||
| 37 | - | ||
| 38 | - deps = [ | ||
| 39 | - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", | ||
| 40 | - "${ability_runtime_native_path}/ability/native:abilitykit_native", | ||
| 41 | - "${ability_runtime_services_path}/abilitymgr:abilityms", | ||
| 42 | - "${ability_runtime_services_path}/abilitymgr:wantagent_manager", | ||
| 43 | - ] | ||
| 44 | - | ||
| 45 | - external_deps = [ | ||
| 46 | - "ability_base:want", | ||
| 47 | - "ability_base:zuri", | ||
| 48 | - "bundle_framework:appexecfwk_base", | ||
| 49 | - "bundle_framework:appexecfwk_core", | ||
| 50 | - "c_utils:utils", | ||
| 51 | - "common_event_service:cesfwk_innerkits", | ||
| 52 | - "ffrt:libffrt", | ||
| 53 | - "hilog:libhilog", | ||
| 54 | - "ipc:ipc_core", | ||
| 55 | - "napi:ace_napi", | ||
| 56 | - "safwk:system_ability_fwk", | ||
| 57 | - "samgr:samgr_proxy", | ||
| 58 | - ] | ||
| 59 | - | ||
| 60 | - if (ability_runtime_graphics) { | ||
| 61 | - external_deps += [ | ||
| 62 | - "input:libmmi-client", | ||
| 63 | - "window_manager:libwm", | ||
| 64 | - ] | ||
| 65 | - } | ||
| 66 | -} | ||
| 67 | - | ||
| 68 | -############################################################################### | ||
| 69 | -group("fuzztest") { | ||
| 70 | - testonly = true | ||
| 71 | - deps = [] | ||
| 72 | - deps += [ | ||
| 73 | - # deps file | ||
| 74 | - ":WantSenderStubFuzzTest", | ||
| 75 | - ] | ||
| 76 | -} | ||
| 77 | -############################################################################### | ||
| @@ -1,16 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | -FUZZ | ||
| @@ -1,25 +0,0 @@ | |||
| 1 | - | ||
| 2 | -<!-- Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 3 | - | ||
| 4 | - Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - you may not use this file except in compliance with the License. | ||
| 6 | - You may obtain a copy of the License at | ||
| 7 | - | ||
| 8 | - http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - | ||
| 10 | - Unless required by applicable law or agreed to in writing, software | ||
| 11 | - distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - See the License for the specific language governing permissions and | ||
| 14 | - limitations under the License. | ||
| 15 | ---> | ||
| 16 | -<fuzz_config> | ||
| 17 | - <fuzztest> | ||
| 18 | - <!-- maximum length of a test input --> | ||
| 19 | - <max_len>1000</max_len> | ||
| 20 | - <!-- maximum total time in seconds to run the fuzzer --> | ||
| 21 | - <max_total_time>300</max_total_time> | ||
| 22 | - <!-- memory usage limit in Mb --> | ||
| 23 | - <rss_limit_mb>4096</rss_limit_mb> | ||
| 24 | - </fuzztest> | ||
| 25 | -</fuzz_config> | ||
| @@ -1,105 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | -using namespace OHOS::AAFwk; | ||
| 26 | - | ||
| 27 | -namespace OHOS { | ||
| 28 | -namespace { | ||
| 29 | -constexpr int INPUT_ZERO = 0; | ||
| 30 | -constexpr int INPUT_ONE = 1; | ||
| 31 | -constexpr int ENABLE = 2; | ||
| 32 | -constexpr int INPUT_THREE = 3; | ||
| 33 | -constexpr size_t U32_AT_SIZE = 4; | ||
| 34 | -constexpr size_t OFFSET_ZERO = 24; | ||
| 35 | -constexpr size_t OFFSET_ONE = 16; | ||
| 36 | -constexpr size_t OFFSET_TWO = 8; | ||
| 37 | -const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.WantSender"; | ||
| 38 | -} | ||
| 39 | - | ||
| 40 | -class WantSenderStubFuzzTest : public WantSenderStub { | ||
| 41 | -public: | ||
| 42 | - WantSenderStubFuzzTest() = default; | ||
| 43 | - virtual ~WantSenderStubFuzzTest() | ||
| 44 | - {} | ||
| 45 | -}; | ||
| 46 | - | ||
| 47 | -uint32_t GetU32Data(const char* ptr) | ||
| 48 | -{ | ||
| 49 | - // convert fuzz input data to an integer | ||
| 50 | - return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[ENABLE] << OFFSET_TWO) | | ||
| 51 | - ptr[INPUT_THREE]; | ||
| 52 | -} | ||
| 53 | - | ||
| 54 | -bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) | ||
| 55 | -{ | ||
| 56 | - uint32_t code = GetU32Data(data); | ||
| 57 | - | ||
| 58 | - MessageParcel parcel; | ||
| 59 | - parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN); | ||
| 60 | - parcel.WriteBuffer(data, size); | ||
| 61 | - parcel.RewindRead(0); | ||
| 62 | - MessageParcel reply; | ||
| 63 | - MessageOption option; | ||
| 64 | - | ||
| 65 | - std::shared_ptr<WantSenderStub> wantsenderstub = std::make_shared<WantSenderStubFuzzTest>(); | ||
| 66 | - | ||
| 67 | - wantsenderstub->OnRemoteRequest(code, parcel, reply, option); | ||
| 68 | - | ||
| 69 | - return true; | ||
| 70 | -} | ||
| 71 | -} | ||
| 72 | - | ||
| 73 | -/* Fuzzer entry point */ | ||
| 74 | -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) | ||
| 75 | -{ | ||
| 76 | - /* Run your code on data */ | ||
| 77 | - if (data == nullptr) { | ||
| 78 | - std::cout << "invalid data" << std::endl; | ||
| 79 | - return 0; | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - /* Validate the length of size */ | ||
| 83 | - if (size < OHOS::U32_AT_SIZE) { | ||
| 84 | - return 0; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - char* ch = static_cast<char*>(malloc(size + 1)); | ||
| 88 | - if (ch == nullptr) { | ||
| 89 | - std::cout << "malloc failed." << std::endl; | ||
| 90 | - return 0; | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - (void)memset_s(ch, size + 1, 0x00, size + 1); | ||
| 94 | - if (memcpy_s(ch, size + 1, data, size) != EOK) { | ||
| 95 | - std::cout << "copy failed." << std::endl; | ||
| 96 | - free(ch); | ||
| 97 | - ch = nullptr; | ||
| 98 | - return 0; | ||
| 99 | - } | ||
| 100 | - | ||
| 101 | - OHOS::DoSomethingInterestingWithMyAPI(ch, size); | ||
| 102 | - free(ch); | ||
| 103 | - ch = nullptr; | ||
| 104 | - return 0; | ||
| 105 | -} | ||
| @@ -1,21 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2024 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| @@ -42,7 +42,6 @@ | |||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | - | ||
| 46 | 45 | ||
| 47 | 46 | ||
| 48 | using namespace std::placeholders; | 47 | using namespace std::placeholders; |
| @@ -569,7 +569,6 @@ group("unittest") { | |||
| 569 | "want_receiver_proxy_test:unittest", | 569 | "want_receiver_proxy_test:unittest", |
| 570 | "want_receiver_stub_test:unittest", | 570 | "want_receiver_stub_test:unittest", |
| 571 | "want_sender_info_test:unittest", | 571 | "want_sender_info_test:unittest", |
| 572 | - "want_sender_stub_test:unittest", | ||
| 573 | "wants_info_test:unittest", | 572 | "wants_info_test:unittest", |
| 574 | "window_config_test:unittest", | 573 | "window_config_test:unittest", |
| 575 | "window_focus_changed_listener_test:unittest", | 574 | "window_focus_changed_listener_test:unittest", |
| @@ -35,7 +35,6 @@ | |||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | - | ||
| 39 | 38 | ||
| 40 | using namespace testing; | 39 | using namespace testing; |
| 41 | using namespace testing::ext; | 40 | using namespace testing::ext; |
| @@ -38,7 +38,6 @@ | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | - | ||
| 42 | 41 | ||
| 43 | using namespace testing; | 42 | using namespace testing; |
| 44 | using namespace testing::ext; | 43 | using namespace testing::ext; |
| @@ -38,7 +38,6 @@ | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | - | ||
| 42 | 41 | ||
| 43 | using namespace testing; | 42 | using namespace testing; |
| 44 | using namespace testing::ext; | 43 | using namespace testing::ext; |
| @@ -42,7 +42,6 @@ | |||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | - | ||
| 46 | 45 | ||
| 47 | 46 | ||
| 48 | 47 | ||
| @@ -37,7 +37,6 @@ | |||
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | - | ||
| 41 | 40 | ||
| 42 | 41 | ||
| 43 | using namespace testing; | 42 | using namespace testing; |
| @@ -42,7 +42,6 @@ | |||
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | - | ||
| 46 | 45 | ||
| 47 | 46 | ||
| 48 | using namespace testing::ext; | 47 | using namespace testing::ext; |
| @@ -32,7 +32,6 @@ | |||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | - | ||
| 36 | 35 | ||
| 37 | 36 | ||
| 38 | using namespace testing::ext; | 37 | using namespace testing::ext; |
| @@ -34,7 +34,6 @@ | |||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | - | ||
| 38 | 37 | ||
| 39 | using namespace testing::ext; | 38 | using namespace testing::ext; |
| 40 | using namespace OHOS::AAFwk; | 39 | using namespace OHOS::AAFwk; |
| @@ -1,75 +0,0 @@ | |||
| 1 | -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. | ||
| 2 | -# Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 3 | -# you may not use this file except in compliance with the License. | ||
| 4 | -# You may obtain a copy of the License at | ||
| 5 | -# | ||
| 6 | -# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 7 | -# | ||
| 8 | -# Unless required by applicable law or agreed to in writing, software | ||
| 9 | -# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 10 | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 11 | -# See the License for the specific language governing permissions and | ||
| 12 | -# limitations under the License. | ||
| 13 | - | ||
| 14 | -import("//build/test.gni") | ||
| 15 | -import("//foundation/ability/ability_runtime/ability_runtime.gni") | ||
| 16 | - | ||
| 17 | -module_output_path = "ability_runtime/ability_runtime/abilitymgr" | ||
| 18 | - | ||
| 19 | -ohos_unittest("want_sender_stub_test") { | ||
| 20 | - module_out_path = module_output_path | ||
| 21 | - sanitize = { | ||
| 22 | - cfi = true | ||
| 23 | - cfi_cross_dso = true | ||
| 24 | - debug = false | ||
| 25 | - blocklist = "../../cfi_blocklist.txt" | ||
| 26 | - } | ||
| 27 | - branch_protector_ret = "pac_ret" | ||
| 28 | - include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock" ] | ||
| 29 | - | ||
| 30 | - sources = [ | ||
| 31 | - "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp", | ||
| 32 | - "want_sender_stub_test.cpp", | ||
| 33 | - ] | ||
| 34 | - | ||
| 35 | - configs = [ | ||
| 36 | - "${ability_runtime_services_path}/abilitymgr:abilityms_config", | ||
| 37 | - "${ability_runtime_test_path}/mock/services_abilitymgr_test:aafwk_mock_config", | ||
| 38 | - ] | ||
| 39 | - cflags = [] | ||
| 40 | - if (target_cpu == "arm") { | ||
| 41 | - cflags += [ "-DBINDER_IPC_32BIT" ] | ||
| 42 | - } | ||
| 43 | - deps = [ | ||
| 44 | - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", | ||
| 45 | - "${ability_runtime_innerkits_path}/app_manager:app_manager", | ||
| 46 | - "${ability_runtime_native_path}/ability/native:abilitykit_native", | ||
| 47 | - "${ability_runtime_services_path}/abilitymgr:abilityms", | ||
| 48 | - "${ability_runtime_services_path}/abilitymgr:wantagent_manager", | ||
| 49 | - "${ability_runtime_services_path}/common:perm_verification", | ||
| 50 | - ] | ||
| 51 | - | ||
| 52 | - external_deps = [ | ||
| 53 | - "ability_base:zuri", | ||
| 54 | - "access_token:libaccesstoken_sdk", | ||
| 55 | - "c_utils:utils", | ||
| 56 | - "common_event_service:cesfwk_innerkits", | ||
| 57 | - "ffrt:libffrt", | ||
| 58 | - "googletest:gmock_main", | ||
| 59 | - "googletest:gtest_main", | ||
| 60 | - "hilog:libhilog", | ||
| 61 | - "ipc:ipc_core", | ||
| 62 | - "napi:ace_napi", | ||
| 63 | - "samgr:samgr_proxy", | ||
| 64 | - ] | ||
| 65 | - | ||
| 66 | - if (background_task_mgr_continuous_task_enable) { | ||
| 67 | - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] | ||
| 68 | - } | ||
| 69 | -} | ||
| 70 | - | ||
| 71 | -group("unittest") { | ||
| 72 | - testonly = true | ||
| 73 | - | ||
| 74 | - deps = [ ":want_sender_stub_test" ] | ||
| 75 | -} | ||
| @@ -1,54 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2021 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | -namespace OHOS { | ||
| 29 | -namespace AAFwk { | ||
| 30 | -class WantSenderStubImplMock : public WantSenderStub { | ||
| 31 | -public: | ||
| 32 | - WantSenderStubImplMock() | ||
| 33 | - {} | ||
| 34 | - virtual ~WantSenderStubImplMock() | ||
| 35 | - {} | ||
| 36 | - | ||
| 37 | - int InvokeSendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) | ||
| 38 | - { | ||
| 39 | - code_ = code; | ||
| 40 | - return 0; | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - int InvokeErrorSendRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) | ||
| 44 | - { | ||
| 45 | - code_ = code; | ||
| 46 | - return UNKNOWN_ERROR; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - int code_ = 0; | ||
| 50 | -}; | ||
| 51 | -} // namespace AAFwk | ||
| 52 | -} // namespace OHOS | ||
| 53 | - | ||
| 54 | - | ||
| @@ -1,126 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2021 Huawei Device Co., Ltd. | ||
| 3 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | - * you may not use this file except in compliance with the License. | ||
| 5 | - * You may obtain a copy of the License at | ||
| 6 | - * | ||
| 7 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | - * | ||
| 9 | - * Unless required by applicable law or agreed to in writing, software | ||
| 10 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | - * See the License for the specific language governing permissions and | ||
| 13 | - * limitations under the License. | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | -using namespace testing::ext; | ||
| 21 | -using namespace testing; | ||
| 22 | - | ||
| 23 | -namespace OHOS { | ||
| 24 | -namespace AAFwk { | ||
| 25 | -class WantSenderStubTest : public testing::Test { | ||
| 26 | -public: | ||
| 27 | - static void SetUpTestCase(void); | ||
| 28 | - static void TearDownTestCase(void); | ||
| 29 | - void SetUp(); | ||
| 30 | - void TearDown(); | ||
| 31 | - void WriteInterfaceToken(MessageParcel& data); | ||
| 32 | - sptr<WantSenderStubImplMock> stub_{ nullptr }; | ||
| 33 | -}; | ||
| 34 | - | ||
| 35 | -void WantSenderStubTest::SetUpTestCase(void) | ||
| 36 | -{} | ||
| 37 | -void WantSenderStubTest::TearDownTestCase(void) | ||
| 38 | -{} | ||
| 39 | -void WantSenderStubTest::TearDown() | ||
| 40 | -{} | ||
| 41 | - | ||
| 42 | -void WantSenderStubTest::SetUp() | ||
| 43 | -{ | ||
| 44 | - stub_ = new WantSenderStubImplMock(); | ||
| 45 | -} | ||
| 46 | - | ||
| 47 | -void WantSenderStubTest::WriteInterfaceToken(MessageParcel& data) | ||
| 48 | -{ | ||
| 49 | - data.WriteInterfaceToken(WantSenderStubImplMock::GetDescriptor()); | ||
| 50 | -} | ||
| 51 | - | ||
| 52 | -/* | ||
| 53 | - * Feature: WantSenderStub | ||
| 54 | - * Function: OnRemoteRequest | ||
| 55 | - * SubFunction: NA | ||
| 56 | - * FunctionPoints: WantSenderStub OnRemoteRequest | ||
| 57 | - * EnvConditions: The code which not exist | ||
| 58 | - * CaseDescription: Verify that on remote request is abnormal | ||
| 59 | - */ | ||
| 60 | -HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_001, TestSize.Level1) | ||
| 61 | -{ | ||
| 62 | - MessageParcel data; | ||
| 63 | - MessageParcel reply; | ||
| 64 | - MessageOption option; | ||
| 65 | - | ||
| 66 | - WriteInterfaceToken(data); | ||
| 67 | - int res = stub_->OnRemoteRequest(10000, data, reply, option); | ||
| 68 | - | ||
| 69 | - EXPECT_EQ(res, IPC_STUB_UNKNOW_TRANS_ERR); | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -/* | ||
| 73 | - * Feature: WantSenderStub | ||
| 74 | - * Function: OnRemoteRequest | ||
| 75 | - * SubFunction: NA | ||
| 76 | - * FunctionPoints: WantSenderStub OnRemoteRequest | ||
| 77 | - * EnvConditions: code = 0 (legacy WANT_SENDER_SEND, removed) | ||
| 78 | - * CaseDescription: Regression lock-in. code 0 was the legacy WANT_SENDER_SEND | ||
| 79 | - * trans code that allowed bypassing | ||
| 80 | - * PendingWantManager::CheckCallerPermission via direct | ||
| 81 | - * IWantSender::Send IPC. The trans code enum was deleted along | ||
| 82 | - * with WantSenderStub::OnRemoteRequest override, so code 0 now | ||
| 83 | - * falls through to IPCObjectStub which returns | ||
| 84 | - * IPC_STUB_UNKNOW_TRANS_ERR. This test prevents reintroduction | ||
| 85 | - * of WANT_SENDER_SEND handling without an explicit security | ||
| 86 | - * review. | ||
| 87 | - */ | ||
| 88 | -HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_Code0_Rejected_0100, TestSize.Level1) | ||
| 89 | -{ | ||
| 90 | - MessageParcel data; | ||
| 91 | - MessageParcel reply; | ||
| 92 | - MessageOption option; | ||
| 93 | - | ||
| 94 | - WriteInterfaceToken(data); | ||
| 95 | - int res = stub_->OnRemoteRequest(0, data, reply, option); | ||
| 96 | - | ||
| 97 | - EXPECT_EQ(res, IPC_STUB_UNKNOW_TRANS_ERR); | ||
| 98 | -} | ||
| 99 | - | ||
| 100 | -/* | ||
| 101 | - * Feature: WantSenderStub | ||
| 102 | - * Function: OnRemoteRequest | ||
| 103 | - * SubFunction: NA | ||
| 104 | - * FunctionPoints: WantSenderStub OnRemoteRequest | ||
| 105 | - * EnvConditions: code = 0, valid interface token + valid SenderInfo payload | ||
| 106 | - * CaseDescription: Verify code 0 is rejected even when a valid-looking | ||
| 107 | - * SenderInfo payload is attached. Guards against partial | ||
| 108 | - * reintroduction (e.g., re-adding SendInner dispatch on code 0 | ||
| 109 | - * based on payload shape rather than trans code definition). | ||
| 110 | - */ | ||
| 111 | -HWTEST_F(WantSenderStubTest, WantSenderStubTest_OnRemoteRequest_Code0_WithPayload_Rejected_0100, TestSize.Level1) | ||
| 112 | -{ | ||
| 113 | - MessageParcel data; | ||
| 114 | - MessageParcel reply; | ||
| 115 | - MessageOption option; | ||
| 116 | - | ||
| 117 | - WriteInterfaceToken(data); | ||
| 118 | - SenderInfo info; | ||
| 119 | - data.WriteParcelable(&info); | ||
| 120 | - | ||
| 121 | - int res = stub_->OnRemoteRequest(0, data, reply, option); | ||
| 122 | - | ||
| 123 | - EXPECT_EQ(res, IPC_STUB_UNKNOW_TRANS_ERR); | ||
| 124 | -} | ||
| 125 | -} // namespace AAFwk | ||
| 126 | -} // namespace OHOS | ||