Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2011 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <cstdlib>
30 : : #include <iostream>
31 : : #include <limits>
32 : :
33 : : #include <sal/types.h>
34 : : #include "boost/noncopyable.hpp"
35 : : #include "cppunit/TestAssert.h"
36 : : #include "cppunit/TestFixture.h"
37 : : #include "cppunit/extensions/HelperMacros.h"
38 : : #include "cppunit/plugin/TestPlugIn.h"
39 : : #include "osl/thread.hxx"
40 : :
41 : : namespace {
42 : :
43 [ - + ]: 10 : class TestThread: public osl::Thread, private boost::noncopyable {
44 : : private:
45 : : virtual void SAL_CALL run();
46 : : };
47 : :
48 : 5 : void TestThread::run() {
49 : : #if defined WNT
50 : : if (std::getenv("URE_TEST_SETTHREADNAME") != 0) {
51 : : // On Windows, setting thread names appears to only take effect when the
52 : : // process is being debugged, so attach a debugger now:
53 : : std::cout << "set: ";
54 : : std::cin.ignore(std::numeric_limits< int >::max(), '\n');
55 : : }
56 : : #endif
57 : 5 : setName("TestThread");
58 [ - + ]: 5 : if (std::getenv("URE_TEST_SETTHREADNAME") != 0) {
59 : : // On Linux, the thread name can now be observed with "ps -L"; on
60 : : // Windows with the Microsoft compiler, the thread name can now be
61 : : // observed in a debugger.
62 : 0 : std::cout << "stop: ";
63 : 0 : std::cin.ignore(std::numeric_limits< int >::max(), '\n');
64 : : }
65 : 5 : }
66 : :
67 [ - + ]: 15 : class Test: public CppUnit::TestFixture {
68 : : private:
69 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE(Test);
[ + - ][ + - ]
[ # # ]
70 [ + - ][ + - ]: 5 : CPPUNIT_TEST(test);
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
71 [ + - ][ + - ]: 10 : CPPUNIT_TEST_SUITE_END();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
72 : :
73 : : void test();
74 : : };
75 : :
76 : 5 : void Test::test() {
77 [ + - ]: 5 : TestThread t;
78 [ + - ]: 5 : t.create();
79 [ + - ][ + - ]: 5 : t.join();
80 : 5 : }
81 : :
82 : 5 : CPPUNIT_TEST_SUITE_REGISTRATION(Test);
83 : :
84 : : }
85 : :
86 [ + - ][ + - ]: 20 : CPPUNIT_PLUGIN_IMPLEMENT();
[ + - ][ + - ]
[ + - ][ # # ]
87 : :
88 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|