11401458bSopenharmony_ci/* 21401458bSopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 31401458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41401458bSopenharmony_ci * you may not use this file except in compliance with the License. 51401458bSopenharmony_ci * You may obtain a copy of the License at 61401458bSopenharmony_ci * 71401458bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81401458bSopenharmony_ci * 91401458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101401458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111401458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121401458bSopenharmony_ci * See the License for the specific language governing permissions and 131401458bSopenharmony_ci * limitations under the License. 141401458bSopenharmony_ci */ 151401458bSopenharmony_ci#include <chrono> 161401458bSopenharmony_ci#include <cinttypes> 171401458bSopenharmony_ci#include <cstring> 181401458bSopenharmony_ci#include <map> 191401458bSopenharmony_ci#include <unistd.h> 201401458bSopenharmony_ci 211401458bSopenharmony_ci#include <gtest/gtest.h> 221401458bSopenharmony_ci#include "hilog/log.h" 231401458bSopenharmony_ci#include "hisysevent_manager_c.h" 241401458bSopenharmony_ci#include "hisysevent_record_c.h" 251401458bSopenharmony_ci#include "ret_code.h" 261401458bSopenharmony_ci#include "string_util.h" 271401458bSopenharmony_ci 281401458bSopenharmony_ciusing namespace testing::ext; 291401458bSopenharmony_ciusing namespace OHOS::HiviewDFX; 301401458bSopenharmony_ci 311401458bSopenharmony_ci#undef LOG_DOMAIN 321401458bSopenharmony_ci#define LOG_DOMAIN 0xD002D08 331401458bSopenharmony_ci 341401458bSopenharmony_ci#undef LOG_TAG 351401458bSopenharmony_ci#define LOG_TAG "HISYSEVENT_MANAGER_C_TEST" 361401458bSopenharmony_ci 371401458bSopenharmony_cinamespace { 381401458bSopenharmony_ciconstexpr int64_t MAX_NUM_OF_QUERY = 10; 391401458bSopenharmony_ciconstexpr size_t MAX_LEN_OF_DOMAIN = 16; 401401458bSopenharmony_ciconstexpr size_t MAX_LEN_OF_NAME = 32; 411401458bSopenharmony_ciconstexpr char TEST_DOMAIN[] = "HIVIEWDFX"; 421401458bSopenharmony_ciconstexpr char TEST_NAME[] = "PLUGIN_LOAD"; 431401458bSopenharmony_ciconstexpr uint32_t QUERY_INTERVAL_TIME = 2; 441401458bSopenharmony_ciconstexpr int ERR_NULL = -1; 451401458bSopenharmony_ci 461401458bSopenharmony_ciint64_t GetMilliseconds() 471401458bSopenharmony_ci{ 481401458bSopenharmony_ci auto now = std::chrono::system_clock::now(); 491401458bSopenharmony_ci auto millisecs = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()); 501401458bSopenharmony_ci return millisecs.count(); 511401458bSopenharmony_ci} 521401458bSopenharmony_ci 531401458bSopenharmony_civoid InitQueryArg(HiSysEventQueryArg& arg) 541401458bSopenharmony_ci{ 551401458bSopenharmony_ci arg.beginTime = 0; 561401458bSopenharmony_ci arg.endTime = GetMilliseconds(); 571401458bSopenharmony_ci arg.maxEvents = MAX_NUM_OF_QUERY; 581401458bSopenharmony_ci} 591401458bSopenharmony_ci 601401458bSopenharmony_civoid InitQueryRule(HiSysEventQueryRule& rule) 611401458bSopenharmony_ci{ 621401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 631401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.eventList[0], TEST_NAME, MAX_LEN_OF_NAME); 641401458bSopenharmony_ci rule.eventListSize = 1; 651401458bSopenharmony_ci rule.condition = nullptr; 661401458bSopenharmony_ci} 671401458bSopenharmony_ci 681401458bSopenharmony_civoid InitQueryRuleWithCondition(HiSysEventQueryRule& rule, const std::string& cond) 691401458bSopenharmony_ci{ 701401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 711401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.eventList[0], TEST_NAME, MAX_LEN_OF_NAME); 721401458bSopenharmony_ci rule.eventListSize = 1; 731401458bSopenharmony_ci (void)StringUtil::CreateCString(&rule.condition, cond); 741401458bSopenharmony_ci} 751401458bSopenharmony_ci 761401458bSopenharmony_civoid RecordBaseParamPrint(const HiSysEventRecord& record) 771401458bSopenharmony_ci{ 781401458bSopenharmony_ci HILOG_DEBUG(LOG_CORE, "event: domain=%{public}s, name=%{public}s, type=%{public}d, tz=%{public}s, " 791401458bSopenharmony_ci "time=%{public}" PRIu64 ", pid=%{public}" PRId64 ", tid=%{public}" PRId64 ", uid=%{public}" 801401458bSopenharmony_ci PRId64 ", traceId=%{public}" PRIu64 ", spandId=%{public}" PRIu64 ", pspanId=%{public}" 811401458bSopenharmony_ci PRIu64 ", level=%{public}s" ", tag=%{public}s", 821401458bSopenharmony_ci record.domain, record.eventName, record.type, 831401458bSopenharmony_ci record.tz, record.time, record.pid, record.tid, record.uid, 841401458bSopenharmony_ci record.traceId, record.spandId, record.pspanId, 851401458bSopenharmony_ci record.level, record.tag == nullptr ? "null" : record.tag); 861401458bSopenharmony_ci} 871401458bSopenharmony_ci 881401458bSopenharmony_civoid OnQueryTest(HiSysEventRecord records[], size_t size) 891401458bSopenharmony_ci{ 901401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "OnQuery: size of records is %{public}zu", size); 911401458bSopenharmony_ci for (size_t i = 0; i < size; i++) { 921401458bSopenharmony_ci HiSysEventRecord record = records[i]; 931401458bSopenharmony_ci ASSERT_EQ(strcmp(record.domain, TEST_DOMAIN), 0); 941401458bSopenharmony_ci ASSERT_GT(strlen(record.eventName), 0); 951401458bSopenharmony_ci ASSERT_GT(strlen(record.tz), 0); 961401458bSopenharmony_ci ASSERT_GT(record.type, 0); 971401458bSopenharmony_ci ASSERT_GT(record.time, 0); 981401458bSopenharmony_ci ASSERT_GE(record.pid, 0); 991401458bSopenharmony_ci ASSERT_GE(record.tid, 0); 1001401458bSopenharmony_ci ASSERT_GE(record.uid, 0); 1011401458bSopenharmony_ci ASSERT_GE(record.traceId, 0); 1021401458bSopenharmony_ci ASSERT_GE(record.spandId, 0); 1031401458bSopenharmony_ci ASSERT_GE(record.pspanId, 0); 1041401458bSopenharmony_ci ASSERT_GT(strlen(record.level), 0); 1051401458bSopenharmony_ci if (record.tag != nullptr) { 1061401458bSopenharmony_ci ASSERT_GT(strlen(record.tag), 0); 1071401458bSopenharmony_ci } 1081401458bSopenharmony_ci ASSERT_GT(strlen(record.jsonStr), 0); 1091401458bSopenharmony_ci RecordBaseParamPrint(record); 1101401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "OnQuery: event=%{public}s", record.jsonStr); 1111401458bSopenharmony_ci } 1121401458bSopenharmony_ci} 1131401458bSopenharmony_ci 1141401458bSopenharmony_civoid OnCompleteTest(int32_t reason, int32_t total) 1151401458bSopenharmony_ci{ 1161401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "OnCompleted, res=%{public}d, total=%{public}d", reason, total); 1171401458bSopenharmony_ci} 1181401458bSopenharmony_ci 1191401458bSopenharmony_civoid InitCallback(HiSysEventQueryCallback& callback) 1201401458bSopenharmony_ci{ 1211401458bSopenharmony_ci callback.OnQuery = OnQueryTest; 1221401458bSopenharmony_ci callback.OnComplete = OnCompleteTest; 1231401458bSopenharmony_ci} 1241401458bSopenharmony_ci 1251401458bSopenharmony_civoid OnEventTest(HiSysEventRecordC record) 1261401458bSopenharmony_ci{ 1271401458bSopenharmony_ci ASSERT_GT(strlen(record.jsonStr), 0); 1281401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "OnEvent: event=%{public}s", record.jsonStr); 1291401458bSopenharmony_ci} 1301401458bSopenharmony_ci 1311401458bSopenharmony_civoid OnServiceDiedTest() 1321401458bSopenharmony_ci{ 1331401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "OnServiceDied"); 1341401458bSopenharmony_ci} 1351401458bSopenharmony_ci 1361401458bSopenharmony_civoid InitWatcher(HiSysEventWatcher& watcher) 1371401458bSopenharmony_ci{ 1381401458bSopenharmony_ci watcher.OnEvent = OnEventTest; 1391401458bSopenharmony_ci watcher.OnServiceDied = OnServiceDiedTest; 1401401458bSopenharmony_ci} 1411401458bSopenharmony_ci 1421401458bSopenharmony_civoid QueryTestWithCondition(const std::string& cond) 1431401458bSopenharmony_ci{ 1441401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); // avoid triggering high frequency queries 1451401458bSopenharmony_ci HiSysEventQueryArg arg; 1461401458bSopenharmony_ci InitQueryArg(arg); 1471401458bSopenharmony_ci 1481401458bSopenharmony_ci HiSysEventQueryRule rule; 1491401458bSopenharmony_ci InitQueryRuleWithCondition(rule, cond); 1501401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 1511401458bSopenharmony_ci 1521401458bSopenharmony_ci HiSysEventQueryCallback callback; 1531401458bSopenharmony_ci InitCallback(callback); 1541401458bSopenharmony_ci 1551401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 1561401458bSopenharmony_ci ASSERT_EQ(res, 0); 1571401458bSopenharmony_ci StringUtil::DeletePointer<char>(&rule.condition); 1581401458bSopenharmony_ci} 1591401458bSopenharmony_ci 1601401458bSopenharmony_cistd::string BuildRecordString(const std::map<std::string, std::string>& recordData) 1611401458bSopenharmony_ci{ 1621401458bSopenharmony_ci std::string recordStr = "{"; 1631401458bSopenharmony_ci for (auto& recordParam : recordData) { 1641401458bSopenharmony_ci recordStr.append(recordParam.first).append(":").append(recordParam.second).append(","); 1651401458bSopenharmony_ci } 1661401458bSopenharmony_ci if (recordData.size() > 0) { 1671401458bSopenharmony_ci recordStr.pop_back(); 1681401458bSopenharmony_ci } 1691401458bSopenharmony_ci recordStr.append("}"); 1701401458bSopenharmony_ci return recordStr; 1711401458bSopenharmony_ci} 1721401458bSopenharmony_ci 1731401458bSopenharmony_civoid RecordParamNameTest(const HiSysEventRecord& record, const std::map<std::string, std::string>& recordData) 1741401458bSopenharmony_ci{ 1751401458bSopenharmony_ci char** params = nullptr; 1761401458bSopenharmony_ci size_t len = 0; 1771401458bSopenharmony_ci OH_HiSysEvent_GetParamNames(&record, ¶ms, &len); 1781401458bSopenharmony_ci ASSERT_EQ(len, recordData.size()); 1791401458bSopenharmony_ci for (size_t i = 0; i < len; i++) { 1801401458bSopenharmony_ci HILOG_DEBUG(LOG_CORE, "param[%{public}zu]=%{public}s", i, params[i]); 1811401458bSopenharmony_ci ASSERT_NE(recordData.find("\"" + std::string(params[i]) + "\""), recordData.end()); 1821401458bSopenharmony_ci } 1831401458bSopenharmony_ci StringUtil::DeletePointers<char>(¶ms, len); 1841401458bSopenharmony_ci} 1851401458bSopenharmony_ci 1861401458bSopenharmony_civoid RecordParamIntValueTest(const HiSysEventRecord& record, const std::string& name, int64_t value) 1871401458bSopenharmony_ci{ 1881401458bSopenharmony_ci int64_t testValue = 0; 1891401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamInt64Value(&record, name.c_str(), &testValue); 1901401458bSopenharmony_ci ASSERT_EQ(res, 0); 1911401458bSopenharmony_ci ASSERT_EQ(testValue, value); 1921401458bSopenharmony_ci} 1931401458bSopenharmony_ci 1941401458bSopenharmony_civoid RecordParamUintValueTest(const HiSysEventRecord& record, const std::string& name, uint64_t value) 1951401458bSopenharmony_ci{ 1961401458bSopenharmony_ci uint64_t testValue = 0; 1971401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamUint64Value(&record, name.c_str(), &testValue); 1981401458bSopenharmony_ci ASSERT_EQ(res, 0); 1991401458bSopenharmony_ci ASSERT_EQ(testValue, value); 2001401458bSopenharmony_ci} 2011401458bSopenharmony_ci 2021401458bSopenharmony_civoid RecordParamDouValueTest(const HiSysEventRecord& record, const std::string& name, double value) 2031401458bSopenharmony_ci{ 2041401458bSopenharmony_ci double testValue = 0; 2051401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamDoubleValue(&record, name.c_str(), &testValue); 2061401458bSopenharmony_ci ASSERT_EQ(res, 0); 2071401458bSopenharmony_ci ASSERT_EQ(testValue, value); 2081401458bSopenharmony_ci} 2091401458bSopenharmony_ci 2101401458bSopenharmony_civoid RecordParamStrValueTest(const HiSysEventRecord& record, const std::string& name, const std::string& value) 2111401458bSopenharmony_ci{ 2121401458bSopenharmony_ci char* testValue = nullptr; 2131401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamStringValue(&record, name.c_str(), &testValue); 2141401458bSopenharmony_ci ASSERT_EQ(res, 0); 2151401458bSopenharmony_ci ASSERT_EQ(strcmp(testValue, value.c_str()), 0); 2161401458bSopenharmony_ci StringUtil::DeletePointer<char>(&testValue); 2171401458bSopenharmony_ci} 2181401458bSopenharmony_ci 2191401458bSopenharmony_civoid RecordParamIntValuesTest(const HiSysEventRecord& record, const std::string& name, 2201401458bSopenharmony_ci const std::vector<int64_t>& values) 2211401458bSopenharmony_ci{ 2221401458bSopenharmony_ci int64_t* testValues = nullptr; 2231401458bSopenharmony_ci size_t len = 0; 2241401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamInt64Values(&record, name.c_str(), &testValues, &len); 2251401458bSopenharmony_ci ASSERT_EQ(res, 0); 2261401458bSopenharmony_ci ASSERT_EQ(values.size(), len); 2271401458bSopenharmony_ci for (size_t i = 0; i < len; i++) { 2281401458bSopenharmony_ci ASSERT_EQ(testValues[i], values[i]); 2291401458bSopenharmony_ci } 2301401458bSopenharmony_ci StringUtil::DeletePointer<int64_t>(&testValues); 2311401458bSopenharmony_ci} 2321401458bSopenharmony_ci 2331401458bSopenharmony_civoid RecordParamUintValuesTest(const HiSysEventRecord& record, const std::string& name, 2341401458bSopenharmony_ci const std::vector<uint64_t>& values) 2351401458bSopenharmony_ci{ 2361401458bSopenharmony_ci uint64_t* testValues = nullptr; 2371401458bSopenharmony_ci size_t len = 0; 2381401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamUint64Values(&record, name.c_str(), &testValues, &len); 2391401458bSopenharmony_ci ASSERT_EQ(res, 0); 2401401458bSopenharmony_ci ASSERT_EQ(values.size(), len); 2411401458bSopenharmony_ci for (size_t i = 0; i < len; i++) { 2421401458bSopenharmony_ci ASSERT_EQ(testValues[i], values[i]); 2431401458bSopenharmony_ci } 2441401458bSopenharmony_ci StringUtil::DeletePointer<uint64_t>(&testValues); 2451401458bSopenharmony_ci} 2461401458bSopenharmony_ci 2471401458bSopenharmony_civoid RecordParamDouValuesTest(const HiSysEventRecord& record, const std::string& name, 2481401458bSopenharmony_ci const std::vector<double>& values) 2491401458bSopenharmony_ci{ 2501401458bSopenharmony_ci double* testValues = nullptr; 2511401458bSopenharmony_ci size_t len = 0; 2521401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamDoubleValues(&record, name.c_str(), &testValues, &len); 2531401458bSopenharmony_ci ASSERT_EQ(res, 0); 2541401458bSopenharmony_ci ASSERT_EQ(values.size(), len); 2551401458bSopenharmony_ci for (size_t i = 0; i < len; i++) { 2561401458bSopenharmony_ci ASSERT_EQ(testValues[i], values[i]); 2571401458bSopenharmony_ci } 2581401458bSopenharmony_ci StringUtil::DeletePointer<double>(&testValues); 2591401458bSopenharmony_ci} 2601401458bSopenharmony_ci 2611401458bSopenharmony_civoid RecordParamStrValuesTest(const HiSysEventRecord& record, const std::string& name, 2621401458bSopenharmony_ci const std::vector<std::string>& values) 2631401458bSopenharmony_ci{ 2641401458bSopenharmony_ci char** testValues = nullptr; 2651401458bSopenharmony_ci size_t len = 0; 2661401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamStringValues(&record, name.c_str(), &testValues, &len); 2671401458bSopenharmony_ci ASSERT_EQ(res, 0); 2681401458bSopenharmony_ci for (size_t i = 0; i < len; i++) { 2691401458bSopenharmony_ci ASSERT_EQ(strcmp(testValues[i], values[i].c_str()), 0); 2701401458bSopenharmony_ci } 2711401458bSopenharmony_ci StringUtil::DeletePointers<char>(&testValues, len); 2721401458bSopenharmony_ci} 2731401458bSopenharmony_ci 2741401458bSopenharmony_civoid RecordParamNameInvalidTest(const HiSysEventRecord& record) 2751401458bSopenharmony_ci{ 2761401458bSopenharmony_ci char** params = nullptr; 2771401458bSopenharmony_ci size_t len = 0; 2781401458bSopenharmony_ci OH_HiSysEvent_GetParamNames(&record, ¶ms, &len); 2791401458bSopenharmony_ci ASSERT_EQ(len, 0); 2801401458bSopenharmony_ci} 2811401458bSopenharmony_ci 2821401458bSopenharmony_civoid RecordParamIntValueInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 2831401458bSopenharmony_ci{ 2841401458bSopenharmony_ci int64_t testValue = 0; 2851401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamInt64Value(&record, name.c_str(), &testValue); 2861401458bSopenharmony_ci ASSERT_EQ(res, expRes); 2871401458bSopenharmony_ci} 2881401458bSopenharmony_ci 2891401458bSopenharmony_civoid RecordParamUintValueInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 2901401458bSopenharmony_ci{ 2911401458bSopenharmony_ci uint64_t testValue = 0; 2921401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamUint64Value(&record, name.c_str(), &testValue); 2931401458bSopenharmony_ci ASSERT_EQ(res, expRes); 2941401458bSopenharmony_ci} 2951401458bSopenharmony_ci 2961401458bSopenharmony_civoid RecordParamDouValueInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 2971401458bSopenharmony_ci{ 2981401458bSopenharmony_ci double testValue = 0; 2991401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamDoubleValue(&record, name.c_str(), &testValue); 3001401458bSopenharmony_ci ASSERT_EQ(res, expRes); 3011401458bSopenharmony_ci} 3021401458bSopenharmony_ci 3031401458bSopenharmony_civoid RecordParamStrValueInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 3041401458bSopenharmony_ci{ 3051401458bSopenharmony_ci char* testValue = nullptr; 3061401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamStringValue(&record, name.c_str(), &testValue); 3071401458bSopenharmony_ci ASSERT_EQ(res, expRes); 3081401458bSopenharmony_ci} 3091401458bSopenharmony_ci 3101401458bSopenharmony_civoid RecordParamIntValuesInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 3111401458bSopenharmony_ci{ 3121401458bSopenharmony_ci int64_t* testValues = nullptr; 3131401458bSopenharmony_ci size_t len = 0; 3141401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamInt64Values(&record, name.c_str(), &testValues, &len); 3151401458bSopenharmony_ci ASSERT_EQ(res, expRes); 3161401458bSopenharmony_ci} 3171401458bSopenharmony_ci 3181401458bSopenharmony_civoid RecordParamUintValuesInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 3191401458bSopenharmony_ci{ 3201401458bSopenharmony_ci uint64_t* testValues = nullptr; 3211401458bSopenharmony_ci size_t len = 0; 3221401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamUint64Values(&record, name.c_str(), &testValues, &len); 3231401458bSopenharmony_ci ASSERT_EQ(res, expRes); 3241401458bSopenharmony_ci} 3251401458bSopenharmony_ci 3261401458bSopenharmony_civoid RecordParamDouValuesInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 3271401458bSopenharmony_ci{ 3281401458bSopenharmony_ci double* testValues = nullptr; 3291401458bSopenharmony_ci size_t len = 0; 3301401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamDoubleValues(&record, name.c_str(), &testValues, &len); 3311401458bSopenharmony_ci ASSERT_EQ(res, expRes); 3321401458bSopenharmony_ci} 3331401458bSopenharmony_ci 3341401458bSopenharmony_civoid RecordParamStrValuesInvalidTest(const HiSysEventRecord& record, const std::string& name, int expRes) 3351401458bSopenharmony_ci{ 3361401458bSopenharmony_ci char** testValues = nullptr; 3371401458bSopenharmony_ci size_t len = 0; 3381401458bSopenharmony_ci int res = OH_HiSysEvent_GetParamStringValues(&record, name.c_str(), &testValues, &len); 3391401458bSopenharmony_ci ASSERT_EQ(res, expRes); 3401401458bSopenharmony_ci} 3411401458bSopenharmony_ci} 3421401458bSopenharmony_ci 3431401458bSopenharmony_ciclass HiSysEventManagerCTest : public testing::Test { 3441401458bSopenharmony_cipublic: 3451401458bSopenharmony_ci void SetUp(); 3461401458bSopenharmony_ci void TearDown(); 3471401458bSopenharmony_ci}; 3481401458bSopenharmony_ci 3491401458bSopenharmony_civoid HiSysEventManagerCTest::SetUp() 3501401458bSopenharmony_ci{} 3511401458bSopenharmony_ci 3521401458bSopenharmony_civoid HiSysEventManagerCTest::TearDown() 3531401458bSopenharmony_ci{} 3541401458bSopenharmony_ci 3551401458bSopenharmony_ci/** 3561401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest001 3571401458bSopenharmony_ci * @tc.desc: Testing to query events. 3581401458bSopenharmony_ci * @tc.type: FUNC 3591401458bSopenharmony_ci * @tc.require: issueI5X08B 3601401458bSopenharmony_ci */ 3611401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest001, TestSize.Level3) 3621401458bSopenharmony_ci{ 3631401458bSopenharmony_ci /** 3641401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 3651401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 3661401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 3671401458bSopenharmony_ci * @tc.steps: step4. query event. 3681401458bSopenharmony_ci */ 3691401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest001 start"); 3701401458bSopenharmony_ci HiSysEventQueryArg arg; 3711401458bSopenharmony_ci InitQueryArg(arg); 3721401458bSopenharmony_ci 3731401458bSopenharmony_ci HiSysEventQueryRule rule; 3741401458bSopenharmony_ci InitQueryRule(rule); 3751401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 3761401458bSopenharmony_ci 3771401458bSopenharmony_ci HiSysEventQueryCallback callback; 3781401458bSopenharmony_ci InitCallback(callback); 3791401458bSopenharmony_ci 3801401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 3811401458bSopenharmony_ci ASSERT_EQ(res, 0); 3821401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest001 end"); 3831401458bSopenharmony_ci} 3841401458bSopenharmony_ci 3851401458bSopenharmony_ci/** 3861401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest002 3871401458bSopenharmony_ci * @tc.desc: Testing to query events with condition. 3881401458bSopenharmony_ci * @tc.type: FUNC 3891401458bSopenharmony_ci * @tc.require: issueI5X08B 3901401458bSopenharmony_ci */ 3911401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest002, TestSize.Level3) 3921401458bSopenharmony_ci{ 3931401458bSopenharmony_ci /** 3941401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 3951401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 3961401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 3971401458bSopenharmony_ci * @tc.steps: step4. query event. 3981401458bSopenharmony_ci */ 3991401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest002 start"); 4001401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"NAME","op":"=", 4011401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 4021401458bSopenharmony_ci QueryTestWithCondition(cond); 4031401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest002 end"); 4041401458bSopenharmony_ci} 4051401458bSopenharmony_ci 4061401458bSopenharmony_ci/** 4071401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest003 4081401458bSopenharmony_ci * @tc.desc: Testing to query events with condition. 4091401458bSopenharmony_ci * @tc.type: FUNC 4101401458bSopenharmony_ci * @tc.require: issueI5X08B 4111401458bSopenharmony_ci */ 4121401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest003, TestSize.Level3) 4131401458bSopenharmony_ci{ 4141401458bSopenharmony_ci /** 4151401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 4161401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 4171401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 4181401458bSopenharmony_ci * @tc.steps: step4. query event. 4191401458bSopenharmony_ci */ 4201401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest003 start"); 4211401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"uid_","op":"=","value":1201}]}})~"; 4221401458bSopenharmony_ci QueryTestWithCondition(cond); 4231401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest003 end"); 4241401458bSopenharmony_ci} 4251401458bSopenharmony_ci 4261401458bSopenharmony_ci/** 4271401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest004 4281401458bSopenharmony_ci * @tc.desc: Testing to query events with condition. 4291401458bSopenharmony_ci * @tc.type: FUNC 4301401458bSopenharmony_ci * @tc.require: issueI5X08B 4311401458bSopenharmony_ci */ 4321401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest004, TestSize.Level3) 4331401458bSopenharmony_ci{ 4341401458bSopenharmony_ci /** 4351401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 4361401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 4371401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 4381401458bSopenharmony_ci * @tc.steps: step4. query event. 4391401458bSopenharmony_ci */ 4401401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest004 start"); 4411401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"pid_","op":">=","value":0}]}})~"; 4421401458bSopenharmony_ci QueryTestWithCondition(cond); 4431401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest004 end"); 4441401458bSopenharmony_ci} 4451401458bSopenharmony_ci 4461401458bSopenharmony_ci/** 4471401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest005 4481401458bSopenharmony_ci * @tc.desc: Testing to query events with condition. 4491401458bSopenharmony_ci * @tc.type: FUNC 4501401458bSopenharmony_ci * @tc.require: issueI5X08B 4511401458bSopenharmony_ci */ 4521401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest005, TestSize.Level3) 4531401458bSopenharmony_ci{ 4541401458bSopenharmony_ci /** 4551401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 4561401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 4571401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 4581401458bSopenharmony_ci * @tc.steps: step4. query event. 4591401458bSopenharmony_ci */ 4601401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest005 start"); 4611401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"type_","op":"<=","value":4}]}})~"; 4621401458bSopenharmony_ci QueryTestWithCondition(cond); 4631401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest005 end"); 4641401458bSopenharmony_ci} 4651401458bSopenharmony_ci 4661401458bSopenharmony_ci/** 4671401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest006 4681401458bSopenharmony_ci * @tc.desc: Testing to query events with condition. 4691401458bSopenharmony_ci * @tc.type: FUNC 4701401458bSopenharmony_ci * @tc.require: issueI5X08B 4711401458bSopenharmony_ci */ 4721401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest006, TestSize.Level3) 4731401458bSopenharmony_ci{ 4741401458bSopenharmony_ci /** 4751401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 4761401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 4771401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 4781401458bSopenharmony_ci * @tc.steps: step4. query event. 4791401458bSopenharmony_ci */ 4801401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest006 start"); 4811401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"pid_","op":">","value":0}]}})~"; 4821401458bSopenharmony_ci QueryTestWithCondition(cond); 4831401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest006 end"); 4841401458bSopenharmony_ci} 4851401458bSopenharmony_ci 4861401458bSopenharmony_ci/** 4871401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest007 4881401458bSopenharmony_ci * @tc.desc: Testing to query events with condition. 4891401458bSopenharmony_ci * @tc.type: FUNC 4901401458bSopenharmony_ci * @tc.require: issueI5X08B 4911401458bSopenharmony_ci */ 4921401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest007, TestSize.Level3) 4931401458bSopenharmony_ci{ 4941401458bSopenharmony_ci /** 4951401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 4961401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 4971401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 4981401458bSopenharmony_ci * @tc.steps: step4. query event. 4991401458bSopenharmony_ci */ 5001401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest007 start"); 5011401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"pid_","op":"<","value":0}]}})~"; 5021401458bSopenharmony_ci QueryTestWithCondition(cond); 5031401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest007 end"); 5041401458bSopenharmony_ci} 5051401458bSopenharmony_ci 5061401458bSopenharmony_ci/** 5071401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest008 5081401458bSopenharmony_ci * @tc.desc: Testing to query events with many rules. 5091401458bSopenharmony_ci * @tc.type: FUNC 5101401458bSopenharmony_ci * @tc.require: issueI5X08B 5111401458bSopenharmony_ci */ 5121401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest008, TestSize.Level3) 5131401458bSopenharmony_ci{ 5141401458bSopenharmony_ci /** 5151401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 5161401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 5171401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 5181401458bSopenharmony_ci * @tc.steps: step4. query event. 5191401458bSopenharmony_ci */ 5201401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest008 start"); 5211401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 5221401458bSopenharmony_ci HiSysEventQueryArg arg; 5231401458bSopenharmony_ci InitQueryArg(arg); 5241401458bSopenharmony_ci 5251401458bSopenharmony_ci HiSysEventQueryRule rule1; 5261401458bSopenharmony_ci (void)StringUtil::CopyCString(rule1.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 5271401458bSopenharmony_ci (void)StringUtil::CopyCString(rule1.eventList[0], TEST_NAME, MAX_LEN_OF_NAME); 5281401458bSopenharmony_ci (void)StringUtil::CopyCString(rule1.eventList[1], "PLUGIN_UNLOAD", MAX_LEN_OF_NAME); 5291401458bSopenharmony_ci rule1.eventListSize = 2; 5301401458bSopenharmony_ci HiSysEventQueryRule rule2; 5311401458bSopenharmony_ci (void)StringUtil::CopyCString(rule2.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 5321401458bSopenharmony_ci (void)StringUtil::CopyCString(rule2.eventList[0], "APP_USAGE", MAX_LEN_OF_NAME); 5331401458bSopenharmony_ci (void)StringUtil::CopyCString(rule2.eventList[1], "SYS_USAGE", MAX_LEN_OF_NAME); 5341401458bSopenharmony_ci rule2.eventListSize = 2; 5351401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule1, rule2 }; 5361401458bSopenharmony_ci 5371401458bSopenharmony_ci HiSysEventQueryCallback callback; 5381401458bSopenharmony_ci InitCallback(callback); 5391401458bSopenharmony_ci 5401401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 5411401458bSopenharmony_ci ASSERT_EQ(res, 0); 5421401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest008 end"); 5431401458bSopenharmony_ci} 5441401458bSopenharmony_ci 5451401458bSopenharmony_ci/** 5461401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest009 5471401458bSopenharmony_ci * @tc.desc: Testing to query events with many conditions. 5481401458bSopenharmony_ci * @tc.type: FUNC 5491401458bSopenharmony_ci * @tc.require: issueI5X08B 5501401458bSopenharmony_ci */ 5511401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest009, TestSize.Level3) 5521401458bSopenharmony_ci{ 5531401458bSopenharmony_ci /** 5541401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 5551401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 5561401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 5571401458bSopenharmony_ci * @tc.steps: step4. query event. 5581401458bSopenharmony_ci */ 5591401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest009 start"); 5601401458bSopenharmony_ci std::string cond1 = R"~({"version":"V1","condition":{"and":[{"param":"NAME","op":"=", 5611401458bSopenharmony_ci "value":"SysEventStore"},{"param":"uid_","op":"=","value":1201}]}})~"; 5621401458bSopenharmony_ci QueryTestWithCondition(cond1); 5631401458bSopenharmony_ci 5641401458bSopenharmony_ci std::string cond2 = R"~({"version":"V1","condition":{"and":[{"param":"type_","op":">","value":0}, 5651401458bSopenharmony_ci {"param":"uid_","op":"=","value":1201}]}})~"; 5661401458bSopenharmony_ci QueryTestWithCondition(cond2); 5671401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest009 end"); 5681401458bSopenharmony_ci} 5691401458bSopenharmony_ci 5701401458bSopenharmony_ci/** 5711401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest010 5721401458bSopenharmony_ci * @tc.desc: Testing to query events with many rules and condtions. 5731401458bSopenharmony_ci * @tc.type: FUNC 5741401458bSopenharmony_ci * @tc.require: issueI5X08B 5751401458bSopenharmony_ci */ 5761401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest010, TestSize.Level3) 5771401458bSopenharmony_ci{ 5781401458bSopenharmony_ci /** 5791401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 5801401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 5811401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 5821401458bSopenharmony_ci * @tc.steps: step4. query event. 5831401458bSopenharmony_ci */ 5841401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest010 start"); 5851401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 5861401458bSopenharmony_ci HiSysEventQueryArg arg; 5871401458bSopenharmony_ci InitQueryArg(arg); 5881401458bSopenharmony_ci 5891401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"time_","op":">", 5901401458bSopenharmony_ci "value":0},{"param":"type_","op":">","value":0}]}})~"; 5911401458bSopenharmony_ci HiSysEventQueryRule rule1; 5921401458bSopenharmony_ci (void)StringUtil::CopyCString(rule1.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 5931401458bSopenharmony_ci (void)StringUtil::CopyCString(rule1.eventList[0], TEST_NAME, MAX_LEN_OF_NAME); 5941401458bSopenharmony_ci (void)StringUtil::CopyCString(rule1.eventList[1], "PLUGIN_UNLOAD", MAX_LEN_OF_NAME); 5951401458bSopenharmony_ci rule1.eventListSize = 2; 5961401458bSopenharmony_ci (void)StringUtil::CreateCString(&rule1.condition, cond); 5971401458bSopenharmony_ci HiSysEventQueryRule rule2; 5981401458bSopenharmony_ci (void)StringUtil::CopyCString(rule2.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 5991401458bSopenharmony_ci (void)StringUtil::CopyCString(rule2.eventList[0], "APP_USAGE", MAX_LEN_OF_NAME); 6001401458bSopenharmony_ci (void)StringUtil::CopyCString(rule2.eventList[1], "SYS_USAGE", MAX_LEN_OF_NAME); 6011401458bSopenharmony_ci rule2.eventListSize = 2; 6021401458bSopenharmony_ci (void)StringUtil::CreateCString(&rule2.condition, cond); 6031401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule1, rule2 }; 6041401458bSopenharmony_ci 6051401458bSopenharmony_ci HiSysEventQueryCallback callback; 6061401458bSopenharmony_ci InitCallback(callback); 6071401458bSopenharmony_ci 6081401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 6091401458bSopenharmony_ci ASSERT_EQ(res, 0); 6101401458bSopenharmony_ci StringUtil::DeletePointer<char>(&rule1.condition); 6111401458bSopenharmony_ci StringUtil::DeletePointer<char>(&rule2.condition); 6121401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest010 end"); 6131401458bSopenharmony_ci} 6141401458bSopenharmony_ci 6151401458bSopenharmony_ci/** 6161401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest011 6171401458bSopenharmony_ci * @tc.desc: Testing to query events with invalid condition. 6181401458bSopenharmony_ci * @tc.type: FUNC 6191401458bSopenharmony_ci * @tc.require: issueI5X08B 6201401458bSopenharmony_ci */ 6211401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest011, TestSize.Level3) 6221401458bSopenharmony_ci{ 6231401458bSopenharmony_ci /** 6241401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 6251401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 6261401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 6271401458bSopenharmony_ci * @tc.steps: step4. query event. 6281401458bSopenharmony_ci */ 6291401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest011 start"); 6301401458bSopenharmony_ci 6311401458bSopenharmony_ci std::string cond1 = R"~({"version":"xx","condition":{}})~"; 6321401458bSopenharmony_ci QueryTestWithCondition(cond1); 6331401458bSopenharmony_ci 6341401458bSopenharmony_ci std::string cond2 = "invalid condition"; 6351401458bSopenharmony_ci QueryTestWithCondition(cond2); 6361401458bSopenharmony_ci 6371401458bSopenharmony_ci std::string cond3 = R"~({"version":"V1","condition":{"invalid":[]}})~"; 6381401458bSopenharmony_ci QueryTestWithCondition(cond3); 6391401458bSopenharmony_ci 6401401458bSopenharmony_ci std::string cond4 = R"~({"version":"V1","condition":{"and":[{"invalid":"PLUGIN_NAME","op":"=", 6411401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 6421401458bSopenharmony_ci QueryTestWithCondition(cond4); 6431401458bSopenharmony_ci 6441401458bSopenharmony_ci std::string cond5 = R"~({"version":"V1","condition":{"and":[{"param":"PLUGIN_NAME","invalid":"=", 6451401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 6461401458bSopenharmony_ci QueryTestWithCondition(cond5); 6471401458bSopenharmony_ci 6481401458bSopenharmony_ci std::string cond6 = R"~({"version":"V1","condition":{"and":[{"param":"PLUGIN_NAME","op":"**", 6491401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 6501401458bSopenharmony_ci QueryTestWithCondition(cond6); 6511401458bSopenharmony_ci 6521401458bSopenharmony_ci std::string cond7 = R"~({"version":"V1","condition":{"and":[{"param":"PLUGIN_NAME","op":"=", 6531401458bSopenharmony_ci "invalid":"SysEventStore"}]}})~"; 6541401458bSopenharmony_ci QueryTestWithCondition(cond7); 6551401458bSopenharmony_ci 6561401458bSopenharmony_ci std::string cond8 = R"~({"version":"V1","condition":{"and":[{"param":"PLUGIN_NAME","op":"=", 6571401458bSopenharmony_ci "value":[]}]}})~"; 6581401458bSopenharmony_ci QueryTestWithCondition(cond8); 6591401458bSopenharmony_ci 6601401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest011 end"); 6611401458bSopenharmony_ci} 6621401458bSopenharmony_ci 6631401458bSopenharmony_ci/** 6641401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest012 6651401458bSopenharmony_ci * @tc.desc: Testing to query events only with domain. 6661401458bSopenharmony_ci * @tc.type: FUNC 6671401458bSopenharmony_ci * @tc.require: issueI5X08B 6681401458bSopenharmony_ci */ 6691401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest012, TestSize.Level3) 6701401458bSopenharmony_ci{ 6711401458bSopenharmony_ci /** 6721401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 6731401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 6741401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 6751401458bSopenharmony_ci * @tc.steps: step4. query event. 6761401458bSopenharmony_ci */ 6771401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest012 start"); 6781401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 6791401458bSopenharmony_ci HiSysEventQueryArg arg; 6801401458bSopenharmony_ci InitQueryArg(arg); 6811401458bSopenharmony_ci HiSysEventQueryRule rule; 6821401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 6831401458bSopenharmony_ci rule.eventListSize = 0; 6841401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 6851401458bSopenharmony_ci HiSysEventQueryCallback callback; 6861401458bSopenharmony_ci InitCallback(callback); 6871401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 6881401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_RULE_INVALID); 6891401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest012 end"); 6901401458bSopenharmony_ci} 6911401458bSopenharmony_ci 6921401458bSopenharmony_ci/** 6931401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest013 6941401458bSopenharmony_ci * @tc.desc: Testing to query events only with name. 6951401458bSopenharmony_ci * @tc.type: FUNC 6961401458bSopenharmony_ci * @tc.require: issueI5X08B 6971401458bSopenharmony_ci */ 6981401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest013, TestSize.Level3) 6991401458bSopenharmony_ci{ 7001401458bSopenharmony_ci /** 7011401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 7021401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 7031401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 7041401458bSopenharmony_ci * @tc.steps: step4. query event. 7051401458bSopenharmony_ci */ 7061401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest013 start"); 7071401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 7081401458bSopenharmony_ci HiSysEventQueryArg arg; 7091401458bSopenharmony_ci InitQueryArg(arg); 7101401458bSopenharmony_ci HiSysEventQueryRule rule; 7111401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.eventList[0], TEST_NAME, MAX_LEN_OF_NAME); 7121401458bSopenharmony_ci rule.eventListSize = 1; 7131401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 7141401458bSopenharmony_ci HiSysEventQueryCallback callback; 7151401458bSopenharmony_ci InitCallback(callback); 7161401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 7171401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_RULE_INVALID); 7181401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest013 end"); 7191401458bSopenharmony_ci} 7201401458bSopenharmony_ci 7211401458bSopenharmony_ci/** 7221401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest014 7231401458bSopenharmony_ci * @tc.desc: Testing to query events only with domain and condition. 7241401458bSopenharmony_ci * @tc.type: FUNC 7251401458bSopenharmony_ci * @tc.require: issueI5X08B 7261401458bSopenharmony_ci */ 7271401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest014, TestSize.Level3) 7281401458bSopenharmony_ci{ 7291401458bSopenharmony_ci /** 7301401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 7311401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 7321401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 7331401458bSopenharmony_ci * @tc.steps: step4. query event. 7341401458bSopenharmony_ci */ 7351401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest014 start"); 7361401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 7371401458bSopenharmony_ci HiSysEventQueryArg arg; 7381401458bSopenharmony_ci InitQueryArg(arg); 7391401458bSopenharmony_ci HiSysEventQueryRule rule; 7401401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.domain, TEST_DOMAIN, MAX_LEN_OF_DOMAIN); 7411401458bSopenharmony_ci rule.eventListSize = 0; 7421401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"NAME","op":"=", 7431401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 7441401458bSopenharmony_ci (void)StringUtil::CreateCString(&rule.condition, cond); 7451401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 7461401458bSopenharmony_ci HiSysEventQueryCallback callback; 7471401458bSopenharmony_ci InitCallback(callback); 7481401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 7491401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_RULE_INVALID); 7501401458bSopenharmony_ci StringUtil::DeletePointer<char>(&rule.condition); 7511401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest014 end"); 7521401458bSopenharmony_ci} 7531401458bSopenharmony_ci 7541401458bSopenharmony_ci/** 7551401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest015 7561401458bSopenharmony_ci * @tc.desc: Testing to query events only with name and condition. 7571401458bSopenharmony_ci * @tc.type: FUNC 7581401458bSopenharmony_ci * @tc.require: issueI5X08B 7591401458bSopenharmony_ci */ 7601401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest015, TestSize.Level3) 7611401458bSopenharmony_ci{ 7621401458bSopenharmony_ci /** 7631401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 7641401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 7651401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 7661401458bSopenharmony_ci * @tc.steps: step4. query event. 7671401458bSopenharmony_ci */ 7681401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest015 start"); 7691401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 7701401458bSopenharmony_ci HiSysEventQueryArg arg; 7711401458bSopenharmony_ci InitQueryArg(arg); 7721401458bSopenharmony_ci HiSysEventQueryRule rule; 7731401458bSopenharmony_ci (void)StringUtil::CopyCString(rule.eventList[0], TEST_NAME, MAX_LEN_OF_NAME); 7741401458bSopenharmony_ci rule.eventListSize = 1; 7751401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"NAME","op":"=", 7761401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 7771401458bSopenharmony_ci (void)StringUtil::CreateCString(&rule.condition, cond); 7781401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 7791401458bSopenharmony_ci HiSysEventQueryCallback callback; 7801401458bSopenharmony_ci InitCallback(callback); 7811401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 7821401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_RULE_INVALID); 7831401458bSopenharmony_ci StringUtil::DeletePointer<char>(&rule.condition); 7841401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest015 end"); 7851401458bSopenharmony_ci} 7861401458bSopenharmony_ci 7871401458bSopenharmony_ci/** 7881401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest016 7891401458bSopenharmony_ci * @tc.desc: Testing to query events only with condition. 7901401458bSopenharmony_ci * @tc.type: FUNC 7911401458bSopenharmony_ci * @tc.require: issueI5X08B 7921401458bSopenharmony_ci */ 7931401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest016, TestSize.Level3) 7941401458bSopenharmony_ci{ 7951401458bSopenharmony_ci /** 7961401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 7971401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 7981401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 7991401458bSopenharmony_ci * @tc.steps: step4. query event. 8001401458bSopenharmony_ci */ 8011401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest016 start"); 8021401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 8031401458bSopenharmony_ci HiSysEventQueryArg arg; 8041401458bSopenharmony_ci InitQueryArg(arg); 8051401458bSopenharmony_ci HiSysEventQueryRule rule; 8061401458bSopenharmony_ci rule.eventListSize = 0; 8071401458bSopenharmony_ci std::string cond = R"~({"version":"V1","condition":{"and":[{"param":"NAME","op":"=", 8081401458bSopenharmony_ci "value":"SysEventStore"}]}})~"; 8091401458bSopenharmony_ci (void)StringUtil::CreateCString(&rule.condition, cond); 8101401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 8111401458bSopenharmony_ci HiSysEventQueryCallback callback; 8121401458bSopenharmony_ci InitCallback(callback); 8131401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 8141401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_RULE_INVALID); 8151401458bSopenharmony_ci StringUtil::DeletePointer<char>(&rule.condition); 8161401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest016 end"); 8171401458bSopenharmony_ci} 8181401458bSopenharmony_ci 8191401458bSopenharmony_ci/** 8201401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest017 8211401458bSopenharmony_ci * @tc.desc: Testing to query events are too frequent. 8221401458bSopenharmony_ci * @tc.type: FUNC 8231401458bSopenharmony_ci * @tc.require: issueI5X08B 8241401458bSopenharmony_ci */ 8251401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest017, TestSize.Level3) 8261401458bSopenharmony_ci{ 8271401458bSopenharmony_ci /** 8281401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 8291401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 8301401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 8311401458bSopenharmony_ci * @tc.steps: step4. query event. 8321401458bSopenharmony_ci */ 8331401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest017 start"); 8341401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 8351401458bSopenharmony_ci HiSysEventQueryArg arg; 8361401458bSopenharmony_ci InitQueryArg(arg); 8371401458bSopenharmony_ci 8381401458bSopenharmony_ci HiSysEventQueryRule rule; 8391401458bSopenharmony_ci InitQueryRule(rule); 8401401458bSopenharmony_ci HiSysEventQueryRule rules[] = { rule }; 8411401458bSopenharmony_ci 8421401458bSopenharmony_ci HiSysEventQueryCallback callback; 8431401458bSopenharmony_ci InitCallback(callback); 8441401458bSopenharmony_ci 8451401458bSopenharmony_ci const int threshhold = 50; 8461401458bSopenharmony_ci const int delayDuration = 1; // 1 second 8471401458bSopenharmony_ci for (int i = 0; i < 2; i++) { // 2 cycles 8481401458bSopenharmony_ci sleep(delayDuration); 8491401458bSopenharmony_ci for (int j = 0; j <= threshhold; j++) { // more than 50 queries in 1 second is never allowed 8501401458bSopenharmony_ci auto ret = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 8511401458bSopenharmony_ci ASSERT_TRUE((ret == ERR_QUERY_TOO_FREQUENTLY) || (ret == IPC_CALL_SUCCEED)); 8521401458bSopenharmony_ci } 8531401458bSopenharmony_ci } 8541401458bSopenharmony_ci 8551401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest017 end"); 8561401458bSopenharmony_ci} 8571401458bSopenharmony_ci 8581401458bSopenharmony_ci/** 8591401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest018 8601401458bSopenharmony_ci * @tc.desc: Testing to query events with too many rules. 8611401458bSopenharmony_ci * @tc.type: FUNC 8621401458bSopenharmony_ci * @tc.require: issueI5X08B 8631401458bSopenharmony_ci */ 8641401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest018, TestSize.Level3) 8651401458bSopenharmony_ci{ 8661401458bSopenharmony_ci /** 8671401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 8681401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 8691401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 8701401458bSopenharmony_ci * @tc.steps: step4. query event. 8711401458bSopenharmony_ci */ 8721401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest018 start"); 8731401458bSopenharmony_ci sleep(QUERY_INTERVAL_TIME); 8741401458bSopenharmony_ci HiSysEventQueryArg arg; 8751401458bSopenharmony_ci InitQueryArg(arg); 8761401458bSopenharmony_ci 8771401458bSopenharmony_ci HiSysEventQueryRule rule; 8781401458bSopenharmony_ci InitQueryRule(rule); 8791401458bSopenharmony_ci const int invalidRuleCnt = 101; // maximum count for query rule is 100. 8801401458bSopenharmony_ci HiSysEventQueryRule rules[invalidRuleCnt]; 8811401458bSopenharmony_ci for (int i = 0; i < invalidRuleCnt; i++) { 8821401458bSopenharmony_ci rules[i] = rule; 8831401458bSopenharmony_ci } 8841401458bSopenharmony_ci 8851401458bSopenharmony_ci HiSysEventQueryCallback callback; 8861401458bSopenharmony_ci InitCallback(callback); 8871401458bSopenharmony_ci 8881401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 8891401458bSopenharmony_ci ASSERT_EQ(res, ERR_TOO_MANY_QUERY_RULES); 8901401458bSopenharmony_ci 8911401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest018 end"); 8921401458bSopenharmony_ci} 8931401458bSopenharmony_ci 8941401458bSopenharmony_ci/** 8951401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest019 8961401458bSopenharmony_ci * @tc.desc: Testing to query events with null param. 8971401458bSopenharmony_ci * @tc.type: FUNC 8981401458bSopenharmony_ci * @tc.require: issueI7O8IM 8991401458bSopenharmony_ci */ 9001401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest019, TestSize.Level0) 9011401458bSopenharmony_ci{ 9021401458bSopenharmony_ci /** 9031401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 9041401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 9051401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 9061401458bSopenharmony_ci * @tc.steps: step4. query event. 9071401458bSopenharmony_ci */ 9081401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest019 start"); 9091401458bSopenharmony_ci HiSysEventQueryRule rules[] = {}; 9101401458bSopenharmony_ci HiSysEventQueryCallback callback; 9111401458bSopenharmony_ci InitCallback(callback); 9121401458bSopenharmony_ci auto res = OH_HiSysEvent_Query(nullptr, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 9131401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_ARG_NULL); 9141401458bSopenharmony_ci 9151401458bSopenharmony_ci HiSysEventQueryArg arg; 9161401458bSopenharmony_ci InitQueryArg(arg); 9171401458bSopenharmony_ci res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), nullptr); 9181401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_CALLBACK_NULL); 9191401458bSopenharmony_ci 9201401458bSopenharmony_ci callback.OnQuery = nullptr; 9211401458bSopenharmony_ci res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 9221401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_CALLBACK_NULL); 9231401458bSopenharmony_ci 9241401458bSopenharmony_ci InitCallback(callback); 9251401458bSopenharmony_ci callback.OnComplete = nullptr; 9261401458bSopenharmony_ci res = OH_HiSysEvent_Query(&arg, rules, sizeof(rules) / sizeof(HiSysEventQueryRule), &callback); 9271401458bSopenharmony_ci ASSERT_EQ(res, ERR_QUERY_CALLBACK_NULL); 9281401458bSopenharmony_ci 9291401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest019 end"); 9301401458bSopenharmony_ci} 9311401458bSopenharmony_ci 9321401458bSopenharmony_ci/** 9331401458bSopenharmony_ci * @tc.name: HiSysEventMgrCQueryTest020 9341401458bSopenharmony_ci * @tc.desc: Testing to query events with invalid condition. 9351401458bSopenharmony_ci * @tc.type: FUNC 9361401458bSopenharmony_ci * @tc.require: issueIAXEER 9371401458bSopenharmony_ci */ 9381401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCQueryTest020, TestSize.Level3) 9391401458bSopenharmony_ci{ 9401401458bSopenharmony_ci /** 9411401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventQueryArg. 9421401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventQueryRule. 9431401458bSopenharmony_ci * @tc.steps: step3. create HiSysEventQueryCallback. 9441401458bSopenharmony_ci * @tc.steps: step4. query event. 9451401458bSopenharmony_ci */ 9461401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest020 start"); 9471401458bSopenharmony_ci std::string rootIsArrayCond = R"~([])~"; 9481401458bSopenharmony_ci QueryTestWithCondition(rootIsArrayCond); 9491401458bSopenharmony_ci std::string condIsArrayCond = R"~({"version":"V1","condition":[]})~"; 9501401458bSopenharmony_ci QueryTestWithCondition(condIsArrayCond); 9511401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCQueryTest020 end"); 9521401458bSopenharmony_ci} 9531401458bSopenharmony_ci 9541401458bSopenharmony_ci/** 9551401458bSopenharmony_ci * @tc.name: HiSysEventMgrCRecordTest001 9561401458bSopenharmony_ci * @tc.desc: Testing to get the record information. 9571401458bSopenharmony_ci * @tc.type: FUNC 9581401458bSopenharmony_ci * @tc.require: issueI5X08B 9591401458bSopenharmony_ci */ 9601401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCRecordTest001, TestSize.Level3) 9611401458bSopenharmony_ci{ 9621401458bSopenharmony_ci /** 9631401458bSopenharmony_ci * @tc.steps: step1. build record. 9641401458bSopenharmony_ci * @tc.steps: step2. check the information from record. 9651401458bSopenharmony_ci */ 9661401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCRecordTest001 start"); 9671401458bSopenharmony_ci const std::map<std::string, std::string> recordData = { 9681401458bSopenharmony_ci {"\"domain_\"", "\"TEST_DOMAIN\""}, 9691401458bSopenharmony_ci {"\"name_\"", "\"TEST_NAME\""}, 9701401458bSopenharmony_ci {"\"type_\"", "4"}, 9711401458bSopenharmony_ci {"\"PARAM_INT\"", "-123"}, 9721401458bSopenharmony_ci {"\"PARAM_INTS\"", "[-1,-2,3]"}, 9731401458bSopenharmony_ci {"\"PARAM_UINT\"", "123"}, 9741401458bSopenharmony_ci {"\"PARAM_UINTS\"", "[1,2,3]"}, 9751401458bSopenharmony_ci {"\"PARAM_DOU\"", "123.456"}, 9761401458bSopenharmony_ci {"\"PARAM_DOUS\"", "[1.1,-2.2,3.3]"}, 9771401458bSopenharmony_ci {"\"PARAM_STR\"", "\"test\""}, 9781401458bSopenharmony_ci {"\"PARAM_STRS\"", "[\"test1\",\"test2\",\"test3\"]"} 9791401458bSopenharmony_ci }; 9801401458bSopenharmony_ci HiSysEventRecord record; 9811401458bSopenharmony_ci auto res = StringUtil::CreateCString(&record.jsonStr, BuildRecordString(recordData)); 9821401458bSopenharmony_ci if (res != 0) { 9831401458bSopenharmony_ci HILOG_WARN(LOG_CORE, "failed to create record string"); 9841401458bSopenharmony_ci ASSERT_TRUE(false); 9851401458bSopenharmony_ci } 9861401458bSopenharmony_ci 9871401458bSopenharmony_ci RecordParamNameTest(record, recordData); 9881401458bSopenharmony_ci RecordParamIntValueTest(record, "PARAM_INT", -123); 9891401458bSopenharmony_ci RecordParamUintValueTest(record, "PARAM_UINT", 123); 9901401458bSopenharmony_ci RecordParamDouValueTest(record, "PARAM_DOU", 123.456); 9911401458bSopenharmony_ci RecordParamStrValueTest(record, "PARAM_STR", "test"); 9921401458bSopenharmony_ci RecordParamIntValuesTest(record, "PARAM_INTS", {-1, -2, 3}); 9931401458bSopenharmony_ci RecordParamUintValuesTest(record, "PARAM_UINTS", {1, 2, 3}); 9941401458bSopenharmony_ci RecordParamDouValuesTest(record, "PARAM_DOUS", {1.1, -2.2, 3.3}); 9951401458bSopenharmony_ci RecordParamStrValuesTest(record, "PARAM_STRS", {"test1", "test2", "test3"}); 9961401458bSopenharmony_ci 9971401458bSopenharmony_ci int expRes = -3; 9981401458bSopenharmony_ci RecordParamIntValueInvalidTest(record, "PARAM_STR", expRes); 9991401458bSopenharmony_ci RecordParamUintValueInvalidTest(record, "PARAM_STR", expRes); 10001401458bSopenharmony_ci RecordParamDouValueInvalidTest(record, "PARAM_STR", expRes); 10011401458bSopenharmony_ci RecordParamIntValuesInvalidTest(record, "PARAM_STRS", expRes); 10021401458bSopenharmony_ci RecordParamUintValuesInvalidTest(record, "PARAM_STRS", expRes); 10031401458bSopenharmony_ci RecordParamDouValuesInvalidTest(record, "PARAM_STRS", expRes); 10041401458bSopenharmony_ci 10051401458bSopenharmony_ci // number is automatically converted to string 10061401458bSopenharmony_ci RecordParamStrValueTest(record, "PARAM_INT", "-123"); 10071401458bSopenharmony_ci RecordParamStrValuesTest(record, "PARAM_INTS", {"-1", "-2", "3"}); 10081401458bSopenharmony_ci 10091401458bSopenharmony_ci StringUtil::DeletePointer<char>(&record.jsonStr); 10101401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCRecordTest001 end"); 10111401458bSopenharmony_ci} 10121401458bSopenharmony_ci 10131401458bSopenharmony_ci/** 10141401458bSopenharmony_ci * @tc.name: HiSysEventMgrCRecordTest002 10151401458bSopenharmony_ci * @tc.desc: Testing to get the record information. 10161401458bSopenharmony_ci * @tc.type: FUNC 10171401458bSopenharmony_ci * @tc.require: issueI5X08B 10181401458bSopenharmony_ci */ 10191401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCRecordTest002, TestSize.Level3) 10201401458bSopenharmony_ci{ 10211401458bSopenharmony_ci /** 10221401458bSopenharmony_ci * @tc.steps: step1. build record. 10231401458bSopenharmony_ci * @tc.steps: step2. check the information from record. 10241401458bSopenharmony_ci */ 10251401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCRecordTest002 start"); 10261401458bSopenharmony_ci HiSysEventRecord record; 10271401458bSopenharmony_ci auto res = StringUtil::CreateCString(&record.jsonStr, "invalid record"); 10281401458bSopenharmony_ci if (res != 0) { 10291401458bSopenharmony_ci HILOG_WARN(LOG_CORE, "failed to create record string"); 10301401458bSopenharmony_ci ASSERT_TRUE(false); 10311401458bSopenharmony_ci } 10321401458bSopenharmony_ci 10331401458bSopenharmony_ci int expRes = -1; 10341401458bSopenharmony_ci RecordParamNameInvalidTest(record); 10351401458bSopenharmony_ci RecordParamIntValueInvalidTest(record, "PARAM_INT", expRes); 10361401458bSopenharmony_ci RecordParamUintValueInvalidTest(record, "PARAM_UINT", expRes); 10371401458bSopenharmony_ci RecordParamDouValueInvalidTest(record, "PARAM_DOU", expRes); 10381401458bSopenharmony_ci RecordParamStrValueInvalidTest(record, "PARAM_STR", expRes); 10391401458bSopenharmony_ci RecordParamIntValuesInvalidTest(record, "PARAM_INTS", expRes); 10401401458bSopenharmony_ci RecordParamUintValuesInvalidTest(record, "PARAM_UINTS", expRes); 10411401458bSopenharmony_ci RecordParamDouValuesInvalidTest(record, "PARAM_DOUS", expRes); 10421401458bSopenharmony_ci RecordParamStrValuesInvalidTest(record, "PARAM_STRS", expRes); 10431401458bSopenharmony_ci 10441401458bSopenharmony_ci StringUtil::DeletePointer<char>(&record.jsonStr); 10451401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCRecordTest002 end"); 10461401458bSopenharmony_ci} 10471401458bSopenharmony_ci 10481401458bSopenharmony_ci/** 10491401458bSopenharmony_ci * @tc.name: HiSysEventMgrCRecordTest003 10501401458bSopenharmony_ci * @tc.desc: Testing to get the record information. 10511401458bSopenharmony_ci * @tc.type: FUNC 10521401458bSopenharmony_ci * @tc.require: issueI5X08B 10531401458bSopenharmony_ci */ 10541401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCRecordTest003, TestSize.Level3) 10551401458bSopenharmony_ci{ 10561401458bSopenharmony_ci /** 10571401458bSopenharmony_ci * @tc.steps: step1. build record. 10581401458bSopenharmony_ci * @tc.steps: step2. check the information from record. 10591401458bSopenharmony_ci */ 10601401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCRecordTest003 start"); 10611401458bSopenharmony_ci HiSysEventRecord record; 10621401458bSopenharmony_ci auto res = StringUtil::CreateCString(&record.jsonStr, R"~({})~"); 10631401458bSopenharmony_ci if (res != 0) { 10641401458bSopenharmony_ci HILOG_WARN(LOG_CORE, "failed to create record string"); 10651401458bSopenharmony_ci ASSERT_TRUE(false); 10661401458bSopenharmony_ci } 10671401458bSopenharmony_ci 10681401458bSopenharmony_ci int expRes = -2; 10691401458bSopenharmony_ci RecordParamNameTest(record, {}); 10701401458bSopenharmony_ci RecordParamIntValueInvalidTest(record, "PARAM_INT", expRes); 10711401458bSopenharmony_ci RecordParamUintValueInvalidTest(record, "PARAM_UINT", expRes); 10721401458bSopenharmony_ci RecordParamDouValueInvalidTest(record, "PARAM_DOU", expRes); 10731401458bSopenharmony_ci RecordParamStrValueInvalidTest(record, "PARAM_STR", expRes); 10741401458bSopenharmony_ci RecordParamIntValuesInvalidTest(record, "PARAM_INTS", expRes); 10751401458bSopenharmony_ci RecordParamUintValuesInvalidTest(record, "PARAM_UINTS", expRes); 10761401458bSopenharmony_ci RecordParamDouValuesInvalidTest(record, "PARAM_DOUS", expRes); 10771401458bSopenharmony_ci RecordParamStrValuesInvalidTest(record, "PARAM_STRS", expRes); 10781401458bSopenharmony_ci 10791401458bSopenharmony_ci StringUtil::DeletePointer<char>(&record.jsonStr); 10801401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCRecordTest003 end"); 10811401458bSopenharmony_ci} 10821401458bSopenharmony_ci 10831401458bSopenharmony_ci/** 10841401458bSopenharmony_ci * @tc.name: HiSysEventMgrCRecordTest004 10851401458bSopenharmony_ci * @tc.desc: Test apis of HisysventRecordC 10861401458bSopenharmony_ci * @tc.type: FUNC 10871401458bSopenharmony_ci * @tc.require: issueI62WJT 10881401458bSopenharmony_ci */ 10891401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCRecordTest004, TestSize.Level3) 10901401458bSopenharmony_ci{ 10911401458bSopenharmony_ci struct HiSysEventRecord record; 10921401458bSopenharmony_ci char*** testp = nullptr; 10931401458bSopenharmony_ci size_t len = 0; 10941401458bSopenharmony_ci OH_HiSysEvent_GetParamNames(&record, testp, &len); 10951401458bSopenharmony_ci ASSERT_TRUE(true); 10961401458bSopenharmony_ci int64_t value1; 10971401458bSopenharmony_ci auto ret = OH_HiSysEvent_GetParamInt64Value(&record, "KEY", &value1); 10981401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 10991401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamInt64Value(&record, nullptr, &value1); 11001401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11011401458bSopenharmony_ci uint64_t value2; 11021401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamUint64Value(&record, "KEY", &value2); 11031401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11041401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamUint64Value(&record, nullptr, &value2); 11051401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11061401458bSopenharmony_ci double value3; 11071401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamDoubleValue(&record, "KEY", &value3); 11081401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11091401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamDoubleValue(&record, nullptr, &value3); 11101401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11111401458bSopenharmony_ci char value4[100]; 11121401458bSopenharmony_ci char* value4p = value4; 11131401458bSopenharmony_ci char** value4pp = &value4p; 11141401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamStringValue(&record, "KEY", value4pp); 11151401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11161401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamStringValue(&record, nullptr, value4pp); 11171401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11181401458bSopenharmony_ci size_t dataLen; 11191401458bSopenharmony_ci int64_t value5[10]; 11201401458bSopenharmony_ci int64_t* value5p = value5; 11211401458bSopenharmony_ci int64_t** value5pp = &value5p; 11221401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamInt64Values(&record, "KEY", value5pp, &dataLen); 11231401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11241401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamInt64Values(&record, nullptr, value5pp, &dataLen); 11251401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11261401458bSopenharmony_ci uint64_t value6[10]; 11271401458bSopenharmony_ci uint64_t* value6p = value6; 11281401458bSopenharmony_ci uint64_t** value6pp = &value6p; 11291401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamUint64Values(&record, "KEY", value6pp, &dataLen); 11301401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11311401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamUint64Values(&record, nullptr, value6pp, &dataLen); 11321401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11331401458bSopenharmony_ci double value7[10]; 11341401458bSopenharmony_ci double* value7p = value7; 11351401458bSopenharmony_ci double** value7pp = &value7p; 11361401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamDoubleValues(&record, "KEY", value7pp, &dataLen); 11371401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11381401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamDoubleValues(&record, nullptr, value7pp, &dataLen); 11391401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11401401458bSopenharmony_ci char v3[10][100] {}; 11411401458bSopenharmony_ci char* dest3p = v3[0]; 11421401458bSopenharmony_ci char** dest3pp = &dest3p; 11431401458bSopenharmony_ci char*** dest3ppp = &dest3pp; 11441401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamStringValues(&record, "KEY", dest3ppp, &dataLen); 11451401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11461401458bSopenharmony_ci ret = OH_HiSysEvent_GetParamStringValues(&record, nullptr, dest3ppp, &dataLen); 11471401458bSopenharmony_ci ASSERT_EQ(ret, ERR_NULL); 11481401458bSopenharmony_ci} 11491401458bSopenharmony_ci 11501401458bSopenharmony_ci/** 11511401458bSopenharmony_ci * @tc.name: HiSysEventMgrCWatchTest001 11521401458bSopenharmony_ci * @tc.desc: Testing to watch events with null param. 11531401458bSopenharmony_ci * @tc.type: FUNC 11541401458bSopenharmony_ci * @tc.require: issueI7O8IM 11551401458bSopenharmony_ci */ 11561401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCWatcherTest001, TestSize.Level0) 11571401458bSopenharmony_ci{ 11581401458bSopenharmony_ci /** 11591401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventWatcher object. 11601401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventWatchRule objects. 11611401458bSopenharmony_ci * @tc.steps: step3. watch event. 11621401458bSopenharmony_ci */ 11631401458bSopenharmony_ci // watcher is null 11641401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCWatcherTest001 start"); 11651401458bSopenharmony_ci auto ret = OH_HiSysEvent_Add_Watcher(nullptr, nullptr, 0); 11661401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 11671401458bSopenharmony_ci 11681401458bSopenharmony_ci // watcher.OnEvent is null 11691401458bSopenharmony_ci HiSysEventWatcher nullWatcher; 11701401458bSopenharmony_ci InitWatcher(nullWatcher); 11711401458bSopenharmony_ci nullWatcher.OnEvent = nullptr; 11721401458bSopenharmony_ci HiSysEventWatchRule rule = {"HIVIEWDFX", "PLUGIN_LOAD", "", 1, 0}; 11731401458bSopenharmony_ci HiSysEventWatchRule rules[] = {rule}; 11741401458bSopenharmony_ci ret = OH_HiSysEvent_Add_Watcher(&nullWatcher, rules, sizeof(rules) / sizeof(HiSysEventWatchRule)); 11751401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 11761401458bSopenharmony_ci 11771401458bSopenharmony_ci // watcher.OnServiceDied is null 11781401458bSopenharmony_ci InitWatcher(nullWatcher); 11791401458bSopenharmony_ci nullWatcher.OnServiceDied = nullptr; 11801401458bSopenharmony_ci ret = OH_HiSysEvent_Add_Watcher(&nullWatcher, rules, sizeof(rules) / sizeof(HiSysEventWatchRule)); 11811401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 11821401458bSopenharmony_ci 11831401458bSopenharmony_ci // watcher does not exist 11841401458bSopenharmony_ci HiSysEventWatcher watcher; 11851401458bSopenharmony_ci InitWatcher(watcher); 11861401458bSopenharmony_ci ret = OH_HiSysEvent_Remove_Watcher(&watcher); 11871401458bSopenharmony_ci ASSERT_EQ(ret, ERR_LISTENER_NOT_EXIST); 11881401458bSopenharmony_ci 11891401458bSopenharmony_ci // normal function test 11901401458bSopenharmony_ci ret = OH_HiSysEvent_Add_Watcher(&watcher, rules, sizeof(rules) / sizeof(HiSysEventWatchRule)); 11911401458bSopenharmony_ci ASSERT_EQ(ret, 0); 11921401458bSopenharmony_ci ret = OH_HiSysEvent_Write("HIVIEWDFX", "PLUGIN_LOAD", HISYSEVENT_BEHAVIOR, nullptr, 0); 11931401458bSopenharmony_ci ASSERT_EQ(ret, 0); 11941401458bSopenharmony_ci sleep(3); 11951401458bSopenharmony_ci ret = OH_HiSysEvent_Remove_Watcher(&watcher); 11961401458bSopenharmony_ci ASSERT_EQ(ret, 0); 11971401458bSopenharmony_ci 11981401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCWatcherTest001 end"); 11991401458bSopenharmony_ci} 12001401458bSopenharmony_ci 12011401458bSopenharmony_ci/** 12021401458bSopenharmony_ci * @tc.name: HiSysEventMgrCWatchTest002 12031401458bSopenharmony_ci * @tc.desc: Testing to watch events with too many rules. 12041401458bSopenharmony_ci * @tc.type: FUNC 12051401458bSopenharmony_ci * @tc.require: issueI7O8IM 12061401458bSopenharmony_ci */ 12071401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCWatchTest002, TestSize.Level0) 12081401458bSopenharmony_ci{ 12091401458bSopenharmony_ci /** 12101401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventWatcher object. 12111401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventWatchRule objects. 12121401458bSopenharmony_ci * @tc.steps: step3. watch event. 12131401458bSopenharmony_ci */ 12141401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCWatchTest002 start"); 12151401458bSopenharmony_ci HiSysEventWatcher watcher; 12161401458bSopenharmony_ci InitWatcher(watcher); 12171401458bSopenharmony_ci HiSysEventWatchRule rule = {"HIVIEWDFX", "PLUGIN_LOAD", "", 1, 0}; 12181401458bSopenharmony_ci const size_t maxNum = 20; 12191401458bSopenharmony_ci HiSysEventWatchRule rules[maxNum + 1]; 12201401458bSopenharmony_ci for (size_t i = 0; i <= maxNum; i++) { 12211401458bSopenharmony_ci rules[i] = rule; 12221401458bSopenharmony_ci } 12231401458bSopenharmony_ci auto ret = OH_HiSysEvent_Add_Watcher(&watcher, rules, sizeof(rules) / sizeof(HiSysEventWatchRule)); 12241401458bSopenharmony_ci ASSERT_EQ(ret, ERR_TOO_MANY_WATCH_RULES); 12251401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCWatchTest002 end"); 12261401458bSopenharmony_ci} 12271401458bSopenharmony_ci 12281401458bSopenharmony_ci/** 12291401458bSopenharmony_ci * @tc.name: HiSysEventMgrCWatchTest003 12301401458bSopenharmony_ci * @tc.desc: Testing to watch events with too many watchers. 12311401458bSopenharmony_ci * @tc.type: FUNC 12321401458bSopenharmony_ci * @tc.require: issueI7O8IM 12331401458bSopenharmony_ci */ 12341401458bSopenharmony_ciHWTEST_F(HiSysEventManagerCTest, HiSysEventMgrCWatchTest003, TestSize.Level0) 12351401458bSopenharmony_ci{ 12361401458bSopenharmony_ci /** 12371401458bSopenharmony_ci * @tc.steps: step1. create HiSysEventWatcher object. 12381401458bSopenharmony_ci * @tc.steps: step2. create HiSysEventWatchRule objects. 12391401458bSopenharmony_ci * @tc.steps: step3. watch event. 12401401458bSopenharmony_ci */ 12411401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCWatchTest003 start"); 12421401458bSopenharmony_ci const size_t maxNum = 30; 12431401458bSopenharmony_ci HiSysEventWatcher watchers[maxNum + 1]; 12441401458bSopenharmony_ci for (size_t i = 0; i <= maxNum; i++) { 12451401458bSopenharmony_ci HiSysEventWatcher watcher; 12461401458bSopenharmony_ci InitWatcher(watcher); 12471401458bSopenharmony_ci watchers[i] = watcher; 12481401458bSopenharmony_ci } 12491401458bSopenharmony_ci HiSysEventWatchRule rule = {"HIVIEWDFX", "PLUGIN_LOAD", "", 1, 0}; 12501401458bSopenharmony_ci HiSysEventWatchRule rules[] = {rule}; 12511401458bSopenharmony_ci for (size_t i = 0; i < maxNum; i++) { 12521401458bSopenharmony_ci (void)OH_HiSysEvent_Add_Watcher(&watchers[i], rules, sizeof(rules) / sizeof(HiSysEventWatchRule)); 12531401458bSopenharmony_ci } 12541401458bSopenharmony_ci auto ret = OH_HiSysEvent_Add_Watcher(&watchers[maxNum], rules, sizeof(rules) / sizeof(HiSysEventWatchRule)); 12551401458bSopenharmony_ci ASSERT_EQ(ret, ERR_TOO_MANY_WATCHERS); 12561401458bSopenharmony_ci 12571401458bSopenharmony_ci for (size_t i = 0; i <= maxNum; i++) { 12581401458bSopenharmony_ci (void)OH_HiSysEvent_Remove_Watcher(&watchers[i]); 12591401458bSopenharmony_ci } 12601401458bSopenharmony_ci HILOG_INFO(LOG_CORE, "HiSysEventMgrCWatchTest003 end"); 12611401458bSopenharmony_ci} 1262