android: Update app-specific/MIME type icons
[LibreOffice.git] / starmath / qa / extras / mmlimport-test.cxx
blob3411953aabcc7e8977078883869cc31ff6b1c7e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/config.h>
11 #include <test/unoapi_test.hxx>
13 #include <sfx2/sfxbasemodel.hxx>
15 #include <document.hxx>
16 #include <smdll.hxx>
18 using namespace ::com::sun::star;
20 class Test : public UnoApiTest
22 public:
23 Test()
24 : UnoApiTest("starmath/qa/extras/data/")
28 void testColor();
29 void testSimple();
30 void testNsPrefixMath();
31 void testMaction();
32 void testMspace();
33 void testtdf99556();
34 void testTdf103430();
35 void testTdf103500();
36 void testTdf137008();
37 void testTdf151842();
38 void testMathmlEntities();
40 CPPUNIT_TEST_SUITE(Test);
41 CPPUNIT_TEST(testColor);
42 CPPUNIT_TEST(testSimple);
43 CPPUNIT_TEST(testNsPrefixMath);
44 CPPUNIT_TEST(testMaction);
45 CPPUNIT_TEST(testMspace);
46 CPPUNIT_TEST(testtdf99556);
47 CPPUNIT_TEST(testTdf103430);
48 CPPUNIT_TEST(testTdf103500);
49 CPPUNIT_TEST(testTdf137008);
50 CPPUNIT_TEST(testTdf151842);
51 CPPUNIT_TEST(testMathmlEntities);
52 CPPUNIT_TEST_SUITE_END();
55 void Test::testColor()
57 loadFromURL(u"color.mml");
58 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
59 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
60 CPPUNIT_ASSERT_EQUAL(OUString("{ color black b"
61 " color white w"
62 " color red r"
63 " color green g"
64 " color blue b"
65 " color yellow y"
66 " color silver s"
67 " color gray g"
68 " color maroon m"
69 " color purple p"
70 " color lime l"
71 " color olive o"
72 " color navy n"
73 " color teal t"
74 " color aqua a"
75 " color fuchsia f"
76 " color crimson c"
77 " color dvip apricot"
78 " a color yellow y"
79 " color rgb 220 20 61 x }"),
80 pDocShell->GetText());
83 void Test::testSimple()
85 loadFromURL(u"simple.mml");
86 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
87 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
88 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("left ( { a + b } right ) ^ 2"),
89 pDocShell->GetText());
92 void Test::testNsPrefixMath()
94 loadFromURL(u"ns-prefix-math.mml");
95 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
96 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
97 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("left ( { a + b } right ) ^ 2"),
98 pDocShell->GetText());
101 void Test::testMaction()
103 loadFromURL(u"maction.mml");
104 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
105 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
106 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("matrix{ 1 ## 2 ## 3 }"),
107 pDocShell->GetText());
110 void Test::testMspace()
112 loadFromURL(u"mspace.mml");
113 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
114 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
115 CPPUNIT_ASSERT_EQUAL(OUString("{ a b ~ c ~~``` d }"), pDocShell->GetText());
118 void Test::testtdf99556()
120 loadFromURL(u"tdf99556-1.mml");
121 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
122 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
123 CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", OUString("sqrt { }"), pDocShell->GetText());
126 void Test::testTdf103430()
128 loadFromURL(u"tdf103430.mml");
129 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
130 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
131 CPPUNIT_ASSERT_EQUAL(
132 OUString("{ frac { { nitalic d ^ 2 nitalic color blue y } } { { color dvip "
133 "apricot nitalic d font sans bold italic color red x } } }"),
134 pDocShell->GetText());
137 void Test::testTdf103500()
139 loadFromURL(u"tdf103500.mml");
140 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
141 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
142 CPPUNIT_ASSERT_EQUAL(
143 OUString("{ { int csup b csub a { { frac { 1 } { x } } ` nitalic d x } } = { "
144 "intd csup b csub a { { frac { 1 } { y } } ` nitalic d y } } }"),
145 pDocShell->GetText());
148 void Test::testTdf137008()
150 // Without the fix in place, this test would have crashed
151 loadFromURL(u"tdf137008.mml");
152 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
153 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
154 CPPUNIT_ASSERT_EQUAL(OUString("matrix{ { } # ## # }"), pDocShell->GetText());
157 void Test::testTdf151842()
159 // Without the fix in place, this test would have crashed
160 loadFromURL(u"tdf151842.odf");
161 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
162 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
163 CPPUNIT_ASSERT_EQUAL(OUString("test"), pDocShell->GetText());
164 SmFormat aFormat = pDocShell->GetFormat();
166 // Without the fix in place, this test would have failed with
167 // - Expected: 4233
168 // - Actual : 423
169 CPPUNIT_ASSERT_EQUAL(tools::Long(4233), aFormat.GetBaseSize().Height());
172 void Test::testMathmlEntities()
174 loadFromURL(u"mthmlentities.mml");
175 SfxBaseModel* pModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
176 SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
177 CPPUNIT_ASSERT_EQUAL(OUString(u"{ \u03C3 \u221E \u221E \u03C3 }"), pDocShell->GetText());
180 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
182 CPPUNIT_PLUGIN_IMPLEMENT();
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */