Files
AnyPS5/core/libs/tests/GuestProprietaryVoiceChatHelper.cpp
T
Matheus Lima da SilvaandClaude Opus 5 e933285d82 feat(libSceProprietaryVoiceChatHelperPrx): implement the voice chat helper lifecycle
Initialize and Terminate track whether the library is initialized, and
SetVoiceChatState returns success without recording anything: the host has
no system voice chat for a title's own voice chat to announce itself to,
and the state argument is unknown.

GetVoiceChatUsageState keeps throwing. With the state argument unreadable
there is no recorded usage state, and whether the console returns the state
or writes it through an output pointer, and how it encodes it, is unknown.

Misuse throws rather than guessing an error code, as the library's error
codes are unknown.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-13 10:34:39 +02:00

54 lines
2.2 KiB
C++

#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
extern "C" {
int APS5_VABI sceProprietaryVoiceChatHelperInitialize();
int APS5_VABI sceProprietaryVoiceChatHelperTerminate();
int APS5_VABI sceProprietaryVoiceChatHelperSetVoiceChatState();
int APS5_VABI sceProprietaryVoiceChatHelperGetVoiceChatUsageState();
}
static void Require(bool value, const char* what) {
if (value) return;
std::printf("ProprietaryVoiceChatHelper: %s\n", what);
std::abort();
}
template <typename TError, typename TCall>
static bool Throws(TCall call) {
try {
call();
} catch (const TError&) {
return true;
}
return false;
}
int main() {
Require(Throws<std::logic_error>([] { sceProprietaryVoiceChatHelperSetVoiceChatState(); }),
"setting the state before initialization did not throw");
Require(Throws<std::logic_error>([] { sceProprietaryVoiceChatHelperGetVoiceChatUsageState(); }),
"reading the usage state before initialization did not throw");
Require(Throws<std::logic_error>([] { sceProprietaryVoiceChatHelperTerminate(); }),
"terminating before initialization did not throw");
Require(sceProprietaryVoiceChatHelperInitialize() == 0, "initialization failed");
Require(Throws<std::logic_error>([] { sceProprietaryVoiceChatHelperInitialize(); }),
"initializing twice did not throw");
Require(sceProprietaryVoiceChatHelperSetVoiceChatState() == 0, "setting the state failed");
Require(Throws<std::runtime_error>([] { sceProprietaryVoiceChatHelperGetVoiceChatUsageState(); }),
"reading the unknown usage state did not throw");
Require(sceProprietaryVoiceChatHelperTerminate() == 0, "termination failed");
Require(Throws<std::logic_error>([] { sceProprietaryVoiceChatHelperSetVoiceChatState(); }),
"setting the state after termination did not throw");
Require(sceProprietaryVoiceChatHelperInitialize() == 0, "initialization after termination failed");
Require(sceProprietaryVoiceChatHelperTerminate() == 0, "termination after reinitialization failed");
std::puts("ProprietaryVoiceChatHelper tests passed");
return 0;
}