diff --git a/AppFreeze/entry/src/main/cpp/AppFreezeCase.cpp b/AppFreeze/entry/src/main/cpp/AppFreezeCase.cpp index 71ef72c8d27da8b4df2204534d44e94a82a96f7f..2edf7ba5785dba8d46a2c438c5dc4466daf52d15 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 85330e3e84d1f6c8a82e544fb315483ca597d23d..d0e1aafcb6b5c3252ef439d9d9d54e8c082fda1d 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 8e2d24ad42693fc877d51bb7820f0a9da68fa135..0f481f696485b8c840d49ad9e7d7dff7f6b71241 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 347b2343f24cbdbac2c20cfd2a0525fe80763411..532fb3f5a8b0e700c010681041650696d4dce601 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 09dc20fc3477d179f899491c434656c40204b9ae..c8ff6d68c40f0f5626466352a55d8fcb0dd3a705 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 30dca84116e3f438624632eee526da69067b31fd..be88d64332a59fc530227ebcb034bdc190dc5d6e 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 b9730ce4a0b09941b9cba0101faa6e52e1cee56d..ecb29b539e082565d1224f484eadea6a6e8be236 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 7591dce5b756fed5cf9dc91ed84794f577e597f1..0bc9ae4526b36a8f4e6645dfaab587e0211e18e9 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 c1f95605b420cb22e313bc257263f1f952b3484c..ef8210d5d23351718515c1119b50b1aca9b3bf21 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 5bd9cd2fcbdfb35fc1e78aa26ff6fa517c4e393a..23597d368f26c1faf45a6e77045b7898cf0ec378 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 ef27751c70c71c84e953426a2970f0a607e0cd58..07542259f083a6e9e40e8c299bc1a4886c6dd2dd 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 6470aca3eb6fe4c54bb53e0156c05175a576e0fb..051d22645dd1f3630c332306c1567d2b031c91bd 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 1b98e3e434f21736d8f820423bb220737d023c15..b08255b45a434d513474b4c0c9caddaa3547c8f7 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 8c86cf54a774ae8d5b03c0556c7181024e4d3f50..497b2548e68a8856d10e5510d18efe3f7f5bebad 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 f0dbbc4a7526d4dd8a251c2584b9a363bbb3f86f..bea460a3fe27c0a3278435a87cace9050b5307ef 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 181ed95b77b3265519a5837c5416b87ffee67440..7d0fd92f0a505e0b3e7e3dfccc47c8154e227962 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 0c500d7fb38da6ca787144eb27324008e07693ea..4fda3d978ae3bfad0b04707a5643994433e46de0 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 eb59cab385f724ea787ed9d875f46b2e60021d17..87750a9dc4578b80e6161233e04ba87610c57667 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 487c3b3a9c816d94696c722f3a58980c17fb730b..cd551ed9666be7454a1e63ae0bed3a5aa751a41e 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 e9d0ac63ad797e9b51a4fda983a5ffa40566e37f..100375f18c5e6f4e4953f5806bb834810e929459 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 3eabefe8d43380d9553bbe2db5a1d9d3ea73bcaf..bdf9ca2371ed99f6a86de35a5438db84c267e691 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 8874a926bc3d479fbf5e14a0f01f5eb4dd7c0778..7aeaaed0a909522670b647de687daaa43cf66731 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 8f9048dbc7fd24ca0ca326f554b8e173764d31da..0fb1f7eb1c2ab933ebb2b3ad48119ae46d03ac7f 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 8e6cad94376d5c31817a5316e8656aba31af9778..8a7d7d067a4cbcb056f874c1861fb1d8256e40f8 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 f2008a97506d4d23bfad0e6c789dc9ce7af76cb9..f4d9163372b744823a140f23a0bab4111775911d 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 fa2524b85928a6b391713f7230f53da47dee781f..2e2a01ab3e835b0afb656313bd87bb5547e23104 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 90088c64e3eacd715e99748302a45856db403c29..ffe8dc5e304fadc6dfef054c9955a92d5871920f 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 a32a5dc357009901b08e855a26a59ed7e55d6d20..e7723ad5dee25f042cf65ed752b4ac414560763a 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 779b7d23b7b8a998ef2bb3b025dab3638bca488d..37af9067efe1f242dbd6fe0c785005762e6c0ef0 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 056bec8c1c177893c9d44642a869f1e6641b2f5e..80960fedd68d03a29bcb78332ed8a41e7aa5e8c7 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 4f1d448c4819d2171b6e52f1f7643ce92b7843ad..2647db9584d518ad5e644dcaf0c016b009d6400f 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 0000000000000000000000000000000000000000..c3a47320c2b674216cccde0fe217dbb8423625cc --- /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 0000000000000000000000000000000000000000..07a9435e8f20c3bbc675b385892b655db01fbada --- /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 0000000000000000000000000000000000000000..98b0ec55fe1e1d9d0a9b8a4eacc0a3c1a8091d1e --- /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 0000000000000000000000000000000000000000..c3a47320c2b674216cccde0fe217dbb8423625cc --- /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 0000000000000000000000000000000000000000..07a9435e8f20c3bbc675b385892b655db01fbada --- /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 0000000000000000000000000000000000000000..98b0ec55fe1e1d9d0a9b8a4eacc0a3c1a8091d1e --- /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 0000000000000000000000000000000000000000..c3a47320c2b674216cccde0fe217dbb8423625cc --- /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 0000000000000000000000000000000000000000..07a9435e8f20c3bbc675b385892b655db01fbada --- /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 0000000000000000000000000000000000000000..98b0ec55fe1e1d9d0a9b8a4eacc0a3c1a8091d1e --- /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 0e722b1b64f5a280e67d46961d56d09e80e8e9fd..a15f924b0b8c3fc12dbe54cb45c144392fc88fa1 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 7c198800ab62b72271317949c35ce9b0e4f85347..d5274f51f2b69790847e2a6fcf56a81c802ed6d3 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内存 */