summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2015-06-04 09:20:31 -0700
committerPhilip Chimento <philip@endlessm.com>2015-06-04 14:27:31 -0700
commitf17a6ff5c41215701b822ccc4d46e89832fbd033 (patch)
tree32e80569771061e8948903002c694dafc3514ea1 /test
parentfbc49cb284067838416c6022d5c7dcb64899e030 (diff)
Add eos-html-extractor and m4 file
This is taken almost directly from the existing version in eos-english. Cleanups to follow in subsequent commits. Previously the m4 code was in two separate macros, but since they were much the same, I combined them into one macro. This also adds a very minimal test for eos-html-extractor; basically as a very quick regression test for the cleanups to follow. [endlessm/eos-sdk#3245]
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am.inc6
-rw-r--r--test/tools/test.html20
-rw-r--r--test/tools/testHtmlExtractor.js30
3 files changed, 55 insertions, 1 deletions
diff --git a/test/Makefile.am.inc b/test/Makefile.am.inc
index 842e8e8..f541a5b 100644
--- a/test/Makefile.am.inc
+++ b/test/Makefile.am.inc
@@ -43,6 +43,7 @@ EXTRA_DIST += \
javascript_tests = \
test/tools/eos-application-manifest/testInit.js \
+ test/tools/testHtmlExtractor.js \
test/webhelper/testTranslate.js \
test/webhelper/testTranslate2.js \
test/webhelper/testWebActions.js \
@@ -51,7 +52,10 @@ javascript_tests = \
test/endless/testCustomContainer.js \
test/endless/testTopbarNavButton.js \
$(NULL)
-EXTRA_DIST += $(javascript_tests)
+EXTRA_DIST += \
+ $(javascript_tests) \
+ test/tools/test.html \
+ $(NULL)
# Run tests when running 'make check'
TESTS = \
diff --git a/test/tools/test.html b/test/tools/test.html
new file mode 100644
index 0000000..4dfda70
--- /dev/null
+++ b/test/tools/test.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html dir="ltr" lang="en-US" class="no-js">
+ <head>
+ <meta charset="utf-8">
+ <title><span name="translatable">Finance Builder</span></title>
+ <meta name="description" content="Finance Builder">
+ <meta name="author" content="Endless Mobile">
+ </head>
+ <body>
+ <section id="choose" class="section">
+ <!-- TRANSLATORS: This is a test of UTF-8 encoded characters -->
+ <div class="Intro"><span name="translatable">My Bü∂get</span></div>
+ <div class="subtitle"><span name="translatable">Choose a template</span></div>
+ <div id="mi-slider" class="mi-slider">
+ <nav id="finance-nav">
+ </nav>
+ </div>
+ </section>
+ </body>
+</html>
diff --git a/test/tools/testHtmlExtractor.js b/test/tools/testHtmlExtractor.js
new file mode 100644
index 0000000..4f46706
--- /dev/null
+++ b/test/tools/testHtmlExtractor.js
@@ -0,0 +1,30 @@
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
+
+const EXPECTED_OUTPUT = '#line 5 "test/tools/test.html"\n\
+_("Finance Builder");\n\
+#line 12 "test/tools/test.html"\n\
+// TRANSLATORS: This is a test of UTF-8 encoded characters\n\
+_("My Bü∂get");\n\
+#line 13 "test/tools/test.html"\n\
+_("Choose a template");\n';
+
+describe('eos-html-extractor', function () {
+ it('works correctly at a minimum', function () {
+ let srcdir = GLib.getenv('TOP_SRCDIR');
+ if (!srcdir)
+ srcdir = '.';
+ let executable = GLib.build_filenamev([srcdir,
+ 'tools/eos-html-extractor']);
+ let operand = GLib.build_filenamev([srcdir, 'test/tools/test.html']);
+ let process = new Gio.Subprocess({
+ argv: [executable, operand, srcdir],
+ flags: Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_MERGE,
+ });
+ process.init(null);
+ let [success, stdout] = process.communicate_utf8(null, null);
+ expect(process.get_if_exited()).toBeTruthy();
+ expect(process.get_exit_status()).toBe(0);
+ expect(stdout).toEqual(EXPECTED_OUTPUT);
+ });
+});