phonebookengines/contactsmodel/tsrc/t_IccImportLock.cpp
changeset 24 0ba2181d7c28
parent 0 e686773b3f54
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 /*
     2 // All rights reserved.
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 // This component and the accompanying materials are made available
     3 * All rights reserved.
     4 // under the terms of "Eclipse Public License v1.0"
     4 * This component and the accompanying materials are made available
     5 // which accompanies this distribution, and is available
     5 * under the terms of "Eclipse Public License v1.0"
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 * which accompanies this distribution, and is available
     7 //
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 // Initial Contributors:
     8 *
     9 // Nokia Corporation - initial contribution.
     9 * Initial Contributors:
    10 //
    10 * Nokia Corporation - initial contribution.
    11 // Contributors:
    11 *
    12 //
    12 * Contributors:
    13 // Description:
    13 *
    14 //
    14 * Description: 
    15 
    15 *
    16 
    16 */
    17 // System includes
    17 
    18 #include <cntdb.h>
    18 #include <cntdb.h>
    19 #include <cntdef.h>
    19 #include <cntdef.h>
    20 #include <cntitem.h>
    20 #include <cntitem.h>
    21 #include <cntfield.h>
    21 #include <cntfield.h>
    22 #include <cntfldst.h>
    22 #include <cntfldst.h>
    27 #include <e32test.h>
    27 #include <e32test.h>
    28 #include <cntdbobs.h>
    28 #include <cntdbobs.h>
    29 #include <e32math.h>
    29 #include <e32math.h>
    30 
    30 
    31 // User includes
    31 // User includes
    32 #include "T_UTILS.H"
    32 #include "t_utils.h"
    33 #include "t_utils2.h"
    33 #include "t_utils2.h"
    34 
    34 
    35 // Constant
    35 // Constant
    36 _LIT(KDatabaseFileName, "c:INC016848.cdb");
    36 _LIT(KDatabaseFileName, "c:INC016848.cdb");
    37 
    37 
    49 
    49 
    50 
    50 
    51 static RTest					TheTest(_L("INC016848 - DB stressing - Group insert"));
    51 static RTest					TheTest(_L("INC016848 - DB stressing - Group insert"));
    52 static RFs						TheFs;
    52 static RFs						TheFs;
    53 
    53 
    54 //
    54 ///////////////////////////////////////////////////////////////////////////////
    55 /* CTestActiveScheduler                                                      */
    55 /* CTestActiveScheduler                                                      */
    56 //  This class has been nicked from the t_currentdb.h / .cpp files
    56 //  This class has been nicked from the t_currentdb.h / .cpp files
    57 class CTestActiveScheduler : public CActiveScheduler
    57 class CTestActiveScheduler : public CActiveScheduler
    58 	{
    58 	{
    59 	public:
    59 	public:
    73 		CContactDatabase::DeleteDatabaseL(KDatabaseFileName);
    73 		CContactDatabase::DeleteDatabaseL(KDatabaseFileName);
    74 		}
    74 		}
    75 	}
    75 	}
    76 
    76 
    77 
    77 
    78 //
    78 ///////////////////////////////////////////////////////////////////////////////
    79 /* CConcurrentDatabaseAccessBase - Specification                             */
    79 /* CConcurrentDatabaseAccessBase - Specification                             */
    80 // Forms the base class for both threads.
    80 // Forms the base class for both threads.
    81 class CConcurrentDatabaseAccessBase : public CBase
    81 class CConcurrentDatabaseAccessBase : public CBase
    82 	{
    82 	{
    83 	public:
    83 	public:
   121 		TBool					iSemaphoreOpen;
   121 		TBool					iSemaphoreOpen;
   122 		HBufC*					iDatabaseName;
   122 		HBufC*					iDatabaseName;
   123 		CTestRegister* 			iFileRegister;
   123 		CTestRegister* 			iFileRegister;
   124 	};
   124 	};
   125 
   125 
   126 //
   126 ///////////////////////////////////////////////////////////////////////////////
   127 /* CConcurrentDatabaseAccessBase - Implementation                            */
   127 /* CConcurrentDatabaseAccessBase - Implementation                            */
   128 CConcurrentDatabaseAccessBase::CConcurrentDatabaseAccessBase()
   128 CConcurrentDatabaseAccessBase::CConcurrentDatabaseAccessBase()
   129 	{
   129 	{
   130 	}
   130 	}
   131 
   131 
   297 	event.Set(TRawEvent::EButton1Up,xCentre+aDx*xEnd,yEnd);
   297 	event.Set(TRawEvent::EButton1Up,xCentre+aDx*xEnd,yEnd);
   298 	UserSvr::AddEvent(event);
   298 	UserSvr::AddEvent(event);
   299 	}
   299 	}
   300 
   300 
   301 
   301 
   302 //
   302 ///////////////////////////////////////////////////////////////////////////////
   303 /* CConcurrentDatabaseInserter - Specification                               */
   303 /* CConcurrentDatabaseInserter - Specification                               */
   304 // This class is the inserter thread. It's thread function should insert
   304 // This class is the inserter thread. It's thread function should insert
   305 // contacts into the database using the t_utils CRandomContactGenerator class
   305 // contacts into the database using the t_utils CRandomContactGenerator class
   306 class CConcurrentDatabaseInserter : public CConcurrentDatabaseAccessBase
   306 class CConcurrentDatabaseInserter : public CConcurrentDatabaseAccessBase
   307 	{
   307 	{
   319 		void	RunTestImplementationL();
   319 		void	RunTestImplementationL();
   320 
   320 
   321 	private:
   321 	private:
   322 	};
   322 	};
   323 
   323 
   324 //
   324 ///////////////////////////////////////////////////////////////////////////////
   325 /* CConcurrentDatabaseInserter - Implementation                              */
   325 /* CConcurrentDatabaseInserter - Implementation                              */
   326 
   326 
   327 CConcurrentDatabaseInserter* CConcurrentDatabaseInserter::NewLC(const TDesC& aFilename)
   327 CConcurrentDatabaseInserter* CConcurrentDatabaseInserter::NewLC(const TDesC& aFilename)
   328 	{
   328 	{
   329 	CConcurrentDatabaseInserter* self = NULL;
   329 	CConcurrentDatabaseInserter* self = NULL;
   433 	CloseSemaphore();
   433 	CloseSemaphore();
   434 	CloseLogFile();
   434 	CloseLogFile();
   435 	CloseTest();
   435 	CloseTest();
   436 	}
   436 	}
   437 
   437 
   438 //
   438 ///////////////////////////////////////////////////////////////////////////////
   439 /* CConcurrentDBGroupInserter                                               */
   439 /* CConcurrentDBGroupInserter                                               */
   440 class CConcurrentDBGroupInserter : public CConcurrentDatabaseAccessBase
   440 class CConcurrentDBGroupInserter : public CConcurrentDatabaseAccessBase
   441 	{
   441 	{
   442 	public:
   442 	public:
   443 		CConcurrentDBGroupInserter();
   443 		CConcurrentDBGroupInserter();
   586 	SyncronizeSignal();
   586 	SyncronizeSignal();
   587 	CloseSemaphore();
   587 	CloseSemaphore();
   588 	CloseTest();
   588 	CloseTest();
   589 	}
   589 	}
   590 
   590 
   591 //
   591 ///////////////////////////////////////////////////////////////////////////////
   592 /* Test Function Prototypes                                                  */
   592 /* Test Function Prototypes                                                  */
   593 //
   593 ///////////////////////////////////////////////////////////////////////////////
   594 void CreateTestDatabaseL(const TDesC& aFilename );
   594 void CreateTestDatabaseL(const TDesC& aFilename );
   595 void TestL();
   595 void TestL();
   596 void doMainL();
   596 void doMainL();
   597 
   597 
   598 //
   598 ///////////////////////////////////////////////////////////////////////////////
   599 /* Test Function Implementations                                             */
   599 /* Test Function Implementations                                             */
   600 //
   600 ///////////////////////////////////////////////////////////////////////////////
   601 void CreateTestDatabaseL(const TDesC& aFilename )
   601 void CreateTestDatabaseL(const TDesC& aFilename )
   602 	{
   602 	{
   603 	CContactDatabase* database = NULL;
   603 	CContactDatabase* database = NULL;
   604 
   604 
   605 	database = CContactDatabase::ReplaceL(aFilename);
   605 	database = CContactDatabase::ReplaceL(aFilename);
   639 	CleanupStack::PopAndDestroy( groupInserter );
   639 	CleanupStack::PopAndDestroy( groupInserter );
   640 
   640 
   641 	}
   641 	}
   642 
   642 
   643 
   643 
   644 //
   644 ////////////////////////////////////////////////////////////////////////////////////
   645 // -------> Static global functions (source)
   645 // -------> Static global functions (source)
   646 //
   646 ////////////////////////////////////////////////////////////////////////////////////
   647 void doMainL()
   647 void doMainL()
   648 	{
   648 	{
   649 	User::LeaveIfError( TheFs.Connect() );
   649 	User::LeaveIfError( TheFs.Connect() );
   650 	CleanupClosePushL(TheFs);
   650 	CleanupClosePushL(TheFs);
   651 
   651