messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionInsertMedia.cpp
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2003-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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // InsertMedia
       
    17 // [Action Parameters]
       
    18 // None
       
    19 // [Action Description]
       
    20 // Resets the Message Server following a RemoveMedia test action.
       
    21 // If RemoveMedia has not been executed previously the action has no effect.
       
    22 // [APIs Used]
       
    23 // RMsvServerSession::SetFailure
       
    24 // __ACTION_INFO_END__
       
    25 // 
       
    26 //
       
    27 
       
    28 /**
       
    29  @file
       
    30 */
       
    31 
       
    32 
       
    33 #include "CMtfTestActionInsertMedia.h"
       
    34 #include "CMtfTestCase.h"
       
    35 #include "CMtfTestActionParameters.h"
       
    36 
       
    37 #include "MSVSERV.H"
       
    38 #include <msvapi.h>
       
    39 
       
    40 CMtfTestAction* CMtfTestActionInsertMedia::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    41 	{
       
    42 	CMtfTestActionInsertMedia* self = new (ELeave) CMtfTestActionInsertMedia(aTestCase);
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL(aActionParameters);
       
    45 	CleanupStack::Pop();
       
    46 	return self;
       
    47 	}
       
    48 	
       
    49 
       
    50 CMtfTestActionInsertMedia::CMtfTestActionInsertMedia(CMtfTestCase& aTestCase)
       
    51 	: CMtfSynchronousTestAction(aTestCase)
       
    52 	{
       
    53 	}
       
    54 
       
    55 
       
    56 CMtfTestActionInsertMedia::~CMtfTestActionInsertMedia()
       
    57 	{
       
    58 	}
       
    59 
       
    60 void CMtfTestActionInsertMedia::ExecuteActionL()
       
    61 	{
       
    62 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionInsertMedia);
       
    63 	RFs fs; 
       
    64 	RMsvServerSession server;
       
    65 	TFileName fsName;
       
    66 	
       
    67 	TInt drive = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0));
       
    68 
       
    69 	fs.Connect();
       
    70 	server.Connect(fs);
       
    71 
       
    72 	// This tells the server to pretend that its media is missing next time it gets a disk notification
       
    73 	server.SetFailure(EDiskFailure, EFalse);
       
    74 
       
    75 	// Generate a disk change notification
       
    76 	fs.FileSystemName(fsName, drive);
       
    77 	fs.MountFileSystem(fsName, drive);
       
    78 
       
    79 	// Close session
       
    80 	server.Close();
       
    81 	fs.Close();
       
    82 
       
    83 	User::After(100000); // wait a bit...
       
    84 	
       
    85 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionInsertMedia);
       
    86 	TestCase().ActionCompletedL(*this);
       
    87 	}
       
    88 
       
    89