From 44c8dfcec6e04a19ef78e2de38c97f49f9fcb8d5 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Tue, 29 Dec 2020 03:03:38 -0800 Subject: test: test test-page.html --- test/test | Bin 49784 -> 0 bytes test/test-page.html | 11 +++++++++++ test/test-script.js | 1 + test/test.c | 24 ++++++++++++++---------- 4 files changed, 26 insertions(+), 10 deletions(-) delete mode 100755 test/test create mode 100644 test/test-page.html create mode 100644 test/test-script.js mode change 100755 => 100644 test/test.c (limited to 'test') diff --git a/test/test b/test/test deleted file mode 100755 index 36de26f..0000000 Binary files a/test/test and /dev/null differ diff --git a/test/test-page.html b/test/test-page.html new file mode 100644 index 0000000..5ae2887 --- /dev/null +++ b/test/test-page.html @@ -0,0 +1,11 @@ + + + + + Title of Test Page + + + + Body Text of Test Page + + diff --git a/test/test-script.js b/test/test-script.js new file mode 100644 index 0000000..a23567e --- /dev/null +++ b/test/test-script.js @@ -0,0 +1 @@ +console.log('hello from test script!'); diff --git a/test/test.c b/test/test.c old mode 100755 new mode 100644 index f715b44..b4fe5b4 --- a/test/test.c +++ b/test/test.c @@ -1,8 +1,3 @@ -//usr/bin/env cc -o test "$0" && ./test; exit - -// (run this file directly with `./test.c` in most shells; if that -// doesn't work, run it with `sh test.c`) - #include #include #include @@ -25,6 +20,7 @@ char* expand(char* phrase) { // expand path with wildcard // integration tests int main() { + // if you don't have node, comment this out, I guess: assert(system("node ../extension/background.js --unhandled-rejections=strict") == 0); // run quick local JS tests // reload the extension so we know it's the latest code. @@ -34,11 +30,19 @@ int main() { assert(file_contents_equal(expand("../fs/mnt/extensions/TabFS*/enabled"), "true")); - // FIXME: synthesize some kind of web page - assert(system("echo about:blank > ../fs/mnt/tabs/create") == 0); - // FIXME: race here - assert(file_contents_equal("../fs/mnt/tabs/last-focused/url.txt", "about:blank")); - assert(system("echo remove > ../fs/mnt/tabs/last-focused/control") == 0); + { + assert(system("echo about:blank > ../fs/mnt/tabs/create") == 0); + // FIXME: race here? + assert(file_contents_equal("../fs/mnt/tabs/last-focused/url.txt", "about:blank")); + assert(system("echo remove > ../fs/mnt/tabs/last-focused/control") == 0); + } + + { + assert(system("echo file://$(pwd)/test-page.html > ../fs/mnt/tabs/create") == 0); + assert(file_contents_equal("../fs/mnt/tabs/last-focused/title.txt", "Title of Test Page")); + assert(file_contents_equal("../fs/mnt/tabs/last-focused/text.txt", "Body Text of Test Page")); + assert(system("echo remove > ../fs/mnt/tabs/last-focused/control") == 0); + } assert(1); printf("Done!\n"); } -- cgit v1.2.3