Merge lp:~charlesk/indicator-power/lp-880881 into lp:indicator-power/14.04

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 232
Merged at revision: 237
Proposed branch: lp:~charlesk/indicator-power/lp-880881
Merge into: lp:indicator-power/14.04
Diff against target: 463 lines (+269/-85)
4 files modified
src/device.c (+40/-13)
src/service.c (+125/-5)
tests/Makefile.am (+7/-0)
tests/test-device.cc (+97/-67)
To merge this branch: bzr merge lp:~charlesk/indicator-power/lp-880881
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+211817@code.launchpad.net

Commit message

If there are two batteries detected, combine their percentages and their time-remainings as per the revised spec.

Description of the change

If there are two batteries detected, combine their percentages and their time-remainings as per the revised spec.

https://wiki.ubuntu.com/Power#Handling_multiple_batteries

If a device has multiple batteries and uses only one of them at a time, they should be presented as separate items inside the battery menu, but everywhere else they should be aggregated (bug 880881). Their percentages should be averaged. If any are discharging, the aggregated time remaining should be the maximum of the times for all those that are discharging, plus the sum of the times for all those that are idle. Otherwise, the aggregated time remaining should be the the maximum of the times for all those that are charging.

For example, if your notebook has two internal batteries — one fully charged, and one that will discharge in 22 minutes — and your wireless mouse battery is estimated to discharge in 27 minutes, then the menu title should represent the mouse. Even though the internal battery will lose power first, the mouse is the device that will lose power first.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Wish I had a machine to test this for real on :-)

review: Approve
233. By Charles Kerr

add translator comments to the new translatable strings.

Revision history for this message
Charles Kerr (charlesk) wrote :

Erp, looks like that didn't merge cleanly.

234. By Charles Kerr

