summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-06-15 23:20:00 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-22 22:08:54 +0200
commitcb17c3035bbd80bd8ea6718bae4c57cfb2555653 (patch)
treef454181a2f58071f5f2ba4408e7e179838ed3fb4 /test
parentface8e0a7d5f530ee3e5e63ab1e3d6ecd497326b (diff)
Initial monitor GUI
Basic monitor functionality, GTK-3.0 and QT5 backends
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makefile.am5
-rw-r--r--test/test-htmlattrtext.cc38
3 files changed, 43 insertions, 1 deletions
diff --git a/test/.gitignore b/test/.gitignore
index b102ce1..aa33417 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -8,3 +8,4 @@
/test-xdg
/test-xdg
/test-observers
+/test-htmlattrtext
diff --git a/test/Makefile.am b/test/Makefile.am
index 4daf511..b5d2cee 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -3,7 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
AM_CXXFLAGS = @DEFINES@
TESTS = test-url test-http test-args test-xdg test-paths test-strings \
- test-observers
+ test-observers test-htmlattrtext
check_PROGRAMS = $(TESTS)
@@ -26,3 +26,6 @@ test_paths_SOURCES = test-paths.cc
test_paths_LDADD = $(top_builddir)/src/libtp.a
test_observers_SOURCES = test-observers.cc
+
+test_htmlattrtext_SOURCES = test-htmlattrtext.cc
+test_htmlattrtext_LDADD = $(top_builddir)/src/libattrstr.a
diff --git a/test/test-htmlattrtext.cc b/test/test-htmlattrtext.cc
new file mode 100644
index 0000000..a0d18e6
--- /dev/null
+++ b/test/test-htmlattrtext.cc
@@ -0,0 +1,38 @@
+// -*- mode: c++; c-basic-offset: 2; -*-
+
+#include "common.hh"
+#include "test.hh"
+
+#include <memory>
+
+#include "gui_htmlattrtext.hh"
+
+namespace {
+
+bool test_sanity() {
+ std::unique_ptr<HtmlAttributedText> attr(HtmlAttributedText::create());
+ HtmlAttributedText::Attribute red(0xff, 0, 0);
+ HtmlAttributedText::Attribute bold;
+ HtmlAttributedText::Attribute green(0, 0xff, 0);
+ bold.set_bold(true);
+ ASSERT_EQ("", attr->html());
+ attr->append("Hello World");
+ ASSERT_EQ("Hello&nbsp;World", attr->html());
+ attr->append(" <!>", red);
+ ASSERT_EQ("Hello&nbsp;World<span style=\"color: rgb(255, 0, 0); \">&nbsp;&lt;!&gt;</span>", attr->html());
+ attr->add(bold, 0, 5);
+ ASSERT_EQ("<span style=\"font-weight: bold; \">Hello</span>&nbsp;World<span style=\"color: rgb(255, 0, 0); \">&nbsp;&lt;!&gt;</span>", attr->html());
+ attr->add(red, 1, 2);
+ ASSERT_EQ("<span style=\"font-weight: bold; \">H<span style=\"color: rgb(255, 0, 0); \">el</span>lo</span>&nbsp;World<span style=\"color: rgb(255, 0, 0); \">&nbsp;&lt;!&gt;</span>", attr->html());
+ attr->set(green, 1, 1);
+ ASSERT_EQ("<span style=\"font-weight: bold; \">H</span><span style=\"color: rgb(0, 255, 0); \">e</span><span style=\"font-weight: bold; \"><span style=\"color: rgb(255, 0, 0); \">l</span>lo</span>&nbsp;World<span style=\"color: rgb(255, 0, 0); \">&nbsp;&lt;!&gt;</span>", attr->html());
+ return true;
+}
+
+} // namespace
+
+int main(void) {
+ BEFORE;
+ RUN(test_sanity());
+ AFTER;
+}