Merge lp:~charlesk/indicator-power/use-dbusmock-notify-template into lp:indicator-power

Proposed by Charles Kerr on 2016-05-25
Status: Approved
Approved by: Antti Kaijanmäki on 2016-05-26
Approved revision: 299
Proposed branch: lp:~charlesk/indicator-power/use-dbusmock-notify-template
Merge into: lp:indicator-power
Diff against target: 620 lines (+219/-217)
5 files modified
debian/control (+0/-2)
tests/CMakeLists.txt (+0/-5)
tests/glib-fixture.h (+11/-11)
tests/test-dbus-fixture.h (+108/-0)
tests/test-notify.cc (+100/-199)
To merge this branch: bzr merge lp:~charlesk/indicator-power/use-dbusmock-notify-template
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) 2016-05-25 Approve on 2016-05-26
PS Jenkins bot continuous-integration Pending
Review via email: mp+295768@code.launchpad.net

Commit message

In tests, use python-dbusmock's notification_daemon mock

Description of the change

No changes to production -- only to test scaffolding.

Use python-dbusmock's notification_daemon mock instead of rolling our own.

To post a comment you must log in.
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM.

review: Approve
300. By Charles Kerr on 2016-05-26

sync tests/CMakeLists.txt dependencies with debian/control

Unmerged revisions

300. By Charles Kerr on 2016-05-26

sync tests/CMakeLists.txt dependencies with debian/control

299. By Charles Kerr on 2016-05-25

remove the dbusmock startup script and instead invoke dbusmock ourselves

298. By Charles Kerr on 2016-05-25

reuse test-dbus-fixture.h from indicator-datetime/16.10

297. By Charles Kerr on 2016-05-25

sync with trunk/16.10

296. By Charles Kerr on 2015-11-29

in tests/test-notify, use dbusmock's notification_daemon template instead of rolling our own

295. By Charles Kerr on 2015-11-29

in tests/CMakeLists.txt, add SCRIPTS_DIR definition to so tests will know where to find start-mock-notifications.py

294. By Charles Kerr on 2015-11-29

add tests/start-mock-notifications.py, a simple dbusmock helper script that can be told to emulate unity7 or unity8 notification server capabilities

293. By Charles Kerr on 2015-11-29

add tests/dbus-fixture.h, a fixture that manages a dbus connection and has helper utils

292. By Charles Kerr on 2015-11-29

in tests/glib-fixture.h, rename the protected loop variable as 'm_loop' for naming consistency

291. By Charles Kerr on 2015-11-29

