fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / filter / qa / cppunit / priority-test.cxx
blob70093fb68d2ea72db4f32df4e6d010a8ae887497
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 // Unit test to check that we get the right filters for the right extensions.
12 #include <limits>
14 #include <cppunit/TestAssert.h>
15 #include <cppunit/TestFixture.h>
16 #include <cppunit/extensions/HelperMacros.h>
17 #include <cppunit/plugin/TestPlugIn.h>
19 #include <sal/types.h>
20 #include <rtl/ustrbuf.hxx>
22 #include <com/sun/star/document/XTypeDetection.hpp>
23 #include <comphelper/processfactory.hxx>
25 #include <unotest/bootstrapfixturebase.hxx>
28 using namespace std;
29 using namespace css;
31 namespace {
33 class PriorityFilterTest
34 : public test::BootstrapFixtureBase
36 public:
37 void testPriority();
39 CPPUNIT_TEST_SUITE(PriorityFilterTest);
40 CPPUNIT_TEST(testPriority);
41 CPPUNIT_TEST_SUITE_END();
44 void PriorityFilterTest::testPriority()
46 uno::Reference<document::XTypeDetection> xDetection(
47 comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.TypeDetection"), uno::UNO_QUERY);
48 CPPUNIT_ASSERT_MESSAGE("No type detection component", xDetection.is());
50 static struct {
51 const char *pURL;
52 const char *pFormat;
53 } aToCheck[] = {
54 { "file:///tmp/foo.xls", "calc_MS_Excel_97" }
55 // TODO: expand this to check more of these priorities
58 for (size_t i = 0; i < SAL_N_ELEMENTS(aToCheck); i++)
60 OUString aURL = OUString::createFromAscii(aToCheck[i].pURL);
61 try
63 OUString aTypeName = xDetection->queryTypeByURL(aURL);
65 OUString aFormatCorrect = OUString::createFromAscii(aToCheck[i].pFormat);
66 OUStringBuffer aMsg("Mis-matching formats ");
67 aMsg.append("'");
68 aMsg.append(aTypeName);
69 aMsg.append("' should be '");
70 aMsg.append(aFormatCorrect);
71 aMsg.append("'");
72 CPPUNIT_ASSERT_MESSAGE(rtl::OUStringToOString(aMsg.makeStringAndClear(),
73 RTL_TEXTENCODING_UTF8).getStr(),
74 aTypeName == aFormatCorrect);
76 catch (const uno::Exception &e)
78 OUStringBuffer aMsg("Exception querying for type: ");
79 aMsg.append("'");
80 aMsg.append(e.Message);
81 aMsg.append("'");
82 CPPUNIT_FAIL(rtl::OUStringToOString(aMsg.makeStringAndClear(),
83 RTL_TEXTENCODING_UTF8).getStr());
88 CPPUNIT_TEST_SUITE_REGISTRATION(PriorityFilterTest);
92 CPPUNIT_PLUGIN_IMPLEMENT();
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */