|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CGlxMedia unit tests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "t_cglxmedia.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/EUnitMacros.h> |
|
26 #include <digia/eunit/EUnitDecorators.h> |
|
27 |
|
28 #include <mpxattribute.h> |
|
29 #include <mpxmediageneraldefs.h> |
|
30 |
|
31 #include <glxmediageneraldefs.h> |
|
32 |
|
33 // INTERNAL INCLUDES |
|
34 #include "glxmedia.h" |
|
35 |
|
36 const TInt KMediaId = 1; |
|
37 |
|
38 _LIT(KMediaTitle, "Captured"); |
|
39 _LIT(KMediaSubTitle, "0 items"); |
|
40 |
|
41 // CONSTRUCTION |
|
42 T_CGlxMedia* T_CGlxMedia::NewL() |
|
43 { |
|
44 T_CGlxMedia* self = T_CGlxMedia::NewLC(); |
|
45 CleanupStack::Pop(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 T_CGlxMedia* T_CGlxMedia::NewLC() |
|
51 { |
|
52 T_CGlxMedia* self = new( ELeave ) T_CGlxMedia(); |
|
53 CleanupStack::PushL( self ); |
|
54 |
|
55 self->ConstructL(); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor (virtual by CBase) |
|
61 T_CGlxMedia::~T_CGlxMedia() |
|
62 { |
|
63 } |
|
64 |
|
65 // Default constructor |
|
66 T_CGlxMedia::T_CGlxMedia() |
|
67 { |
|
68 } |
|
69 |
|
70 // Second phase construct |
|
71 void T_CGlxMedia::ConstructL() |
|
72 { |
|
73 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
74 // It generates the test case table. |
|
75 CEUnitTestSuiteClass::ConstructL(); |
|
76 } |
|
77 |
|
78 // METHODS |
|
79 |
|
80 |
|
81 void T_CGlxMedia::SetupL( ) |
|
82 { |
|
83 iCGlxMedia = new (ELeave) CGlxMedia(TGlxMediaId(KMediaId));; |
|
84 iCGlxMedia->SetTextValueL(KMPXMediaGeneralTitle, KMediaTitle); |
|
85 iCGlxMedia->SetTextValueL(KMPXMediaGeneralSubTitle, KMediaSubTitle); |
|
86 iCGlxMedia->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
87 } |
|
88 |
|
89 void T_CGlxMedia::Teardown( ) |
|
90 { |
|
91 delete iCGlxMedia; |
|
92 iCGlxMedia = NULL; |
|
93 } |
|
94 |
|
95 void T_CGlxMedia::T_CGlxMedia_DeleteAttributeL( ) |
|
96 { |
|
97 // Delete non existing attribute |
|
98 EUNIT_PRINT(_L("Delete non existing attribute")); |
|
99 iCGlxMedia->DeleteAttribute(KMPXMediaGeneralThumbnail1); |
|
100 EUNIT_ASSERT_DESC(iCGlxMedia->Count() == 3, "3 attributes should remain"); |
|
101 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KMPXMediaGeneralTitle), "Title attribute should remain"); |
|
102 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KMPXMediaGeneralSubTitle), "Subtitle attribute should remain"); |
|
103 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KGlxMediaGeneralSystemItem), "System item attribute should remain"); |
|
104 |
|
105 // Delete existing attribute |
|
106 EUNIT_PRINT(_L("Delete existing attribute")); |
|
107 iCGlxMedia->DeleteAttribute(KMPXMediaGeneralSubTitle); |
|
108 EUNIT_ASSERT_DESC(iCGlxMedia->Count() == 2, "2 attributes should remain"); |
|
109 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KMPXMediaGeneralTitle), "Title attribute should remain"); |
|
110 EUNIT_ASSERT_DESC(!iCGlxMedia->IsSupported(KMPXMediaGeneralSubTitle), "Subtitle attribute shouldn't remain"); |
|
111 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KGlxMediaGeneralSystemItem), "System item attribute should remain"); |
|
112 } |
|
113 |
|
114 void T_CGlxMedia::T_CGlxMedia_DeleteAttribute2_SubTest1L( ) |
|
115 { |
|
116 #ifdef _DEBUG |
|
117 // Delete index less than 0 |
|
118 EUNIT_PRINT(_L("Delete index less than 0")); |
|
119 EUNIT_ASSERT_PANIC_DESC(iCGlxMedia->DeleteAttribute(-1), "Images & videos", EGlxPanicIllegalArgument, "Incorrect panic"); |
|
120 #endif // _DEBUG |
|
121 } |
|
122 |
|
123 void T_CGlxMedia::T_CGlxMedia_DeleteAttribute2_SubTest2L( ) |
|
124 { |
|
125 #ifdef _DEBUG |
|
126 // Delete index greater than number of attributes |
|
127 EUNIT_PRINT(_L("Delete index greater than number of attributes")); |
|
128 EUNIT_ASSERT_PANIC_DESC(iCGlxMedia->DeleteAttribute(3), "Images & videos", EGlxPanicIllegalArgument, "Incorrect panic"); |
|
129 #endif // _DEBUG |
|
130 } |
|
131 |
|
132 void T_CGlxMedia::T_CGlxMedia_DeleteAttribute2_SubTest3L( ) |
|
133 { |
|
134 // Delete existing attribute |
|
135 EUNIT_PRINT(_L("Delete existing attribute")); |
|
136 iCGlxMedia->DeleteAttribute(2); |
|
137 EUNIT_ASSERT_DESC(iCGlxMedia->Count() == 2, "2 attributes should remain"); |
|
138 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KMPXMediaGeneralTitle), "Title attribute should remain"); |
|
139 EUNIT_ASSERT_DESC(iCGlxMedia->IsSupported(KMPXMediaGeneralSubTitle), "Subtitle attribute should remain"); |
|
140 EUNIT_ASSERT_DESC(!iCGlxMedia->IsSupported(KGlxMediaGeneralSystemItem), "System item attribute shouldn't remain"); |
|
141 } |
|
142 |
|
143 |
|
144 // TEST TABLE |
|
145 EUNIT_BEGIN_TEST_TABLE( |
|
146 T_CGlxMedia, |
|
147 "Add test suite description here.", |
|
148 "UNIT" ) |
|
149 |
|
150 EUNIT_TEST( |
|
151 "DeleteAttribute - test1", |
|
152 "CGlxMedia", |
|
153 "DeleteAttribute - test1", |
|
154 "FUNCTIONALITY", |
|
155 SetupL, T_CGlxMedia_DeleteAttributeL, Teardown) |
|
156 |
|
157 EUNIT_TEST( |
|
158 "DeleteAttribute2 - test2, subtest1", |
|
159 "CGlxMedia", |
|
160 "DeleteAttribute2 - test2, subtest1", |
|
161 "FUNCTIONALITY", |
|
162 SetupL, T_CGlxMedia_DeleteAttribute2_SubTest1L, Teardown) |
|
163 |
|
164 EUNIT_TEST( |
|
165 "DeleteAttribute2 - test2, subtest2", |
|
166 "CGlxMedia", |
|
167 "DeleteAttribute2 - test2, subtest2", |
|
168 "FUNCTIONALITY", |
|
169 SetupL, T_CGlxMedia_DeleteAttribute2_SubTest2L, Teardown) |
|
170 |
|
171 EUNIT_TEST( |
|
172 "DeleteAttribute2 - test2, subtest3", |
|
173 "CGlxMedia", |
|
174 "DeleteAttribute2 - test2, subtest3", |
|
175 "FUNCTIONALITY", |
|
176 SetupL, T_CGlxMedia_DeleteAttribute2_SubTest3L, Teardown) |
|
177 |
|
178 |
|
179 EUNIT_END_TEST_TABLE |
|
180 |
|
181 // END OF FILE |