remove libdbustest, we're calling dbusmock directly so we can use templates with parameters

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2016-05-16 18:09:57 +0000
3+++ debian/control 2016-05-26 20:21:58 +0000
4@@ -17,8 +17,6 @@
5 # for tests
6 libgtest-dev,
7 python3-dbusmock,
8- dbus-test-runner,
9- libdbustest1-dev,
10 Standards-Version: 3.9.5
11 Homepage: https://launchpad.net/indicator-power
12 # If you aren't a member of ~indicator-applet-developers but need to upload
13
14=== modified file 'tests/CMakeLists.txt'
15--- tests/CMakeLists.txt 2016-05-16 17:59:03 +0000
16+++ tests/CMakeLists.txt 2016-05-26 20:21:58 +0000
17@@ -5,11 +5,6 @@
18 set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR})
19 set_target_properties (gtest PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -w)
20
21-# dbustest
22-pkg_check_modules(DBUSTEST REQUIRED
23- dbustest-1>=14.04.0)
24-include_directories (SYSTEM ${DBUSTEST_INCLUDE_DIRS})
25-
26 # add warnings
27 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${C_WARNING_ARGS}")
28 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-global-constructors") # Google Test
29
30=== modified file 'tests/glib-fixture.h'
31--- tests/glib-fixture.h 2016-05-16 21:28:14 +0000
32+++ tests/glib-fixture.h 2016-05-26 20:21:58 +0000
33@@ -44,7 +44,7 @@
34 {
35 setlocale(LC_ALL, "C.UTF-8");
36
37- loop = g_main_loop_new(nullptr, false);
38+ m_loop = g_main_loop_new(nullptr, false);
39
40 // only use local, temporary settings
41 g_assert(g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, true));
42@@ -62,7 +62,7 @@
43 {
44 g_test_assert_expected_messages ();
45
46- g_clear_pointer(&loop, g_main_loop_unref);
47+ g_clear_pointer(&m_loop, g_main_loop_unref);
48 }
49
50 void expectLogMessage (const gchar *domain, GLogLevelFlags level, const gchar *pattern)
51@@ -94,11 +94,11 @@
52 // wait for the signal or for timeout, whichever comes first
53 const auto handler_id = g_signal_connect_swapped(o, signal,
54 G_CALLBACK(g_main_loop_quit),
55- loop);
56+ m_loop);
57 const auto timeout_id = g_timeout_add_seconds(timeout_seconds,
58 wait_for_signal__timeout,
59- loop);
60- g_main_loop_run(loop);
61+ m_loop);
62+ g_main_loop_run(m_loop);
63 g_source_remove(timeout_id);
64 g_signal_handler_disconnect(o, handler_id);
65 }
66@@ -106,8 +106,8 @@
67 /* convenience func to loop for N msec */
68 void wait_msec(int msec=50)
69 {
70- const auto id = g_timeout_add(msec, wait_msec__timeout, loop);
71- g_main_loop_run(loop);
72+ const auto id = g_timeout_add(msec, wait_msec__timeout, m_loop);
73+ g_main_loop_run(m_loop);
74 g_source_remove(id);
75 }
76
77@@ -148,8 +148,8 @@
78 g_main_loop_quit(tmp->loop);
79 };
80
81- const auto timeout_id = g_timeout_add(timeout_msec, wait_msec__timeout, loop);
82- data.loop = loop;
83+ const auto timeout_id = g_timeout_add(timeout_msec, wait_msec__timeout, m_loop);
84+ data.loop = m_loop;
85 const auto watch_id = g_bus_watch_name_on_connection(
86 connection,
87 name,
88@@ -160,7 +160,7 @@
89 nullptr // user_data_free_func
90 );
91
92- g_main_loop_run(loop);
93+ g_main_loop_run(m_loop);
94
95 g_bus_unwatch_name(watch_id);
96 g_source_remove(timeout_id);
97@@ -223,6 +223,6 @@
98 );
99 }
100
101- GMainLoop* loop {};
102+ GMainLoop* m_loop {};
103 };
104
105
106=== added file 'tests/test-dbus-fixture.h'
107--- tests/test-dbus-fixture.h 1970-01-01 00:00:00 +0000
108+++ tests/test-dbus-fixture.h 2016-05-26 20:21:58 +0000
109@@ -0,0 +1,108 @@
110+/*
111+ * Copyright 2013-2016 Canonical Ltd.
112+ *
113+ * This program is free software: you can redistribute it and/or modify it
114+ * under the terms of the GNU General Public License version 3, as published
115+ * by the Free Software Foundation.
116+ *
117+ * This program is distributed in the hope that it will be useful, but
118+ * WITHOUT ANY WARRANTY; without even the implied warranties of
119+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
120+ * PURPOSE. See the GNU General Public License for more details.
121+ *
122+ * You should have received a copy of the GNU General Public License along
123+ * with this program. If not, see <http://www.gnu.org/licenses/>.
124+ *
125+ * Authors:
126+ * Charles Kerr <charles.kerr@canonical.com>
127+ */
128+
129+#pragma once
130+
131+#include "glib-fixture.h"
132+
133+/***
134+****
135+***/
136+
137+class TestDBusFixture: public GlibFixture
138+{
139+ public:
140+
141+ TestDBusFixture() =default;
142+ virtual ~TestDBusFixture() =default;
143+
144+ explicit TestDBusFixture(const std::vector<std::string>& service_dirs_in):
145+ service_dirs(service_dirs_in)
146+ {
147+ }
148+
149+ private:
150+
151+ typedef GlibFixture super;
152+
153+ static void
154+ on_bus_opened (GObject* /*object*/, GAsyncResult * res, gpointer gself)
155+ {
156+ auto self = static_cast<TestDBusFixture*>(gself);
157+
158+ GError* err {};
159+ self->m_bus = g_bus_get_finish (res, &err);
160+ g_assert_no_error (err);
161+
162+ g_main_loop_quit (self->m_loop);
163+ }
164+
165+ static void
166+ on_bus_closed (GObject* /*object*/, GAsyncResult * res, gpointer gself)
167+ {
168+ auto self = static_cast<TestDBusFixture*>(gself);
169+
170+ GError* err {};
171+ g_dbus_connection_close_finish (self->m_bus, res, &err);
172+ g_assert_no_error (err);
173+
174+ g_main_loop_quit (self->m_loop);
175+ }
176+
177+ protected:
178+
179+ GTestDBus * m_test_dbus {};
180+ GDBusConnection * m_bus {};
181+ const std::vector<std::string> service_dirs;
182+
183+ virtual void SetUp() override
184+ {
185+ super::SetUp ();
186+
187+ // pull up a test dbus
188+ m_test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
189+ for (const auto& dir : service_dirs)
190+ g_test_dbus_add_service_dir (m_test_dbus, dir.c_str());
191+ g_test_dbus_up (m_test_dbus);
192+ const char * address = g_test_dbus_get_bus_address (m_test_dbus);
193+ g_setenv ("DBUS_SYSTEM_BUS_ADDRESS", address, true);
194+ g_setenv ("DBUS_SESSION_BUS_ADDRESS", address, true);
195+ g_debug ("test_dbus's address is %s", address);
196+
197+ // wait for the GDBusConnection before returning
198+ g_bus_get (G_BUS_TYPE_SYSTEM, nullptr, on_bus_opened, this);
199+ g_main_loop_run (m_loop);
200+ }
201+
202+ virtual void TearDown() override
203+ {
204+ wait_msec();
205+
206+ // close the bus
207+ g_dbus_connection_close(m_bus, nullptr, on_bus_closed, this);
208+ g_main_loop_run(m_loop);
209+ g_clear_object(&m_bus);
210+
211+ // tear down the test dbus
212+ g_test_dbus_down(m_test_dbus);
213+ g_clear_object(&m_test_dbus);
214+
215+ super::TearDown();
216+ }
217+};
218
219=== modified file 'tests/test-notify.cc'
220--- tests/test-notify.cc 2016-05-16 17:59:03 +0000
221+++ tests/test-notify.cc 2016-05-26 20:21:58 +0000
222@@ -17,8 +17,7 @@
223 * Charles Kerr <charles.kerr@canonical.com>
224 */
225
226-
227-#include "glib-fixture.h"
228+#include "test-dbus-fixture.h"
229
230 #include "dbus-shared.h"
231 #include "device.h"
232@@ -26,181 +25,107 @@
233
234 #include <gtest/gtest.h>
235
236-#include <libdbustest/dbus-test.h>
237-
238 #include <libnotify/notify.h>
239
240-#include <glib.h>
241 #include <gio/gio.h>
242
243 /***
244 ****
245 ***/
246
247-class NotifyFixture: public GlibFixture
248+class NotifyFixture: public TestDBusFixture
249 {
250-private:
251-
252- typedef GlibFixture super;
253-
254- static constexpr char const * NOTIFY_BUSNAME {"org.freedesktop.Notifications"};
255- static constexpr char const * NOTIFY_INTERFACE {"org.freedesktop.Notifications"};
256- static constexpr char const * NOTIFY_PATH {"/org/freedesktop/Notifications"};
257-
258-protected:
259-
260- DbusTestService * service = nullptr;
261- DbusTestDbusMock * mock = nullptr;
262- DbusTestDbusMockObject * obj = nullptr;
263- GDBusConnection * bus = nullptr;
264-
265- static constexpr int FIRST_NOTIFY_ID {1234};
266-
267- static constexpr int NOTIFICATION_CLOSED_EXPIRED {1};
268- static constexpr int NOTIFICATION_CLOSED_DISMISSED {2};
269- static constexpr int NOTIFICATION_CLOSED_API {3};
270- static constexpr int NOTIFICATION_CLOSED_UNDEFINED {4};
271-
272- static constexpr char const * METHOD_CLOSE {"CloseNotification"};
273- static constexpr char const * METHOD_NOTIFY {"Notify"};
274- static constexpr char const * METHOD_GET_CAPS {"GetCapabilities"};
275- static constexpr char const * METHOD_GET_INFO {"GetServerInformation"};
276- static constexpr char const * SIGNAL_CLOSED {"NotificationClosed"};
277-
278- static constexpr char const * HINT_TIMEOUT {"x-canonical-snap-decisions-timeout"};
279-
280-protected:
281-
282- void SetUp()
283- {
284- super::SetUp();
285-
286- g_setenv ("XDG_DATA_HOME", XDG_DATA_HOME, TRUE);
287-
288- // init DBusMock / dbus-test-runner
289-
290- service = dbus_test_service_new(nullptr);
291-
292- GError * error = nullptr;
293- mock = dbus_test_dbus_mock_new(NOTIFY_BUSNAME);
294- obj = dbus_test_dbus_mock_get_object(mock,
295- NOTIFY_PATH,
296- NOTIFY_INTERFACE,
297- &error);
298- g_assert_no_error (error);
299-
300- // METHOD_GET_INFO
301- dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_GET_INFO,
302- nullptr,
303- G_VARIANT_TYPE("(ssss)"),
304- "ret = ('mock-notify', 'test vendor', '1.0', '1.1')",
305- &error);
306- g_assert_no_error (error);
307-
308- // METHOD_NOTIFY
309- auto str = g_strdup_printf("try:\n"
310- " self.NextNotifyId\n"
311- "except AttributeError:\n"
312- " self.NextNotifyId = %d\n"
313- "ret = self.NextNotifyId\n"
314- "self.NextNotifyId += 1\n",
315- FIRST_NOTIFY_ID);
316- dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_NOTIFY,
317- G_VARIANT_TYPE("(susssasa{sv}i)"),
318- G_VARIANT_TYPE_UINT32,
319- str,
320- &error);
321- g_assert_no_error (error);
322- g_free (str);
323-
324- // METHOD_CLOSE
325- str = g_strdup_printf("self.EmitSignal('%s', '%s', 'uu', [ args[0], %d ])",
326- NOTIFY_INTERFACE,
327- SIGNAL_CLOSED,
328- NOTIFICATION_CLOSED_API);
329- dbus_test_dbus_mock_object_add_method(mock, obj, METHOD_CLOSE,
330- G_VARIANT_TYPE("(u)"),
331- nullptr,
332- str,
333- &error);
334- g_assert_no_error (error);
335- g_free (str);
336-
337- dbus_test_service_add_task(service, DBUS_TEST_TASK(mock));
338- dbus_test_service_start_tasks(service);
339-
340- bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
341- g_dbus_connection_set_exit_on_close(bus, FALSE);
342- g_object_add_weak_pointer(G_OBJECT(bus), reinterpret_cast<gpointer*>(&bus));
343-
344- notify_init(SERVICE_EXEC);
345- }
346-
347- virtual void TearDown()
348- {
349- notify_uninit();
350-
351- g_clear_object(&mock);
352- g_clear_object(&service);
353- g_object_unref(bus);
354-
355- // wait a little while for the scaffolding to shut down,
356- // but don't block on it forever...
357- unsigned int cleartry = 0;
358- while ((bus != nullptr) && (cleartry < 50))
359- {
360- g_usleep(100000);
361- while (g_main_pending())
362- g_main_iteration(true);
363- cleartry++;
364- }
365-
366- super::TearDown();
367- }
368-
369- /***
370- ****
371- ***/
372-
373- int get_notify_call_count() const
374- {
375- guint len {0u};
376- GError* error {nullptr};
377- dbus_test_dbus_mock_object_get_method_calls(mock, obj, METHOD_NOTIFY, &len, &error);
378- g_assert_no_error(error);
379- return len;
380- }
381-
382- std::string get_notify_call_sound_file(int call_number)
383- {
384- std::string ret;
385-
386- guint len {0u};
387- GError* error {nullptr};
388- auto calls = dbus_test_dbus_mock_object_get_method_calls(mock, obj, METHOD_NOTIFY, &len, &error);
389- g_return_val_if_fail(int(len) > call_number, ret);
390- g_assert_no_error(error);
391-
392- constexpr int HINTS_PARAM_POSITION {6};
393- const auto& call = calls[call_number];
394- g_return_val_if_fail(g_variant_n_children(call.params) > HINTS_PARAM_POSITION, ret);
395- auto hints = g_variant_get_child_value(call.params, HINTS_PARAM_POSITION);
396- const gchar* sound_file = nullptr;
397- auto success = g_variant_lookup(hints, "sound-file", "&s", &sound_file);
398- g_return_val_if_fail(success, ret);
399- if (sound_file != nullptr)
400- ret = sound_file;
401- g_clear_pointer(&hints, g_variant_unref);
402-
403- return ret;
404- }
405-
406- void clear_method_calls()
407- {
408- GError* error{nullptr};
409- ASSERT_TRUE(dbus_test_dbus_mock_object_clear_method_calls(mock, obj, &error));
410- g_assert_no_error(error);
411- }
412+ typedef TestDBusFixture super;
413+
414+ void start_unity7_notifications()
415+ {
416+ start_notifications("{ \"capabilities\": \""
417+ "append "
418+ "body "
419+ "body-markup "
420+ "icon-static "
421+ "image/svg+xml "
422+ "private-icon-only "
423+ "private-synchronous "
424+ "truncation "
425+ "x-canonical-append "
426+ "x-canonical-private-icon-only "
427+ "x-canonical-private-synchronous "
428+ "x-canonical-truncation"
429+ "\" }"
430+ );
431+ }
432+
433+ void start_unity8_notifications()
434+ {
435+ start_notifications("{ \"capabilities\": \""
436+ "body "
437+ "body-markup "
438+ "icon-static "
439+ "image/svg+xml "
440+ "sound-file "
441+ "suppress-sound "
442+ "urgency "
443+ "value "
444+ "x-canonical-non-shaped-icon "
445+ "x-canonical-private-affirmative-tint "
446+ "x-canonical-private-icon-only "
447+ "x-canonical-private-menu-model "
448+ "x-canonical-private-rejection-tint "
449+ "x-canonical-private-synchronous "
450+ "x-canonical-secondary-icon "
451+ "x-canonical-snap-decisions "
452+ "x-canonical-snap-decisions-swipe "
453+ "x-canonical-snap-decisions-timeout "
454+ "x-canonical-switch-to-application "
455+ "x-canonical-truncation "
456+ "x-canonical-value-bar-tint"
457+ "\" }"
458+ );
459+ }
460+
461+ void start_notifications(const char* parameters)
462+ {
463+ std::array<const char*,8> child_argv = {
464+ "python3", "-m", "dbusmock",
465+ "--template", "notification_daemon",
466+ "--parameters", parameters,
467+ nullptr
468+ };
469+ GError* error {};
470+ g_spawn_async(
471+ nullptr /*working directory*/,
472+ const_cast<char**>(child_argv.data()),
473+ nullptr /*envp*/,
474+ G_SPAWN_SEARCH_PATH,
475+ nullptr /*child_setup*/,
476+ nullptr /*user_data*/,
477+ nullptr /*child_pid*/,
478+ &error
479+ );
480+ g_assert_no_error(error);
481+
482+ wait_for_name_owned(m_bus, "org.freedesktop.Notifications");
483+ }
484+
485+
486+protected:
487+
488+ void SetUp() override
489+ {
490+ super::SetUp();
491+
492+ start_unity8_notifications();
493+
494+ notify_init(G_LOG_DOMAIN);
495+ }
496+
497+ void TearDown() override
498+ {
499+ notify_uninit();
500+
501+ super::TearDown();
502+ }
503 };
504
505 /***
506@@ -216,7 +141,6 @@
507 ****
508 ***/
509
510-
511 namespace
512 {
513 static constexpr double percent_critical {2.0};
514@@ -319,11 +243,11 @@
515 // charge should show up on the bus.
516 auto notifier = indicator_power_notifier_new ();
517 indicator_power_notifier_set_battery (notifier, battery);
518- indicator_power_notifier_set_bus (notifier, bus);
519+ indicator_power_notifier_set_bus (notifier, m_bus);
520 wait_msec();
521
522 ChangedParams changed_params;
523- auto sub_tag = g_dbus_connection_signal_subscribe (bus,
524+ auto sub_tag = g_dbus_connection_signal_subscribe (m_bus,
525 nullptr,
526 "org.freedesktop.DBus.Properties",
527 "PropertiesChanged",
528@@ -358,9 +282,9 @@
529 }
530
531 // cleanup
532- g_dbus_connection_signal_unsubscribe (bus, sub_tag);
533+ g_dbus_connection_signal_unsubscribe (m_bus, sub_tag);
534+ g_object_unref (notifier);
535 g_object_unref (battery);
536- g_object_unref (notifier);
537 }
538
539 /***
540@@ -369,18 +293,6 @@
541
542 TEST_F(NotifyFixture, EventsThatChangeNotifications)
543 {
544- // GetCapabilities returns an array containing 'actions', so that we'll
545- // get snap decisions and the 'IsWarning' property
546- GError * error = nullptr;
547- dbus_test_dbus_mock_object_add_method (mock,
548- obj,
549- METHOD_GET_CAPS,
550- nullptr,
551- G_VARIANT_TYPE_STRING_ARRAY,
552- "ret = ['actions', 'body']",
553- &error);
554- g_assert_no_error (error);
555-
556 auto battery = indicator_power_device_new ("/object/path",
557 UP_DEVICE_KIND_BATTERY,
558 percent_low + 1.0,
559@@ -397,9 +309,9 @@
560 // charge should show up on the bus.
561 auto notifier = indicator_power_notifier_new ();
562 indicator_power_notifier_set_battery (notifier, battery);
563- indicator_power_notifier_set_bus (notifier, bus);
564+ indicator_power_notifier_set_bus (notifier, m_bus);
565 ChangedParams changed_params;
566- auto sub_tag = g_dbus_connection_signal_subscribe (bus,
567+ auto sub_tag = g_dbus_connection_signal_subscribe (m_bus,
568 nullptr,
569 "org.freedesktop.DBus.Properties",
570 "PropertiesChanged",
571@@ -423,9 +335,6 @@
572 EXPECT_EQ (FIELD_POWER_LEVEL|FIELD_IS_WARNING, changed_params.fields);
573 EXPECT_EQ (indicator_power_notifier_get_power_level(battery), changed_params.power_level);
574 EXPECT_TRUE (changed_params.is_warning);
575- EXPECT_EQ (1, get_notify_call_count());
576- EXPECT_EQ (low_power_uri, get_notify_call_sound_file(0));
577- clear_method_calls();
578
579 // now test that the warning changes if the level goes down even lower...
580 changed_params = ChangedParams();
581@@ -433,9 +342,6 @@
582 wait_msec();
583 EXPECT_EQ (FIELD_POWER_LEVEL, changed_params.fields);
584 EXPECT_STREQ (POWER_LEVEL_STR_VERY_LOW, changed_params.power_level.c_str());
585- EXPECT_EQ (1, get_notify_call_count());
586- EXPECT_EQ (low_power_uri, get_notify_call_sound_file(0));
587- clear_method_calls();
588
589 // ...and that the warning is taken down if the battery is plugged back in...
590 changed_params = ChangedParams();
591@@ -443,7 +349,6 @@
592 wait_msec();
593 EXPECT_EQ (FIELD_IS_WARNING, changed_params.fields);
594 EXPECT_FALSE (changed_params.is_warning);
595- EXPECT_EQ (0, get_notify_call_count());
596
597 // ...and that it comes back if we unplug again...
598 changed_params = ChangedParams();
599@@ -451,9 +356,6 @@
600 wait_msec();
601 EXPECT_EQ (FIELD_IS_WARNING, changed_params.fields);
602 EXPECT_TRUE (changed_params.is_warning);
603- EXPECT_EQ (1, get_notify_call_count());
604- EXPECT_EQ (low_power_uri, get_notify_call_sound_file(0));
605- clear_method_calls();
606
607 // ...and that it's taken down if the power level is OK
608 changed_params = ChangedParams();
609@@ -462,10 +364,9 @@
610 EXPECT_EQ (FIELD_POWER_LEVEL|FIELD_IS_WARNING, changed_params.fields);
611 EXPECT_STREQ (POWER_LEVEL_STR_OK, changed_params.power_level.c_str());
612 EXPECT_FALSE (changed_params.is_warning);
613- EXPECT_EQ (0, get_notify_call_count());
614
615 // cleanup
616- g_dbus_connection_signal_unsubscribe (bus, sub_tag);
617+ g_dbus_connection_signal_unsubscribe (m_bus, sub_tag);
618 g_object_unref (notifier);
619 g_object_unref (battery);
620 }

Subscribers

People subscribed via source and target branches