summaryrefslogtreecommitdiff
path: root/basic/qa/cppunit/basictest.hxx
blob: 79a3fe397653d948240b06c37bd46abbd700228e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright 2012 LibreOffice contributors.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
#ifndef _BASICTEST_HXX
#define _BASICTEST_HXX

#include <sal/types.h>
#include "cppunit/TestFixture.h"
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
#include <test/bootstrapfixture.hxx>
#include "basic/sbstar.hxx"
#include "basic/basrdll.hxx"

class BasicTestBase : public test::BootstrapFixture
{
    private:
    bool mbError;
    public:
    BasicTestBase() : mbError(false) {};


    DECL_LINK( BasicErrorHdl, StarBASIC * );
    bool HasError() { return mbError; }
    void ResetError()
    {
        StarBASIC::SetGlobalErrorHdl( Link() );
        mbError = false;
    }
    BasicDLL& basicDLL()
    {
        static BasicDLL maDll; // we need a dll instance for resouce manager etc.
        return maDll;
    }
};

IMPL_LINK( BasicTestBase, BasicErrorHdl, StarBASIC *, /*pBasic*/)
{
    fprintf(stderr,"Got error: \n\t%s!!!\n", rtl::OUStringToOString( StarBASIC::GetErrorText(), RTL_TEXTENCODING_UTF8 ).getStr() );
    mbError = true;
    return 0;
}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */