Settings: its rows in five groups
CI / build (pull_request) Successful in 2m22s
Site / build (pull_request) Successful in 10s

Settings had grown to 21 rows in one list. It opens on five groups (This
device, Display, GNSS and radio, Network, System); Enter opens one, Back
returns to the groups, and Back from the groups leaves Settings.

SettingsMenu holds the groups and which one is open (host-tested: every
setting is in exactly one group). The guide, the how-tos, the README,
the scripts' messages and the firmware's own name the new paths, such as
"Settings > System > Firmware".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0162FokPdvY2KsS4NBfwyWPk
This commit is contained in:
2026-10-10 00:11:52 +02:00
co-authored by Claude Opus 5.5
parent 37335b4829
commit 0c52613b72
43 changed files with 305 additions and 98 deletions
+53 -3
View File
@@ -12,10 +12,10 @@ struct Fixture {
Settings settings{store, bus};
SettingsMenu menu{settings};
Fixture() { settings.load(); }
// Opens the group the row is in: the index is into that group.
int row(SettingsMenu::Row r) {
for (int i = 0; i < menu.count(); i++)
if (menu.row(i) == r) return i;
return -1;
int i = -1;
return menu.reveal(r, i) ? i : -1;
}
};
@@ -28,6 +28,53 @@ void test_every_row_has_a_label() {
for (int i = 0; i < f.menu.count(); i++) TEST_ASSERT_FALSE(f.menu.label(i).empty());
}
void test_the_groups_are_listed_first() {
Fixture f;
TEST_ASSERT_FALSE(f.menu.inGroup());
TEST_ASSERT_EQUAL(5, f.menu.count());
for (int i = 0; i < f.menu.count(); i++)
TEST_ASSERT_EQUAL(static_cast<int>(SettingsMenu::Kind::Group), static_cast<int>(f.menu.kind(i)));
TEST_ASSERT_EQUAL_STRING("This device", f.menu.label(0).c_str());
TEST_ASSERT_EQUAL_STRING("Display", f.menu.label(1).c_str());
TEST_ASSERT_FALSE(f.menu.close()); // nothing to close: Back leaves Settings
}
void test_a_group_opens_and_closes() {
Fixture f;
TEST_ASSERT_TRUE(f.menu.open(1));
TEST_ASSERT_TRUE(f.menu.inGroup());
TEST_ASSERT_EQUAL_STRING("Display", f.menu.title().c_str());
TEST_ASSERT_EQUAL(6, f.menu.count());
TEST_ASSERT_EQUAL_STRING("Brightness", f.menu.label(0).c_str());
TEST_ASSERT_EQUAL_STRING("Launcher", f.menu.label(5).c_str());
TEST_ASSERT_FALSE(f.menu.open(0)); // a row of a group isn't a group
TEST_ASSERT_TRUE(f.menu.close());
TEST_ASSERT_EQUAL(1, f.menu.groupIndex()); // where the selection goes back to
TEST_ASSERT_EQUAL(5, f.menu.count());
TEST_ASSERT_FALSE(f.menu.open(5));
}
void test_every_setting_is_in_one_group() {
Fixture f;
int total = 0;
for (int g = 0; g < 5; g++) {
TEST_ASSERT_TRUE(f.menu.open(g));
TEST_ASSERT_TRUE(f.menu.count() > 0 && f.menu.count() <= 8); // a title and 8 rows fit the screen
for (int i = 0; i < f.menu.count(); i++) {
TEST_ASSERT_FALSE(f.menu.label(i).empty());
TEST_ASSERT_NOT_EQUAL(static_cast<int>(SettingsMenu::Kind::Group), static_cast<int>(f.menu.kind(i)));
}
total += f.menu.count();
f.menu.close();
}
TEST_ASSERT_EQUAL(21, total);
int i = -1;
TEST_ASSERT_TRUE(f.menu.reveal(SettingsMenu::Row::Vpn, i));
TEST_ASSERT_EQUAL_STRING("Network", f.menu.title().c_str());
TEST_ASSERT_EQUAL_STRING("VPN", f.menu.label(i).c_str());
TEST_ASSERT_FALSE(f.menu.reveal(SettingsMenu::Row::GroupDisplay, i));
}
void test_values_are_human_readable() {
Fixture f;
TEST_ASSERT_EQUAL_STRING("60%", f.menu.value(f.row(SettingsMenu::Row::Brightness)).c_str());
@@ -183,6 +230,9 @@ void test_gnss_and_coordinate_rows_toggle() {
int main() {
UNITY_BEGIN();
RUN_TEST(test_every_row_has_a_label);
RUN_TEST(test_the_groups_are_listed_first);
RUN_TEST(test_a_group_opens_and_closes);
RUN_TEST(test_every_setting_is_in_one_group);
RUN_TEST(test_values_are_human_readable);
RUN_TEST(test_toggle_rows_flip_on_select);
RUN_TEST(test_the_launcher_is_a_grid_or_a_list);