kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit 580ca5f81c934b9e252302a6162c08f7ca28adf0
parent b2b434448086b621cf3750525aa918a0da1a90b5
Author: lash <dev@holbrook.no>
Date:   Fri, 31 May 2024 18:24:10 +0100

Rehabilitate gtk nav test

Diffstat:
Msrc/gtk/nav.c | 2+-
Msrc/gtk/tests/nav.c | 69+++++++++++++++++++++++++++++++++++++++++++++++----------------------
2 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/src/gtk/nav.c b/src/gtk/nav.c @@ -64,7 +64,7 @@ GtkWidget* kee_nav_back(int force) { } if (r == 0 || r == BEAMENU_DEFAULT) { if (stack_crsr < 2) { - debug_log(DEBUG_CRITICAL, "menu stack underrun"); + debug_log(DEBUG_WARNING, "menu stack underrun"); return NULL; } r = stack[stack_crsr-1]; diff --git a/src/gtk/tests/nav.c b/src/gtk/tests/nav.c @@ -2,53 +2,78 @@ #include "nav.h" -int main(int argc, char **argv) { - struct KeeNav nav; - GtkLabel *a; - GtkLabel *b; - GtkLabel *c; - GtkLabel *r; + +int test_stack() { + //struct KeeNav nav; + int r; + GtkWidget *a; + GtkWidget *b; + GtkWidget *c; + GtkWidget *o; gtk_init(); a = gtk_label_new("foo"); b = gtk_label_new("bar"); c = gtk_label_new("baz"); - memset(&nav, 0, sizeof(struct KeeNav)); - r = kee_nav_push(&nav, a); + r = kee_nav_init(".."); + if (r) { + return 1; + } + r = kee_nav_set(a, 0); if (r) { return 1; } - r = kee_nav_push(&nav, b); + o = kee_nav_get(); + if (!o) { + return 1; + } + r = kee_nav_set(b, 1); if (r) { return 1; } - r = kee_nav_pop(&nav); - if (r != a) { + o = kee_nav_get(); + if (!o) { return 1; } - kee_nav_push(&nav, b); - r = kee_nav_pop(&nav); - if (r != a) { + o = kee_nav_back(1); + if (o != a) { return 1; } - r = kee_nav_pop(&nav); - if (r != NULL) { + kee_nav_set(b, 1); + o = kee_nav_back(1); + if (o != a) { return 1; } - kee_nav_push(&nav, c); - r = kee_nav_pop(&nav); - if (r != NULL) { + o = kee_nav_back(1); + if (o) { return 1; } - r = kee_nav_pop(&nav); - if (r) { + kee_nav_set(c, 2); + o = kee_nav_back(1); + if (o == NULL) { return 1; } - r = kee_nav_pop(&nav); + o = kee_nav_back(1); + if (o) { + return 1; + } + + o = kee_nav_back(1); + if (o) { + return 1; + } + + return 0; +} + +int main(int argc, char **argv) { + int r; + + r = test_stack(); if (r) { return 1; }