aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-10-04 22:18:47 +0000
committerGravatar Brendan Taylor <whateley@gmail.com>2011-11-23 18:37:57 -0700
commit5cb7ce2b677a227a3a14c8de2203ceb23bf3e1b6 (patch)
tree63bec05475968a37cef503518dab7cb6d32f92b6 /tests
parent3eab4641aa978cbbc8d5c9fc041b307c2874e3f4 (diff)
add toggle command
Diffstat (limited to 'tests')
-rw-r--r--tests/test-command.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test-command.c b/tests/test-command.c
index db08097..9b01928 100644
--- a/tests/test-command.c
+++ b/tests/test-command.c
@@ -308,6 +308,51 @@ test_no_such_command (void) {
/* if we didn't crash then we're ok! */
}
+// TODO: test toggling emits an event
+void
+test_toggle_int (void) {
+ g_assert_cmpint(0, ==, uzbl.behave.forward_keys);
+
+ parse_cmd_line("toggle forward_keys", NULL);
+ g_assert_cmpint(1, ==, uzbl.behave.forward_keys);
+
+ parse_cmd_line("toggle forward_keys", NULL);
+ g_assert_cmpint(0, ==, uzbl.behave.forward_keys);
+
+ // if cycle values are specified it should use those
+ parse_cmd_line("toggle forward_keys 1 2", NULL);
+ g_assert_cmpint(1, ==, uzbl.behave.forward_keys);
+
+ parse_cmd_line("toggle forward_keys 1 2", NULL);
+ g_assert_cmpint(2, ==, uzbl.behave.forward_keys);
+
+ // and wrap to the first value when it reaches the end.
+ parse_cmd_line("toggle forward_keys 1 2", NULL);
+ g_assert_cmpint(1, ==, uzbl.behave.forward_keys);
+}
+
+void
+test_toggle_string (void) {
+ parse_cmd_line("set useragent = something interesting", NULL);
+ g_assert_cmpstr("something interesting", ==, uzbl.net.useragent);
+
+ // when something was set, it gets reset
+ parse_cmd_line("toggle useragent", NULL);
+ g_assert_cmpstr("", ==, uzbl.net.useragent);
+
+ // if cycle values are specified it should use those
+ parse_cmd_line("set useragent = something interesting", NULL);
+ parse_cmd_line("toggle useragent 'x' 'y'", NULL);
+ g_assert_cmpstr("x", ==, uzbl.net.useragent);
+
+ parse_cmd_line("toggle useragent 'x' 'y'", NULL);
+ g_assert_cmpstr("y", ==, uzbl.net.useragent);
+
+ // and wrap to the first value when it reaches the end.
+ parse_cmd_line("toggle useragent 'x' 'y'", NULL);
+ g_assert_cmpstr("x", ==, uzbl.net.useragent);
+}
+
int
main (int argc, char *argv[]) {
/* set up tests */
@@ -329,6 +374,10 @@ main (int argc, char *argv[]) {
g_test_add_func("/test-command/no-such-command", test_no_such_command);
+ g_test_add_func("/test-command/toggle-int", test_toggle_int);
+ // we should probably test toggle float, but meh.
+ g_test_add_func("/test-command/toggle-string", test_toggle_string);
+
/* set up uzbl */
initialize(argc, argv);