[refactor] organize GUI code by responsibility

This commit is contained in:
dijunkun
2026-07-19 21:23:20 +08:00
parent 1f86c43458
commit eeb6a2a1ae
73 changed files with 7918 additions and 7229 deletions
+22 -20
View File
@@ -10,7 +10,8 @@ std::filesystem::path FindRepoRoot() {
std::filesystem::path current = std::filesystem::current_path();
while (!current.empty()) {
if (std::filesystem::exists(current / "xmake.lua") &&
std::filesystem::exists(current / "submodules/minirtc/src/api/minirtc.h")) {
std::filesystem::exists(current /
"submodules/minirtc/src/api/minirtc.h")) {
return current;
}
current = current.parent_path();
@@ -18,7 +19,7 @@ std::filesystem::path FindRepoRoot() {
return {};
}
std::string ReadFile(const std::filesystem::path& path) {
std::string ReadFile(const std::filesystem::path &path) {
std::ifstream file(path, std::ios::binary);
if (!file) {
return {};
@@ -29,8 +30,8 @@ std::string ReadFile(const std::filesystem::path& path) {
return stream.str();
}
bool ExpectContains(const char* name, const std::string& value,
const std::string& expected) {
bool ExpectContains(const char *name, const std::string &value,
const std::string &expected) {
if (value.find(expected) != std::string::npos) {
return true;
}
@@ -39,8 +40,8 @@ bool ExpectContains(const char* name, const std::string& value,
return false;
}
bool ExpectNotContains(const char* name, const std::string& value,
const std::string& unexpected) {
bool ExpectNotContains(const char *name, const std::string &value,
const std::string &unexpected) {
if (value.find(unexpected) == std::string::npos) {
return true;
}
@@ -62,12 +63,14 @@ int main() {
ReadFile(repo_root / "submodules/minirtc/src/api/minirtc.h");
const std::string peer_connection =
ReadFile(repo_root / "submodules/minirtc/src/pc/peer_connection.cpp");
const std::string connection_status_window =
ReadFile(repo_root / "src/gui/windows/connection_status_window.cpp");
const std::string render_h = ReadFile(repo_root / "src/gui/render.h");
const std::string render_cpp = ReadFile(repo_root / "src/gui/render.cpp");
const std::string remote_peer_panel =
ReadFile(repo_root / "src/gui/panels/remote_peer_panel.cpp");
const std::string connection_status_window = ReadFile(
repo_root / "src/gui/views/windows/connection_status_window.cpp");
const std::string runtime_state_h =
ReadFile(repo_root / "src/gui/runtime/runtime_state.h");
const std::string remote_session_h =
ReadFile(repo_root / "src/gui/runtime/remote_session.h");
const std::string connection_runtime_cpp =
ReadFile(repo_root / "src/gui/runtime/connection_runtime.cpp");
bool ok = true;
ok &= ExpectContains("minirtc.h", minirtc_api, "RemoteUnavailable");
@@ -80,20 +83,19 @@ int main() {
"\"Device offline\"");
ok &= ExpectNotContains("peer_connection.cpp", peer_connection,
"ConnectionStatus::DeviceOffline");
ok &= ExpectContains("connection_status_window.cpp",
connection_status_window,
ok &= ExpectContains("connection_status_window.cpp", connection_status_window,
"localization::device_offline");
ok &= ExpectContains("render.h", render_h,
ok &= ExpectContains("runtime_state.h", runtime_state_h,
"pending_presence_probe_started_at_");
ok &= ExpectContains("render.h", render_h,
ok &= ExpectContains("remote_session.h", remote_session_h,
"connection_attempt_started_at_");
ok &= ExpectContains("render.cpp", render_cpp,
ok &= ExpectContains("connection_runtime.cpp", connection_runtime_cpp,
"HandleConnectionTimeouts");
ok &= ExpectContains("render.cpp", render_cpp,
ok &= ExpectContains("connection_runtime.cpp", connection_runtime_cpp,
"kPresenceProbeTimeout");
ok &= ExpectContains("render.cpp", render_cpp,
ok &= ExpectContains("connection_runtime.cpp", connection_runtime_cpp,
"kConnectionAttemptTimeout");
ok &= ExpectContains("remote_peer_panel.cpp", remote_peer_panel,
ok &= ExpectContains("connection_runtime.cpp", connection_runtime_cpp,
"connection_attempt_started_at_");
return ok ? 0 : 1;