!262 告警处理

Merge pull request !262 from 田岚清/master
This commit is contained in:
openharmony_ci
2025-07-22 11:15:01 +00:00
committed by Gitee
5 changed files with 123 additions and 28 deletions
@@ -61,14 +61,14 @@ public:
return m_id;
}
private:
CalendarAccount m_account;
CalendarConfig m_config;
CalendarAccount m_account = {"", "", std::nullopt};
CalendarConfig m_config = {true, 0};
int m_id = 0;
std::unique_ptr<Uri> m_eventUri;
std::unique_ptr<Uri> m_attendeeUri;
std::unique_ptr<Uri> m_calendarUri;
std::unique_ptr<Uri> m_reminderUrl;
std::unique_ptr<Uri> m_instanceUrl;
std::unique_ptr<Uri> m_eventUri = nullptr;
std::unique_ptr<Uri> m_attendeeUri = nullptr;
std::unique_ptr<Uri> m_calendarUri = nullptr;
std::unique_ptr<Uri> m_reminderUrl = nullptr;
std::unique_ptr<Uri> m_instanceUrl = nullptr;
};
} // namespace OHOS::Calendar
#endif // NATIVE_CALENDAR_H
+18 -11
View File
@@ -519,25 +519,32 @@ std::optional<Location> ResultSetToLocation(DataShareResultSetPtr &resultSet)
{
Location out;
string value;
double maxLon = 180;
double maxLat = 90;
auto ret = GetValue(resultSet, "eventLocation", value);
out.location = std::make_optional<string>(value);
ret = GetValue(resultSet, "location_longitude", value);
double longitudeValue = -1;
std::stringstream str2digit;
str2digit << value;
str2digit >> longitudeValue;
if (longitudeValue != -1) {
out.longitude = std::make_optional<double>(longitudeValue);
double longitudeValue = 0;
if (!value.empty()) {
str2digit << value;
str2digit >> longitudeValue;
if (fabs(longitudeValue) <= maxLon) {
out.longitude = std::make_optional<double>(longitudeValue);
}
}
ret = GetValue(resultSet, "location_latitude", value);
double latitudeValue = -1;
double latitudeValue = 0;
str2digit.clear();
str2digit << value;
str2digit >> latitudeValue;
if (latitudeValue != -1) {
out.latitude = std::make_optional<double>(latitudeValue);
if (!value.empty()) {
str2digit << value;
str2digit >> latitudeValue;
if (fabs(latitudeValue) <= maxLat) {
out.latitude = std::make_optional<double>(latitudeValue);
}
}
if (ret != DataShare::E_OK) {
return std::nullopt;
}
@@ -129,7 +129,7 @@ HWTEST_F(CalendarTest, GetEvent_test_1, testing::ext::TestSize.Level1)
const string title = "GetEvent_test_1";
event.title = title;
event.type = EventType::Important;
Location testLocation { "test", 123, 456 };
Location testLocation {"test", 123.12, 45.45};
event.location = std::make_optional<Location>(testLocation);
event.startTime = 1766620800000;
event.endTime = 1766620800000;
@@ -179,11 +179,7 @@ HWTEST_F(CalendarTest, UpdateEvent_DeleteLocation_test, testing::ext::TestSize.L
{
Event event;
event.title = "UpdateEvent_Location";
event.location = {
"test",
123,
456
};
event.location = {"test", 123.12, 45.45};
auto eventId = calendar->AddEvent(event);
ASSERT_NE(eventId, 0);
auto events = calendar->GetEvents(FilterById({eventId}), {});
@@ -213,7 +209,7 @@ HWTEST_F(CalendarTest, UpdateEvent_AddLocation_test, testing::ext::TestSize.Leve
EXPECT_EQ(newEvent.location.has_value(), true);
EXPECT_EQ(newEvent.location.value().location.has_value(), true);
EXPECT_EQ(newEvent.location.value().longitude.has_value(), false);
newEvent.location = {"test", 123, 456};
newEvent.location = {"test", 123.12, 45.45};
auto ret = calendar->UpdateEvent(newEvent);
EXPECT_EQ(ret, true);
@@ -249,7 +249,7 @@ HWTEST_F(EventFilterTest, FilterByTitle_and_eventKey_002, testing::ext::TestSize
const string title = "FilterByTitle_and_eventKey_002";
Event event;
event.title = title;
Location testLocation { "test", 123, 456 };
Location testLocation {"test", 123.12, 45.45};
event.location = std::make_optional<Location>(testLocation);
event.isAllDay = true;
event.attendees = {{"xiaoming", "xiaoming@abc.com", NONE, UNKNOWN, REQUIRED},
@@ -52,10 +52,30 @@ HWTEST_F(EventLocationTest, AddEventWithLocation, testing::ext::TestSize.Level1)
Event event;
const string title = "AddEventWithLocation";
event.title = title;
Location testLocation {"test", 123.12, 45.45};
event.location = std::make_optional<Location>(testLocation);
auto eventId = calendar->AddEvent(event);
ASSERT_NE(eventId, 0);
auto events = calendar->GetEvents(FilterByTitle(title), {});
ASSERT_EQ(events.size(), 1);
auto resultEvent = events.at(0);
EXPECT_EQ(resultEvent.title.value(), title);
ASSERT_NE(resultEvent.location, std::nullopt);
auto result = resultEvent.location.value();
EXPECT_EQ(result.location.value(), testLocation.location.value());
EXPECT_EQ(result.longitude.value(), testLocation.longitude.value());
EXPECT_EQ(result.latitude.value(), testLocation.latitude.value());
}
HWTEST_F(EventLocationTest, AddEventWithMaxLocation, testing::ext::TestSize.Level1)
{
Event event;
const string title = "AddEventWithMaxLocation";
event.title = title;
Location testLocation {
"test",
123,
456
180,
90
};
event.location = std::make_optional<Location>(testLocation);
auto eventId = calendar->AddEvent(event);
@@ -70,4 +90,76 @@ HWTEST_F(EventLocationTest, AddEventWithLocation, testing::ext::TestSize.Level1)
EXPECT_EQ(result.longitude.value(), testLocation.longitude.value());
EXPECT_EQ(result.latitude.value(), testLocation.latitude.value());
}
HWTEST_F(EventLocationTest, AddEventWithMinLocation, testing::ext::TestSize.Level1)
{
Event event;
const string title = "AddEventWithMinLocation";
event.title = title;
Location testLocation {
"test",
-180,
-90
};
event.location = std::make_optional<Location>(testLocation);
auto eventId = calendar->AddEvent(event);
ASSERT_NE(eventId, 0);
auto events = calendar->GetEvents(FilterByTitle(title), {});
ASSERT_EQ(events.size(), 1);
auto resultEvent = events.at(0);
EXPECT_EQ(resultEvent.title.value(), title);
ASSERT_NE(resultEvent.location, std::nullopt);
auto result = resultEvent.location.value();
EXPECT_EQ(result.location.value(), testLocation.location.value());
EXPECT_EQ(result.longitude.value(), testLocation.longitude.value());
EXPECT_EQ(result.latitude.value(), testLocation.latitude.value());
}
HWTEST_F(EventLocationTest, AddEventWithOutMinLocation, testing::ext::TestSize.Level1)
{
Event event;
const string title = "AddEventWithOutMinLocation";
event.title = title;
Location testLocation {
"test",
-180.99,
-90.99
};
event.location = std::make_optional<Location>(testLocation);
auto eventId = calendar->AddEvent(event);
ASSERT_NE(eventId, 0);
auto events = calendar->GetEvents(FilterByTitle(title), {});
ASSERT_EQ(events.size(), 1);
auto resultEvent = events.at(0);
EXPECT_EQ(resultEvent.title.value(), title);
ASSERT_NE(resultEvent.location, std::nullopt);
auto result = resultEvent.location.value();
EXPECT_EQ(result.location.value(), "test");
EXPECT_EQ(result.longitude.has_value(), false);
EXPECT_EQ(result.latitude.has_value(), false);
}
HWTEST_F(EventLocationTest, AddEventWithOutMaxLocation, testing::ext::TestSize.Level1)
{
Event event;
const string title = "AddEventWithOutMaxLocation";
event.title = title;
Location testLocation {
"test",
180.99,
90.99
};
event.location = std::make_optional<Location>(testLocation);
auto eventId = calendar->AddEvent(event);
ASSERT_NE(eventId, 0);
auto events = calendar->GetEvents(FilterByTitle(title), {});
ASSERT_EQ(events.size(), 1);
auto resultEvent = events.at(0);
EXPECT_EQ(resultEvent.title.value(), title);
ASSERT_NE(resultEvent.location, std::nullopt);
auto result = resultEvent.location.value();
EXPECT_EQ(result.location.value(), "test");
EXPECT_EQ(result.longitude.has_value(), false);
EXPECT_EQ(result.latitude.has_value(), false);
}
}