summaryrefslogtreecommitdiff
path: root/test/test-htmlattrtext.cc
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/test-htmlattrtext.cc
parentface8e0a7d5f530ee3e5e63ab1e3d6ecd497326b (diff)
Initial monitor GUI
Basic monitor functionality, GTK-3.0 and QT5 backends
Diffstat (limited to 'test/test-htmlattrtext.cc')
-rw-r--r--test/test-htmlattrtext.cc38
1 files changed, 38 insertions, 0 deletions
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;
+}