bool battery_supported;
};
+// maintained within a test suite
+static bool changed_callback_registered = false;
+
// dummy
-static void __changed_cb(struct battery_info *info, void *data) {}
+static void __changed_cb(struct battery_info *info, void *data)
+{
+ EXPECT_NE(info, nullptr) << "Failed to receive battery information";
+}
TEST_F(BATTERY, GetBackendP)
{
}
ret = hal_device_battery_register_changed_event(__changed_cb, NULL);
- EXPECT_EQ(ret, 0) << "Failed to register changed callback";
+ ASSERT_EQ(ret, 0) << "Failed to register changed callback";
+
+ changed_callback_registered = true;
}
TEST_F(BATTERY, UnregisterChangedEventP)
return;
}
- ret = hal_device_battery_register_changed_event(__changed_cb, NULL);
- ASSERT_EQ(ret, 0) << "Failed to register changed callback";
-
- if (ret == 0) {
- ret = hal_device_battery_unregister_changed_event(__changed_cb);
- EXPECT_EQ(ret, 0) << "Failed to unregister changed callback";
+ if (!changed_callback_registered) {
+ SKIP_MESSAGE("Unable to test unregister as there is no registered callback");
+ return;
}
+
+ ret = hal_device_battery_unregister_changed_event(__changed_cb);
+ ASSERT_EQ(ret, 0) << "Failed to unregister changed callback";
+
+ changed_callback_registered = false;
}
TEST_F(BATTERY, GetCurrentStateP)