diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c
index 8102f928..388da85f 100644
--- a/tests/functionaltests/functionaltests.c
+++ b/tests/functionaltests/functionaltests.c
@@ -150,6 +150,12 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(autoping_sends_ping_after_interval),
PROF_FUNC_TEST(autoping_server_not_supporting_ping),
+ /* Autoping availability warning - negative cases wait ~3s */
+ PROF_FUNC_TEST(autoping_warning_shown_when_disabled),
+ PROF_FUNC_TEST(autoping_warning_not_shown_when_server_unsupported),
+ PROF_FUNC_TEST(autoping_warning_not_shown_when_autoping_enabled),
+ PROF_FUNC_TEST(autoping_warning_not_shown_when_user_disabled),
+
/* Service Discovery - XEP-0030 */
PROF_FUNC_TEST(disco_info_shows_identity),
PROF_FUNC_TEST(disco_info_shows_features),
diff --git a/tests/functionaltests/test_autoping.c b/tests/functionaltests/test_autoping.c
index 1e1a1332..f3539c26 100644
--- a/tests/functionaltests/test_autoping.c
+++ b/tests/functionaltests/test_autoping.c
@@ -112,3 +112,99 @@ autoping_server_not_supporting_ping(void** state)
// Should show error about ping not being supported
assert_true(prof_output_regex("Server ping not supported"));
}
+
+/*
+ * Autoping availability warning.
+ *
+ * The warning fires from the on-connect disco handler, so the three inputs
+ * (server ping support, autoping interval, warning preference) must all be
+ * set before prof_connect().
+ */
+
+/* Stable substring of the warning text emitted by iq.c. */
+#define AUTOPING_WARNING_MATCH "This server supports XEP-0199"
+
+static void
+_stub_server_disco(gboolean with_ping)
+{
+ if (with_ping) {
+ stbbr_for_query("http://jabber.org/protocol/disco#info",
+ ""
+ ""
+ ""
+ ""
+ ""
+ ""
+ );
+ } else {
+ stbbr_for_query("http://jabber.org/protocol/disco#info",
+ ""
+ ""
+ ""
+ ""
+ ""
+ );
+ }
+}
+
+void
+autoping_warning_shown_when_disabled(void** state)
+{
+ // All conditions met: server supports ping, autoping off, warning on (default).
+ _stub_server_disco(TRUE);
+
+ prof_input("/autoping set 0");
+ assert_true(prof_output_exact("Autoping disabled."));
+
+ prof_connect();
+
+ assert_true(prof_output_regex(AUTOPING_WARNING_MATCH));
+}
+
+void
+autoping_warning_not_shown_when_server_unsupported(void** state)
+{
+ // Server does not advertise urn:xmpp:ping -> no warning even with autoping off.
+ _stub_server_disco(FALSE);
+
+ prof_input("/autoping set 0");
+ assert_true(prof_output_exact("Autoping disabled."));
+
+ prof_connect();
+
+ prof_timeout(NEGATIVE_ASSERT_TIMEOUT);
+ assert_false(prof_output_regex(AUTOPING_WARNING_MATCH));
+}
+
+void
+autoping_warning_not_shown_when_autoping_enabled(void** state)
+{
+ // Warning is suppressed while autoping is enabled.
+ _stub_server_disco(TRUE);
+
+ prof_input("/autoping set 30");
+ assert_true(prof_output_exact("Autoping interval set to 30 seconds."));
+
+ prof_connect();
+
+ prof_timeout(NEGATIVE_ASSERT_TIMEOUT);
+ assert_false(prof_output_regex(AUTOPING_WARNING_MATCH));
+}
+
+void
+autoping_warning_not_shown_when_user_disabled(void** state)
+{
+ // User opted out -> no warning. Command takes on|off ("enable|disable" doc is wrong).
+ _stub_server_disco(TRUE);
+
+ prof_input("/autoping set 0");
+ assert_true(prof_output_exact("Autoping disabled."));
+
+ prof_input("/autoping warning off");
+ assert_true(prof_output_exact("Autoping availability warning disabled."));
+
+ prof_connect();
+
+ prof_timeout(NEGATIVE_ASSERT_TIMEOUT);
+ assert_false(prof_output_regex(AUTOPING_WARNING_MATCH));
+}
diff --git a/tests/functionaltests/test_autoping.h b/tests/functionaltests/test_autoping.h
index 9456a50d..c4915cbf 100644
--- a/tests/functionaltests/test_autoping.h
+++ b/tests/functionaltests/test_autoping.h
@@ -4,3 +4,7 @@ void autoping_timeout_set(void** state);
void autoping_timeout_zero_disables(void** state);
void autoping_sends_ping_after_interval(void** state);
void autoping_server_not_supporting_ping(void** state);
+void autoping_warning_shown_when_disabled(void** state);
+void autoping_warning_not_shown_when_server_unsupported(void** state);
+void autoping_warning_not_shown_when_autoping_enabled(void** state);
+void autoping_warning_not_shown_when_user_disabled(void** state);