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 #ifndef  SVTOOLS_HISTORYOPTTEST_HXX
25 #define  SVTOOLS_HISTORYOPTTEST_HXX
26 
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <unotools/historyoptions.hxx>
29 
30 namespace css = ::com::sun::star;
31 
32 class HistoryOptTest
33 {
34     public:
35 
36         HistoryOptTest();
37         virtual ~HistoryOptTest();
38 
39         //---------------------------------------------------------------------
40         /** unit test of picklist */
41 		void checkPicklist();
42 
43         //---------------------------------------------------------------------
44         /** unit test of URL list */
45 		void checkURLHistory();
46 
47         //---------------------------------------------------------------------
48         /** unit test of Help bookmarks */
49 		void checkHelpBookmarks();
50 
51     private:
52 
53         //---------------------------------------------------------------------
54         /** test every well known history list in the same way.
55          *  Only the count of created and tested items can be defined from outside
56          *  e.g. usefull for stress tests.
57          *
58          *  @param  eHistory
59          *          specify the history list for testing.
60          *
61          *  @param  nMaxItems
62          *          max count of new created and tested history items.
63          */
64         void impl_testHistory(EHistoryType eHistory ,
65                               ::sal_Int32  nMaxItems);
66 
67         //---------------------------------------------------------------------
68         /** try to clear the whole list and check the results.
69          *  If list could not be cleared successfully an exception is thrown.
70          */
71         void impl_clearList();
72 
73         //---------------------------------------------------------------------
74         /** define a new size for the current list and check the results.
75          *  Note: The given size must match against the defined constraints.
76          *  That must be checked before this method is called.
77          *
78          *  @param  nSize
79          *          the new size.
80          */
81         void impl_setSize(::sal_Int32 nSize);
82 
83         //---------------------------------------------------------------------
84         /** create a new item (means it's properties using a special schema using the
85          *  item id).
86          *
87          *  Note: This method does not check if creation was successfully.
88          *        Therefore exists more specialized method impl_existsItem()
89          *        and impl_existsItemAtPosition().
90          *
91          *  @param  nItem
92          *          id of the item
93          */
94         void impl_appendItem(::sal_Int32 nItem);
95 
96         //---------------------------------------------------------------------
97         /** check if an entry for given item id realy exists (in memory and xcu file).
98          *
99          *  @param  nItem
100          *          id of the item
101          *
102          *  @return true if item exists - false otherwise.
103          */
104         ::sal_Bool impl_existsItem(::sal_Int32 nItem);
105 
106         //---------------------------------------------------------------------
107         /** check if an entry for given item id realy exists (in memory and xcu file).
108          *  Further it checks if the requested item is placed at the also specified
109          *  position inside history list.
110          *
111          *  @param  nItem
112          *          id of the item
113          *
114          *  @param  nIndex
115          *          expected position of item inside history list.
116          *
117          *  @return true if item exists at right position - false otherwise.
118          */
119         ::sal_Bool impl_existsItemAtIndex(::sal_Int32 nItem ,
120                                           ::sal_Int32 nIndex);
121 
122         //---------------------------------------------------------------------
123         /** create an URL suitable for the given item id.
124          *
125          *  @param  nItem
126          *          id of the item
127          *
128          *  @return the new created URL.
129          */
130         ::rtl::OUString impl_createItemURL(::sal_Int32 nItem);
131 
132         //---------------------------------------------------------------------
133         /** create a title suitable for the given item id.
134          *
135          *  @param  nItem
136          *          id of the item
137          *
138          *  @return the new created title.
139          */
140         ::rtl::OUString impl_createItemTitle(::sal_Int32 nItem);
141 
142         //---------------------------------------------------------------------
143         /** create a password suitable for the given item id.
144          *
145          *  @param  nItem
146          *          id of the item
147          *
148          *  @return the new created password.
149          */
150         ::rtl::OUString impl_createItemPassword(::sal_Int32 nItem);
151 
152         //---------------------------------------------------------------------
153         /** returns direct access to the item list inside histories.xcu
154          *  suitable for the current defined list type (m_eList).
155          *
156          *  @return reference to the item list configuration
157          */
158         css::uno::Reference< css::container::XNameAccess > impl_getItemList();
159 
160         //---------------------------------------------------------------------
161         /** returns direct access to the order list inside histories.xcu
162          *  suitable for the current defined list type (m_eList).
163          *
164          *  @return reference to the order list configuration
165          */
166         css::uno::Reference< css::container::XNameAccess > impl_getOrderList();
167 
168         //---------------------------------------------------------------------
169         /** returns direct access to the history list inside histories.xcu
170          *  suitable for the current defined list type (m_eList).
171          *
172          *  @return reference to the history list configuration
173          */
174         css::uno::Reference< css::container::XNameAccess > impl_getNewHistory();
175 
176         //---------------------------------------------------------------------
177         /** returns direct access to the history config inside common.xcu
178          *  suitable for the current defined list type (m_eList).
179          *
180          *  @return reference to the history configuration
181          */
182         css::uno::Reference< css::container::XNameAccess > impl_getOldHistory();
183 
184     private:
185 
186         // the config item which should be tested here
187         SvtHistoryOptions m_aConfigItem;
188 
189         // defines the special list for testing (picklist, history or url list)
190         EHistoryType m_eList;
191 
192         // underlying configuration of the tested config items for cross over checks
193         css::uno::Reference< css::container::XNameAccess > m_xHistoriesXCU;
194 
195         // underlying configuration of the tested config items for cross over checks
196         css::uno::Reference< css::container::XNameAccess > m_xCommonXCU;
197 };
198 
199 #endif // #ifndef  SVTOOLS_HISTORYOPTTEST_HXX
200