CpSettingFormEntryItemData::CpSettingFormEntryItemData(HbDataForm *dataForm,
        const QString &text /*= QString()*/,
        const QString &description /*= QString()*/,
        const HbIcon &icon /*= HbIcon()*/,
        const HbDataFormModelItem *parent/* = 0*/) :
        CpSettingFormItemData(HbDataFormModelItem::CustomItemBase,QString(),parent),
        d_ptr(new CpSettingFormEntryItemDataPrivate(dataForm))
{
	setType ( static_cast<HbDataFormModelItem::DataItemType> (CpSettingFormEntryItemData::ListEntryItem) );
	
	d_ptr->init(this);
	
    setText(text);
    setDescription(description);
    setIcon(icon.iconName());
}
Esempio n. 2
0
/*!
     Test Case Description: \n
         Verify this class could create the corresponding CpSettingFormEntryItemData. \n
	 <b>Function 1:</b> \n
     1. Fucntion Name: \n &nbsp;&nbsp;
            explicit CpSettingFormEntryItemDataImpl(CpItemDataHelper &itemDataHelper,const QString &text = QString(), \n
                                                    const QString &description = QString(),const HbIcon &icon = HbIcon(), \n
                                                    const HbDataFormModelItem *parent = 0) \n
     2. Case Descrition: \n &nbsp;&nbsp;
            Test the first constructor function. \n
     3. Input Parameters: \n &nbsp;&nbsp;
            <1> itemDataHelper = CpItemDataHelper, text = Qstring(XX),description = Qstring(XX),
            	  icon = HbIcon(), parent = new HbDataFormModelItem() \n &nbsp;&nbsp;
            <2> itemDataHelper = CpItemDataHelper , text = Qstring(),
            	  description = Qstring(), icon = HbIcon(), parent = 0 \n
     4. Expected result: \n &nbsp;&nbsp;
            <1>  pdataimp != 0 \n &nbsp;&nbsp;
            <2> no crash  \n
    <b>Function 2:</b> \n
	 1. Fucntion Name: \n &nbsp;&nbsp;
        explicit CpSettingFormEntryItemDataImpl(HbDataForm *dataForm,const QString &text = QString(), \n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
        																				const QString &description = QString(),const HbIcon &icon = HbIcon(), \n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
        																				   const HbDataFormModelItem *parent = 0) \n 
     2.  Case Descrition: \n &nbsp;&nbsp;
         Test the second constructor function. \n
     3.  Input Parameters: \n &nbsp;&nbsp;
            <1> dataform = new HbDataForm(), text = Qstring(XX), description Qstring(XX), 
            	  icon = HbIcon(XX), parent = new HbDataFormModelItem(), \n &nbsp;&nbsp;
						<2> dataForm = 0, text = Qstring(), description Qstring(), icon = HbIcon(), parent = 0 \n
     4.  Expected result: \n &nbsp;&nbsp;
            pdata != 0 \n      
     <b>Function 3:</b> \n
	 1. Fucntion Name: \n &nbsp;&nbsp;
         explicit CpSettingFormEntryItemDataImpl(EntryItemType type,CpItemDataHelper &itemDataHelper, \n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
         																				 const QString &text = QString(),const QString &description = QString(), \n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
         																				 const QString &icon = QString(),const HbDataFormModelItem *parent = 0)  \n 
     2. Case Descrition: \n &nbsp;&nbsp;
         Test the third constructor function. \n
     3. Input Parameters: \n &nbsp;&nbsp;
            <1> type = HbDataFormModelItem::DataItemType,  itemDataHelper = CpItemDataHelper, \n &nbsp;&nbsp; &nbsp;&nbsp;
            	  text = QString(XX),  description = QString(XX),  icon = QString(XX), parent = new HbDataFormModelItem() \n &nbsp;&nbsp;
			<2> type = HbDataFormModelItem::DataItemType,  itemDataHelper = CpItemDataHelper default, \n &nbsp;&nbsp;
							  text = QString(),  description = QString(),  icon = QString(), parent = 0 \n
     4. Expected result: \n &nbsp;&nbsp;
            <1> pdataimp != 0, pdataimp->icon() != icon,\n &nbsp;&nbsp;
			<2> pdataimp != 0, pdataimp->icon() == 0, \n            
     <b>Function 4:</b> \n
	 1. Fucntion Name: \n &nbsp;&nbsp;
         explicit CpSettingFormEntryItemDataImpl(EntryItemType type,HbDataForm *dataForm,const QString &text = QString(),\n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
            																		 const QString &description = QString(),const QString &icon = QString(),\n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
            																		 const HbDataFormModelItem *parent = 0) \n
     2. Case Descrition: \n &nbsp;&nbsp;
         Test the forth constructor function. \n
     3. Input Parameters: \n &nbsp;&nbsp;
            <1> type = HbDataFormModelItem::DataItemType, dataform = new HbDataForm(),   \n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
            	  text = QString(XX),  description = QString(XX),  icon = QString(XX), parent = new HbDataFormModelItem() \n &nbsp;&nbsp;
            <2> type = HbDataFormModelItem::DataItemType,  dataform = 0, text = QString(),   \n &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
            		description = QString(),  icon = QString(), parent = 0 \n
     4. Expected result: \n &nbsp;&nbsp;
            <1> pdataimp != 0, pdataimp->icon() != icon,\n &nbsp;&nbsp;
			<2> pdataimp != 0, pdataimp->icon() == 0, \n   						    
*/
void TestCpAPI::testCpSettingFormEntryItemDataImpl()
{
    //Define the parameters for the constructors.
    QString strText = "testText";
    QString strDes = "testDescription";
    QString strIcon = "iconString";
    CpItemDataHelper *pHelper = new CpItemDataHelper();
    HbDataFormModelItem *aParent = new HbDataFormModelItem();
    HbIcon icon = HbIcon("icon");  
    HbDataForm *pDataform = new HbDataForm();
    CpSettingFormEntryItemData::EntryItemType EType1 = CpSettingFormEntryItemData::ListEntryItem;
    CpSettingFormEntryItemData::EntryItemType EType2 = CpSettingFormEntryItemData::ButtonEntryItem;
    // test the first constructor function.
    CpSettingFormEntryItemDataImpl<CpBaseSettingView> *pdataimp =
            new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( *pHelper, strText, strDes, icon, aParent ); // first constructor
    QVERIFY (pdataimp != 0);
    QVERIFY( pdataimp->text() == strText );
    QVERIFY( pdataimp->description()==strDes );
    QVERIFY( pdataimp->icon() == icon.iconName() );
    delete pdataimp;
    pdataimp = 0; 
    pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( *pHelper, QString(), QString(), icon, 0);
    QVERIFY (pdataimp != 0);
    delete pdataimp;
    pdataimp = 0; 
        
    pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>(0); // set parameter as "0"
    QVERIFY (pdataimp != 0);
    QVERIFY( pdataimp->text() == 0 );
    QVERIFY( pdataimp->description()==0 );
    delete pdataimp;
    pdataimp = 0;
    // test the second constructor function.
    pdataimp = new CpSettingFormEntryItemDataImpl <CpBaseSettingView> ( pDataform,strText, strDes, icon, aParent ); //second contructor
    QVERIFY( pdataimp->text() == strText );
    QVERIFY( pdataimp->description()==strDes );
    QVERIFY( pdataimp->icon() == icon.iconName() );
    delete pdataimp;
    pdataimp = 0;
    pdataimp = new CpSettingFormEntryItemDataImpl <CpBaseSettingView> ( 0, QString(), QString(), icon, 0 );
    QVERIFY (pdataimp != 0);
    delete pdataimp;
    pdataimp = 0; 
    // test the third constructor function.
    pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>( EType1,*pHelper, strText, strDes, strIcon, aParent );// the third constructor
    HbDataFormModelItem::DataItemType EdataItmeTypeTemp1 = pdataimp->type();
    QVERIFY (EdataItmeTypeTemp1 == EType1);
    QVERIFY( pdataimp->text() == strText );
    QVERIFY( pdataimp->description()==strDes );
    QVERIFY( pdataimp->icon() == strIcon );
    delete pdataimp;
    pdataimp = 0;    
    // test the forth constructor function.
    pdataimp = new CpSettingFormEntryItemDataImpl<CpBaseSettingView>(EType2,pDataform, strText, strDes, strIcon, aParent );// the fourth constructor
    CpSettingFormEntryItemData::DataItemType EdataItmeTypeTemp2 = pdataimp->type();
    QVERIFY (EdataItmeTypeTemp2 == EType2);
    QVERIFY( pdataimp->text() == strText );
    QVERIFY( pdataimp->description()==strDes );
    QVERIFY( pdataimp->icon() == strIcon );
    delete pdataimp;
    pdataimp = 0;
  
    delete pHelper;
    pHelper=0;
    delete pDataform;
    pDataform = 0;
}