- interface gtkmm-4 : véhicules, ajout par VIN, mises à jour, dossier, téléchargement avec reprise et arrêt, choix de la clé, confirmation, écriture avec progression, fin avec guide d'installation ; travail dans un thread, résultats renvoyés via Glib::Dispatcher - préférences : dossier de téléchargement, langue (système par défaut), recherche automatique de nouvelle version d'OpenPU - recherche de nouvelle version (releases GitHub, format tags Gitea accepté) avec ouverture de la page dans le navigateur ; openpu-cli app-update - versions : project(VERSION) + git describe régénéré à chaque build, openpu-cli --version, À propos, User-Agent, CHANGELOG, tools/release.sh (étiquette annotée, push vers tous les remotes, release GitHub) - traductions gettext : textes anglais, fr.po complet (96 chaînes), extracteur de secours sans xgettext - core : module job (téléchargement licence/fw/carte), liens des guides PDF, ordre des véhicules conservé (ordered_json) - licence MIT (LICENSE, en-têtes SPDX) ; dépôt principal sur GitHub - validé dans WSLg : parcours complet jusqu'à l'écriture d'une clé loop (FAT32 propre, fichiers téléchargés supprimés) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
113 lines
3.6 KiB
C++
113 lines
3.6 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#include "openpu/storage.hpp"
|
|
|
|
#include "test_util.hpp"
|
|
|
|
#include <doctest/doctest.h>
|
|
|
|
using namespace openpu;
|
|
|
|
TEST_CASE("official vehicles.json (with BOM) is understood")
|
|
{
|
|
const std::string official = "\xEF\xBB\xBF"
|
|
R"({"VF3AAAAAAAAAAAAA1":{"name":"5008","type":"nac","wave":"path_guide_wave_4"},)"
|
|
R"("VR3AAAAAAAAAAAAA2":{"name":"e208","type":"rcc","wave":"path_guide_rcc",)"
|
|
R"("undeletedFiles":{"fw":"C:\\dl\\PSA_rcc.tar","license":"C:\\dl\\license_X.key"}}})";
|
|
const auto v = VehicleStore::parse(official);
|
|
REQUIRE(v.size() == 2);
|
|
CHECK(v[0].vin == "VF3AAAAAAAAAAAAA1");
|
|
CHECK(v[0].type == HeadUnitType::Nac);
|
|
CHECK(v[0].guideKey == "path_guide_wave_4");
|
|
CHECK(v[1].type == HeadUnitType::Rcc);
|
|
CHECK(v[1].pendingFirmware == "C:\\dl\\PSA_rcc.tar");
|
|
CHECK(v[1].pendingLicense == "C:\\dl\\license_X.key");
|
|
CHECK(v[1].pendingMap.empty());
|
|
}
|
|
|
|
TEST_CASE("vehicle store round trip")
|
|
{
|
|
TempDir tmp;
|
|
VehicleStore store(tmp.path() / "sub" / "vehicles.json");
|
|
store.load(); // missing file
|
|
CHECK(store.all().empty());
|
|
|
|
Vehicle a;
|
|
a.vin = "VF3AAAAAAAAAAAAA1";
|
|
a.name = "Ma 208";
|
|
a.type = HeadUnitType::Nac;
|
|
a.guideKey = "path_guide_wave_2";
|
|
store.upsert(a);
|
|
Vehicle b = a;
|
|
b.vin = "VR3AAAAAAAAAAAAA2";
|
|
b.type = HeadUnitType::CronyNonav;
|
|
b.pendingMap = "/dl/map.tar";
|
|
store.upsert(b);
|
|
a.name = "renamed";
|
|
store.upsert(a);
|
|
store.save();
|
|
|
|
VehicleStore again(store.file());
|
|
again.load();
|
|
REQUIRE(again.all().size() == 2);
|
|
REQUIRE(again.find("VF3AAAAAAAAAAAAA1") != nullptr);
|
|
CHECK(again.find("VF3AAAAAAAAAAAAA1")->name == "renamed");
|
|
CHECK(again.find("VR3AAAAAAAAAAAAA2")->type == HeadUnitType::CronyNonav);
|
|
CHECK(again.find("VR3AAAAAAAAAAAAA2")->pendingMap == "/dl/map.tar");
|
|
CHECK(again.remove("VF3AAAAAAAAAAAAA1"));
|
|
CHECK_FALSE(again.remove("VF3AAAAAAAAAAAAA1"));
|
|
CHECK(again.all().size() == 1);
|
|
}
|
|
|
|
TEST_CASE("corrupt vehicles file is an error, not silently emptied")
|
|
{
|
|
TempDir tmp;
|
|
writeAll(tmp.path() / "vehicles.json", "{broken");
|
|
VehicleStore store(tmp.path() / "vehicles.json");
|
|
CHECK_THROWS_AS(store.load(), StorageError);
|
|
}
|
|
|
|
TEST_CASE("settings round trip")
|
|
{
|
|
TempDir tmp;
|
|
const auto file = tmp.path() / "config.json";
|
|
Settings s = Settings::load(file);
|
|
CHECK(s.language.empty());
|
|
CHECK_FALSE(s.pending.has_value());
|
|
CHECK_FALSE(s.effectiveDownloadDir().empty());
|
|
|
|
s.language = "fr";
|
|
s.downloadDir = "/data/dl";
|
|
PendingDownload p;
|
|
p.vin = "VR3AAAAAAAAAAAAA2";
|
|
p.firmware = true;
|
|
p.firmwareFile = "PSA_rcc.tar";
|
|
p.licenseFile = "license_X.key";
|
|
s.pending = p;
|
|
s.save(file);
|
|
|
|
const Settings r = Settings::load(file);
|
|
CHECK(r.language == "fr");
|
|
CHECK(r.effectiveDownloadDir() == "/data/dl");
|
|
REQUIRE(r.pending.has_value());
|
|
CHECK(r.pending->firmware);
|
|
CHECK_FALSE(r.pending->map);
|
|
CHECK(r.pending->licenseFile == "license_X.key");
|
|
CHECK(r.checkAppUpdates); // default
|
|
|
|
s.checkAppUpdates = false;
|
|
s.save(file);
|
|
CHECK_FALSE(Settings::load(file).checkAppUpdates);
|
|
}
|
|
|
|
TEST_CASE("XDG paths")
|
|
{
|
|
// Only checks the shape: paths end with our application directory.
|
|
#ifdef __HAIKU__
|
|
CHECK(paths::configDir().filename() == "OpenPU");
|
|
CHECK(paths::defaultDownloadDir().filename() == "OpenPU downloads");
|
|
#else
|
|
CHECK(paths::configDir().filename() == "openpu");
|
|
CHECK(paths::defaultDownloadDir().filename() == "OpenPU");
|
|
#endif
|
|
}
|