1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package complex.ConfigItems;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir import com.sun.star.beans.NamedValue;
31*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
32*cdf0e10cSrcweir import com.sun.star.task.XJob;
33*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir import org.junit.After;
37*cdf0e10cSrcweir import org.junit.AfterClass;
38*cdf0e10cSrcweir import org.junit.Before;
39*cdf0e10cSrcweir import org.junit.BeforeClass;
40*cdf0e10cSrcweir import org.junit.Test;
41*cdf0e10cSrcweir import org.openoffice.test.OfficeConnection;
42*cdf0e10cSrcweir // import static org.junit.Assert.*;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir //-----------------------------------------------
45*cdf0e10cSrcweir /** @short  todo document me
46*cdf0e10cSrcweir  * @deprecated this tests seems no longer work as expected.
47*cdf0e10cSrcweir  */
48*cdf0e10cSrcweir public class CheckConfigItems
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir     //-------------------------------------------
51*cdf0e10cSrcweir     // some const
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     //-------------------------------------------
54*cdf0e10cSrcweir     // member
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir     /** points to the global uno service manager. */
57*cdf0e10cSrcweir     private XMultiServiceFactory m_xSmgr = null;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     /** implements real config item tests in C++. */
60*cdf0e10cSrcweir     private XJob m_xTest = null;
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     //-------------------------------------------
63*cdf0e10cSrcweir     // test environment
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     //-------------------------------------------
66*cdf0e10cSrcweir     /** @short  A function to tell the framework,
67*cdf0e10cSrcweir                 which test functions are available.
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir         @return All test methods.
70*cdf0e10cSrcweir         @todo   Think about selection of tests from outside ...
71*cdf0e10cSrcweir      */
72*cdf0e10cSrcweir //    public String[] getTestMethodNames()
73*cdf0e10cSrcweir //    {
74*cdf0e10cSrcweir //        return new String[]
75*cdf0e10cSrcweir //        {
76*cdf0e10cSrcweir //            "checkPicklist",
77*cdf0e10cSrcweir //            "checkURLHistory",
78*cdf0e10cSrcweir //            "checkHelpBookmarks",
79*cdf0e10cSrcweir //            "checkPrintOptions",
80*cdf0e10cSrcweir //            "checkAccessibilityOptions",
81*cdf0e10cSrcweir //			"checkUserOptions"
82*cdf0e10cSrcweir //        };
83*cdf0e10cSrcweir //    }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     //-------------------------------------------
86*cdf0e10cSrcweir     /** @short  Create the environment for following tests.
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir      * @throws java.lang.Exception
89*cdf0e10cSrcweir      * @descr  Use either a component loader from desktop or
90*cdf0e10cSrcweir                 from frame
91*cdf0e10cSrcweir      */
92*cdf0e10cSrcweir     @Before public void before()
93*cdf0e10cSrcweir         throws java.lang.Exception
94*cdf0e10cSrcweir     {
95*cdf0e10cSrcweir         // get uno service manager from global test environment
96*cdf0e10cSrcweir         m_xSmgr = getMSF();
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         // TODO register helper service
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir         // create module manager
101*cdf0e10cSrcweir         m_xTest = UnoRuntime.queryInterface(XJob.class, m_xSmgr.createInstance("com.sun.star.comp.svl.ConfigItemTest"));
102*cdf0e10cSrcweir     }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     //-------------------------------------------
105*cdf0e10cSrcweir     /**
106*cdf0e10cSrcweir      * @throws java.lang.Exception
107*cdf0e10cSrcweir      * @short  close the environment.
108*cdf0e10cSrcweir      */
109*cdf0e10cSrcweir     @After public void after()
110*cdf0e10cSrcweir         throws java.lang.Exception
111*cdf0e10cSrcweir     {
112*cdf0e10cSrcweir         // TODO deregister helper service
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir         m_xTest = null;
115*cdf0e10cSrcweir         m_xSmgr = null;
116*cdf0e10cSrcweir     }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     //-------------------------------------------
119*cdf0e10cSrcweir     /**
120*cdf0e10cSrcweir      * @throws java.lang.Exception
121*cdf0e10cSrcweir      * @todo document me
122*cdf0e10cSrcweir      */
123*cdf0e10cSrcweir     @Test public void checkPicklist()
124*cdf0e10cSrcweir         throws java.lang.Exception
125*cdf0e10cSrcweir     {
126*cdf0e10cSrcweir         impl_triggerTest("checkPicklist");
127*cdf0e10cSrcweir     }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     //-------------------------------------------
130*cdf0e10cSrcweir     /**
131*cdf0e10cSrcweir      * @throws java.lang.Exception
132*cdf0e10cSrcweir      * @todo document me
133*cdf0e10cSrcweir      */
134*cdf0e10cSrcweir     @Test public void checkURLHistory()
135*cdf0e10cSrcweir         throws java.lang.Exception
136*cdf0e10cSrcweir     {
137*cdf0e10cSrcweir         impl_triggerTest("checkURLHistory");
138*cdf0e10cSrcweir     }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     //-------------------------------------------
141*cdf0e10cSrcweir     /**
142*cdf0e10cSrcweir      * @throws java.lang.Exception
143*cdf0e10cSrcweir      * @todo document me
144*cdf0e10cSrcweir      */
145*cdf0e10cSrcweir     @Test public void checkHelpBookmarks()
146*cdf0e10cSrcweir         throws java.lang.Exception
147*cdf0e10cSrcweir     {
148*cdf0e10cSrcweir         impl_triggerTest("checkHelpBookmarks");
149*cdf0e10cSrcweir     }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir     //-------------------------------------------
152*cdf0e10cSrcweir     /**
153*cdf0e10cSrcweir      * @throws java.lang.Exception
154*cdf0e10cSrcweir      * @todo document me
155*cdf0e10cSrcweir      */
156*cdf0e10cSrcweir //     @Test public void checkPrintOptions()
157*cdf0e10cSrcweir //         throws java.lang.Exception
158*cdf0e10cSrcweir //     {
159*cdf0e10cSrcweir //         impl_triggerTest("checkPrintOptions");
160*cdf0e10cSrcweir //     }
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir     //-------------------------------------------
163*cdf0e10cSrcweir     /**
164*cdf0e10cSrcweir      * @throws java.lang.Exception
165*cdf0e10cSrcweir      * @todo document me
166*cdf0e10cSrcweir      */
167*cdf0e10cSrcweir     @Test public void checkAccessibilityOptions()
168*cdf0e10cSrcweir         throws java.lang.Exception
169*cdf0e10cSrcweir     {
170*cdf0e10cSrcweir         impl_triggerTest("checkAccessibilityOptions");
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	//-------------------------------------------
174*cdf0e10cSrcweir     /**
175*cdf0e10cSrcweir      * @throws java.lang.Exception
176*cdf0e10cSrcweir      * @todo document me
177*cdf0e10cSrcweir 	 */
178*cdf0e10cSrcweir 	@Test public void checkUserOptions()
179*cdf0e10cSrcweir 		throws java.lang.Exception
180*cdf0e10cSrcweir 	{
181*cdf0e10cSrcweir 		impl_triggerTest("checkUserOptions");
182*cdf0e10cSrcweir 	}
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     //-------------------------------------------
185*cdf0e10cSrcweir     /** @todo document me
186*cdf0e10cSrcweir      */
187*cdf0e10cSrcweir     private void impl_triggerTest(String sTest)
188*cdf0e10cSrcweir         throws java.lang.Exception
189*cdf0e10cSrcweir     {
190*cdf0e10cSrcweir         NamedValue[] lArgs          = new NamedValue[1];
191*cdf0e10cSrcweir                      lArgs[0]       = new NamedValue();
192*cdf0e10cSrcweir                      lArgs[0].Name  = "Test";
193*cdf0e10cSrcweir                      lArgs[0].Value = sTest;
194*cdf0e10cSrcweir         m_xTest.execute(lArgs);
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir        private XMultiServiceFactory getMSF()
199*cdf0e10cSrcweir     {
200*cdf0e10cSrcweir         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
201*cdf0e10cSrcweir         return xMSF1;
202*cdf0e10cSrcweir     }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     // setup and close connections
205*cdf0e10cSrcweir     @BeforeClass public static void setUpConnection() throws Exception {
206*cdf0e10cSrcweir         System.out.println("setUpConnection()");
207*cdf0e10cSrcweir         connection.setUp();
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     @AfterClass public static void tearDownConnection()
211*cdf0e10cSrcweir         throws InterruptedException, com.sun.star.uno.Exception
212*cdf0e10cSrcweir     {
213*cdf0e10cSrcweir         System.out.println("tearDownConnection()");
214*cdf0e10cSrcweir         connection.tearDown();
215*cdf0e10cSrcweir     }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir     private static final OfficeConnection connection = new OfficeConnection();
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir }
220