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