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 #include "UserOptTest.hxx"
25
26 namespace css = ::com::sun::star;
27
28 //=============================================================================
29 static const ::rtl::OUString MESSAGE_SETCOMPANY_FAILED = ::rtl::OUString::createFromAscii("set company failed") ;
30 static const ::rtl::OUString MESSAGE_SETFIRSTNAME_FAILED = ::rtl::OUString::createFromAscii("set firstname failed") ;
31 static const ::rtl::OUString MESSAGE_SETLASTNAME_FAILED = ::rtl::OUString::createFromAscii("set lastname failed") ;
32 static const ::rtl::OUString MESSAGE_SETID_FAILED = ::rtl::OUString::createFromAscii("set ID failed") ;
33 static const ::rtl::OUString MESSAGE_SETSTREET_FAILED = ::rtl::OUString::createFromAscii("set street failed") ;
34 static const ::rtl::OUString MESSAGE_SETCITY_FAILED = ::rtl::OUString::createFromAscii("set city failed") ;
35 static const ::rtl::OUString MESSAGE_SETSTATE_FAILED = ::rtl::OUString::createFromAscii("set state failed") ;
36 static const ::rtl::OUString MESSAGE_SETZIP_FAILED = ::rtl::OUString::createFromAscii("set zip failed") ;
37 static const ::rtl::OUString MESSAGE_SETCOUNTRY_FAILED = ::rtl::OUString::createFromAscii("set country failed") ;
38 static const ::rtl::OUString MESSAGE_SETPOSITION_FAILED = ::rtl::OUString::createFromAscii("set position failed") ;
39 static const ::rtl::OUString MESSAGE_SETTITLE_FAILED = ::rtl::OUString::createFromAscii("set title failed") ;
40 static const ::rtl::OUString MESSAGE_SETTELEPHONEHOME_FAILED = ::rtl::OUString::createFromAscii("set telephonehome failed") ;
41 static const ::rtl::OUString MESSAGE_SETTELEPHONEWORK_FAILED = ::rtl::OUString::createFromAscii("set telephonework failed") ;
42 static const ::rtl::OUString MESSAGE_SETFAX_FAILED = ::rtl::OUString::createFromAscii("set fax failed") ;
43 static const ::rtl::OUString MESSAGE_SETEMAIL_FAILED = ::rtl::OUString::createFromAscii("set email failed") ;
44 static const ::rtl::OUString MESSAGE_SETCUSTOMERNUMBER_FAILED = ::rtl::OUString::createFromAscii("set customernumber failed");
45 static const ::rtl::OUString MESSAGE_SETFATHERSNAME_FAILED = ::rtl::OUString::createFromAscii("set fathersname failed") ;
46 static const ::rtl::OUString MESSAGE_SETAPARTMENT_FAILED = ::rtl::OUString::createFromAscii("set apartment failed") ;
47
48 //=============================================================================
49
50
UserOptTest()51 UserOptTest::UserOptTest()
52 :m_aConfigItem()
53 ,m_xCfg()
54 {
55 }
56
~UserOptTest()57 UserOptTest::~UserOptTest()
58 {
59 }
60
impl_checkUserData()61 void UserOptTest::impl_checkUserData()
62 {
63 impl_checkSetCompany( ::rtl::OUString() );
64 impl_checkSetFirstName( ::rtl::OUString() );
65 impl_checkSetLastName( ::rtl::OUString() );
66 impl_checkSetID( ::rtl::OUString() );
67 impl_checkSetStreet( ::rtl::OUString() );
68 impl_checkSetCity( ::rtl::OUString() );
69 impl_checkSetState( ::rtl::OUString() );
70 impl_checkSetZip( ::rtl::OUString() );
71 impl_checkSetCountry( ::rtl::OUString() );
72 impl_checkSetPosition( ::rtl::OUString() );
73 impl_checkSetTitle( ::rtl::OUString() );
74 impl_checkSetTelephoneHome( ::rtl::OUString() );
75 impl_checkSetTelephoneWork( ::rtl::OUString() );
76 impl_checkSetFax( ::rtl::OUString() );
77 impl_checkSetEmail( ::rtl::OUString() );
78 //impl_checkSetCustomerNumber( ::rtl::OUString() );
79 impl_checkSetFathersName( ::rtl::OUString() );
80 impl_checkSetApartment( ::rtl::OUString() );
81
82 impl_checkSetCompany( ::rtl::OUString::createFromAscii("RedFlag2000") );
83 impl_checkSetFirstName( ::rtl::OUString::createFromAscii("Yan") );
84 impl_checkSetLastName( ::rtl::OUString::createFromAscii("Wu") );
85 impl_checkSetID( ::rtl::OUString::createFromAscii("wuy") );
86 impl_checkSetStreet( ::rtl::OUString::createFromAscii("SouthFifthRing") );
87 impl_checkSetCity( ::rtl::OUString::createFromAscii("Beijing") );
88 impl_checkSetState( ::rtl::OUString::createFromAscii("Beijing") );
89 impl_checkSetZip( ::rtl::OUString::createFromAscii("100176") );
90 impl_checkSetCountry( ::rtl::OUString::createFromAscii("China") );
91 impl_checkSetPosition( ::rtl::OUString::createFromAscii("Engineer") );
92 impl_checkSetTitle( ::rtl::OUString::createFromAscii("Software Engineer") );
93 impl_checkSetTelephoneHome( ::rtl::OUString::createFromAscii("010-51570010") );
94 impl_checkSetTelephoneWork( ::rtl::OUString::createFromAscii("010-51570010") );
95 impl_checkSetFax( ::rtl::OUString::createFromAscii("010-51570010") );
96 impl_checkSetEmail( ::rtl::OUString::createFromAscii("wuy@redflag2000.cn") );
97 //impl_checkSetCustomerNumber( ::rtl::OUString::createFromAscii("87654321") );
98 impl_checkSetFathersName( ::rtl::OUString::createFromAscii("father") );
99 impl_checkSetApartment( ::rtl::OUString::createFromAscii("apartment") );
100 }
101
impl_checkSetCompany(const::rtl::OUString & sUserData)102 void UserOptTest::impl_checkSetCompany( const ::rtl::OUString& sUserData )
103 {
104 m_aConfigItem.SetCompany( sUserData );
105
106 ::rtl::OUString sCheck = m_aConfigItem.GetCompany();
107 if ( sCheck != sUserData )
108 throw css::uno::Exception(MESSAGE_SETCOMPANY_FAILED, 0);
109 }
110
impl_checkSetFirstName(const::rtl::OUString & sUserData)111 void UserOptTest::impl_checkSetFirstName( const ::rtl::OUString& sUserData )
112 {
113 m_aConfigItem.SetFirstName( sUserData );
114
115 ::rtl::OUString sCheck = m_aConfigItem.GetFirstName();
116 if ( sCheck != sUserData )
117 throw css::uno::Exception(MESSAGE_SETFIRSTNAME_FAILED, 0);
118 }
119
impl_checkSetLastName(const::rtl::OUString & sUserData)120 void UserOptTest::impl_checkSetLastName( const ::rtl::OUString& sUserData )
121 {
122 m_aConfigItem.SetLastName( sUserData );
123
124 ::rtl::OUString sCheck = m_aConfigItem.GetLastName();
125 if ( sCheck != sUserData )
126 throw css::uno::Exception(MESSAGE_SETLASTNAME_FAILED, 0);
127 }
128
impl_checkSetID(const::rtl::OUString & sUserData)129 void UserOptTest::impl_checkSetID( const ::rtl::OUString& sUserData )
130 {
131 m_aConfigItem.SetID( sUserData );
132
133 ::rtl::OUString sCheck = m_aConfigItem.GetID();
134 if ( sCheck != sUserData )
135 throw css::uno::Exception(MESSAGE_SETID_FAILED, 0);
136 }
137
impl_checkSetStreet(const::rtl::OUString & sUserData)138 void UserOptTest::impl_checkSetStreet( const ::rtl::OUString& sUserData )
139 {
140 m_aConfigItem.SetStreet( sUserData );
141
142 ::rtl::OUString sCheck = m_aConfigItem.GetStreet();
143 if ( sCheck != sUserData )
144 throw css::uno::Exception(MESSAGE_SETSTREET_FAILED, 0);
145 }
146
impl_checkSetCity(const::rtl::OUString & sUserData)147 void UserOptTest::impl_checkSetCity( const ::rtl::OUString& sUserData )
148 {
149 m_aConfigItem.SetCity( sUserData );
150
151 ::rtl::OUString sCheck = m_aConfigItem.GetCity();
152 if ( sCheck != sUserData )
153 throw css::uno::Exception(MESSAGE_SETCITY_FAILED, 0);
154 }
155
impl_checkSetState(const::rtl::OUString & sUserData)156 void UserOptTest::impl_checkSetState( const ::rtl::OUString& sUserData )
157 {
158 m_aConfigItem.SetState( sUserData );
159
160 ::rtl::OUString sCheck = m_aConfigItem.GetState();
161 if ( sCheck != sUserData )
162 throw css::uno::Exception(MESSAGE_SETSTATE_FAILED, 0);
163 }
164
impl_checkSetZip(const::rtl::OUString & sUserData)165 void UserOptTest::impl_checkSetZip( const ::rtl::OUString& sUserData )
166 {
167 m_aConfigItem.SetZip( sUserData );
168
169 ::rtl::OUString sCheck = m_aConfigItem.GetZip();
170 if ( sCheck != sUserData )
171 throw css::uno::Exception(MESSAGE_SETZIP_FAILED, 0);
172 }
173
impl_checkSetCountry(const::rtl::OUString & sUserData)174 void UserOptTest::impl_checkSetCountry( const ::rtl::OUString& sUserData )
175 {
176 m_aConfigItem.SetCountry( sUserData );
177
178 ::rtl::OUString sCheck = m_aConfigItem.GetCountry();
179 if ( sCheck != sUserData )
180 throw css::uno::Exception(MESSAGE_SETCOUNTRY_FAILED, 0);
181 }
182
impl_checkSetPosition(const::rtl::OUString & sUserData)183 void UserOptTest::impl_checkSetPosition( const ::rtl::OUString& sUserData )
184 {
185 m_aConfigItem.SetPosition( sUserData );
186
187 ::rtl::OUString sCheck = m_aConfigItem.GetPosition();
188 if ( sCheck != sUserData )
189 throw css::uno::Exception(MESSAGE_SETPOSITION_FAILED, 0);
190 }
191
impl_checkSetTitle(const::rtl::OUString & sUserData)192 void UserOptTest::impl_checkSetTitle( const ::rtl::OUString& sUserData )
193 {
194 m_aConfigItem.SetTitle( sUserData );
195
196 ::rtl::OUString sCheck = m_aConfigItem.GetTitle();
197 if ( sCheck != sUserData )
198 throw css::uno::Exception(MESSAGE_SETTITLE_FAILED, 0);
199 }
200
impl_checkSetTelephoneHome(const::rtl::OUString & sUserData)201 void UserOptTest::impl_checkSetTelephoneHome( const ::rtl::OUString& sUserData )
202 {
203 m_aConfigItem.SetTelephoneHome( sUserData );
204
205 ::rtl::OUString sCheck = m_aConfigItem.GetTelephoneHome();
206 if ( sCheck != sUserData )
207 throw css::uno::Exception(MESSAGE_SETTELEPHONEHOME_FAILED, 0);
208 }
209
impl_checkSetTelephoneWork(const::rtl::OUString & sUserData)210 void UserOptTest::impl_checkSetTelephoneWork( const ::rtl::OUString& sUserData )
211 {
212 m_aConfigItem.SetTelephoneWork( sUserData );
213
214 ::rtl::OUString sCheck = m_aConfigItem.GetTelephoneWork();
215 if ( sCheck != sUserData )
216 throw css::uno::Exception(MESSAGE_SETTELEPHONEWORK_FAILED, 0);
217 }
218
impl_checkSetFax(const::rtl::OUString & sUserData)219 void UserOptTest::impl_checkSetFax( const ::rtl::OUString& sUserData )
220 {
221 m_aConfigItem.SetFax( sUserData );
222
223 ::rtl::OUString sCheck = m_aConfigItem.GetFax();
224 if ( sCheck != sUserData )
225 throw css::uno::Exception(MESSAGE_SETFAX_FAILED, 0);
226 }
227
impl_checkSetEmail(const::rtl::OUString & sUserData)228 void UserOptTest::impl_checkSetEmail( const ::rtl::OUString& sUserData )
229 {
230 m_aConfigItem.SetEmail( sUserData );
231
232 ::rtl::OUString sCheck = m_aConfigItem.GetEmail();
233 if ( sCheck != sUserData )
234 throw css::uno::Exception(MESSAGE_SETEMAIL_FAILED, 0);
235 }
236
impl_checkSetCustomerNumber(const::rtl::OUString & sUserData)237 void UserOptTest::impl_checkSetCustomerNumber( const ::rtl::OUString& sUserData )
238 {
239 m_aConfigItem.SetCustomerNumber( sUserData );
240
241 ::rtl::OUString sCheck = m_aConfigItem.GetCustomerNumber();
242 if ( sCheck != sUserData )
243 throw css::uno::Exception(MESSAGE_SETCUSTOMERNUMBER_FAILED, 0);
244 }
245
impl_checkSetFathersName(const::rtl::OUString & sUserData)246 void UserOptTest::impl_checkSetFathersName( const ::rtl::OUString& sUserData )
247 {
248 m_aConfigItem.SetFathersName( sUserData );
249
250 ::rtl::OUString sCheck = m_aConfigItem.GetFathersName();
251 if ( sCheck != sUserData )
252 throw css::uno::Exception(MESSAGE_SETFATHERSNAME_FAILED, 0);
253 }
254
impl_checkSetApartment(const::rtl::OUString & sUserData)255 void UserOptTest::impl_checkSetApartment( const ::rtl::OUString& sUserData )
256 {
257 m_aConfigItem.SetApartment( sUserData );
258
259 ::rtl::OUString sCheck = m_aConfigItem.GetApartment();
260 if ( sCheck != sUserData )
261 throw css::uno::Exception(MESSAGE_SETAPARTMENT_FAILED, 0);
262 }
263