email/pop3andsmtpmtm/clientmtms/test/src/ctestimapsyncdownloadrules.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "ctestimapsyncdownloadrules.h"
       
    17 #include "cimapsyncdownloadrules.h"
       
    18 #include <cdbcols.h>
       
    19 
       
    20 /**
       
    21 Constructor
       
    22 */
       
    23 CTestImapSyncDownloadRules::CTestImapSyncDownloadRules()
       
    24 	{
       
    25 	}
       
    26 
       
    27 /**
       
    28 Destructor
       
    29 */
       
    30 CTestImapSyncDownloadRules::~CTestImapSyncDownloadRules()
       
    31 	{
       
    32 	delete iRules;
       
    33 	}
       
    34 
       
    35 /**
       
    36 Test setup
       
    37 */
       
    38 void CTestImapSyncDownloadRules::SetupL()
       
    39 	{
       
    40 	iRules = CImapSyncDownloadRules::NewL();
       
    41 	Reset();
       
    42 	}
       
    43 
       
    44 /**
       
    45 Reset member variables
       
    46 */
       
    47 void CTestImapSyncDownloadRules::Reset()
       
    48 	{
       
    49 	iBearerTypes = KCommDbBearerCSD;
       
    50 	iMailInfo.iTotalSizeLimit = KMaxTInt;
       
    51 	iMailInfo.iBodyTextSizeLimit = KMaxTInt;
       
    52 	iMailInfo.iAttachmentSizeLimit = KMaxTInt;
       
    53 	iMailInfo.iPartialMailOptions = ENoSizeLimits;
       
    54 	iMailInfo.iMaxEmailSize = KMaxTInt;
       
    55 	iMailInfo.iGetMailBodyParts = EGetImap4EmailHeaders;
       
    56 	iMailInfo.iDestinationFolder = 0;
       
    57 	}
       
    58 
       
    59 /**
       
    60 Test create empty rules list
       
    61 */
       
    62 void CTestImapSyncDownloadRules::TestCreateEmptyL()
       
    63 	{
       
    64 	INFO_PRINTF1(_L("TestCreateEmptyL - Start"));
       
    65 
       
    66 	ASSERT_FALSE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
    67 
       
    68 	CImapSyncDownloadRules* rules = CImapSyncDownloadRules::NewLC();
       
    69 	ASSERT_FALSE(rules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
    70 	CleanupStack::PopAndDestroy(rules);
       
    71 
       
    72 	INFO_PRINTF1(_L("TestCreateEmptyL - Complete"));
       
    73 	}
       
    74 
       
    75 /**
       
    76 Test adding new rules
       
    77 */
       
    78 void CTestImapSyncDownloadRules::TestAddRulesL()
       
    79 	{
       
    80 	INFO_PRINTF1(_L("TestAddRulesL - Start"));
       
    81 
       
    82 	iMailInfo.iBodyTextSizeLimit = 2;
       
    83 	iMailInfo.iAttachmentSizeLimit = 3;
       
    84 	iMailInfo.iPartialMailOptions = EBodyTextOnly;
       
    85 	iMailInfo.iMaxEmailSize = 4;
       
    86 	iMailInfo.iGetMailBodyParts = EGetImap4EmailBodyText;
       
    87 
       
    88 	iBearerTypes = KCommDbBearerWLAN;
       
    89 	iMailInfo.iTotalSizeLimit = 1;
       
    90 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
    91 
       
    92 	iBearerTypes = KCommDbBearerWcdma;
       
    93 	iMailInfo.iTotalSizeLimit = 100;
       
    94 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
    95 
       
    96 	iBearerTypes = KCommDbBearerLAN;
       
    97 	iMailInfo.iTotalSizeLimit = 200;
       
    98 	ASSERT_EQUALS(2, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 31, iBearerTypes, iMailInfo));
       
    99 
       
   100 	Reset();
       
   101 	ASSERT_TRUE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   102 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iBodyTextSizeLimit), 2);
       
   103 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iAttachmentSizeLimit), 3);
       
   104 	ASSERT_EQUALS(iMailInfo.iPartialMailOptions, EBodyTextOnly);
       
   105 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iMaxEmailSize), 4);
       
   106 	ASSERT_EQUALS(iMailInfo.iGetMailBodyParts, EGetImap4EmailBodyText);
       
   107 	ASSERT_EQUALS(iBearerTypes, static_cast<TUint32>(KCommDbBearerWcdma));
       
   108 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iTotalSizeLimit), 100);
       
   109 
       
   110 	Reset();
       
   111 	ASSERT_TRUE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   112 	ASSERT_EQUALS(iBearerTypes, static_cast<TUint32>(KCommDbBearerWLAN));
       
   113 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iTotalSizeLimit), 1);
       
   114 
       
   115 	Reset();
       
   116 	ASSERT_TRUE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 2, iBearerTypes, iMailInfo));
       
   117 	ASSERT_EQUALS(iBearerTypes, static_cast<TUint32>(KCommDbBearerLAN));
       
   118 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iTotalSizeLimit), 200);
       
   119 
       
   120 	iBearerTypes = KCommDbBearerLAN;
       
   121 	iMailInfo.iTotalSizeLimit = 200;
       
   122 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, iBearerTypes, iMailInfo));
       
   123 	Reset();
       
   124 
       
   125 	ASSERT_TRUE(iRules->GetRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, iBearerTypes, iMailInfo));
       
   126 	ASSERT_EQUALS(iBearerTypes, static_cast<TUint32>(KCommDbBearerLAN));
       
   127 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iTotalSizeLimit), 200);
       
   128 
       
   129 	INFO_PRINTF1(_L("TestAddRulesL - Complete"));
       
   130 	}
       
   131 
       
   132 /**
       
   133 Test passing invalid parameters to add rule routine
       
   134 */
       
   135 void CTestImapSyncDownloadRules::TestAddRuleInvalidArgumentL()
       
   136 	{
       
   137 	INFO_PRINTF1(_L("TestAddRuleInvalidArgumentL - Start"));
       
   138 
       
   139 #ifdef _DEBUG
       
   140 	INFO_PRINTF1(_L("Not tested on debug builds as it would panic"));
       
   141 #else //_DEBUG
       
   142 	TInt err = KErrNone;
       
   143 	TRAP(err, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, -1, iBearerTypes, iMailInfo));
       
   144 	ASSERT_EQUALS(err, KErrArgument);
       
   145 
       
   146 	err = KErrNone;
       
   147 	TRAP(err, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, KMaxImapSyncDownloadRules, iBearerTypes, iMailInfo));
       
   148 	ASSERT_EQUALS(err, KErrArgument);
       
   149 
       
   150 	iBearerTypes = 0;
       
   151 	err = KErrNone;
       
   152 	TRAP(err, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   153 	ASSERT_EQUALS(err, KErrArgument);
       
   154 #endif //_DEBUG
       
   155 
       
   156 	INFO_PRINTF1(_L("TestAddRuleInvalidArgumentL - Complete"));
       
   157 	}
       
   158 
       
   159 /**
       
   160 Test trying to add a rule with a bearer type that already exists
       
   161 */
       
   162 void CTestImapSyncDownloadRules::TestAddRuleBearerTypeAlreadyExistsL()
       
   163 	{
       
   164 	INFO_PRINTF1(_L("TestAddRuleBearerTypeAlreadyExistsL - Start"));
       
   165 
       
   166 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   167 	ASSERT_EQUALS(KErrAlreadyExists, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   168 
       
   169 	INFO_PRINTF1(_L("TestAddRuleBearerTypeAlreadyExistsL - Complete"));
       
   170 	}
       
   171 
       
   172 /**
       
   173 Test trying to add too many rules
       
   174 */
       
   175 void CTestImapSyncDownloadRules::TestAddRuleOverflowL()
       
   176 	{
       
   177 	INFO_PRINTF1(_L("TestAddRuleOverflowL - Start"));
       
   178 
       
   179 	iBearerTypes = 1;
       
   180 	for (TInt rule = 0; rule < KMaxImapSyncDownloadRules; ++rule)
       
   181 		{
       
   182 		ASSERT_EQUALS(rule, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, rule, iBearerTypes, iMailInfo));
       
   183 		iBearerTypes <<= 1;
       
   184 		}
       
   185 
       
   186 	iBearerTypes = 1;	
       
   187 	ASSERT_EQUALS(KErrOverflow, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   188 
       
   189 	INFO_PRINTF1(_L("TestAddRuleOverflowL - Complete"));
       
   190 	}
       
   191 
       
   192 /**
       
   193 Test rule deletion
       
   194 */
       
   195 void CTestImapSyncDownloadRules::TestDeleteRulesL()
       
   196 	{
       
   197 	INFO_PRINTF1(_L("TestDeleteRulesL - Start"));
       
   198 
       
   199 	iBearerTypes = KCommDbBearerPAN;
       
   200 	iMailInfo.iTotalSizeLimit = 1;
       
   201 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   202 
       
   203 	iBearerTypes = KCommDbBearerWcdma;
       
   204 	iMailInfo.iTotalSizeLimit = 100;
       
   205 	ASSERT_EQUALS(1, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   206 
       
   207 	iBearerTypes = KCommDbBearerLAN;
       
   208 	iMailInfo.iTotalSizeLimit = 200;
       
   209 	ASSERT_EQUALS(2, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 2, iBearerTypes, iMailInfo));
       
   210 
       
   211 	iBearerTypes = KCommDbBearerWLAN;
       
   212 	iMailInfo.iTotalSizeLimit = 300;
       
   213 	ASSERT_EQUALS(3, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 3, iBearerTypes, iMailInfo));
       
   214 
       
   215 	Reset();
       
   216 
       
   217 	ASSERT_TRUE(iRules->DeleteRuleL(CImapSyncDownloadRules::EInboxRulesType, 2));
       
   218 	ASSERT_TRUE(iRules->DeleteRuleL(CImapSyncDownloadRules::EInboxRulesType, 0));
       
   219 
       
   220 	ASSERT_TRUE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   221 	ASSERT_EQUALS(iBearerTypes, static_cast<TUint32>(KCommDbBearerWcdma));
       
   222 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iTotalSizeLimit), 100);
       
   223 
       
   224 	Reset();
       
   225 	ASSERT_TRUE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   226 	ASSERT_EQUALS(iBearerTypes, static_cast<TUint32>(KCommDbBearerWLAN));
       
   227 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iTotalSizeLimit), 300);
       
   228 
       
   229 	Reset();
       
   230 	ASSERT_FALSE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 2, iBearerTypes, iMailInfo));
       
   231 	ASSERT_FALSE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 3, iBearerTypes, iMailInfo));
       
   232 
       
   233 	INFO_PRINTF1(_L("TestDeleteRulesL - Complete"));
       
   234 	}
       
   235 
       
   236 /**
       
   237 Test passing invalid parameters to add delete routine
       
   238 */
       
   239 void CTestImapSyncDownloadRules::TestDeleteRuleInvalidArgumentL()
       
   240 	{
       
   241 	INFO_PRINTF1(_L("TestDeleteRuleInvalidArgumentL - Start"));
       
   242 
       
   243 #ifdef _DEBUG
       
   244 	INFO_PRINTF1(_L("Not tested on debug builds as it would panic"));
       
   245 #else //_DEBUG
       
   246 	TInt err = KErrNone;
       
   247 	TRAP(err, iRules->DeleteRuleL(CImapSyncDownloadRules::EInboxRulesType, -1));
       
   248 	ASSERT_EQUALS(err, KErrArgument);
       
   249 
       
   250 	err = KErrNone;
       
   251 	TRAP(err, iRules->DeleteRuleL(CImapSyncDownloadRules::EInboxRulesType, KMaxImapSyncDownloadRules));
       
   252 	ASSERT_EQUALS(err, KErrArgument);
       
   253 #endif //_DEBUG
       
   254 
       
   255 	INFO_PRINTF1(_L("TestDeleteRuleInvalidArgumentL - Complete"));
       
   256 	}
       
   257 
       
   258 /**
       
   259 Test deleting rules by bearer type
       
   260 */
       
   261 void CTestImapSyncDownloadRules::TestDeleteBearerTypesL()
       
   262 	{
       
   263 	INFO_PRINTF1(_L("TestDeleteBearerTypesL - Start"));
       
   264 
       
   265 	iBearerTypes = KCommDbBearerPAN | KCommDbBearerWcdma;
       
   266 	iMailInfo.iTotalSizeLimit = 1;
       
   267 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   268 
       
   269 	iBearerTypes = KCommDbBearerLAN;
       
   270 	iMailInfo.iTotalSizeLimit = 200;
       
   271 	ASSERT_EQUALS(1, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   272 
       
   273 	iBearerTypes = KCommDbBearerWLAN;
       
   274 	iMailInfo.iTotalSizeLimit = 300;
       
   275 	ASSERT_EQUALS(2, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 2, iBearerTypes, iMailInfo));
       
   276 
       
   277 	TBool ruleRemoved;
       
   278 
       
   279 	ASSERT_EQUALS(0, iRules->DeleteBearerTypesL(CImapSyncDownloadRules::EInboxRulesType, KCommDbBearerPAN, ruleRemoved));
       
   280 	ASSERT_FALSE(ruleRemoved);
       
   281 	ASSERT_EQUALS(1, iRules->DeleteBearerTypesL(CImapSyncDownloadRules::EInboxRulesType, KCommDbBearerLAN , ruleRemoved));
       
   282 	ASSERT_TRUE(ruleRemoved);
       
   283 	ASSERT_FALSE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 2, iBearerTypes, iMailInfo));
       
   284 	ASSERT_EQUALS(KErrNotFound, iRules->DeleteBearerTypesL(CImapSyncDownloadRules::EInboxRulesType, KCommDbBearerWcdma | KCommDbBearerWLAN, ruleRemoved));
       
   285 
       
   286 	INFO_PRINTF1(_L("TestDeleteBearerTypesL - Complete"));
       
   287 	}
       
   288 
       
   289 /**
       
   290 Test passing invalid parameters to delete bearer types routine
       
   291 */
       
   292 void CTestImapSyncDownloadRules::TestDeleteBearerTypesInvalidArgumentL()
       
   293 	{
       
   294 	INFO_PRINTF1(_L("TestDeleteBearerTypesInvalidArgumentL - Start"));
       
   295 
       
   296 #ifdef _DEBUG
       
   297 	INFO_PRINTF1(_L("Not tested on debug builds as it would panic"));
       
   298 #else //_DEBUG
       
   299 	iBearerTypes = 0;
       
   300 	TInt err = KErrNone;
       
   301 	TBool ruleRemoved;
       
   302 	TRAP(err, iRules->DeleteBearerTypesL(CImapSyncDownloadRules::EInboxRulesType, iBearerTypes, ruleRemoved));
       
   303 	ASSERT_EQUALS(err, KErrArgument);
       
   304 #endif //_DEBUG
       
   305 
       
   306 	INFO_PRINTF1(_L("TestDeleteBearerTypesInvalidArgumentL - Complete"));
       
   307 	}
       
   308 
       
   309 /**
       
   310 Test passing invalid parameters to get rule routine
       
   311 */
       
   312 void CTestImapSyncDownloadRules::TestGetRuleByPosInvalidArgumentL()
       
   313 	{
       
   314 	INFO_PRINTF1(_L("TestGetRuleByPosInvalidArgumentL - Start"));
       
   315 
       
   316 #ifdef _DEBUG
       
   317 	INFO_PRINTF1(_L("Not tested on debug builds as it would panic"));
       
   318 #else //_DEBUG
       
   319 	TInt err = KErrNone;
       
   320 	TRAP(err, iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, -1, iBearerTypes, iMailInfo));
       
   321 	ASSERT_EQUALS(err, KErrArgument);
       
   322 
       
   323 	err = KErrNone;
       
   324 	TRAP(err, iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, KMaxImapSyncDownloadRules, iBearerTypes, iMailInfo));
       
   325 	ASSERT_EQUALS(err, KErrArgument);
       
   326 #endif //_DEBUG
       
   327 
       
   328 	INFO_PRINTF1(_L("TestGetRuleByPosInvalidArgumentL - Complete"));
       
   329 	}
       
   330 
       
   331 /**
       
   332 Test getting rules for bearer types
       
   333 */
       
   334 void CTestImapSyncDownloadRules::TestGetRuleByBearerL()
       
   335 	{
       
   336 	INFO_PRINTF1(_L("TestGetRuleByBearerL - Start"));
       
   337 
       
   338 	iBearerTypes = KCommDbBearerPAN | KCommDbBearerWcdma;
       
   339 	iMailInfo.iTotalSizeLimit = 1;
       
   340 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   341 
       
   342 	iBearerTypes = KCommDbBearerLAN;
       
   343 	iMailInfo.iTotalSizeLimit = 200;
       
   344 	ASSERT_EQUALS(1, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   345 
       
   346 	iBearerTypes = KCommDbBearerWLAN;
       
   347 	iMailInfo.iTotalSizeLimit = 300;
       
   348 	ASSERT_EQUALS(2, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 2, iBearerTypes, iMailInfo));
       
   349 
       
   350 	iBearerTypes = KCommDbBearerPAN;
       
   351 	ASSERT_EQUALS(0, iRules->GetMailInfoL(CImapSyncDownloadRules::EInboxRulesType, iBearerTypes, iMailInfo));
       
   352 
       
   353 	iBearerTypes = KCommDbBearerPAN | KCommDbBearerWcdma;
       
   354 	ASSERT_EQUALS(0, iRules->GetMailInfoL(CImapSyncDownloadRules::EInboxRulesType, iBearerTypes, iMailInfo));
       
   355 
       
   356 	iBearerTypes = KCommDbBearerPAN | KCommDbBearerWLAN;
       
   357 	ASSERT_EQUALS(KErrNotFound, iRules->GetMailInfoL(CImapSyncDownloadRules::EInboxRulesType, iBearerTypes, iMailInfo));
       
   358 
       
   359 	iBearerTypes = KCommDbBearerWLAN;
       
   360 	ASSERT_EQUALS(2, iRules->GetMailInfoL(CImapSyncDownloadRules::EInboxRulesType, iBearerTypes, iMailInfo));
       
   361 
       
   362 	INFO_PRINTF1(_L("TestGetRuleByBearerL - Complete"));	
       
   363 	}
       
   364 
       
   365 /**
       
   366 Test passing invalid parameters to get rule routine
       
   367 */
       
   368 void CTestImapSyncDownloadRules::TestGetRuleByBearerInvalidArgumentL()
       
   369 	{
       
   370 	INFO_PRINTF1(_L("TestGetRuleByBearerInvalidArgumentL - Start"));
       
   371 
       
   372 #ifdef _DEBUG
       
   373 	INFO_PRINTF1(_L("Not tested on debug builds as it would panic"));
       
   374 #else //_DEBUG
       
   375 	iBearerTypes = 0;
       
   376 	TInt err = KErrNone;
       
   377 	TRAP(err, iRules->GetMailInfoL(CImapSyncDownloadRules::EInboxRulesType, iBearerTypes, iMailInfo));
       
   378 	ASSERT_EQUALS(err, KErrArgument);
       
   379 #endif //_DEBUG
       
   380 
       
   381 	INFO_PRINTF1(_L("TestGetRuleByBearerInvalidArgumentL - Complete"));
       
   382 	}
       
   383 
       
   384 /**
       
   385 Test class reset
       
   386 */
       
   387 void CTestImapSyncDownloadRules::TestResetL()
       
   388 	{
       
   389 	INFO_PRINTF1(_L("TestResetL - Start"));
       
   390 
       
   391 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   392 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, iBearerTypes, iMailInfo));
       
   393 
       
   394 	iRules->Reset();
       
   395 	ASSERT_FALSE(iRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   396 	ASSERT_FALSE(iRules->GetRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, iBearerTypes, iMailInfo));
       
   397 
       
   398 	INFO_PRINTF1(_L("TestResetL - Complete"));
       
   399 	}
       
   400 
       
   401 /**
       
   402 Test class copy
       
   403 */
       
   404 void CTestImapSyncDownloadRules::TestCopyL()
       
   405 	{
       
   406 	INFO_PRINTF1(_L("TestCopyL - Start"));
       
   407 
       
   408 	iMailInfo.iBodyTextSizeLimit = 1;
       
   409 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, iBearerTypes, iMailInfo));
       
   410 	iMailInfo.iAttachmentSizeLimit = 2;
       
   411 	ASSERT_EQUALS(0, iRules->AddRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, iBearerTypes, iMailInfo));
       
   412 
       
   413 	CImapSyncDownloadRules* newRules = iRules->CopyL();
       
   414 	CleanupStack::PushL(newRules);
       
   415 
       
   416 	TUint32 bearerTypes;
       
   417 	ASSERT_TRUE(newRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, bearerTypes, iMailInfo));
       
   418 	ASSERT_EQUALS(bearerTypes, iBearerTypes);
       
   419 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iBodyTextSizeLimit), 1);
       
   420 
       
   421 	ASSERT_FALSE(newRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 1, iBearerTypes, iMailInfo));
       
   422 
       
   423 	ASSERT_TRUE(newRules->GetRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, bearerTypes, iMailInfo));
       
   424 	ASSERT_EQUALS(bearerTypes, iBearerTypes);
       
   425 	ASSERT_EQUALS(static_cast<TInt>(iMailInfo.iAttachmentSizeLimit), 2);
       
   426 
       
   427 	ASSERT_FALSE(newRules->GetRuleL(CImapSyncDownloadRules::EFolderRulesType, 1, iBearerTypes, iMailInfo));
       
   428 
       
   429 	CleanupStack::PopAndDestroy(newRules);
       
   430 
       
   431 	newRules = iRules->CopyLC();
       
   432 	ASSERT_TRUE(newRules->GetRuleL(CImapSyncDownloadRules::EInboxRulesType, 0, bearerTypes, iMailInfo));
       
   433 	ASSERT_TRUE(newRules->GetRuleL(CImapSyncDownloadRules::EFolderRulesType, 0, bearerTypes, iMailInfo));
       
   434 	CleanupStack::PopAndDestroy(newRules);
       
   435 
       
   436 	INFO_PRINTF1(_L("TestCopyL - Complete"));
       
   437 	}
       
   438 
       
   439 CTestSuite* CTestImapSyncDownloadRules::CreateSuiteL(const TDesC& aName)
       
   440 	{
       
   441 	SUB_SUITE;
       
   442 	ADD_TEST_STEP(TestCreateEmptyL);
       
   443 	ADD_TEST_STEP(TestAddRulesL);
       
   444 	ADD_TEST_STEP(TestAddRuleInvalidArgumentL);
       
   445 	ADD_TEST_STEP(TestAddRuleBearerTypeAlreadyExistsL);
       
   446 	ADD_TEST_STEP(TestAddRuleOverflowL);
       
   447 	ADD_TEST_STEP(TestDeleteRulesL);
       
   448 	ADD_TEST_STEP(TestDeleteRuleInvalidArgumentL);
       
   449 	ADD_TEST_STEP(TestDeleteBearerTypesL);
       
   450 	ADD_TEST_STEP(TestDeleteBearerTypesInvalidArgumentL);
       
   451 	ADD_TEST_STEP(TestGetRuleByPosInvalidArgumentL);
       
   452 	ADD_TEST_STEP(TestGetRuleByBearerL);	
       
   453 	ADD_TEST_STEP(TestGetRuleByBearerInvalidArgumentL);
       
   454 	ADD_TEST_STEP(TestResetL);
       
   455 	ADD_TEST_STEP(TestCopyL);
       
   456 	END_SUITE;
       
   457 	}