From 54bbb80c82a5febe1ce696c2bbaddc9860bbacce Mon Sep 17 00:00:00 2001 From: yanmengzhao Date: Fri, 25 Jul 2025 16:47:37 +0800 Subject: [PATCH] fix: update Copyright for dfx sample code Signed-off-by: yanmengzhao --- .../entry/src/main/cpp/AppFreezeCase.cpp | 14 ++ AppFreeze/entry/src/main/cpp/napi_init.cpp | 15 ++ AppFreeze/entry/src/main/ets/pages/Index.ets | 15 ++ .../src/main/ets/pages/appfreezecase.ets | 16 +- .../entry/src/main/cpp/CppCrashAdvise1.cpp | 14 ++ .../entry/src/main/cpp/CppCrashAdvise2.cpp | 20 ++- .../entry/src/main/cpp/CppCrashAdvise3.cpp | 14 ++ .../entry/src/main/cpp/CppCrashAdvise4.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse1.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse2.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse3.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse4.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse5.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse6.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalyse7.cpp | 14 ++ .../src/main/cpp/CppCrashCaseAnalysis8.cpp | 14 ++ .../src/main/cpp/CppCrashQuestionCheck1.cpp | 14 ++ .../src/main/cpp/CppCrashQuestionCheck2.cpp | 14 ++ CppCrash/entry/src/main/cpp/napi_init.cpp | 15 ++ .../entry/src/main/cpp/address_problems.cpp | 15 ++ .../src/main/cpp/address_sanitizer_case1.cpp | 15 ++ .../src/main/cpp/address_sanitizer_case2.cpp | 15 ++ .../src/main/cpp/address_sanitizer_case3.cpp | 14 ++ .../src/main/cpp/address_sanitizer_case4.cpp | 14 ++ .../entry/src/main/cpp/napi_init.cpp | 15 ++ .../entry/src/main/cpp/resource_leak.cpp | 17 ++- .../entry/src/main/cpp/task_demo1.cpp | 18 ++- .../entry/src/main/cpp/task_demo2.cpp | 15 ++ .../main/ets/pages/address_overflow_case.cpp | 15 ++ .../src/main/ets/pages/addressproblems.cpp | 15 ++ .../entry/src/main/ets/pages/setHwAsan.cpp | 4 +- .../oh_modules/@ohos/hamock/index.ets | 17 +++ .../oh_modules/@ohos/hypium/BuildProfile.ets | 17 +++ .../oh_modules/@ohos/hypium/index.ets | 137 ++++++++++++++++++ .../.ohpm/oh_modules/@ohos/hamock/index.ets | 17 +++ .../oh_modules/@ohos/hypium/BuildProfile.ets | 17 +++ .../.ohpm/oh_modules/@ohos/hypium/index.ets | 137 ++++++++++++++++++ .../oh_modules/@ohos/hamock/index.ets | 17 +++ .../oh_modules/@ohos/hypium/BuildProfile.ets | 17 +++ .../oh_modules/@ohos/hypium/index.ets | 137 ++++++++++++++++++ .../src/main/cpp/JSFinalizationRegistry.cpp | 15 ++ .../entry/src/main/ets/pages/arkmem.ets | 15 ++ 42 files changed, 984 insertions(+), 8 deletions(-) create mode 100644 MemoryDetection/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets create mode 100644 MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets create mode 100644 MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets create mode 100644 MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hamock/index.ets create mode 100644 MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/BuildProfile.ets create mode 100644 MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/index.ets create mode 100644 MemoryDetection/oh_modules/@ohos/hamock/index.ets create mode 100644 MemoryDetection/oh_modules/@ohos/hypium/BuildProfile.ets create mode 100644 MemoryDetection/oh_modules/@ohos/hypium/index.ets diff --git a/AppFreeze/entry/src/main/cpp/AppFreezeCase.cpp b/AppFreeze/entry/src/main/cpp/AppFreezeCase.cpp index 71ef72c8..2edf7ba5 100644 --- a/AppFreeze/entry/src/main/cpp/AppFreezeCase.cpp +++ b/AppFreeze/entry/src/main/cpp/AppFreezeCase.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:AppFreeze 类问题优化建议 */ diff --git a/AppFreeze/entry/src/main/cpp/napi_init.cpp b/AppFreeze/entry/src/main/cpp/napi_init.cpp index 85330e3e..d0e1aafc 100644 --- a/AppFreeze/entry/src/main/cpp/napi_init.cpp +++ b/AppFreeze/entry/src/main/cpp/napi_init.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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 "napi/native_api.h" static napi_value Add(napi_env env, napi_callback_info info) diff --git a/AppFreeze/entry/src/main/ets/pages/Index.ets b/AppFreeze/entry/src/main/ets/pages/Index.ets index 8e2d24ad..0f481f69 100644 --- a/AppFreeze/entry/src/main/ets/pages/Index.ets +++ b/AppFreeze/entry/src/main/ets/pages/Index.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + @Entry @Component struct Index { diff --git a/AppFreeze/entry/src/main/ets/pages/appfreezecase.ets b/AppFreeze/entry/src/main/ets/pages/appfreezecase.ets index 347b2343..532fb3f5 100644 --- a/AppFreeze/entry/src/main/ets/pages/appfreezecase.ets +++ b/AppFreeze/entry/src/main/ets/pages/appfreezecase.ets @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:应用冻屏优化建议 */ @@ -36,7 +50,7 @@ function xxxFunction1(fileUris : string[]): void { // [End appfreeze_advise3] // [Start appfreeze_case_3_positive] -async function xxxFunction2(fileUris : string[]): void { +async function xxxFunction2(fileUris : string[]) : Promise { // ... AppStorage.setOrCreate('isLoadingPic', true); // 用于页面 load 效果展示 for (const fileuri of fileUris) { diff --git a/CppCrash/entry/src/main/cpp/CppCrashAdvise1.cpp b/CppCrash/entry/src/main/cpp/CppCrashAdvise1.cpp index 09dc20fc..c8ff6d68 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashAdvise1.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashAdvise1.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:CppCrash类问题优化建议 */ diff --git a/CppCrash/entry/src/main/cpp/CppCrashAdvise2.cpp b/CppCrash/entry/src/main/cpp/CppCrashAdvise2.cpp index 30dca841..be88d643 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashAdvise2.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashAdvise2.cpp @@ -1,4 +1,18 @@ -/** +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:CppCrash类问题优化建议 */ @@ -71,7 +85,7 @@ public: void Detection(std::string& url); void Detection2(std::string& url); static bool DoCheck(const std::string& url); - + private: EventHandler handler; }; @@ -117,7 +131,7 @@ void Advise4Negative() // [Start cppcrash_advise_4_negative] std::shared_ptr smartPointer = nullptr; smartPointer->method(); -// [End cppcrash_advise_4_negative] +// [End cppcrash_advise_4_negative] } void Advise4Positive() diff --git a/CppCrash/entry/src/main/cpp/CppCrashAdvise3.cpp b/CppCrash/entry/src/main/cpp/CppCrashAdvise3.cpp index b9730ce4..ecb29b53 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashAdvise3.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashAdvise3.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:CppCrash类问题优化建议 */ diff --git a/CppCrash/entry/src/main/cpp/CppCrashAdvise4.cpp b/CppCrash/entry/src/main/cpp/CppCrashAdvise4.cpp index 7591dce5..0bc9ae45 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashAdvise4.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashAdvise4.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:CppCrash类问题优化建议 */ diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse1.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse1.cpp index c1f95605..ef8210d5 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse1.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse1.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse2.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse2.cpp index 5bd9cd2f..23597d36 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse2.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse2.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse3.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse3.cpp index ef27751c..07542259 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse3.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse3.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse4.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse4.cpp index 6470aca3..051d2264 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse4.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse4.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse5.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse5.cpp index 1b98e3e4..b08255b4 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse5.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse5.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse6.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse6.cpp index 8c86cf54..497b2548 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse6.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse6.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse7.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse7.cpp index f0dbbc4a..bea460a3 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse7.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalyse7.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/7/17. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalysis8.cpp b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalysis8.cpp index 181ed95b..7d0fd92f 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashCaseAnalysis8.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashCaseAnalysis8.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:CppCrash类问题案例 */ diff --git a/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck1.cpp b/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck1.cpp index 0c500d7f..4fda3d97 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck1.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck1.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck2.cpp b/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck2.cpp index eb59cab3..87750a9d 100644 --- a/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck2.cpp +++ b/CppCrash/entry/src/main/cpp/CppCrashQuestionCheck2.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ // // Created on 2025/5/20. // diff --git a/CppCrash/entry/src/main/cpp/napi_init.cpp b/CppCrash/entry/src/main/cpp/napi_init.cpp index 487c3b3a..cd551ed9 100644 --- a/CppCrash/entry/src/main/cpp/napi_init.cpp +++ b/CppCrash/entry/src/main/cpp/napi_init.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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 "napi/native_api.h" // [Start cppcrash_case_4] diff --git a/MemoryDetection/entry/src/main/cpp/address_problems.cpp b/MemoryDetection/entry/src/main/cpp/address_problems.cpp index e9d0ac63..100375f1 100644 --- a/MemoryDetection/entry/src/main/cpp/address_problems.cpp +++ b/MemoryDetection/entry/src/main/cpp/address_problems.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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 /** diff --git a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case1.cpp b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case1.cpp index 3eabefe8..bdf9ca23 100644 --- a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case1.cpp +++ b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case1.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:地址越界优化建议 */ diff --git a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case2.cpp b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case2.cpp index 8874a926..7aeaaed0 100644 --- a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case2.cpp +++ b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case2.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:地址越界优化建议 */ diff --git a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case3.cpp b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case3.cpp index 8f9048db..0fb1f7eb 100644 --- a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case3.cpp +++ b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case3.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:地址越界优化建议 */ diff --git a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case4.cpp b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case4.cpp index 8e6cad94..8a7d7d06 100644 --- a/MemoryDetection/entry/src/main/cpp/address_sanitizer_case4.cpp +++ b/MemoryDetection/entry/src/main/cpp/address_sanitizer_case4.cpp @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2025 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. + */ /** * 最佳实践:地址越界优化建议 */ diff --git a/MemoryDetection/entry/src/main/cpp/napi_init.cpp b/MemoryDetection/entry/src/main/cpp/napi_init.cpp index f2008a97..f4d91633 100644 --- a/MemoryDetection/entry/src/main/cpp/napi_init.cpp +++ b/MemoryDetection/entry/src/main/cpp/napi_init.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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 "napi/native_api.h" #include diff --git a/MemoryDetection/entry/src/main/cpp/resource_leak.cpp b/MemoryDetection/entry/src/main/cpp/resource_leak.cpp index fa2524b8..2e2a01ab 100644 --- a/MemoryDetection/entry/src/main/cpp/resource_leak.cpp +++ b/MemoryDetection/entry/src/main/cpp/resource_leak.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:资源泄漏类问题优化建议 */ @@ -150,7 +165,7 @@ class Task {}; // [Start resource_leak_advise5_positive] class ThreadPool { // 线程池实现,支持线程生命周期管理和回收 -public: +public: // ... static bool addTask(const Task& task) { // ... diff --git a/MemoryDetection/entry/src/main/cpp/task_demo1.cpp b/MemoryDetection/entry/src/main/cpp/task_demo1.cpp index 90088c64..ffe8dc5e 100644 --- a/MemoryDetection/entry/src/main/cpp/task_demo1.cpp +++ b/MemoryDetection/entry/src/main/cpp/task_demo1.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + // // Created on 2025/7/24. // @@ -34,4 +49,5 @@ void Run() { task->Start(); delete task; // 析构发生在 lambda 执行前 std::this_thread::sleep_for(std::chrono::milliseconds(1)); -} \ No newline at end of file +} +// [End address_sanitizer_advise2_negative] \ No newline at end of file diff --git a/MemoryDetection/entry/src/main/cpp/task_demo2.cpp b/MemoryDetection/entry/src/main/cpp/task_demo2.cpp index a32a5dc3..e7723ad5 100644 --- a/MemoryDetection/entry/src/main/cpp/task_demo2.cpp +++ b/MemoryDetection/entry/src/main/cpp/task_demo2.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + // // Created on 2025/7/24. // diff --git a/MemoryDetection/entry/src/main/ets/pages/address_overflow_case.cpp b/MemoryDetection/entry/src/main/ets/pages/address_overflow_case.cpp index 779b7d23..37af9067 100644 --- a/MemoryDetection/entry/src/main/ets/pages/address_overflow_case.cpp +++ b/MemoryDetection/entry/src/main/ets/pages/address_overflow_case.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:地址越界问题案例 */ diff --git a/MemoryDetection/entry/src/main/ets/pages/addressproblems.cpp b/MemoryDetection/entry/src/main/ets/pages/addressproblems.cpp index 056bec8c..80960fed 100644 --- a/MemoryDetection/entry/src/main/ets/pages/addressproblems.cpp +++ b/MemoryDetection/entry/src/main/ets/pages/addressproblems.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:地址越界经典问题类型 * heap-use-after-free diff --git a/MemoryDetection/entry/src/main/ets/pages/setHwAsan.cpp b/MemoryDetection/entry/src/main/ets/pages/setHwAsan.cpp index 4f1d448c..2647db95 100644 --- a/MemoryDetection/entry/src/main/ets/pages/setHwAsan.cpp +++ b/MemoryDetection/entry/src/main/ets/pages/setHwAsan.cpp @@ -4,7 +4,7 @@ */ // [Start hw_asan_hvigorw] -hvigorw [taskNames...] -p ohos-enable-hwasan=true +hvigorw [taskNames...] -p ohos-enable-hwasan=true // [End hw_asan_hvigorw] /** @@ -13,7 +13,7 @@ hvigorw [taskNames...] -p ohos-enable-hwasan=true */ // [Start hw_asan_hvigorw_two] -hvigorw [taskNames...] +hvigorw [taskNames...] // [End hw_asan_hvigorw_two] /** diff --git a/MemoryDetection/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets b/MemoryDetection/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets new file mode 100644 index 00000000..c3a47320 --- /dev/null +++ b/MemoryDetection/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export { MockSetup, MockKit, when } from './src/main/mock/MockKit'; +export { ArgumentMatchers } from './src/main/mock/ArgumentMatchers'; \ No newline at end of file diff --git a/MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets b/MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets new file mode 100644 index 00000000..07a9435e --- /dev/null +++ b/MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.21'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets b/MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets new file mode 100644 index 00000000..98b0ec55 --- /dev/null +++ b/MemoryDetection/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets @@ -0,0 +1,137 @@ +/* + * 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 + * + * 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. + */ + +import Core from './src/main/core'; +import {TestType, Size, Level, DEFAULT} from './src/main/Constant'; +import DataDriver from './src/main/module/config/DataDriver'; +import ExpectExtend from './src/main/module/assert/ExpectExtend'; +import OhReport from './src/main/module/report/OhReport'; +export { xdescribe, xit, describe, it } from './index.ts'; + +export declare class Hypium { + static setData(data: Object): void + static setTimeConfig(systemTime: Object): void + static hypiumTest(abilityDelegator: Object, abilityDelegatorArguments: Object, testsuite: Function): void + static set(key: string, value: Object): void + static get(key: string): Object + static registerAssert(customAssertion: Function): void + static unregisterAssert(customAssertion: string | Function): void + static hypiumWorkerTest(abilityDelegator: Object, abilityDelegatorArguments: Object, + testsuite: Function, workerPort: Object): void; + static hypiumInitWorkers(abilityDelegator: Object, scriptURL: string, workerNum: number, params: Object): void; +} + +export { + Core, + DataDriver, + ExpectExtend, + OhReport, + TestType, + Size, + Level, + DEFAULT +}; + +type allExpectType = Object | undefined | null + +export declare function beforeItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function afterItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function beforeEach(callback: Function): void + +export declare function afterEach(callback: Function): void + +export declare function beforeAll(callback: Function): void + +export declare function afterAll(callback: Function): void + +export declare interface Assert { + assertClose(expectValue: number, precision: number): void + assertContain(expectValue: allExpectType): void + assertEqual(expectValue: allExpectType): void + assertFail(): void + assertFalse(): void + assertTrue(): void + assertInstanceOf(expectValue: string): void + assertLarger(expectValue: number): void + assertLess(expectValue: number): void + assertNull(): void + assertThrowError(expectValue: string | Function): void + assertUndefined(): void + assertLargerOrEqual(expectValue: number):void + assertLessOrEqual(expectValue: number):void + assertNaN():void + assertNegUnlimited(): void + assertPosUnlimited(): void + not(): Assert; + assertDeepEquals(expectValue: allExpectType):void + assertPromiseIsPending(): Promise + assertPromiseIsRejected(): Promise + assertPromiseIsRejectedWith(expectValue?: allExpectType): Promise + assertPromiseIsRejectedWithError(...expectValue: allExpectType[]): Promise + assertPromiseIsResolved(): Promise + assertPromiseIsResolvedWith(expectValue?: allExpectType): Promise + message(msg: string): Assert +} + +export declare function expect(actualValue?: allExpectType): Assert + +export declare class ArgumentMatchers { + public static any: allExpectType; + public static anyString: string; + public static anyBoolean: Boolean; + public static anyNumber: Number; + public static anyObj: Object; + public static anyFunction: Function; + public static matchRegexs(regex: RegExp): void +} + +declare interface whenResult { + afterReturn: (value: allExpectType) => allExpectType + afterReturnNothing: () => undefined + afterAction: (action: allExpectType) => allExpectType + afterThrow: (e_msg: string) => string +} + +export declare function when(f:Function): (...args: (allExpectType | void)[]) => whenResult + +export declare interface VerificationMode { + times(count: Number): void + never(): void + once(): void + atLeast(count: Number): void + atMost(count: Number): void +} + +export declare class MockKit { + constructor() + mockFunc(obj: Object, func: Function): Function + mockObject(obj: Object): Object + verify(methodName: String, argsArray: Array): VerificationMode + ignoreMock(obj: Object, func: Function): void + clear(obj: Object): void + clearAll(): void +} + +export declare class SysTestKit { + static getDescribeName(): string; + static getItName(): string; + static getItAttribute(): TestType | Size | Level + static actionStart(tag: string): void + static actionEnd(tag: string): void + static existKeyword(keyword: string, timeout?: number): boolean +} + diff --git a/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hamock/index.ets b/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hamock/index.ets new file mode 100644 index 00000000..c3a47320 --- /dev/null +++ b/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hamock/index.ets @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export { MockSetup, MockKit, when } from './src/main/mock/MockKit'; +export { ArgumentMatchers } from './src/main/mock/ArgumentMatchers'; \ No newline at end of file diff --git a/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/BuildProfile.ets b/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/BuildProfile.ets new file mode 100644 index 00000000..07a9435e --- /dev/null +++ b/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.21'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/index.ets b/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/index.ets new file mode 100644 index 00000000..98b0ec55 --- /dev/null +++ b/MemoryDetection/oh_modules/.ohpm/oh_modules/@ohos/hypium/index.ets @@ -0,0 +1,137 @@ +/* + * 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 + * + * 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. + */ + +import Core from './src/main/core'; +import {TestType, Size, Level, DEFAULT} from './src/main/Constant'; +import DataDriver from './src/main/module/config/DataDriver'; +import ExpectExtend from './src/main/module/assert/ExpectExtend'; +import OhReport from './src/main/module/report/OhReport'; +export { xdescribe, xit, describe, it } from './index.ts'; + +export declare class Hypium { + static setData(data: Object): void + static setTimeConfig(systemTime: Object): void + static hypiumTest(abilityDelegator: Object, abilityDelegatorArguments: Object, testsuite: Function): void + static set(key: string, value: Object): void + static get(key: string): Object + static registerAssert(customAssertion: Function): void + static unregisterAssert(customAssertion: string | Function): void + static hypiumWorkerTest(abilityDelegator: Object, abilityDelegatorArguments: Object, + testsuite: Function, workerPort: Object): void; + static hypiumInitWorkers(abilityDelegator: Object, scriptURL: string, workerNum: number, params: Object): void; +} + +export { + Core, + DataDriver, + ExpectExtend, + OhReport, + TestType, + Size, + Level, + DEFAULT +}; + +type allExpectType = Object | undefined | null + +export declare function beforeItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function afterItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function beforeEach(callback: Function): void + +export declare function afterEach(callback: Function): void + +export declare function beforeAll(callback: Function): void + +export declare function afterAll(callback: Function): void + +export declare interface Assert { + assertClose(expectValue: number, precision: number): void + assertContain(expectValue: allExpectType): void + assertEqual(expectValue: allExpectType): void + assertFail(): void + assertFalse(): void + assertTrue(): void + assertInstanceOf(expectValue: string): void + assertLarger(expectValue: number): void + assertLess(expectValue: number): void + assertNull(): void + assertThrowError(expectValue: string | Function): void + assertUndefined(): void + assertLargerOrEqual(expectValue: number):void + assertLessOrEqual(expectValue: number):void + assertNaN():void + assertNegUnlimited(): void + assertPosUnlimited(): void + not(): Assert; + assertDeepEquals(expectValue: allExpectType):void + assertPromiseIsPending(): Promise + assertPromiseIsRejected(): Promise + assertPromiseIsRejectedWith(expectValue?: allExpectType): Promise + assertPromiseIsRejectedWithError(...expectValue: allExpectType[]): Promise + assertPromiseIsResolved(): Promise + assertPromiseIsResolvedWith(expectValue?: allExpectType): Promise + message(msg: string): Assert +} + +export declare function expect(actualValue?: allExpectType): Assert + +export declare class ArgumentMatchers { + public static any: allExpectType; + public static anyString: string; + public static anyBoolean: Boolean; + public static anyNumber: Number; + public static anyObj: Object; + public static anyFunction: Function; + public static matchRegexs(regex: RegExp): void +} + +declare interface whenResult { + afterReturn: (value: allExpectType) => allExpectType + afterReturnNothing: () => undefined + afterAction: (action: allExpectType) => allExpectType + afterThrow: (e_msg: string) => string +} + +export declare function when(f:Function): (...args: (allExpectType | void)[]) => whenResult + +export declare interface VerificationMode { + times(count: Number): void + never(): void + once(): void + atLeast(count: Number): void + atMost(count: Number): void +} + +export declare class MockKit { + constructor() + mockFunc(obj: Object, func: Function): Function + mockObject(obj: Object): Object + verify(methodName: String, argsArray: Array): VerificationMode + ignoreMock(obj: Object, func: Function): void + clear(obj: Object): void + clearAll(): void +} + +export declare class SysTestKit { + static getDescribeName(): string; + static getItName(): string; + static getItAttribute(): TestType | Size | Level + static actionStart(tag: string): void + static actionEnd(tag: string): void + static existKeyword(keyword: string, timeout?: number): boolean +} + diff --git a/MemoryDetection/oh_modules/@ohos/hamock/index.ets b/MemoryDetection/oh_modules/@ohos/hamock/index.ets new file mode 100644 index 00000000..c3a47320 --- /dev/null +++ b/MemoryDetection/oh_modules/@ohos/hamock/index.ets @@ -0,0 +1,17 @@ +/* + * 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. + */ + +export { MockSetup, MockKit, when } from './src/main/mock/MockKit'; +export { ArgumentMatchers } from './src/main/mock/ArgumentMatchers'; \ No newline at end of file diff --git a/MemoryDetection/oh_modules/@ohos/hypium/BuildProfile.ets b/MemoryDetection/oh_modules/@ohos/hypium/BuildProfile.ets new file mode 100644 index 00000000..07a9435e --- /dev/null +++ b/MemoryDetection/oh_modules/@ohos/hypium/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.21'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/MemoryDetection/oh_modules/@ohos/hypium/index.ets b/MemoryDetection/oh_modules/@ohos/hypium/index.ets new file mode 100644 index 00000000..98b0ec55 --- /dev/null +++ b/MemoryDetection/oh_modules/@ohos/hypium/index.ets @@ -0,0 +1,137 @@ +/* + * 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 + * + * 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. + */ + +import Core from './src/main/core'; +import {TestType, Size, Level, DEFAULT} from './src/main/Constant'; +import DataDriver from './src/main/module/config/DataDriver'; +import ExpectExtend from './src/main/module/assert/ExpectExtend'; +import OhReport from './src/main/module/report/OhReport'; +export { xdescribe, xit, describe, it } from './index.ts'; + +export declare class Hypium { + static setData(data: Object): void + static setTimeConfig(systemTime: Object): void + static hypiumTest(abilityDelegator: Object, abilityDelegatorArguments: Object, testsuite: Function): void + static set(key: string, value: Object): void + static get(key: string): Object + static registerAssert(customAssertion: Function): void + static unregisterAssert(customAssertion: string | Function): void + static hypiumWorkerTest(abilityDelegator: Object, abilityDelegatorArguments: Object, + testsuite: Function, workerPort: Object): void; + static hypiumInitWorkers(abilityDelegator: Object, scriptURL: string, workerNum: number, params: Object): void; +} + +export { + Core, + DataDriver, + ExpectExtend, + OhReport, + TestType, + Size, + Level, + DEFAULT +}; + +type allExpectType = Object | undefined | null + +export declare function beforeItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function afterItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function beforeEach(callback: Function): void + +export declare function afterEach(callback: Function): void + +export declare function beforeAll(callback: Function): void + +export declare function afterAll(callback: Function): void + +export declare interface Assert { + assertClose(expectValue: number, precision: number): void + assertContain(expectValue: allExpectType): void + assertEqual(expectValue: allExpectType): void + assertFail(): void + assertFalse(): void + assertTrue(): void + assertInstanceOf(expectValue: string): void + assertLarger(expectValue: number): void + assertLess(expectValue: number): void + assertNull(): void + assertThrowError(expectValue: string | Function): void + assertUndefined(): void + assertLargerOrEqual(expectValue: number):void + assertLessOrEqual(expectValue: number):void + assertNaN():void + assertNegUnlimited(): void + assertPosUnlimited(): void + not(): Assert; + assertDeepEquals(expectValue: allExpectType):void + assertPromiseIsPending(): Promise + assertPromiseIsRejected(): Promise + assertPromiseIsRejectedWith(expectValue?: allExpectType): Promise + assertPromiseIsRejectedWithError(...expectValue: allExpectType[]): Promise + assertPromiseIsResolved(): Promise + assertPromiseIsResolvedWith(expectValue?: allExpectType): Promise + message(msg: string): Assert +} + +export declare function expect(actualValue?: allExpectType): Assert + +export declare class ArgumentMatchers { + public static any: allExpectType; + public static anyString: string; + public static anyBoolean: Boolean; + public static anyNumber: Number; + public static anyObj: Object; + public static anyFunction: Function; + public static matchRegexs(regex: RegExp): void +} + +declare interface whenResult { + afterReturn: (value: allExpectType) => allExpectType + afterReturnNothing: () => undefined + afterAction: (action: allExpectType) => allExpectType + afterThrow: (e_msg: string) => string +} + +export declare function when(f:Function): (...args: (allExpectType | void)[]) => whenResult + +export declare interface VerificationMode { + times(count: Number): void + never(): void + once(): void + atLeast(count: Number): void + atMost(count: Number): void +} + +export declare class MockKit { + constructor() + mockFunc(obj: Object, func: Function): Function + mockObject(obj: Object): Object + verify(methodName: String, argsArray: Array): VerificationMode + ignoreMock(obj: Object, func: Function): void + clear(obj: Object): void + clearAll(): void +} + +export declare class SysTestKit { + static getDescribeName(): string; + static getItName(): string; + static getItAttribute(): TestType | Size | Level + static actionStart(tag: string): void + static actionEnd(tag: string): void + static existKeyword(keyword: string, timeout?: number): boolean +} + diff --git a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/cpp/JSFinalizationRegistry.cpp b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/cpp/JSFinalizationRegistry.cpp index 0e722b1b..a15f924b 100644 --- a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/cpp/JSFinalizationRegistry.cpp +++ b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/cpp/JSFinalizationRegistry.cpp @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 源码请参考:https://gitee.com/openharmony/arkcompiler_ets_runtime */ diff --git a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/pages/arkmem.ets b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/pages/arkmem.ets index 7c198800..d5274f51 100644 --- a/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/pages/arkmem.ets +++ b/PerformanceAnalysis/ArkTSMemAnalysis/entry/src/main/ets/pages/arkmem.ets @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2025 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. + */ + /** * 最佳实践:分析ArkTS/JS内存 */ -- Gitee