diff options
author | Robert Tari <robert@tari.in> | 2024-02-01 18:44:01 +0100 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2024-02-01 18:44:01 +0100 |
commit | d77ad890a0bb3b8e366c6dea23ca93f71e35d5d5 (patch) | |
tree | bb39fcf3f5051bec3e78d92974403571778e351a | |
parent | 0692cc58d1046b79671491866294692a48b05554 (diff) | |
download | ayatana-indicator-datetime-d77ad890a0bb3b8e366c6dea23ca93f71e35d5d5.tar.gz ayatana-indicator-datetime-d77ad890a0bb3b8e366c6dea23ca93f71e35d5d5.tar.bz2 ayatana-indicator-datetime-d77ad890a0bb3b8e366c6dea23ca93f71e35d5d5.zip |
Fix tests relying on the default EDS appointment colour
-rw-r--r-- | src/engine-eds.cpp | 30 | ||||
-rw-r--r-- | tests/test-eds-ics-all-day-events.cpp | 9 | ||||
-rw-r--r-- | tests/test-eds-ics-missing-trigger.cpp | 74 | ||||
-rw-r--r-- | tests/test-eds-ics-nonrepeating-events.cpp | 9 | ||||
-rw-r--r-- | tests/test-eds-ics-repeating-events.cpp | 9 | ||||
-rw-r--r-- | tests/test-eds-ics-tzids-2.cpp | 39 | ||||
-rw-r--r-- | tests/test-eds-ics-tzids-utc.cpp | 36 | ||||
-rw-r--r-- | tests/test-eds-ics-tzids.cpp | 37 |
8 files changed, 176 insertions, 67 deletions
diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp index 2748fc1..7a61fc0 100644 --- a/src/engine-eds.cpp +++ b/src/engine-eds.cpp @@ -1,6 +1,6 @@ /* * Copyright 2014 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -1074,6 +1074,34 @@ private: } g_slist_free_full(categ_list, g_free); + // Get the colour - we might need this override in the future + + /*if (icc) + { + ECalComponentPropertyBag *pBag = e_cal_component_property_bag_new_from_component (icc, NULL, NULL); + + if (pBag) + { + guint nProperties = e_cal_component_property_bag_get_count (pBag); + + for (guint nProperty = 0; nProperty < nProperties; nProperty++) + { + ICalProperty *pProperty = e_cal_component_property_bag_get (pBag, nProperty); + gchar *sName = i_cal_property_get_property_name (pProperty); + gboolean bColour = !g_strcmp0 (sName, "COLOR"); + + if (bColour) + { + baseline.color = i_cal_property_get_value_as_string (pProperty); + + break; + } + } + + e_cal_component_property_bag_free (pBag); + } + }*/ + g_debug("%s got appointment from %s to %s: %s", G_STRLOC, baseline.begin.format("%F %T %z").c_str(), baseline.end.format("%F %T %z").c_str(), diff --git a/tests/test-eds-ics-all-day-events.cpp b/tests/test-eds-ics-all-day-events.cpp index 93bc9e3..0fa40fd 100644 --- a/tests/test-eds-ics-all-day-events.cpp +++ b/tests/test-eds-ics-all-day-events.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -81,7 +81,6 @@ TEST_F(VAlarmFixture, MultipleAppointments) // what we expect to get... Appointment expected_appt; expected_appt.uid = "20150521T111538Z-7449-1000-3572-0@ghidorah"; - expected_appt.color = "#becedd"; expected_appt.summary = "Memorial Day"; expected_appt.begin = DateTime{gtz,2015,5,25,0,0,0}; expected_appt.end = DateTime{gtz,2015,5,26,0,0,0}; @@ -93,10 +92,14 @@ TEST_F(VAlarmFixture, MultipleAppointments) EXPECT_EQ(expected_appt.begin, appt.begin); EXPECT_EQ(expected_appt.end, appt.end); EXPECT_EQ(expected_appt.uid, appt.uid); - EXPECT_EQ(expected_appt.color, appt.color); EXPECT_EQ(expected_appt.summary, appt.summary); EXPECT_EQ(0, appt.alarms.size()); + EXPECT_PRED3([](auto sColourIn, auto sColourExpected1, auto sColourExpected2) + { + return sColourIn == sColourExpected1 || sColourIn == sColourExpected2; + }, appt.color, "#becedd", "#62a0ea"); + // cleanup g_time_zone_unref(gtz); } diff --git a/tests/test-eds-ics-missing-trigger.cpp b/tests/test-eds-ics-missing-trigger.cpp index 71a7707..4030999 100644 --- a/tests/test-eds-ics-missing-trigger.cpp +++ b/tests/test-eds-ics-missing-trigger.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021-2023 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -78,25 +78,25 @@ TEST_F(VAlarmFixture, MissingTriggers) wait_msec(max_wait_sec * G_TIME_SPAN_MILLISECOND); } - // build expected: one-time alarm - std::vector<Appointment> expected; - Appointment a; - a.type = Appointment::ALARM; - a.uid = "20150617T211838Z-6217-32011-2036-1@lomiri-phablet"; - a.color = "#becedd"; - a.summary = "One Time Alarm"; - a.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0}; - a.end = a.begin; - a.alarms.resize(1); - a.alarms[0].audio_url = "file://" ALARM_DEFAULT_SOUND; - a.alarms[0].time = a.begin; - a.alarms[0].text = a.summary; - expected.push_back(a); - - // build expected: recurring alarm - a.uid = "20150617T211913Z-6217-32011-2036-5@lomiri-phablet"; - a.summary = "Recurring Alarm"; - a.alarms[0].text = a.summary; + // build expected: one-time alarm 1 + std::vector<Appointment> expected1; + Appointment a1; + a1.type = Appointment::ALARM; + a1.uid = "20150617T211838Z-6217-32011-2036-1@lomiri-phablet"; + a1.color = "#becedd"; + a1.summary = "One Time Alarm"; + a1.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0}; + a1.end = a1.begin; + a1.alarms.resize(1); + a1.alarms[0].audio_url = "file://" ALARM_DEFAULT_SOUND; + a1.alarms[0].time = a1.begin; + a1.alarms[0].text = a1.summary; + expected1.push_back(a1); + + // build expected: recurring alarm 1 + a1.uid = "20150617T211913Z-6217-32011-2036-5@lomiri-phablet"; + a1.summary = "Recurring Alarm"; + a1.alarms[0].text = a1.summary; std::array<DateTime,13> recurrences { DateTime{ gtz, 2015, 6, 18, 10, 1, 0 }, DateTime{ gtz, 2015, 6, 19, 10, 1, 0 }, @@ -113,13 +113,41 @@ TEST_F(VAlarmFixture, MissingTriggers) DateTime{ gtz, 2015, 6, 30, 10, 1, 0 }, }; for (const auto& time : recurrences) { - a.begin = a.end = a.alarms[0].time = time; - expected.push_back(a); + a1.begin = a1.end = a1.alarms[0].time = time; + expected1.push_back(a1); + } + + // build expected: one-time alarm 2 + std::vector<Appointment> expected2; + Appointment a2; + a2.type = Appointment::ALARM; + a2.uid = "20150617T211838Z-6217-32011-2036-1@lomiri-phablet"; + a2.color = "#62a0ea"; + a2.summary = "One Time Alarm"; + a2.begin = DateTime { gtz, 2015, 6, 18, 10, 0, 0}; + a2.end = a2.begin; + a2.alarms.resize(1); + a2.alarms[0].audio_url = "file://" ALARM_DEFAULT_SOUND; + a2.alarms[0].time = a2.begin; + a2.alarms[0].text = a2.summary; + expected2.push_back(a2); + + // build expected: recurring alarm 2 + a2.uid = "20150617T211913Z-6217-32011-2036-5@lomiri-phablet"; + a2.summary = "Recurring Alarm"; + a2.alarms[0].text = a2.summary; + for (const auto& time : recurrences) { + a2.begin = a2.end = a2.alarms[0].time = time; + expected2.push_back(a2); } // the planner should match what we've got in the calendar.ics file const auto appts = planner->appointments().get(); - EXPECT_EQ(expected, appts); + + EXPECT_PRED3([](auto lAppointmentsIn, auto lAppointmentsExpected1, auto lAppointmentsExpected2) + { + return lAppointmentsIn == lAppointmentsExpected1 || lAppointmentsIn == lAppointmentsExpected2; + }, appts, expected1, expected2); // cleanup g_time_zone_unref(gtz); diff --git a/tests/test-eds-ics-nonrepeating-events.cpp b/tests/test-eds-ics-nonrepeating-events.cpp index 06b6b95..49fc9be 100644 --- a/tests/test-eds-ics-nonrepeating-events.cpp +++ b/tests/test-eds-ics-nonrepeating-events.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021-2022 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -81,7 +81,6 @@ TEST_F(VAlarmFixture, MultipleAppointments) // what we expect to get... Appointment expected_appt; expected_appt.uid = "20150520T000726Z-3878-32011-1770-81@lomiri-phablet"; - expected_appt.color = "#becedd"; expected_appt.summary = "Alarm"; std::array<Alarm,1> expected_alarms = { Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5,20,20,00,0)}) @@ -93,10 +92,14 @@ TEST_F(VAlarmFixture, MultipleAppointments) for (size_t i=0, n=expected_alarms.size(); i<n; i++) { const auto& appt = appts[i]; EXPECT_EQ(expected_appt.uid, appt.uid); - EXPECT_EQ(expected_appt.color, appt.color); EXPECT_EQ(expected_appt.summary, appt.summary); EXPECT_EQ(1, appt.alarms.size()); EXPECT_EQ(expected_alarms[i], appt.alarms[0]); + + EXPECT_PRED3([](auto sColourIn, auto sColourExpected1, auto sColourExpected2) + { + return sColourIn == sColourExpected1 || sColourIn == sColourExpected2; + }, appt.color, "#becedd", "#62a0ea"); } // cleanup diff --git a/tests/test-eds-ics-repeating-events.cpp b/tests/test-eds-ics-repeating-events.cpp index 2be5aa5..a570d0f 100644 --- a/tests/test-eds-ics-repeating-events.cpp +++ b/tests/test-eds-ics-repeating-events.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021-2022 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -81,7 +81,6 @@ TEST_F(VAlarmFixture, MultipleAppointments) // what we expect to get... Appointment expected_appt; expected_appt.uid = "20150507T211449Z-4262-32011-1418-1@lomiri-phablet"; - expected_appt.color = "#becedd"; expected_appt.summary = "Alarm"; std::array<Alarm,8> expected_alarms = { Alarm({"Alarm", "file://" ALARM_DEFAULT_SOUND, DateTime(gtz,2015,5, 8,16,40,0)}), @@ -100,10 +99,14 @@ TEST_F(VAlarmFixture, MultipleAppointments) for (size_t i=0, n=expected_alarms.size(); i<n; i++) { const auto& appt = appts[i]; EXPECT_EQ(expected_appt.uid, appt.uid); - EXPECT_EQ(expected_appt.color, appt.color); EXPECT_EQ(expected_appt.summary, appt.summary); EXPECT_EQ(1, appt.alarms.size()); EXPECT_EQ(expected_alarms[i], appt.alarms[0]); + + EXPECT_PRED3([](auto sColourIn, auto sColourExpected1, auto sColourExpected2) + { + return sColourIn == sColourExpected1 || sColourIn == sColourExpected2; + }, appt.color, "#becedd", "#62a0ea"); } // cleanup diff --git a/tests/test-eds-ics-tzids-2.cpp b/tests/test-eds-ics-tzids-2.cpp index 36ef0fe..1bef68b 100644 --- a/tests/test-eds-ics-tzids-2.cpp +++ b/tests/test-eds-ics-tzids-2.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021-2022 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -79,20 +79,35 @@ TEST_F(VAlarmFixture, MultipleAppointments) } // what we expect to get... - std::array<Appointment,1> expected_appts; - auto appt = &expected_appts[0]; - appt->uid = "109264742"; - appt->color = "#becedd"; - appt->summary = "National Incubator Initiative for Clean Energy (NIICE) FOA: Pre-Concept Paper Informational Webinar"; - appt->begin = DateTime{gtz,2014,1,21,11,0,0}; - appt->end = DateTime{gtz,2014,1,21,13,0,0}; - appt->alarms = std::vector<Alarm>{ Alarm({"Reminder", "", DateTime(gtz,2014,1,21,10,45,0)}) }; + std::array<Appointment,1> expected_appts1; + auto appt1 = &expected_appts1[0]; + appt1->uid = "109264742"; + appt1->color = "#becedd"; + appt1->summary = "National Incubator Initiative for Clean Energy (NIICE) FOA: Pre-Concept Paper Informational Webinar"; + appt1->begin = DateTime{gtz,2014,1,21,11,0,0}; + appt1->end = DateTime{gtz,2014,1,21,13,0,0}; + appt1->alarms = std::vector<Alarm>{ Alarm({"Reminder", "", DateTime(gtz,2014,1,21,10,45,0)}) }; + + std::array<Appointment,1> expected_appts2; + auto appt2 = &expected_appts2[0]; + appt2->uid = "109264742"; + appt2->color = "#62a0ea"; + appt2->summary = "National Incubator Initiative for Clean Energy (NIICE) FOA: Pre-Concept Paper Informational Webinar"; + appt2->begin = DateTime{gtz,2014,1,21,11,0,0}; + appt2->end = DateTime{gtz,2014,1,21,13,0,0}; + appt2->alarms = std::vector<Alarm>{ Alarm({"Reminder", "", DateTime(gtz,2014,1,21,10,45,0)}) }; // compare it to what we actually loaded... const auto appts = planner->appointments().get(); - EXPECT_EQ(expected_appts.size(), appts.size()); - for (size_t i=0, n=std::min(appts.size(),expected_appts.size()); i<n; i++) - EXPECT_EQ(expected_appts[i], appts[i]); + EXPECT_EQ(expected_appts1.size(), appts.size()); + EXPECT_EQ(expected_appts2.size(), appts.size()); + for (size_t i=0, n=std::min(appts.size(),expected_appts1.size()); i<n; i++) + { + EXPECT_PRED3([](auto pAppointmentIn, auto pAppointmentExpected1, auto pAppointmentExpected2) + { + return pAppointmentIn == pAppointmentExpected1 || pAppointmentIn == pAppointmentExpected2; + }, appts[i], expected_appts1[i], expected_appts2[i]); + } // cleanup g_time_zone_unref(gtz); diff --git a/tests/test-eds-ics-tzids-utc.cpp b/tests/test-eds-ics-tzids-utc.cpp index 3a79485..d88e95d 100644 --- a/tests/test-eds-ics-tzids-utc.cpp +++ b/tests/test-eds-ics-tzids-utc.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021-2022 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -80,19 +80,33 @@ TEST_F(VAlarmFixture, UTCAppointments) } // what we expect to get... - std::array<Appointment,1> expected_appts; - auto appt = &expected_appts[0]; - appt->uid = "20160322T132738Z"; - appt->color = "#becedd"; - appt->summary = "UTC event"; - appt->begin = DateTime{gtz,2016,3,22,15,0,0}; - appt->end = DateTime{gtz,2016,3,22,16,0,0}; + std::array<Appointment,1> expected_appts1; + auto appt1 = &expected_appts1[0]; + appt1->uid = "20160322T132738Z"; + appt1->color = "#becedd"; + appt1->summary = "UTC event"; + appt1->begin = DateTime{gtz,2016,3,22,15,0,0}; + appt1->end = DateTime{gtz,2016,3,22,16,0,0}; + + std::array<Appointment,1> expected_appts2; + auto appt2 = &expected_appts2[0]; + appt2->uid = "20160322T132738Z"; + appt2->color = "#62a0ea"; + appt2->summary = "UTC event"; + appt2->begin = DateTime{gtz,2016,3,22,15,0,0}; + appt2->end = DateTime{gtz,2016,3,22,16,0,0}; // compare it to what we actually loaded... const auto appts = planner->appointments().get(); - EXPECT_EQ(expected_appts.size(), appts.size()); - for (size_t i=0, n=std::min(appts.size(),expected_appts.size()); i<n; i++) - EXPECT_EQ(expected_appts[i], appts[i]); + EXPECT_EQ(expected_appts1.size(), appts.size()); + EXPECT_EQ(expected_appts2.size(), appts.size()); + for (size_t i=0, n=std::min(appts.size(),expected_appts1.size()); i<n; i++) + { + EXPECT_PRED3([](auto pAppointmentIn, auto pAppointmentExpected1, auto pAppointmentExpected2) + { + return pAppointmentIn == pAppointmentExpected1 || pAppointmentIn == pAppointmentExpected2; + }, appts[i], expected_appts1[i], expected_appts2[i]); + } // cleanup g_time_zone_unref(gtz); diff --git a/tests/test-eds-ics-tzids.cpp b/tests/test-eds-ics-tzids.cpp index c6b4dc4..4999e66 100644 --- a/tests/test-eds-ics-tzids.cpp +++ b/tests/test-eds-ics-tzids.cpp @@ -1,6 +1,6 @@ /* * Copyright 2015 Canonical Ltd. - * Copyright 2021-2022 Robert Tari + * Copyright 2021-2024 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -79,19 +79,34 @@ TEST_F(VAlarmFixture, MultipleAppointments) } // what we expect to get... - std::array<Appointment,1> expected_appts; - auto appt = &expected_appts[0]; - appt->uid = "8ggc30kh89qql8vjumgtug7l14@google.com"; - appt->color = "#becedd"; - appt->summary = "Hello"; - appt->begin = DateTime{gtz,2015,7,1,20,0,0}; - appt->end = DateTime{gtz,2015,7,1,22,0,0}; + std::array<Appointment,1> expected_appts1; + auto appt1 = &expected_appts1[0]; + appt1->uid = "8ggc30kh89qql8vjumgtug7l14@google.com"; + appt1->color = "#becedd"; + appt1->summary = "Hello"; + appt1->begin = DateTime{gtz,2015,7,1,20,0,0}; + appt1->end = DateTime{gtz,2015,7,1,22,0,0}; + + std::array<Appointment,1> expected_appts2; + auto appt2 = &expected_appts2[0]; + appt2->uid = "8ggc30kh89qql8vjumgtug7l14@google.com"; + appt2->color = "#62a0ea"; + appt2->summary = "Hello"; + appt2->begin = DateTime{gtz,2015,7,1,20,0,0}; + appt2->end = DateTime{gtz,2015,7,1,22,0,0}; // compare it to what we actually loaded... const auto appts = planner->appointments().get(); - EXPECT_EQ(expected_appts.size(), appts.size()); - for (size_t i=0, n=std::min(appts.size(),expected_appts.size()); i<n; i++) - EXPECT_EQ(expected_appts[i], appts[i]); + EXPECT_EQ(expected_appts1.size(), appts.size()); + EXPECT_EQ(expected_appts2.size(), appts.size()); + + for (size_t i=0, n=std::min(appts.size(),expected_appts1.size()); i<n; i++) + { + EXPECT_PRED3([](auto pAppointmentIn, auto pAppointmentExpected1, auto pAppointmentExpected2) + { + return pAppointmentIn == pAppointmentExpected1 || pAppointmentIn == pAppointmentExpected2; + }, appts[i], expected_appts1[i], expected_appts2[i]); + } // cleanup g_time_zone_unref(gtz); |