bump product version to 4.1.6.2
[LibreOffice.git] / testtools / source / servicetests / TestBase.java
blobf3d2651ac4530a17aaa5e5a2af60bf943ffdbeaf
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package servicetests;
21 import com.sun.star.uno.UnoRuntime;
22 import complexlib.ComplexTestCase;
23 import util.WaitUnreachable;
25 public abstract class TestBase extends ComplexTestCase {
26 public final String[] getTestMethodNames() {
27 return new String[] { "test" };
30 public final void test() throws Exception {
31 TestServiceFactory factory = getTestServiceFactory();
32 TestService2 t = UnoRuntime.queryInterface(
33 TestService2.class, factory.get());
34 assure(t != null);
35 assure(UnoRuntime.queryInterface(TestService1.class, t) == t);
36 assure(UnoRuntime.queryInterface(XTestService1.class, t) == t);
37 assure(UnoRuntime.queryInterface(XTestService2.class, t) == t);
38 assure(t.fn1() == 1);
39 assure(t.getProp1() == 1);
40 t.setProp1(0);
41 assure(t.getProp1() == 0);
42 assure(t.getProp2() == 2);
43 /*try {
44 t.getProp3Void();
45 failed();
46 } catch (VoidPropertyException e) {
47 }*/
48 assure(t.getProp3Long() == 3);
49 /*try {
50 t.getProp4None();
51 failed();
52 } catch (OptionalPropertyException e) {
53 }*/
54 assure(t.getProp4Long() == 4);
55 /*try {
56 t.getProp5None();
57 failed();
58 } catch (OptionalPropertyException e) {
60 try {
61 t.getProp5Void();
62 failed();
63 } catch (VoidPropertyException e) {
64 }*/
65 assure(t.getProp5Long() == 5);
66 assure(t.getProp6() == 6);
67 /*t.clearProp6();
68 try {
69 t.getProp6();
70 failed();
71 } catch (VoidPropertyException e) {
72 }*/
73 t.setProp6(0);
74 assure(t.getProp6() == 0);
75 /*try {
76 t.getProp7None();
77 failed();
78 } catch (OptionalPropertyException e) {
80 try {
81 t.setProp7None(0);
82 failed();
83 } catch (OptionalPropertyException e) {
85 try {
86 t.clearProp7None();
87 failed();
88 } catch (OptionalPropertyException e) {
89 }*/
90 assure(t.getProp7() == 7);
91 /*t.clearProp7();
92 try {
93 t.getProp7();
94 failed();
95 } catch (VoidPropertyException e) {
96 }*/
97 t.setProp7(0);
98 assure(t.getProp7() == 0);
99 /*try {
100 t.getProp8None();
101 failed();
102 } catch (OptionalPropertyException e) {
104 try {
105 t.setProp8None(0);
106 failed();
107 } catch (OptionalPropertyException e) {
109 assure(t.getProp8Long() == 8);
110 t.setProp8Long(0);
111 assure(t.getProp8Long() == 0);
112 assure(t.fn2() == 2);
113 XTestService3 t3 = UnoRuntime.queryInterface(XTestService3.class, t);
114 assure(t3 != null);
115 assure(t3.fn3() == 3);
116 XTestService4 t4 = UnoRuntime.queryInterface(XTestService4.class, t);
117 assure(t4 == null);
118 WaitUnreachable u = new WaitUnreachable(t);
119 t = null;
120 WaitUnreachable.ensureFinalization(t3);
121 t3 = null;
122 WaitUnreachable.ensureFinalization(t4);
123 t4 = null;
124 u.waitUnreachable();
125 factory.dispose();
128 protected abstract TestServiceFactory getTestServiceFactory()
129 throws Exception;
131 protected interface TestServiceFactory {
132 Object get() throws Exception;
134 void dispose() throws Exception;