Files
radiantwave/tests/test_settings_menu.cpp
T
NeilClack c3b3d6774a Warning screen, smarter license re-validation, version reporting
Warning screen
- New reusable WarningPage (word-wrapped message, ENTER acknowledges and
  continues to the screen you were about to enter).
- First use: pressing Play while the selected audio is still downloading.
  Dynamic Audio requires every file; a fixed track requires its own file.

License re-validation
- No longer re-verifies on every Home render. Checks now run only when the
  email/license key is entered or changed, on the manual option, at startup
  when already due, and hourly while valid.
- Invalid + unchanged credentials are never re-checked (persisted pair).
- Valid re-checks at most once per hour, anchored on a DB timestamp so an
  overdue check runs immediately after a power cycle.
- New system_kv keys track the checked pair, outcome, and last-check time.
- Added a System Settings row "Manually Validate License Key OK|Invalid"
  (OK green, Invalid red, label white) that runs a check immediately.

Portal / local integration
- License validation request now sends the app version as `appVersion`.
- The entered license key is mirrored to ~/.local/radiantwave/license.txt.

Misc
- "Please connect to WiFi" only shows when no WiFi is joined AND the internet
  is unreachable (fixes the NetworkManager-missing and Ethernet cases).
- Added unit tests for the audio-download warning, license scheduling policy,
  license request shape, and the new settings-menu entry.
2026-10-14 10:58:40 -05:00

60 lines
2.4 KiB
C++

#include "settings_menu.h"
#include <gtest/gtest.h>
#include <set>
#include <string>
namespace settings = radiantwave::settings;
TEST(SystemSettingsMenuTest, ListsTheSystemSettingsInOrder) {
const auto entries = settings::systemSettingEntries();
ASSERT_EQ(entries.size(), 8u);
EXPECT_EQ(entries[0].label, "Email Address");
EXPECT_EQ(entries[0].id, settings::SystemSettingId::EmailAddress);
EXPECT_EQ(entries[1].label, "License Key");
EXPECT_EQ(entries[1].id, settings::SystemSettingId::LicenseKey);
EXPECT_EQ(entries[2].label, "Manually Validate License Key");
EXPECT_EQ(entries[2].id, settings::SystemSettingId::ManualValidateLicense);
EXPECT_EQ(entries[3].label, "System Name");
EXPECT_EQ(entries[3].id, settings::SystemSettingId::SystemName);
EXPECT_EQ(entries[4].label, "Schedule");
EXPECT_EQ(entries[4].id, settings::SystemSettingId::Schedule);
EXPECT_EQ(entries[5].label, "WiFi Setup");
EXPECT_EQ(entries[5].id, settings::SystemSettingId::WiFiSetup);
EXPECT_EQ(entries[6].label, "Time Zone Setup");
EXPECT_EQ(entries[6].id, settings::SystemSettingId::Timezone);
EXPECT_EQ(entries[7].label, "Date Format");
EXPECT_EQ(entries[7].id, settings::SystemSettingId::DateFormat);
}
TEST(SystemSettingsMenuTest, LabelsAreNonEmptyAndUnique) {
const auto entries = settings::systemSettingEntries();
std::set<std::string> labels;
std::set<int> ids;
for (const auto& entry : entries) {
EXPECT_FALSE(entry.label.empty());
labels.insert(entry.label);
ids.insert(static_cast<int>(entry.id));
}
EXPECT_EQ(labels.size(), entries.size());
EXPECT_EQ(ids.size(), entries.size());
}
TEST(SystemSettingsMenuTest, EveryEntryMapsToAKnownPage) {
for (const auto& entry : settings::systemSettingEntries()) {
switch (entry.id) {
case settings::SystemSettingId::EmailAddress:
case settings::SystemSettingId::LicenseKey:
case settings::SystemSettingId::ManualValidateLicense:
case settings::SystemSettingId::SystemName:
case settings::SystemSettingId::Schedule:
case settings::SystemSettingId::WiFiSetup:
case settings::SystemSettingId::Timezone:
case settings::SystemSettingId::DateFormat:
SUCCEED();
break;
default:
FAIL() << "Unhandled SystemSettingId for label " << entry.label;
}
}
}