1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package complex.ConfigItems;
25 
26 import com.sun.star.beans.NamedValue;
27 import com.sun.star.lang.XMultiServiceFactory;
28 import com.sun.star.task.XJob;
29 import com.sun.star.uno.UnoRuntime;
30 
31 
32 import org.junit.After;
33 import org.junit.AfterClass;
34 import org.junit.Before;
35 import org.junit.BeforeClass;
36 import org.junit.Test;
37 import org.openoffice.test.OfficeConnection;
38 // import static org.junit.Assert.*;
39 
40 //-----------------------------------------------
41 /** @short  todo document me
42  * @deprecated this tests seems no longer work as expected.
43  */
44 public class CheckConfigItems
45 {
46     //-------------------------------------------
47     // some const
48 
49     //-------------------------------------------
50     // member
51 
52     /** points to the global uno service manager. */
53     private XMultiServiceFactory m_xSmgr = null;
54 
55     /** implements real config item tests in C++. */
56     private XJob m_xTest = null;
57 
58     //-------------------------------------------
59     // test environment
60 
61     //-------------------------------------------
62     /** @short  A function to tell the framework,
63                 which test functions are available.
64 
65         @return All test methods.
66         @todo   Think about selection of tests from outside ...
67      */
68 //    public String[] getTestMethodNames()
69 //    {
70 //        return new String[]
71 //        {
72 //            "checkPicklist",
73 //            "checkURLHistory",
74 //            "checkHelpBookmarks",
75 //            "checkPrintOptions",
76 //            "checkAccessibilityOptions",
77 //			"checkUserOptions"
78 //        };
79 //    }
80 
81     //-------------------------------------------
82     /** @short  Create the environment for following tests.
83 
84      * @throws java.lang.Exception
85      * @descr  Use either a component loader from desktop or
86                 from frame
87      */
before()88     @Before public void before()
89         throws java.lang.Exception
90     {
91         // get uno service manager from global test environment
92         m_xSmgr = getMSF();
93 
94         // TODO register helper service
95 
96         // create module manager
97         m_xTest = UnoRuntime.queryInterface(XJob.class, m_xSmgr.createInstance("com.sun.star.comp.svl.ConfigItemTest"));
98     }
99 
100     //-------------------------------------------
101     /**
102      * @throws java.lang.Exception
103      * @short  close the environment.
104      */
after()105     @After public void after()
106         throws java.lang.Exception
107     {
108         // TODO deregister helper service
109 
110         m_xTest = null;
111         m_xSmgr = null;
112     }
113 
114     //-------------------------------------------
115     /**
116      * @throws java.lang.Exception
117      * @todo document me
118      */
checkPicklist()119     @Test public void checkPicklist()
120         throws java.lang.Exception
121     {
122         impl_triggerTest("checkPicklist");
123     }
124 
125     //-------------------------------------------
126     /**
127      * @throws java.lang.Exception
128      * @todo document me
129      */
checkURLHistory()130     @Test public void checkURLHistory()
131         throws java.lang.Exception
132     {
133         impl_triggerTest("checkURLHistory");
134     }
135 
136     //-------------------------------------------
137     /**
138      * @throws java.lang.Exception
139      * @todo document me
140      */
checkHelpBookmarks()141     @Test public void checkHelpBookmarks()
142         throws java.lang.Exception
143     {
144         impl_triggerTest("checkHelpBookmarks");
145     }
146 
147     //-------------------------------------------
148     /**
149      * @throws java.lang.Exception
150      * @todo document me
151      */
152 //     @Test public void checkPrintOptions()
153 //         throws java.lang.Exception
154 //     {
155 //         impl_triggerTest("checkPrintOptions");
156 //     }
157 
158     //-------------------------------------------
159     /**
160      * @throws java.lang.Exception
161      * @todo document me
162      */
checkAccessibilityOptions()163     @Test public void checkAccessibilityOptions()
164         throws java.lang.Exception
165     {
166         impl_triggerTest("checkAccessibilityOptions");
167     }
168 
169 	//-------------------------------------------
170     /**
171      * @throws java.lang.Exception
172      * @todo document me
173 	 */
checkUserOptions()174 	@Test public void checkUserOptions()
175 		throws java.lang.Exception
176 	{
177 		impl_triggerTest("checkUserOptions");
178 	}
179 
180     //-------------------------------------------
181     /** @todo document me
182      */
impl_triggerTest(String sTest)183     private void impl_triggerTest(String sTest)
184         throws java.lang.Exception
185     {
186         NamedValue[] lArgs          = new NamedValue[1];
187                      lArgs[0]       = new NamedValue();
188                      lArgs[0].Name  = "Test";
189                      lArgs[0].Value = sTest;
190         m_xTest.execute(lArgs);
191     }
192 
193 
getMSF()194        private XMultiServiceFactory getMSF()
195     {
196         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
197         return xMSF1;
198     }
199 
200     // setup and close connections
setUpConnection()201     @BeforeClass public static void setUpConnection() throws Exception {
202         System.out.println("setUpConnection()");
203         connection.setUp();
204     }
205 
tearDownConnection()206     @AfterClass public static void tearDownConnection()
207         throws InterruptedException, com.sun.star.uno.Exception
208     {
209         System.out.println("tearDownConnection()");
210         connection.tearDown();
211     }
212 
213     private static final OfficeConnection connection = new OfficeConnection();
214 
215 }
216