applayerpluginsandutils/bookmarksupport/test/Integration/TestBookmarksSuite/TestUpdateVisitedStep.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2005-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 // Contains implementation of CTestUpdateVisitedStep class
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology 
       
    21 */
       
    22 
       
    23 // System Include
       
    24 #include <bookmarkdatabase.h>
       
    25 
       
    26 // User Include
       
    27 #include "TestUpdateVisitedStep.h"
       
    28 
       
    29 /**
       
    30 Constructor. Sets the test step name
       
    31 @internalTechnology
       
    32 @test
       
    33 */
       
    34 CTestUpdateVisitedStep::CTestUpdateVisitedStep(CTestBookmarksServer& aTestServer) : CTestBookmarksBaseStep(aTestServer)
       
    35 	{
       
    36 	//Call base class method to set human readable name for test step
       
    37 	SetTestStepName(KTestUpdateVisitedStep);
       
    38 	}
       
    39 
       
    40 
       
    41 /**
       
    42 Base class pure virtual.
       
    43 @internalTechnology
       
    44 @test
       
    45 @param		None
       
    46 @return		EPass or EFail indicating the result of the test step.
       
    47 */
       
    48 TVerdict CTestUpdateVisitedStep::doTestStepL()
       
    49 	{
       
    50 	TInt error = KErrNone;
       
    51 	RBkFolder parentFolder;
       
    52 	if ((error = GetParentFolder(KMainTestFolder(), parentFolder)) != KErrNone)
       
    53 		{
       
    54 		ERR_PRINTF3(_L("Error %D occured while opening parent folder %S"), error, &(KMainTestFolder()));
       
    55 		SetTestStepResult(EFail);
       
    56 		}
       
    57 	else
       
    58 		{
       
    59 		CleanupClosePushL(parentFolder);
       
    60 		RBkBookmark bookmark = iBkDb.CreateBookmarkL(&parentFolder);
       
    61 		CleanupClosePushL(bookmark);
       
    62 		DoTest(bookmark);
       
    63 		DoTest(bookmark);
       
    64 		iBkDb.DeleteItemL(bookmark.Id());
       
    65 		CleanupStack::PopAndDestroy(2, &parentFolder);
       
    66 		}
       
    67 	return TestStepResult();
       
    68 	}	// doTestStepL
       
    69 
       
    70 /**
       
    71 Tests UpdateVisited() API
       
    72 @internalTechnology
       
    73 @test
       
    74 @param		Reference to handle to the bookmark that is under test
       
    75 @return		None
       
    76 */
       
    77 void CTestUpdateVisitedStep::DoTest(RBkBookmark& aBookmark)
       
    78 	{
       
    79 	const TInt KOneSecond = 1000000;
       
    80 	TTime initialTime;
       
    81 	// Set the time to universal time
       
    82 	initialTime.UniversalTime();
       
    83 	INFO_PRINTF2(_L("Current time before updating = %Ld"), initialTime.Int64());
       
    84 	INFO_PRINTF1(_L("Updating LastVisited..."));
       
    85 
       
    86 	// Call updatevisited after one second
       
    87 	User::After(KOneSecond);
       
    88 	aBookmark.UpdateVisited();
       
    89 	TTime lastVisitedTime = aBookmark.LastVisited();
       
    90 	INFO_PRINTF2(_L("LastVisitedTime after updating = %Ld"), lastVisitedTime.Int64());
       
    91 
       
    92 	// Check whether last visited is greater than the initial time
       
    93 	if(lastVisitedTime <= initialTime)
       
    94 		{
       
    95 		INFO_PRINTF1(_L("LastVisited was not updated properly"));
       
    96 		SetTestStepResult(EFail);
       
    97 		}
       
    98 	else
       
    99 		{
       
   100 		INFO_PRINTF1(_L("LastVisited was updated properly"));
       
   101 		}
       
   102 	}	// DoTest
       
   103 
       
   104