8
8
9
9
#include < nui/frontend/elements.hpp>
10
10
#include < nui/frontend/attributes.hpp>
11
+ #include < nui/frontend/svg_elements.hpp>
12
+ #include < nui/frontend/svg_attributes.hpp>
11
13
#include < nui/frontend/dom/reference.hpp>
12
14
#include < nui/frontend/utility/stabilize.hpp>
13
15
@@ -677,4 +679,58 @@ namespace Nui::Tests
677
679
678
680
EXPECT_EQ (Nui::val::global (" document" )[" body" ][" childNodes" ][1 ][" nodeValue" ].as <std::string>(), " Changed" );
679
681
}
682
+
683
+ TEST_F (TestRender, CanRenderSvgElement)
684
+ {
685
+ using namespace Nui ::Elements;
686
+ namespace se = Nui::Elements::Svg;
687
+ namespace sa = Nui::Attributes::Svg;
688
+
689
+ render (body{}(se::svg{}()));
690
+
691
+ ASSERT_EQ (Nui::val::global (" document" )[" body" ][" children" ][" length" ].as <long long >(), 1 );
692
+ EXPECT_EQ (Nui::val::global (" document" )[" body" ][" children" ][0 ][" tagName" ].as <std::string>(), " svg" );
693
+ }
694
+
695
+ TEST_F (TestRender, RenderedSvgNamespaceIsSetCorrectly)
696
+ {
697
+ using namespace Nui ::Elements;
698
+ namespace se = Nui::Elements::Svg;
699
+ namespace sa = Nui::Attributes::Svg;
700
+
701
+ render (body{}(se::svg{}()));
702
+
703
+ ASSERT_EQ (Nui::val::global (" document" )[" body" ][" children" ][" length" ].as <long long >(), 1 );
704
+ EXPECT_EQ (
705
+ Nui::val::global (" document" )[" body" ][" children" ][0 ].as <Nui::val>()[" namespaceURI" ].as <std::string>(),
706
+ " http://www.w3.org/2000/svg" );
707
+ }
708
+
709
+ TEST_F (TestRender, SvgElementChildIsAppended)
710
+ {
711
+ using namespace Nui ::Elements;
712
+ namespace se = Nui::Elements::Svg;
713
+ namespace sa = Nui::Attributes::Svg;
714
+
715
+ render (body{}(se::svg{}(se::circle{}())));
716
+
717
+ ASSERT_EQ (Nui::val::global (" document" )[" body" ][" children" ][" length" ].as <long long >(), 1 );
718
+ ASSERT_EQ (Nui::val::global (" document" )[" body" ][" children" ][0 ][" children" ][" length" ].as <long long >(), 1 );
719
+ EXPECT_EQ (
720
+ Nui::val::global (" document" )[" body" ][" children" ][0 ][" children" ][0 ][" tagName" ].as <std::string>(), " circle" );
721
+ }
722
+
723
+ TEST_F (TestRender, SvgElementAttributeIsSet)
724
+ {
725
+ using namespace Nui ::Elements;
726
+ namespace se = Nui::Elements::Svg;
727
+ namespace sa = Nui::Attributes::Svg;
728
+
729
+ render (body{}(se::svg{}(se::circle{sa::cx = 10 }())));
730
+
731
+ ASSERT_EQ (Nui::val::global (" document" )[" body" ][" children" ][" length" ].as <long long >(), 1 );
732
+ ASSERT_EQ (Nui::val::global (" document" )[" body" ][" children" ][0 ][" children" ][" length" ].as <long long >(), 1 );
733
+ EXPECT_EQ (
734
+ Nui::val::global (" document" )[" body" ][" children" ][0 ][" children" ][0 ][" attributes" ][" cx" ].as <long long >(), 10 );
735
+ }
680
736
}
0 commit comments