remove history event record

Signed-off-by: Ricky <yuegang7@huawei.com>
Change-Id: I1ee499da277b35b50bc8887f985e011dc27107b2
This commit is contained in:
Ricky 2024-11-18 11:42:08 +08:00
parent b1458c2737
commit 086add3d02
5 changed files with 0 additions and 702 deletions

View File

@ -119,15 +119,6 @@ public:
*/
void DumpState(const std::string &event, const int32_t &userId, std::vector<std::string> &state);
/**
* Dumps state of history common event.
*
* @param event Specifies the information for the common event. Set null string ("") if you want to dump all.
* @param userId Indicates the user ID.
* @param state Indicates the state of common event service.
*/
void DumpHistoryState(const std::string &event, const int32_t &userId, std::vector<std::string> &state);
private:
bool ProcessUnorderedEvent(
const CommonEventRecord &eventRecord, const std::shared_ptr<EventSubscriberRecord> &subscriberRecord = nullptr);
@ -177,20 +168,10 @@ private:
void GetUnorderedEventRecords(
const std::string &event, const int32_t &userId, std::vector<std::shared_ptr<OrderedEventRecord>> &records);
void GetHistoryEventRecords(
const std::string &event, const int32_t &userId, std::list<HistoryEventRecord> &records);
void DumpStateByCommonEventRecord(const std::shared_ptr<OrderedEventRecord> &record, std::string &dumpInfo);
void DumpStateBySubscriberRecord(const std::shared_ptr<OrderedEventRecord> &record, std::string &dumpInfo);
void DumpHistoryStateBySubscriberRecord(const HistoryEventRecord &record, std::string &dumpInfo);
void DumpHistoryStateByCommonEventRecord(const HistoryEventRecord &record, std::string &dumpInfo);
void EnqueueHistoryEventRecord(const std::shared_ptr<OrderedEventRecord> &eventRecordPtr,
bool hasLastSubscribe);
void PublishFrozenEventsInner(const FrozenRecords &frozenEventRecords);
void SendOrderedEventProcTimeoutHiSysEvent(const std::shared_ptr<EventSubscriberRecord> &subscriberRecord,
@ -202,14 +183,11 @@ private:
std::shared_ptr<OrderedEventHandler> handlerOrdered_;
std::vector<std::shared_ptr<OrderedEventRecord>> orderedEventQueue_;
std::vector<std::shared_ptr<OrderedEventRecord>> unorderedEventQueue_;
std::list<HistoryEventRecord> historyEventRecords_;
bool pendingTimeoutMessage_;
bool scheduled_;
const int64_t TIMEOUT = 10000; // How long we allow a receiver to run before giving up on it. Unit: ms
std::mutex orderedMutex_;
std::mutex unorderedMutex_;
std::mutex historyMutex_;
const size_t HISTORY_MAX_SIZE = 100;
std::shared_ptr<ffrt::queue> orderedQueue_ = nullptr;
std::shared_ptr<ffrt::queue> unorderedQueue_ = nullptr;

View File

@ -261,8 +261,6 @@ bool CommonEventControlManager::NotifyUnorderedEvent(std::shared_ptr<OrderedEven
std::lock_guard<std::mutex> lock(unorderedMutex_);
NotifyUnorderedEventLocked(eventRecord);
EnqueueHistoryEventRecord(eventRecord, false);
auto it = std::find(unorderedEventQueue_.begin(), unorderedEventQueue_.end(), eventRecord);
if (it != unorderedEventQueue_.end()) {
@ -423,62 +421,6 @@ bool CommonEventControlManager::EnqueueOrderedRecord(const std::shared_ptr<Order
return true;
}
void CommonEventControlManager::EnqueueHistoryEventRecord(
const std::shared_ptr<OrderedEventRecord> &eventRecordPtr, bool hasLastSubscribe)
{
#ifdef BUILD_VARIANT_USER
EVENT_LOGD("User version don't record history");
return;
#endif
if (eventRecordPtr == nullptr) {
EVENT_LOGE("eventRecordPtr is nullptr");
return;
}
HistoryEventRecord record;
record.want = eventRecordPtr->commonEventData->GetWant();
record.code = eventRecordPtr->commonEventData->GetCode();
record.data = eventRecordPtr->commonEventData->GetData();
record.sticky = eventRecordPtr->publishInfo->IsSticky();
record.ordered = eventRecordPtr->publishInfo->IsOrdered();
record.subscriberPermissions = eventRecordPtr->publishInfo->GetSubscriberPermissions();
record.recordTime = eventRecordPtr->recordTime;
record.pid = eventRecordPtr->eventRecordInfo.pid;
record.uid = eventRecordPtr->eventRecordInfo.uid;
record.userId = eventRecordPtr->userId;
record.bundleName = eventRecordPtr->eventRecordInfo.bundleName;
record.isSystemApp = eventRecordPtr->eventRecordInfo.isSystemApp;
record.isSystemEvent = eventRecordPtr->isSystemEvent;
for (auto vec : eventRecordPtr->receivers) {
if (vec == nullptr) {
continue;
}
HistorySubscriberRecord receiver;
receiver.recordTime = vec->recordTime;
receiver.bundleName = vec->eventRecordInfo.bundleName;
receiver.priority = vec->eventSubscribeInfo->GetPriority();
receiver.userId = vec->eventSubscribeInfo->GetUserId();
receiver.permission = vec->eventSubscribeInfo->GetPermission();
receiver.deviceId = vec->eventSubscribeInfo->GetDeviceId();
receiver.isFreeze = vec->isFreeze;
receiver.freezeTime = vec->freezeTime;
record.receivers.emplace_back(receiver);
}
record.hasLastSubscribe = hasLastSubscribe;
record.deliveryState = eventRecordPtr->deliveryState;
record.dispatchTime = eventRecordPtr->dispatchTime;
record.receiverTime = eventRecordPtr->receiverTime;
record.state = eventRecordPtr->state;
record.resultAbort = eventRecordPtr->resultAbort;
std::lock_guard<std::mutex> lock(historyMutex_);
if (historyEventRecords_.size() == HISTORY_MAX_SIZE) {
historyEventRecords_.pop_front();
}
historyEventRecords_.emplace_back(record);
}
bool CommonEventControlManager::ScheduleOrderedCommonEvent()
{
EVENT_LOGD("enter");
@ -605,8 +547,6 @@ void CommonEventControlManager::ProcessNextOrderedEvent(bool isSendMsg)
sp->commonEventData->GetWant().GetAction().c_str(), sp->nextReceiver, numReceivers);
CancelTimeout();
EnqueueHistoryEventRecord(sp, hasLastSubscribe);
orderedEventQueue_.erase(orderedEventQueue_.begin());
sp = nullptr;
@ -965,33 +905,6 @@ void CommonEventControlManager::GetOrderedEventRecords(
}
}
void CommonEventControlManager::GetHistoryEventRecords(
const std::string &event, const int32_t &userId, std::list<HistoryEventRecord> &records)
{
EVENT_LOGD("enter");
if (event.empty() && userId == ALL_USER) {
records = historyEventRecords_;
} else if (event.empty()) {
for (auto vec : historyEventRecords_) {
if (vec.userId == userId) {
records.push_back(vec);
}
}
} else if (userId == ALL_USER) {
for (auto vec : historyEventRecords_) {
if (vec.want.GetAction() == event) {
records.push_back(vec);
}
}
} else {
for (auto vec : historyEventRecords_) {
if (vec.want.GetAction() == event && vec.userId == userId) {
records.push_back(vec);
}
}
}
}
void CommonEventControlManager::DumpStateByCommonEventRecord(
const std::shared_ptr<OrderedEventRecord> &record, std::string &dumpInfo)
{
@ -1106,120 +1019,6 @@ void CommonEventControlManager::DumpStateByCommonEventRecord(
isSystemEvent + want + code + data + lastSubscriber + state + receiverTime + dispatchTime + resultAbort;
}
void CommonEventControlManager::DumpHistoryStateByCommonEventRecord(
const HistoryEventRecord &record, std::string &dumpInfo)
{
EVENT_LOGD("enter");
char systime[LENGTH];
strftime(systime, sizeof(char) * LENGTH, "%Y%m%d %I:%M %p", &record.recordTime);
std::string recordTime = "\tTime: " + std::string(systime) + "\n";
std::string pid = "\tPID: " + std::to_string(record.pid) + "\n";
std::string uid = "\tUID: " + std::to_string(record.uid) + "\n";
std::string userId;
switch (record.userId) {
case UNDEFINED_USER:
userId = "UNDEFINED_USER";
break;
case ALL_USER:
userId = "ALL_USER";
break;
default:
userId = std::to_string(record.userId);
break;
}
userId = "\tUSERID: " + userId + "\n";
std::string bundleName = "\tBundleName: " + record.bundleName + "\n";
std::string permission = "\tRequiredPermission: ";
std::string separator;
size_t permissionNum = 0;
for (auto permissionVec : record.subscriberPermissions) {
if (permissionNum == 0) {
separator = "";
} else {
separator = ", ";
}
permission = permission + separator + permissionVec;
permissionNum++;
}
permission = permission + "\n";
std::string isSticky;
if (record.sticky) {
isSticky = "\tIsSticky: true\n";
} else {
isSticky = "\tIsSticky: false\n";
}
std::string isOrdered;
if (record.ordered) {
isOrdered = "\tIsOrdered: true\n";
} else {
isOrdered = "\tIsOrdered: false\n";
}
std::string isSystemApp = record.isSystemApp ? "true" : "false";
isSystemApp = "\tIsSystemApp: " + isSystemApp + "\n";
std::string isSystemEvent = record.isSystemEvent ? "true" : "false";
isSystemEvent = "\tIsSystemEvent: " + isSystemEvent + "\n";
std::string action = "\t\tAction: " + record.want.GetAction() + "\n";
std::string entities = "\t\tEntity: ";
size_t entityNum = 0;
for (auto entitiesVec : record.want.GetEntities()) {
if (entityNum == 0) {
separator = "";
} else {
separator = ", ";
}
entities = entities + separator + entitiesVec;
entityNum++;
}
entities = entities + "\n";
std::string scheme = "\t\tScheme: " + record.want.GetScheme() + "\n";
std::string uri = "\t\tUri: " + record.want.GetUriString() + "\n";
std::string flags = "\t\tFlags: " + std::to_string(record.want.GetFlags()) + "\n";
std::string type = "\t\tType: " + record.want.GetType() + "\n";
std::string bundle = "\t\tBundleName: " + record.want.GetBundle() + "\n";
std::string ability = "\t\tAbilityName: " + record.want.GetElement().GetAbilityName() + "\n";
std::string deviced = "\t\tDevicedID: " + record.want.GetElement().GetDeviceID() + "\n";
std::string want = "\tWant:\n" + action + entities + scheme + uri + flags + type + bundle + ability + deviced;
std::string code = "\tCode: " + std::to_string(record.code) + "\n";
std::string data = "\tData: " + record.data + "\n";
std::string lastSubscriber;
if (record.hasLastSubscribe) {
lastSubscriber = "\tHasLastSubscriber: true\n";
} else {
lastSubscriber = "\tHasLastSubscriber: false\n";
}
std::string state;
switch (record.state) {
case OrderedEventRecord::IDLE:
state = "\tEventState: IDLE\n";
break;
case OrderedEventRecord::RECEIVING:
state = "\tEventState: RECEIVING\n";
break;
case OrderedEventRecord::RECEIVED:
state = "\tEventState: RECEIVED\n";
break;
}
std::string dispatchTime = "\tDispatchTime: " + std::to_string(record.dispatchTime) + "\n";
std::string receiverTime = "\tReceiverTime: " + std::to_string(record.receiverTime) + "\n";
std::string resultAbort = record.resultAbort ? "true" : "false";
resultAbort = "\tResultAbort: " + resultAbort + "\n";
dumpInfo = recordTime + pid + uid + userId + bundleName + permission + isSticky + isOrdered + isSystemApp +
isSystemEvent + want + code + data + lastSubscriber + state + receiverTime + dispatchTime + resultAbort;
}
void CommonEventControlManager::DumpStateBySubscriberRecord(
const std::shared_ptr<OrderedEventRecord> &record, std::string &dumpInfo)
{
@ -1265,81 +1064,6 @@ void CommonEventControlManager::DumpStateBySubscriberRecord(
}
}
void CommonEventControlManager::DumpHistoryStateBySubscriberRecord(
const HistoryEventRecord &record, std::string &dumpInfo)
{
EVENT_LOGD("enter");
if (record.receivers.empty()) {
dumpInfo = "\tSubscribers:\tNo information";
return;
}
size_t num = 0;
for (auto receiver : record.receivers) {
num++;
std::string title = std::to_string(num);
if (num == 1) {
title = "\tSubscribers:\tTotal " + std::to_string(record.receivers.size()) +
" subscribers\n\tNO " + title + "\n";
} else {
title = "\tNO " + title + "\n";
}
char systime[LENGTH];
strftime(systime, sizeof(char) * LENGTH, "%Y%m%d %I:%M %p", &receiver.recordTime);
std::string format = "\t\t";
std::string recordTime = format + "Time: " + std::string(systime) + "\n";
std::string bundleName = format + "BundleName: " + receiver.bundleName + "\n";
std::string priority = format + "Priority: " + std::to_string(receiver.priority) + "\n";
std::string userId;
switch (receiver.userId) {
case UNDEFINED_USER:
userId = "UNDEFINED_USER";
break;
case ALL_USER:
userId = "ALL_USER";
break;
default:
userId = std::to_string(receiver.userId);
break;
}
userId = format + "USERID: " + userId + "\n";
std::string permission = format + "Permission: " + receiver.permission + "\n";
std::string deviceId = format + "DevicedID: " + receiver.deviceId + "\n";
std::string isFreeze = receiver.isFreeze ? "true" : "false";
isFreeze = format + "IsFreeze: " + isFreeze + "\n";
std::string freezeTime;
if (receiver.freezeTime == 0) {
freezeTime = format + "FreezeTime: -\n";
} else {
freezeTime = format + "FreezeTime: " + std::to_string(receiver.freezeTime) + "\n";
}
std::string deliveryState;
switch (record.deliveryState[num - 1]) {
case OrderedEventRecord::PENDING:
deliveryState = "\t\tEventState: PENDING\n";
break;
case OrderedEventRecord::DELIVERED:
deliveryState = "\t\tEventState: DELIVERED\n";
break;
case OrderedEventRecord::SKIPPED:
deliveryState = "\t\tEventState: SKIPPED\n";
break;
case OrderedEventRecord::TIMEOUT:
deliveryState = "\t\tEventState: TIMEOUT\n";
break;
}
dumpInfo = dumpInfo + title + recordTime + bundleName + priority + userId + permission + deviceId + isFreeze +
freezeTime + deliveryState;
}
}
void CommonEventControlManager::DumpState(
const std::string &event, const int32_t &userId, std::vector<std::string> &state)
{
@ -1379,39 +1103,6 @@ void CommonEventControlManager::DumpState(
}
}
void CommonEventControlManager::DumpHistoryState(
const std::string &event, const int32_t &userId, std::vector<std::string> &state)
{
EVENT_LOGD("enter");
std::list<HistoryEventRecord> records;
std::lock_guard<std::mutex> lock(historyMutex_);
GetHistoryEventRecords(event, userId, records);
if (records.empty()) {
state.emplace_back("History Events:\tNo information");
return;
}
size_t num = 0;
for (auto record : records) {
num++;
std::string no = std::to_string(num);
if (num == 1) {
no = "History Events:\tTotal " + std::to_string(records.size()) + " information\nNO " + no + "\n";
} else {
no = "NO " + no + "\n";
}
std::string commonEventRecord;
DumpHistoryStateByCommonEventRecord(record, commonEventRecord);
std::string subscriberRecord;
DumpHistoryStateBySubscriberRecord(record, subscriberRecord);
std::string stateInfo = no + commonEventRecord + subscriberRecord;
state.emplace_back(stateInfo);
}
}
void CommonEventControlManager::SendOrderedEventProcTimeoutHiSysEvent(
const std::shared_ptr<EventSubscriberRecord> &subscriberRecord, const std::string &eventName)
{

View File

@ -422,9 +422,6 @@ void InnerCommonEventManager::DumpState(const uint8_t &dumpType, const std::stri
break;
}
case DumpEventType::HISTORY: {
if (controlPtr_) {
controlPtr_->DumpHistoryState(event, userId, state);
}
break;
}
default: {
@ -432,7 +429,6 @@ void InnerCommonEventManager::DumpState(const uint8_t &dumpType, const std::stri
DelayedSingleton<CommonEventStickyManager>::GetInstance()->DumpState(event, userId, state);
if (controlPtr_) {
controlPtr_->DumpState(event, userId, state);
controlPtr_->DumpHistoryState(event, userId, state);
}
break;
}

View File

@ -512,73 +512,6 @@ HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_1800, Le
GTEST_LOG_(INFO) << "CommonEventControlManager_1800 end";
}
/**
* @tc.name: CommonEventControlManager_1900
* @tc.desc: test GetHistoryEventRecords and vec->userId == userId.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_1900, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_1900 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = 100;
commonEventControlManager->historyEventRecords_.emplace_back(historyEventRecord);
std::string event = "";
int32_t userId = 100;
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_1900 end";
}
/**
* @tc.name: CommonEventControlManager_2000
* @tc.desc: test GetHistoryEventRecords and vec->userId == userId and GetAction == event.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_2000, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2000 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = 100;
commonEventControlManager->historyEventRecords_.emplace_back(historyEventRecord);
std::string event = "aa";
int32_t userId = 100;
// set GetAction == event
MockGetAction(false);
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2000 end";
}
/**
* @tc.name: CommonEventControlManager_2100
* @tc.desc: test GetHistoryEventRecords and vec->userId != userId and GetAction != event.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_2100, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2100 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = 90;
commonEventControlManager->historyEventRecords_.emplace_back(historyEventRecord);
std::string event = "aa";
int32_t userId = 100;
// set GetAction != event
MockGetAction(true);
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2100 end";
}
/**
* @tc.name: CommonEventControlManager_2200
* @tc.desc: test DumpStateByCommonEventRecord and record->userId is UNDEFINED_USER.
@ -728,121 +661,6 @@ HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_2700, Le
GTEST_LOG_(INFO) << "CommonEventControlManager_2700 end";
}
/**
* @tc.name: CommonEventControlManager_2800
* @tc.desc: test DumpHistoryStateByCommonEventRecord and record.userId is UNDEFINED_USER.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_2800, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2800 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
record.userId = UNDEFINED_USER;
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateByCommonEventRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_2800 end";
}
/**
* @tc.name: CommonEventControlManager_2900
* @tc.desc: test DumpHistoryStateByCommonEventRecord and record.userId is default.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_2900, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2900 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
record.userId = 100;
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateByCommonEventRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_2900 end";
}
/**
* @tc.name: CommonEventControlManager_3000
* @tc.desc: test DumpHistoryStateByCommonEventRecord and permissionNum is 1.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_3000, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_3000 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
record.userId = UNDEFINED_USER;
std::string bb = "bb";
std::string cc = "cc";
record.subscriberPermissions.emplace_back(bb);
record.subscriberPermissions.emplace_back(cc);
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateByCommonEventRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_3000 end";
}
/**
* @tc.name: CommonEventControlManager_3100
* @tc.desc: test DumpHistoryStateByCommonEventRecord and record.state is OrderedEventRecord::RECEIVING.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_3100, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_3100 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
record.userId = UNDEFINED_USER;
record.state = OrderedEventRecord::RECEIVING;
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateByCommonEventRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_3100 end";
}
/**
* @tc.name: CommonEventControlManager_3200
* @tc.desc: test DumpHistoryStateByCommonEventRecord and record.state is OrderedEventRecord::RECEIVED.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_3200, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_3200 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
record.userId = UNDEFINED_USER;
record.state = OrderedEventRecord::RECEIVED;
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateByCommonEventRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_3200 end";
}
/**
* @tc.name: CommonEventControlManager_3300
* @tc.desc: test DumpHistoryStateByCommonEventRecord and record.state is default.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_3300, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_3300 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
record.userId = UNDEFINED_USER;
record.state = 100;
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateByCommonEventRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_3300 end";
}
/**
* @tc.name: CommonEventControlManager_3400
* @tc.desc: test DumpStateBySubscriberRecord and record->receivers is empty.
@ -948,72 +766,6 @@ HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_3800, Le
GTEST_LOG_(INFO) << "CommonEventControlManager_3800 end";
}
/**
* @tc.name: CommonEventControlManager_3900
* @tc.desc: test DumpHistoryStateBySubscriberRecord and receiver.userId is UNDEFINED_USER.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_3900, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_3900 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
// set record.receivers is not empty
HistorySubscriberRecord historySubscriberRecord;
historySubscriberRecord.userId = UNDEFINED_USER;
record.receivers.emplace_back(historySubscriberRecord);
record.deliveryState.emplace_back(OrderedEventRecord::PENDING);
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateBySubscriberRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_3900 end";
}
/**
* @tc.name: CommonEventControlManager_4000
* @tc.desc: test DumpHistoryStateBySubscriberRecord and receiver.userId is default.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_4000, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_4000 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
// set record.receivers is not empty
HistorySubscriberRecord historySubscriberRecord;
historySubscriberRecord.userId = 100;
record.receivers.emplace_back(historySubscriberRecord);
record.deliveryState.emplace_back(OrderedEventRecord::TIMEOUT);
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateBySubscriberRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_4000 end";
}
/**
* @tc.name: CommonEventControlManager_4100
* @tc.desc: test DumpHistoryStateBySubscriberRecord and receiver.freezeTime is 1.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerBranchTest, CommonEventControlManager_4100, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_4100 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
HistoryEventRecord record;
// set record.receivers is not empty
HistorySubscriberRecord historySubscriberRecord;
historySubscriberRecord.freezeTime = 1;
record.receivers.emplace_back(historySubscriberRecord);
record.deliveryState.emplace_back(100);
std::string dumpInfo = "aa";
commonEventControlManager->DumpHistoryStateBySubscriberRecord(record, dumpInfo);
GTEST_LOG_(INFO) << "CommonEventControlManager_4100 end";
}
/**
* @tc.name: CommonEventControlManager_4200
* @tc.desc: test SendOrderedEventProcTimeoutHiSysEvent and subscriberRecord is nullptr.

View File

@ -97,23 +97,6 @@ HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_0300, Level1)
GTEST_LOG_(INFO) << "CommonEventControlManager_0300 end";
}
/**
* @tc.name: CommonEventControlManager_0400
* @tc.desc: test EnqueueHistoryEventRecord function and eventRecordPtr is nullptr.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_0400, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_0400 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::shared_ptr<OrderedEventRecord> eventRecordPtr = nullptr;
bool hasLastSubscribe = true;
commonEventControlManager->EnqueueHistoryEventRecord(eventRecordPtr, hasLastSubscribe);
GTEST_LOG_(INFO) << "CommonEventControlManager_0400 end";
}
/**
* @tc.name: CommonEventControlManager_0500
* @tc.desc: test NotifyOrderedEvent function and eventRecordPtr is nullptr.
@ -514,107 +497,5 @@ HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_2400, Level1)
GTEST_LOG_(INFO) << "CommonEventControlManager_2400 end";
}
/**
* @tc.name: CommonEventControlManager_2500
* @tc.desc: test GetHistoryEventRecords function.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_2500, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2500 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::string event = "";
int32_t userId = ALL_USER;
std::list<HistoryEventRecord> records;
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2500 end";
}
/**
* @tc.name: CommonEventControlManager_2600
* @tc.desc: test GetHistoryEventRecords function.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_2600, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2600 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::string event = "";
int32_t userId = ALL_USER - 1;
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = ALL_USER - 1;
commonEventControlManager->historyEventRecords_.emplace_back();
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2600 end";
}
/**
* @tc.name: CommonEventControlManager_2700
* @tc.desc: test GetHistoryEventRecords function.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_2700, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2700 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::string event = "";
int32_t userId = ALL_USER + 1;
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = ALL_USER + 2;
commonEventControlManager->historyEventRecords_.emplace_back();
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2700 end";
}
/**
* @tc.name: CommonEventControlManager_2800
* @tc.desc: test GetHistoryEventRecords function.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_2800, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2800 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::string event = "aa";
int32_t userId = ALL_USER + 1;
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = ALL_USER + 2;
commonEventControlManager->historyEventRecords_.emplace_back();
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2800 end";
}
/**
* @tc.name: CommonEventControlManager_2900
* @tc.desc: test GetHistoryEventRecords function.
* @tc.type: FUNC
*/
HWTEST_F(CommonEventControlManagerTest, CommonEventControlManager_2900, Level1)
{
GTEST_LOG_(INFO) << "CommonEventControlManager_2900 start";
std::shared_ptr<CommonEventControlManager> commonEventControlManager =
std::make_shared<CommonEventControlManager>();
ASSERT_NE(nullptr, commonEventControlManager);
std::string event = "aa";
int32_t userId = ALL_USER + 1;
std::list<HistoryEventRecord> records;
HistoryEventRecord historyEventRecord;
historyEventRecord.userId = ALL_USER + 1;
commonEventControlManager->historyEventRecords_.emplace_back();
commonEventControlManager->GetHistoryEventRecords(event, userId, records);
GTEST_LOG_(INFO) << "CommonEventControlManager_2900 end";
}
}
}