|
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 // CopySelection |
|
17 // [Action Parameters] |
|
18 // Session <input>: Reference to the session. |
|
19 // Selection <input>: Reference to the selection. |
|
20 // TargetId <input>: Value of the target id. |
|
21 // [Action Description] |
|
22 // Copies the entry to the target. |
|
23 // [APIs Used] |
|
24 // CMsvEntry::SetEntryL |
|
25 // CMsvEntry::CopyL |
|
26 // __ACTION_INFO_END__ |
|
27 // |
|
28 // |
|
29 |
|
30 /** |
|
31 @file |
|
32 */ |
|
33 |
|
34 |
|
35 #include "CMtfTestActionCopySelection.h" |
|
36 #include "CMtfTestCase.h" |
|
37 #include "CMtfTestActionParameters.h" |
|
38 #include "MtfTestActionUtilsUser.h" |
|
39 |
|
40 |
|
41 CMtfTestAction* CMtfTestActionCopySelection::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
42 { |
|
43 CMtfTestActionCopySelection* self = new (ELeave) CMtfTestActionCopySelection(aTestCase); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(aActionParameters); |
|
46 CleanupStack::Pop(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 CMtfTestActionCopySelection::CMtfTestActionCopySelection(CMtfTestCase& aTestCase) |
|
52 : CMtfTestAction(aTestCase) |
|
53 { |
|
54 } |
|
55 |
|
56 |
|
57 CMtfTestActionCopySelection::~CMtfTestActionCopySelection() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 void CMtfTestActionCopySelection::ExecuteActionL() |
|
63 { |
|
64 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCopySelection); |
|
65 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
66 CMsvEntrySelection* paramSelection = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(1)); |
|
67 TMsvId paramTargetId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2)); |
|
68 |
|
69 TInt count = paramSelection->Count(); |
|
70 if (count == 0) |
|
71 User::Leave(KErrArgument); |
|
72 |
|
73 TMsvId entryId = (*paramSelection)[0]; |
|
74 |
|
75 CMsvEntry* entry = CMsvEntry::NewL(*paramSession,entryId,TMsvSelectionOrdering()); |
|
76 CleanupStack::PushL(entry); |
|
77 entry->SetEntryL(entryId); |
|
78 entry->SetEntryL(entry->Entry().Parent()); |
|
79 iOperation = entry->CopyL(*paramSelection,paramTargetId,iStatus); |
|
80 CleanupStack::PopAndDestroy(entry); |
|
81 CActiveScheduler::Add(this); |
|
82 SetActive(); |
|
83 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCopySelection); |
|
84 } |
|
85 |
|
86 |
|
87 void CMtfTestActionCopySelection::DoCancel() |
|
88 { |
|
89 iOperation->Cancel(); |
|
90 } |
|
91 |
|
92 |
|
93 void CMtfTestActionCopySelection::RunL() |
|
94 { |
|
95 TInt err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus); |
|
96 |
|
97 delete iOperation; |
|
98 |
|
99 User::LeaveIfError(err); |
|
100 |
|
101 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCopySelection); |
|
102 TestCase().ActionCompletedL(*this); |
|
103 } |
|
104 |