139a19a47SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
339a19a47SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
439a19a47SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
539a19a47SAndrew Rist  * distributed with this work for additional information
639a19a47SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
739a19a47SAndrew Rist  * to you under the Apache License, Version 2.0 (the
839a19a47SAndrew Rist  * "License"); you may not use this file except in compliance
939a19a47SAndrew Rist  * with the License.  You may obtain a copy of the License at
1039a19a47SAndrew Rist  *
1139a19a47SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1239a19a47SAndrew Rist  *
1339a19a47SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1439a19a47SAndrew Rist  * software distributed under the License is distributed on an
1539a19a47SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1639a19a47SAndrew Rist  * KIND, either express or implied.  See the License for the
1739a19a47SAndrew Rist  * specific language governing permissions and limitations
1839a19a47SAndrew Rist  * under the License.
1939a19a47SAndrew Rist  *
2039a19a47SAndrew Rist  *************************************************************/
2139a19a47SAndrew Rist 
2239a19a47SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef  SVTOOLS_HISTORYOPTTEST_HXX
25cdf0e10cSrcweir #define  SVTOOLS_HISTORYOPTTEST_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
28cdf0e10cSrcweir #include <unotools/historyoptions.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace css = ::com::sun::star;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class HistoryOptTest
33cdf0e10cSrcweir {
34cdf0e10cSrcweir     public:
35cdf0e10cSrcweir 
36cdf0e10cSrcweir         HistoryOptTest();
37cdf0e10cSrcweir         virtual ~HistoryOptTest();
38cdf0e10cSrcweir 
39cdf0e10cSrcweir         //---------------------------------------------------------------------
40cdf0e10cSrcweir         /** unit test of picklist */
41cdf0e10cSrcweir 		void checkPicklist();
42cdf0e10cSrcweir 
43cdf0e10cSrcweir         //---------------------------------------------------------------------
44cdf0e10cSrcweir         /** unit test of URL list */
45cdf0e10cSrcweir 		void checkURLHistory();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir         //---------------------------------------------------------------------
48cdf0e10cSrcweir         /** unit test of Help bookmarks */
49cdf0e10cSrcweir 		void checkHelpBookmarks();
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     private:
52cdf0e10cSrcweir 
53cdf0e10cSrcweir         //---------------------------------------------------------------------
54cdf0e10cSrcweir         /** test every well known history list in the same way.
55cdf0e10cSrcweir          *  Only the count of created and tested items can be defined from outside
56*86e1cf34SPedro Giffuni          *  e.g. useful for stress tests.
57cdf0e10cSrcweir          *
58cdf0e10cSrcweir          *  @param  eHistory
59cdf0e10cSrcweir          *          specify the history list for testing.
60cdf0e10cSrcweir          *
61cdf0e10cSrcweir          *  @param  nMaxItems
62cdf0e10cSrcweir          *          max count of new created and tested history items.
63cdf0e10cSrcweir          */
64cdf0e10cSrcweir         void impl_testHistory(EHistoryType eHistory ,
65cdf0e10cSrcweir                               ::sal_Int32  nMaxItems);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         //---------------------------------------------------------------------
68cdf0e10cSrcweir         /** try to clear the whole list and check the results.
69cdf0e10cSrcweir          *  If list could not be cleared successfully an exception is thrown.
70cdf0e10cSrcweir          */
71cdf0e10cSrcweir         void impl_clearList();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         //---------------------------------------------------------------------
74cdf0e10cSrcweir         /** define a new size for the current list and check the results.
75cdf0e10cSrcweir          *  Note: The given size must match against the defined constraints.
76cdf0e10cSrcweir          *  That must be checked before this method is called.
77cdf0e10cSrcweir          *
78cdf0e10cSrcweir          *  @param  nSize
79cdf0e10cSrcweir          *          the new size.
80cdf0e10cSrcweir          */
81cdf0e10cSrcweir         void impl_setSize(::sal_Int32 nSize);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         //---------------------------------------------------------------------
84cdf0e10cSrcweir         /** create a new item (means it's properties using a special schema using the
85cdf0e10cSrcweir          *  item id).
86cdf0e10cSrcweir          *
87cdf0e10cSrcweir          *  Note: This method does not check if creation was successfully.
88cdf0e10cSrcweir          *        Therefore exists more specialized method impl_existsItem()
89cdf0e10cSrcweir          *        and impl_existsItemAtPosition().
90cdf0e10cSrcweir          *
91cdf0e10cSrcweir          *  @param  nItem
92cdf0e10cSrcweir          *          id of the item
93cdf0e10cSrcweir          */
94cdf0e10cSrcweir         void impl_appendItem(::sal_Int32 nItem);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir         //---------------------------------------------------------------------
97*86e1cf34SPedro Giffuni         /** check if an entry for given item id really exists (in memory and xcu file).
98cdf0e10cSrcweir          *
99cdf0e10cSrcweir          *  @param  nItem
100cdf0e10cSrcweir          *          id of the item
101cdf0e10cSrcweir          *
102cdf0e10cSrcweir          *  @return true if item exists - false otherwise.
103cdf0e10cSrcweir          */
104cdf0e10cSrcweir         ::sal_Bool impl_existsItem(::sal_Int32 nItem);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         //---------------------------------------------------------------------
107*86e1cf34SPedro Giffuni         /** check if an entry for given item id really exists (in memory and xcu file).
108cdf0e10cSrcweir          *  Further it checks if the requested item is placed at the also specified
109cdf0e10cSrcweir          *  position inside history list.
110cdf0e10cSrcweir          *
111cdf0e10cSrcweir          *  @param  nItem
112cdf0e10cSrcweir          *          id of the item
113cdf0e10cSrcweir          *
114cdf0e10cSrcweir          *  @param  nIndex
115cdf0e10cSrcweir          *          expected position of item inside history list.
116cdf0e10cSrcweir          *
117cdf0e10cSrcweir          *  @return true if item exists at right position - false otherwise.
118cdf0e10cSrcweir          */
119cdf0e10cSrcweir         ::sal_Bool impl_existsItemAtIndex(::sal_Int32 nItem ,
120cdf0e10cSrcweir                                           ::sal_Int32 nIndex);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         //---------------------------------------------------------------------
123cdf0e10cSrcweir         /** create an URL suitable for the given item id.
124cdf0e10cSrcweir          *
125cdf0e10cSrcweir          *  @param  nItem
126cdf0e10cSrcweir          *          id of the item
127cdf0e10cSrcweir          *
128cdf0e10cSrcweir          *  @return the new created URL.
129cdf0e10cSrcweir          */
130cdf0e10cSrcweir         ::rtl::OUString impl_createItemURL(::sal_Int32 nItem);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         //---------------------------------------------------------------------
133cdf0e10cSrcweir         /** create a title suitable for the given item id.
134cdf0e10cSrcweir          *
135cdf0e10cSrcweir          *  @param  nItem
136cdf0e10cSrcweir          *          id of the item
137cdf0e10cSrcweir          *
138cdf0e10cSrcweir          *  @return the new created title.
139cdf0e10cSrcweir          */
140cdf0e10cSrcweir         ::rtl::OUString impl_createItemTitle(::sal_Int32 nItem);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         //---------------------------------------------------------------------
143cdf0e10cSrcweir         /** create a password suitable for the given item id.
144cdf0e10cSrcweir          *
145cdf0e10cSrcweir          *  @param  nItem
146cdf0e10cSrcweir          *          id of the item
147cdf0e10cSrcweir          *
148cdf0e10cSrcweir          *  @return the new created password.
149cdf0e10cSrcweir          */
150cdf0e10cSrcweir         ::rtl::OUString impl_createItemPassword(::sal_Int32 nItem);
151cdf0e10cSrcweir 
152cdf0e10cSrcweir         //---------------------------------------------------------------------
153cdf0e10cSrcweir         /** returns direct access to the item list inside histories.xcu
154cdf0e10cSrcweir          *  suitable for the current defined list type (m_eList).
155cdf0e10cSrcweir          *
156cdf0e10cSrcweir          *  @return reference to the item list configuration
157cdf0e10cSrcweir          */
158cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > impl_getItemList();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir         //---------------------------------------------------------------------
161cdf0e10cSrcweir         /** returns direct access to the order list inside histories.xcu
162cdf0e10cSrcweir          *  suitable for the current defined list type (m_eList).
163cdf0e10cSrcweir          *
164cdf0e10cSrcweir          *  @return reference to the order list configuration
165cdf0e10cSrcweir          */
166cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > impl_getOrderList();
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         //---------------------------------------------------------------------
169cdf0e10cSrcweir         /** returns direct access to the history list inside histories.xcu
170cdf0e10cSrcweir          *  suitable for the current defined list type (m_eList).
171cdf0e10cSrcweir          *
172cdf0e10cSrcweir          *  @return reference to the history list configuration
173cdf0e10cSrcweir          */
174cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > impl_getNewHistory();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         //---------------------------------------------------------------------
177cdf0e10cSrcweir         /** returns direct access to the history config inside common.xcu
178cdf0e10cSrcweir          *  suitable for the current defined list type (m_eList).
179cdf0e10cSrcweir          *
180cdf0e10cSrcweir          *  @return reference to the history configuration
181cdf0e10cSrcweir          */
182cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > impl_getOldHistory();
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     private:
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         // the config item which should be tested here
187cdf0e10cSrcweir         SvtHistoryOptions m_aConfigItem;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir         // defines the special list for testing (picklist, history or url list)
190cdf0e10cSrcweir         EHistoryType m_eList;
191cdf0e10cSrcweir 
192cdf0e10cSrcweir         // underlying configuration of the tested config items for cross over checks
193cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > m_xHistoriesXCU;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir         // underlying configuration of the tested config items for cross over checks
196cdf0e10cSrcweir         css::uno::Reference< css::container::XNameAccess > m_xCommonXCU;
197cdf0e10cSrcweir };
198cdf0e10cSrcweir 
199cdf0e10cSrcweir #endif // #ifndef  SVTOOLS_HISTORYOPTTEST_HXX
200