sync to lp:indicator-power

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/device.c'
--- src/device.c 2014-03-13 15:31:33 +0000
+++ src/device.c 2014-03-25 19:49:27 +0000
@@ -595,10 +595,12 @@
595595
596 if (p->state == UP_DEVICE_STATE_CHARGING)596 if (p->state == UP_DEVICE_STATE_CHARGING)
597 {597 {
598 /* TRANSLATORS: H:MM (hours, minutes) to charge the battery. Example: "1:30 to charge" */
598 str = g_strdup_printf (_("%0d:%02d to charge"), hours, minutes);599 str = g_strdup_printf (_("%0d:%02d to charge"), hours, minutes);
599 }600 }
600 else // discharging601 else // discharging
601 {602 {
603 /* TRANSLATORS: H:MM (hours, minutes) to discharge the battery. Example: "1:30 left"*/
602 str = g_strdup_printf (_("%0d:%02d left"), hours, minutes);604 str = g_strdup_printf (_("%0d:%02d left"), hours, minutes);
603 }605 }
604 }606 }
@@ -631,22 +633,38 @@
631 if (p->state == UP_DEVICE_STATE_CHARGING)633 if (p->state == UP_DEVICE_STATE_CHARGING)
632 {634 {
633 if (hours > 0)635 if (hours > 0)
634 str = g_strdup_printf (_("%d %s %d %s to charge"),636 {
635 hours, g_dngettext (NULL, "hour", "hours", hours),637 /* TRANSLATORS: "X (hour,hours) Y (minute,minutes) to charge" the battery.
636 minutes, g_dngettext (NULL, "minute", "minutes", minutes));638 Example: "1 hour 10 minutes to charge" */
639 str = g_strdup_printf (_("%d %s %d %s to charge"),
640 hours, g_dngettext (NULL, "hour", "hours", hours),
641 minutes, g_dngettext (NULL, "minute", "minutes", minutes));
642 }
637 else643 else
638 str = g_strdup_printf (_("%d %s to charge"),644 {
639 minutes, g_dngettext (NULL, "minute", "minutes", minutes));645 /* TRANSLATORS: "Y (minute,minutes) to charge" the battery.
646 Example: "59 minutes to charge" */
647 str = g_strdup_printf (_("%d %s to charge"),
648 minutes, g_dngettext (NULL, "minute", "minutes", minutes));
649 }
640 }650 }
641 else // discharging651 else // discharging
642 {652 {
643 if (hours > 0)653 if (hours > 0)
644 str = g_strdup_printf (_("%d %s %d %s left"),654 {
645 hours, g_dngettext (NULL, "hour", "hours", hours),655 /* TRANSLATORS: "X (hour,hours) Y (minute,minutes) left" until the battery's empty.
646 minutes, g_dngettext (NULL, "minute", "minutes", minutes));656 Example: "1 hour 10 minutes left" */
647 else657 str = g_strdup_printf (_("%d %s %d %s left"),
648 str = g_strdup_printf (_("%d %s left"),658 hours, g_dngettext (NULL, "hour", "hours", hours),
649 minutes, g_dngettext (NULL, "minute", "minutes", minutes));659 minutes, g_dngettext (NULL, "minute", "minutes", minutes));
660 }
661 else
662 {
663 /* TRANSLATORS: "Y (minute,minutes) left" until the battery's empty.
664 Example: "59 minutes left" */
665 str = g_strdup_printf (_("%d %s left"),
666 minutes, g_dngettext (NULL, "minute", "minutes", minutes));
667 }
650 }668 }
651 }669 }
652 else670 else
@@ -700,6 +718,7 @@
700718
701 if (p->state == UP_DEVICE_STATE_FULLY_CHARGED)719 if (p->state == UP_DEVICE_STATE_FULLY_CHARGED)
702 {720 {
721 /* TRANSLATORS: example: "battery (charged)" */
703 str = g_strdup_printf (_("%s (charged)"), kind_str);722 str = g_strdup_printf (_("%s (charged)"), kind_str);
704 }723 }
705 else724 else
@@ -715,9 +734,14 @@
715 }734 }
716735
717 if (time_str && *time_str)736 if (time_str && *time_str)
718 str = g_strdup_printf (_("%s (%s)"), kind_str, time_str);737 {
738 /* TRANSLATORS: example: "battery (time remaining)" */
739 str = g_strdup_printf (_("%s (%s)"), kind_str, time_str);
740 }
719 else741 else
720 str = g_strdup (kind_str);742 {
743 str = g_strdup (kind_str);
744 }
721745
722 g_free (time_str);746 g_free (time_str);
723 }747 }
@@ -783,14 +807,17 @@
783807
784 if (want_time && want_percent)808 if (want_time && want_percent)
785 {809 {
810 /* TRANSLATORS: after the icon, a time-remaining string + battery %. Example: "(0:59, 33%)" */
786 str = g_strdup_printf (_("(%s, %.0lf%%)"), time_str, p->percentage);811 str = g_strdup_printf (_("(%s, %.0lf%%)"), time_str, p->percentage);
787 }812 }
788 else if (want_time)813 else if (want_time)
789 {814 {
815 /* TRANSLATORS: after the icon, a time-remaining string Example: "(0:59)" */
790 str = g_strdup_printf (_("(%s)"), time_str);816 str = g_strdup_printf (_("(%s)"), time_str);
791 }817 }
792 else if (want_percent)818 else if (want_percent)
793 {819 {
820 /* TRANSLATORS: after the icon, a battery %. Example: "(33%)" */
794 str = g_strdup_printf (_("(%.0lf%%)"), p->percentage);821 str = g_strdup_printf (_("(%.0lf%%)"), p->percentage);
795 }822 }
796 else823 else
797824
=== modified file 'src/service.c'
--- src/service.c 2014-03-13 22:27:29 +0000
+++ src/service.c 2014-03-25 19:49:27 +0000
@@ -1135,6 +1135,129 @@
1135 }1135 }
1136}1136}
11371137
1138/* If a device has multiple batteries and uses only one of them at a time,
1139 they should be presented as separate items inside the battery menu,
1140 but everywhere else they should be aggregated (bug 880881).
1141 Their percentages should be averaged. If any are discharging,
1142 the aggregated time remaining should be the maximum of the times
1143 for all those that are discharging, plus the sum of the times
1144 for all those that are idle. Otherwise, the aggregated time remaining
1145 should be the the maximum of the times for all those that are charging. */
1146static IndicatorPowerDevice *
1147create_totalled_battery_device (const GList * devices)
1148{
1149 const GList * l;
1150 guint n_charged = 0;
1151 guint n_charging = 0;
1152 guint n_discharging = 0;
1153 guint n_batteries = 0;
1154 double sum_percent = 0;
1155 time_t max_discharge_time = 0;
1156 time_t max_charge_time = 0;
1157 time_t sum_charged_time = 0;
1158 IndicatorPowerDevice * device = NULL;
1159
1160 for (l=devices; l!=NULL; l=l->next)
1161 {
1162 const IndicatorPowerDevice * device = INDICATOR_POWER_DEVICE(l->data);
1163
1164 if (indicator_power_device_get_kind(device) == UP_DEVICE_KIND_BATTERY)
1165 {
1166 const double percent = indicator_power_device_get_percentage (device);
1167 const time_t t = indicator_power_device_get_time (device);
1168 const UpDeviceState state = indicator_power_device_get_state (device);
1169
1170 ++n_batteries;
1171
1172 if (percent > 0.01)
1173 sum_percent += percent;
1174
1175 if (state == UP_DEVICE_STATE_CHARGING)
1176 {
1177 ++n_charging;
1178 max_charge_time = MAX(max_charge_time, t);
1179 }
1180 else if (state == UP_DEVICE_STATE_DISCHARGING)
1181 {
1182 ++n_discharging;
1183 max_discharge_time = MAX(max_discharge_time, t);
1184 }
1185 else if (state == UP_DEVICE_STATE_FULLY_CHARGED)
1186 {
1187 ++n_charged;
1188 sum_charged_time += t;
1189 }
1190 }
1191 }
1192
1193 if (n_batteries > 1)
1194 {
1195 const double percent = sum_percent / n_batteries;
1196 UpDeviceState state;
1197 time_t time_left;
1198
1199 if (n_discharging > 0)
1200 {
1201 state = UP_DEVICE_STATE_DISCHARGING;
1202 time_left = max_discharge_time + sum_charged_time;
1203 }
1204 else if (n_charging > 0)
1205 {
1206 state = UP_DEVICE_STATE_CHARGING;
1207 time_left = max_charge_time;
1208 }
1209 else if (n_charged > 0)
1210 {
1211 state = UP_DEVICE_STATE_FULLY_CHARGED;
1212 time_left = 0;
1213 }
1214 else
1215 {
1216 state = UP_DEVICE_STATE_UNKNOWN;
1217 time_left = 0;
1218 }
1219
1220 device = indicator_power_device_new (NULL,
1221 UP_DEVICE_KIND_BATTERY,
1222 percent,
1223 state,
1224 time_left);
1225 }
1226
1227 return device;
1228}
1229
1230/**
1231 * If there are multiple UP_DEVICE_KIND_BATTERY devices in the list,
1232 * they're merged into a new 'totalled' device representing the sum of them.
1233 *
1234 * Returns: (element-type IndicatorPowerDevice)(transfer full): a list of devices
1235 */
1236static GList*
1237merge_batteries_together (GList * devices)
1238{
1239 GList * ret;
1240 IndicatorPowerDevice * merged_device;
1241
1242 if ((merged_device = create_totalled_battery_device (devices)))
1243 {
1244 GList * l;
1245
1246 ret = g_list_append (NULL, merged_device);
1247
1248 for (l=devices; l!=NULL; l=l->next)
1249 if (indicator_power_device_get_kind(INDICATOR_POWER_DEVICE(l->data)) != UP_DEVICE_KIND_BATTERY)
1250 ret = g_list_append (ret, g_object_ref(l->data));
1251 }
1252 else /* not enough batteries to merge */
1253 {
1254 ret = g_list_copy (devices);
1255 g_list_foreach (ret, (GFunc)g_object_ref, NULL);
1256 }
1257
1258 return ret;
1259}
1260
1138IndicatorPowerDevice *1261IndicatorPowerDevice *
1139indicator_power_service_choose_primary_device (GList * devices)1262indicator_power_service_choose_primary_device (GList * devices)
1140{1263{
@@ -1142,13 +1265,10 @@
11421265
1143 if (devices != NULL)1266 if (devices != NULL)
1144 {1267 {
1145 GList * tmp;1268 GList * tmp = merge_batteries_together (devices);
1146
1147 tmp = g_list_copy (devices);
1148 tmp = g_list_sort (tmp, device_compare_func);1269 tmp = g_list_sort (tmp, device_compare_func);
1149 primary = g_object_ref (tmp->data);1270 primary = g_object_ref (tmp->data);
11501271 g_list_free_full (tmp, (GDestroyNotify)g_object_unref);
1151 g_list_free (tmp);
1152 }1272 }
11531273
1154 return primary;1274 return primary;
11551275
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2014-03-05 04:57:52 +0000
+++ tests/Makefile.am 2014-03-25 19:49:27 +0000
@@ -25,6 +25,13 @@
25### tests: indicator-power-device25### tests: indicator-power-device
26###26###
2727
28dear-reader-please-note-the-next-test-takes-90-seconds:
29 @echo "#!/bin/bash" > $@
30 @echo "exit 0" >> $@
31 @chmod +x $@
32TESTS += dear-reader-please-note-the-next-test-takes-90-seconds
33CLEANFILES += dear-reader-please-note-the-next-test-takes-90-seconds
34
28TEST_LIBS = $(COVERAGE_LDFLAGS) libgtest.a -lpthread35TEST_LIBS = $(COVERAGE_LDFLAGS) libgtest.a -lpthread
29TEST_CPPFLAGS = $(SERVICE_DEPS_CFLAGS) $(AM_CPPFLAGS)36TEST_CPPFLAGS = $(SERVICE_DEPS_CFLAGS) $(AM_CPPFLAGS)
3037
3138
=== modified file 'tests/test-device.cc'
--- tests/test-device.cc 2014-03-13 15:32:04 +0000
+++ tests/test-device.cc 2014-03-25 19:49:27 +0000
@@ -19,6 +19,7 @@
1919
20#include <gio/gio.h>20#include <gio/gio.h>
21#include <gtest/gtest.h>21#include <gtest/gtest.h>
22#include <cmath> // ceil()
22#include "device.h"23#include "device.h"
23#include "service.h"24#include "service.h"
2425
@@ -668,77 +669,106 @@
668 g_free (real_lang);669 g_free (real_lang);
669}670}
670671
671672/* If a device has multiple batteries and uses only one of them at a time,
672/* The menu title should tell you at a glance what you need to know most: what673 they should be presented as separate items inside the battery menu,
673 device will lose power soonest (and optionally when), or otherwise which674 but everywhere else they should be aggregated (bug 880881).
674 device will take longest to charge (and optionally how long it will take). */675 Their percentages should be averaged. If any are discharging,
676 the aggregated time remaining should be the maximum of the times
677 for all those that are discharging, plus the sum of the times
678 for all those that are idle. Otherwise, the aggregated time remaining
679 should be the the maximum of the times for all those that are charging. */
675TEST_F(DeviceTest, ChoosePrimary)680TEST_F(DeviceTest, ChoosePrimary)
676{681{
677 GList * device_list;682 struct Description
678 IndicatorPowerDevice * a;683 {
679 IndicatorPowerDevice * b;684 const char * path;
680685 UpDeviceKind kind;
681 a = indicator_power_device_new ("/org/freedesktop/UPower/devices/mouse",686 UpDeviceState state;
682 UP_DEVICE_KIND_MOUSE,
683 0.0,
684 UP_DEVICE_STATE_DISCHARGING,
685 0);
686 b = indicator_power_device_new ("/org/freedesktop/UPower/devices/battery",
687 UP_DEVICE_KIND_BATTERY,
688 0.0,
689 UP_DEVICE_STATE_DISCHARGING,
690 0);
691
692 /* device states + time left to {discharge,charge} + % of charge left,
693 sorted in order of preference wrt the spec's criteria.
694 So tests[i] should be picked over any test with an index greater than i */
695 struct {
696 int kind;
697 int state;
698 guint64 time;687 guint64 time;
699 double percentage;688 double percentage;
689 };
690
691 const Description descriptions[] = {
692 { "/some/path/d0", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 10, 60.0 }, // 0
693 { "/some/path/d1", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 20, 80.0 }, // 1
694 { "/some/path/d2", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 30, 100.0 }, // 2
695
696 { "/some/path/c0", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 10, 60.0 }, // 3
697 { "/some/path/c1", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 20, 80.0 }, // 4
698 { "/some/path/c2", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 30, 100.0 }, // 5
699
700 { "/some/path/f0", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_FULLY_CHARGED, 0, 100.0 }, // 6
701 { "/some/path/m0", UP_DEVICE_KIND_MOUSE, UP_DEVICE_STATE_DISCHARGING, 20, 80.0 }, // 7
702 { "/some/path/m1", UP_DEVICE_KIND_MOUSE, UP_DEVICE_STATE_FULLY_CHARGED, 0, 100.0 }, // 8
703 { "/some/path/pw", UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 } // 9
704 };
705
706 std::vector<IndicatorPowerDevice*> devices;
707 for(const auto& desc : descriptions)
708 devices.push_back(indicator_power_device_new(desc.path, desc.kind, desc.percentage, desc.state, desc.time));
709
710 const struct {
711 std::vector<int> device_indices;
712 Description expected;
700 } tests[] = {713 } tests[] = {
701 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 49, 50.0 },714
702 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 50, 50.0 },715 { { 0 }, descriptions[0] }, // 1 discharging
703 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 50, 100.0 },716 { { 0, 1 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 20, 70.0 } }, // 2 discharging
704 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 51, 50.0 },717 { { 1, 2 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 30, 90.0 } }, // 2 discharging
705 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 50, 50.0 },718 { { 0, 1, 2 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 30, 80.0 } }, // 3 discharging
706 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 50.0 },719
707 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 49, 100.0 },720 { { 3 }, descriptions[3] }, // 1 charging
708 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 48, 50.0 },721 { { 3, 4 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 20, 70.0 } }, // 2 charging
709 { UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 },722 { { 4, 5 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 30, 90.0 } }, // 2 charging
710 { UP_DEVICE_KIND_KEYBOARD, UP_DEVICE_STATE_FULLY_CHARGED, 0, 50.0 },723 { { 3, 4, 5 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 30, 80.0 } }, // 3 charging
711 { UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 }724
725 { { 6 }, descriptions[6] }, // 1 charged
726 { { 6, 0 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 10, 80.0 } }, // 1 charged, 1 discharging
727 { { 6, 3 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_CHARGING, 10, 80.0 } }, // 1 charged, 1 charging
728 { { 6, 0, 3 }, { nullptr, UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_DISCHARGING, 10, 73.3 } }, // 1 charged, 1 charging, 1 discharging
729
730 { { 0, 7 }, descriptions[0] }, // 1 discharging battery, 1 discharging mouse. pick the one with the least time left.
731 { { 2, 7 }, descriptions[7] }, // 1 discharging battery, 1 discharging mouse. pick the one with the least time left.
732
733 { { 0, 8 }, descriptions[0] }, // 1 discharging battery, 1 fully-charged mouse. pick the one that's discharging.
734 { { 6, 7 }, descriptions[7] }, // 1 discharging mouse, 1 fully-charged battery. pick the one that's discharging.
735
736 { { 0, 9 }, descriptions[0] }, // everything comes before power lines
737 { { 3, 9 }, descriptions[3] },
738 { { 7, 9 }, descriptions[7] }
712 };739 };
713740
714 device_list = NULL;741 for(const auto& test : tests)
715 device_list = g_list_append (device_list, a);742 {
716 device_list = g_list_append (device_list, b);743 const auto& x = test.expected;
717744
718 for (int i=0, n=G_N_ELEMENTS(tests); i<n; i++)745 GList * device_glist = nullptr;
719 {746 for(const auto& i : test.device_indices)
720 for (int j=i+1; j<n; j++)747 device_glist = g_list_append(device_glist, devices[i]);
721 {748
722 g_object_set (a, INDICATOR_POWER_DEVICE_KIND, tests[i].kind,749 auto primary = indicator_power_service_choose_primary_device(device_glist);
723 INDICATOR_POWER_DEVICE_STATE, tests[i].state,750 EXPECT_STREQ(x.path, indicator_power_device_get_object_path(primary));
724 INDICATOR_POWER_DEVICE_TIME, guint64(tests[i].time),751 EXPECT_EQ(x.kind, indicator_power_device_get_kind(primary));
725 INDICATOR_POWER_DEVICE_PERCENTAGE, tests[i].percentage,752 EXPECT_EQ(x.state, indicator_power_device_get_state(primary));
726 NULL);753 EXPECT_EQ(x.time, indicator_power_device_get_time(primary));
727 g_object_set (b, INDICATOR_POWER_DEVICE_KIND, tests[j].kind,754 EXPECT_EQ((int)ceil(x.percentage), (int)ceil(indicator_power_device_get_percentage(primary)));
728 INDICATOR_POWER_DEVICE_STATE, tests[j].state,755 g_object_unref(primary);
729 INDICATOR_POWER_DEVICE_TIME, guint64(tests[j].time),756
730 INDICATOR_POWER_DEVICE_PERCENTAGE, tests[j].percentage,757 // reverse the list and repeat the test
731 NULL);758 // to confirm that list order doesn't matter
732 ASSERT_EQ (a, indicator_power_service_choose_primary_device(device_list));759 device_glist = g_list_reverse (device_glist);
733 g_object_unref (G_OBJECT(a));760 primary = indicator_power_service_choose_primary_device (device_glist);
734761 EXPECT_STREQ(x.path, indicator_power_device_get_object_path(primary));
735 /* reverse the list to check that list order doesn't matter */762 EXPECT_EQ(x.kind, indicator_power_device_get_kind(primary));
736 device_list = g_list_reverse (device_list);763 EXPECT_EQ(x.state, indicator_power_device_get_state(primary));
737 ASSERT_EQ (a, indicator_power_service_choose_primary_device(device_list));764 EXPECT_EQ(x.time, indicator_power_device_get_time(primary));
738 g_object_unref (G_OBJECT(a));765 EXPECT_EQ((int)ceil(x.percentage), (int)ceil(indicator_power_device_get_percentage(primary)));
739 }766 g_object_unref(primary);
740 }767
741768 // cleanup
742 // cleanup769 g_list_free(device_glist);
743 g_list_free_full (device_list, g_object_unref);770 }
771
772 for (auto& device : devices)
773 g_object_unref (device);
744}774}

Subscribers

People subscribed via source and target branches