contentmgmt/referencedrmagent/tcaf/source/ManagerStep.cpp
branchRCL_3
changeset 95 641f389e9157
parent 53 030c4fbc13d7
child 96 a71299154b21
equal deleted inserted replaced
92:f18401adf8e1 95:641f389e9157
   878 	SetTestStepName(KCAFManagerAttributeStep);
   878 	SetTestStepName(KCAFManagerAttributeStep);
   879 	}
   879 	}
   880 
   880 
   881 TVerdict CCAFManagerAttributeStep::doTestStepL()
   881 TVerdict CCAFManagerAttributeStep::doTestStepL()
   882 	{
   882 	{
       
   883 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
   884     TBool wmdrmFlag = EFalse;     
       
   885     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
   886          
       
   887     if(wmdrmFlag)     
       
   888         {     
       
   889         TVerdict verdict = doWmdrmTestStepL();     
       
   890         return verdict;     
       
   891         }     
       
   892 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT    
       
   893 
   883 	TInt attribute;
   894 	TInt attribute;
   884 	TInt value = KErrNone;
   895 	TInt value = KErrNone;
   885 	TInt expectedValue;
   896 	TInt expectedValue;
   886 	TPtrC uri;
   897 	TPtrC uri;
   887 	TPtrC uniqueId;
   898 	TPtrC uniqueId;
   933 	SetTestStepName(KCAFManagerAttributeSetStep);
   944 	SetTestStepName(KCAFManagerAttributeSetStep);
   934 	}
   945 	}
   935 
   946 
   936 TVerdict CCAFManagerAttributeSetStep::doTestStepL()
   947 TVerdict CCAFManagerAttributeSetStep::doTestStepL()
   937 	{
   948 	{
       
   949 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
   950     TBool wmdrmFlag = EFalse;     
       
   951     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
   952          
       
   953     if(wmdrmFlag)     
       
   954         {     
       
   955         TVerdict verdict = doWmdrmTestStepL();     
       
   956         return verdict;     
       
   957         }     
       
   958 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT    
       
   959 
   938 	TInt value1;
   960 	TInt value1;
   939 	TInt value2;
   961 	TInt value2;
   940 	TInt expectedValue1;
   962 	TInt expectedValue1;
   941 	TInt expectedValue2;
   963 	TInt expectedValue2;
   942 	TInt attribute1;
   964 	TInt attribute1;
  1007 	SetTestStepName(KCAFManagerStringAttributeStep);
  1029 	SetTestStepName(KCAFManagerStringAttributeStep);
  1008 	}
  1030 	}
  1009 
  1031 
  1010 TVerdict CCAFManagerStringAttributeStep::doTestStepL()
  1032 TVerdict CCAFManagerStringAttributeStep::doTestStepL()
  1011 	{
  1033 	{
       
  1034 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
  1035     TBool wmdrmFlag = EFalse;     
       
  1036     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
  1037          
       
  1038     if(wmdrmFlag)     
       
  1039         {     
       
  1040         TVerdict verdict = doWmdrmTestStepL();     
       
  1041         return verdict;     
       
  1042         }     
       
  1043 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT        
       
  1044      
  1012 	TInt expectedResult;
  1045 	TInt expectedResult;
  1013 	TInt attribute;
  1046 	TInt attribute;
  1014 	TPtrC expectedValue;
  1047 	TPtrC expectedValue;
  1015 	TBuf <200> value;
  1048 	TBuf <200> value;
  1016 	TInt result = KErrNone;
  1049 	TInt result = KErrNone;
  1071 	SetTestStepName(KCAFManagerStringAttributeSetStep);
  1104 	SetTestStepName(KCAFManagerStringAttributeSetStep);
  1072 	}
  1105 	}
  1073 
  1106 
  1074 TVerdict CCAFManagerStringAttributeSetStep::doTestStepL()
  1107 TVerdict CCAFManagerStringAttributeSetStep::doTestStepL()
  1075 	{
  1108 	{
       
  1109 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
  1110     TBool wmdrmFlag = EFalse;     
       
  1111     GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);     
       
  1112          
       
  1113     if(wmdrmFlag)     
       
  1114         {     
       
  1115         TVerdict verdict = doWmdrmTestStepL();     
       
  1116         return verdict;     
       
  1117         }     
       
  1118 #endif  //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT     
       
  1119      
  1076 	TPtrC expectedValue1;
  1120 	TPtrC expectedValue1;
  1077 	TPtrC expectedValue2;
  1121 	TPtrC expectedValue2;
  1078 	TBuf <200> value1;
  1122 	TBuf <200> value1;
  1079 	TBuf <200> value2;
  1123 	TBuf <200> value2;
  1080 	TInt result1;
  1124 	TInt result1;
  1577     		
  1621     		
  1578 	__UHEAP_MARKEND;
  1622 	__UHEAP_MARKEND;
  1579 	return TestStepResult();
  1623 	return TestStepResult();
  1580 	}
  1624 	}
  1581 
  1625 
       
  1626 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
       
  1627       
       
  1628 // The following methods test the various manager attribute APIs for WMDRM content.     
       
  1629       
       
  1630 TVerdict CCAFManagerAttributeStep::doWmdrmTestStepL()     
       
  1631     {     
       
  1632     SetTestStepResult(EFail);     
       
  1633          
       
  1634     TInt attribVal;     
       
  1635     GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);     
       
  1636          
       
  1637     TInt expectedValue;     
       
  1638     GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);     
       
  1639       
       
  1640     __UHEAP_MARK;     
       
  1641          
       
  1642     TPtrC header;     
       
  1643     HBufC8* headerData = NULL;     
       
  1644          
       
  1645     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1646         {     
       
  1647         headerData = ConvertDes16toHBufC8LC(header);     
       
  1648         }     
       
  1649     else     
       
  1650         {     
       
  1651         headerData = CreateWmdrmHeaderLC();      
       
  1652         }     
       
  1653          
       
  1654     TInt value;     
       
  1655     CManager *manager = CManager::NewLC();     
       
  1656          
       
  1657     User::LeaveIfError(manager->GetAttribute(*headerData, attribVal, value));     
       
  1658     if(expectedValue == value)     
       
  1659         {     
       
  1660         SetTestStepResult(EPass);     
       
  1661         }     
       
  1662     else     
       
  1663         {     
       
  1664         INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);     
       
  1665         }     
       
  1666              
       
  1667     CleanupStack::PopAndDestroy(2, headerData);          
       
  1668                  
       
  1669     __UHEAP_MARKEND;     
       
  1670     return TestStepResult();     
       
  1671     }     
       
  1672          
       
  1673       
       
  1674 TVerdict CCAFManagerAttributeSetStep::doWmdrmTestStepL()     
       
  1675     {     
       
  1676     SetTestStepResult(EFail);     
       
  1677          
       
  1678     TInt attribute1;     
       
  1679     GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
       
  1680          
       
  1681     TInt attribute2;     
       
  1682     GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
       
  1683          
       
  1684     TInt expectedValue1;     
       
  1685     GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
       
  1686          
       
  1687     TInt expectedValue2;     
       
  1688     GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
       
  1689       
       
  1690 __UHEAP_MARK;     
       
  1691          
       
  1692     TPtrC header;     
       
  1693     HBufC8* headerData = NULL;     
       
  1694          
       
  1695     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1696         {     
       
  1697         headerData = ConvertDes16toHBufC8LC(header);     
       
  1698         }     
       
  1699     else     
       
  1700         {     
       
  1701         headerData = CreateWmdrmHeaderLC();      
       
  1702         }     
       
  1703                  
       
  1704     RAttributeSet attributeSet;     
       
  1705     CleanupClosePushL(attributeSet);     
       
  1706     attributeSet.AddL(attribute1);     
       
  1707     attributeSet.AddL(attribute2);     
       
  1708              
       
  1709     CManager *manager = CManager::NewLC();       
       
  1710     TInt result = manager->GetAttributeSet(*headerData, attributeSet);     
       
  1711     if(result == KErrNone)     
       
  1712         {     
       
  1713         SetTestStepResult(EPass);     
       
  1714         }     
       
  1715     else     
       
  1716         {     
       
  1717         INFO_PRINTF1(_L("CManager::GetAttributeSet() failed"));     
       
  1718         }     
       
  1719              
       
  1720     TInt value1;         
       
  1721     User::LeaveIfError(attributeSet.GetValue(attribute1, value1));     
       
  1722              
       
  1723     TInt value2;     
       
  1724     User::LeaveIfError(attributeSet.GetValue(attribute2, value2));     
       
  1725              
       
  1726     if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)     
       
  1727         {     
       
  1728         SetTestStepResult(EPass);     
       
  1729         }     
       
  1730     else     
       
  1731         {     
       
  1732         INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));     
       
  1733         }     
       
  1734              
       
  1735     CleanupStack::PopAndDestroy(3, headerData);          
       
  1736       
       
  1737 __UHEAP_MARKEND;     
       
  1738       
       
  1739     return TestStepResult();     
       
  1740     }     
       
  1741       
       
  1742       
       
  1743 TVerdict CCAFManagerStringAttributeStep::doWmdrmTestStepL()     
       
  1744     {     
       
  1745     SetTestStepResult(EFail);     
       
  1746          
       
  1747     TInt attribVal;     
       
  1748     GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);     
       
  1749          
       
  1750     TPtrC expectedValue;     
       
  1751     GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);     
       
  1752          
       
  1753     TInt expectedResult;     
       
  1754     GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);     
       
  1755       
       
  1756 __UHEAP_MARK;     
       
  1757          
       
  1758     TPtrC header;     
       
  1759     HBufC8* headerData = NULL;     
       
  1760          
       
  1761     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1762         {     
       
  1763         headerData = ConvertDes16toHBufC8LC(header);     
       
  1764         }     
       
  1765     else     
       
  1766         {     
       
  1767         headerData = CreateWmdrmHeaderLC();      
       
  1768         }     
       
  1769          
       
  1770     CManager* manager = CManager::NewLC();           
       
  1771     TBuf <200> value;     
       
  1772     TInt result = manager->GetStringAttribute(*headerData, attribVal, value);     
       
  1773     if(result == expectedResult && value == expectedValue)     
       
  1774         {     
       
  1775         SetTestStepResult(EPass);     
       
  1776         }     
       
  1777     else     
       
  1778         {     
       
  1779         INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);     
       
  1780         INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);     
       
  1781         }     
       
  1782              
       
  1783     CleanupStack::PopAndDestroy(2, headerData);          
       
  1784          
       
  1785 __UHEAP_MARKEND;     
       
  1786       
       
  1787     return TestStepResult();     
       
  1788     }     
       
  1789       
       
  1790       
       
  1791 TVerdict CCAFManagerStringAttributeSetStep::doWmdrmTestStepL()     
       
  1792     {     
       
  1793     SetTestStepResult(EFail);     
       
  1794       
       
  1795     TInt attribute1;         
       
  1796     GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);     
       
  1797          
       
  1798     TInt attribute2;     
       
  1799     GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);     
       
  1800          
       
  1801     TPtrC expectedValue1;     
       
  1802     GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);     
       
  1803          
       
  1804     TPtrC expectedValue2;     
       
  1805     GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);     
       
  1806          
       
  1807 __UHEAP_MARK;     
       
  1808          
       
  1809     TPtrC header;     
       
  1810     HBufC8* headerData = NULL;     
       
  1811          
       
  1812     if(GetStringFromConfig(ConfigSection(),_L("header"), header))     
       
  1813         {     
       
  1814         headerData = ConvertDes16toHBufC8LC(header);     
       
  1815         }     
       
  1816     else     
       
  1817         {     
       
  1818         headerData = CreateWmdrmHeaderLC();      
       
  1819         }     
       
  1820       
       
  1821     RStringAttributeSet attributeSet;     
       
  1822     CleanupClosePushL(attributeSet);     
       
  1823     attributeSet.AddL(attribute1);     
       
  1824     attributeSet.AddL(attribute2);     
       
  1825              
       
  1826     CManager* manager = CManager::NewLC();       
       
  1827     TInt result = manager->GetStringAttributeSet(*headerData, attributeSet);     
       
  1828     TBuf <200> value1;     
       
  1829     TBuf <200> value2;     
       
  1830     if(result == KErrNone)     
       
  1831         {     
       
  1832         TInt result3 = attributeSet.GetValue(attribute1, value1);     
       
  1833         TInt result4 = attributeSet.GetValue(attribute2, value2);     
       
  1834                  
       
  1835         if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2     
       
  1836          && result3 == KErrNone && result4 == KErrNone)     
       
  1837             {     
       
  1838             SetTestStepResult(EPass);     
       
  1839             }     
       
  1840         else     
       
  1841             {     
       
  1842             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);     
       
  1843             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);     
       
  1844             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);     
       
  1845             INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);      
       
  1846             }     
       
  1847             }     
       
  1848     else     
       
  1849         {     
       
  1850         INFO_PRINTF1(_L("CManager::GetStringAttributeSet() failed"));     
       
  1851         }        
       
  1852          
       
  1853     CleanupStack::PopAndDestroy(3, headerData);          
       
  1854       
       
  1855 __UHEAP_MARKEND;     
       
  1856       
       
  1857     return TestStepResult();     
       
  1858     }     
       
  1859       
       
  1860 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT