|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "UT_CMusAvaCallEventMonitor.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 #include <EUnitMacros.h> |
|
24 |
|
25 // INTERNAL INCLUDES |
|
26 #include "musavacalleventmonitor.h" |
|
27 #include "musavacallmonitorobserver.h" |
|
28 #include "mussesseioninformationapi.h" |
|
29 |
|
30 |
|
31 // CONSTRUCTION |
|
32 UT_CMusAvaCallEventMonitor* UT_CMusAvaCallEventMonitor::NewL() |
|
33 { |
|
34 UT_CMusAvaCallEventMonitor* self = UT_CMusAvaCallEventMonitor::NewLC(); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 UT_CMusAvaCallEventMonitor* UT_CMusAvaCallEventMonitor::NewLC() |
|
40 { |
|
41 UT_CMusAvaCallEventMonitor* self = new( ELeave ) UT_CMusAvaCallEventMonitor(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // Destructor (virtual by CBase) |
|
48 UT_CMusAvaCallEventMonitor::~UT_CMusAvaCallEventMonitor() |
|
49 { |
|
50 } |
|
51 |
|
52 // Default constructor |
|
53 UT_CMusAvaCallEventMonitor::UT_CMusAvaCallEventMonitor() |
|
54 { |
|
55 } |
|
56 |
|
57 // Second phase construct |
|
58 void UT_CMusAvaCallEventMonitor::ConstructL() |
|
59 { |
|
60 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
61 // It generates the test case table. |
|
62 CEUnitTestSuiteClass::ConstructL(); |
|
63 } |
|
64 |
|
65 |
|
66 // METHODS |
|
67 |
|
68 |
|
69 void UT_CMusAvaCallEventMonitor::SetupL() |
|
70 { |
|
71 iObserver = CMusAvaCallMonitorObserverStub::NewL(); |
|
72 iCallEventMonitor = CMusAvaCallEventMonitor::NewL( *iObserver ); |
|
73 } |
|
74 |
|
75 void UT_CMusAvaCallEventMonitor::Teardown() |
|
76 { |
|
77 delete iObserver; |
|
78 iObserver = NULL; |
|
79 delete iCallEventMonitor; |
|
80 iCallEventMonitor = NULL; |
|
81 } |
|
82 |
|
83 void UT_CMusAvaCallEventMonitor::UT_CMusAvaCallEventMonitor_GetTelNumberLL() |
|
84 { |
|
85 // Test tel number |
|
86 _LIT( KTelNbr, "12345678" ); |
|
87 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
88 NMusSessionInformationApi::KMusTelNumber, |
|
89 KTelNbr ) ); |
|
90 |
|
91 TBuf<CMusAvaCallEventMonitor::KMusTelNumberMaxLength> telNumber; |
|
92 TBool isSipUri( ETrue ); |
|
93 |
|
94 iCallEventMonitor->GetTelNumberL( telNumber, isSipUri ); |
|
95 |
|
96 EUNIT_ASSERT( !isSipUri ); |
|
97 EUNIT_ASSERT_EQUALS( telNumber, KTelNbr ); |
|
98 |
|
99 |
|
100 // Test SIP URI |
|
101 _LIT( KSipUri, "sip:12345678@host" ); |
|
102 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
103 NMusSessionInformationApi::KMusTelNumber, |
|
104 KSipUri) ); |
|
105 iCallEventMonitor->GetTelNumberL( telNumber, isSipUri ); |
|
106 EUNIT_ASSERT( isSipUri ); |
|
107 EUNIT_ASSERT_EQUALS( telNumber, KSipUri ); |
|
108 |
|
109 |
|
110 #if 0 |
|
111 // This case can't be run since Unit tests use a stub of RProperty::Get |
|
112 // and the stub doesn't return KErrOverflow, but results USER 11 panic |
|
113 // if the value does not fit into given buffer. |
|
114 |
|
115 |
|
116 // Test with a SIP URI that is too long to fit into telNumber buffer |
|
117 _LIT( KLongSipUri, |
|
118 "sip:567890@domain.9012345678901234567890123456789012345678901234567890\ |
|
119 1234567890123456789012345678901" ); |
|
120 |
|
121 User::LeaveIfError( RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
122 NMusSessionInformationApi::KMusTelNumber, |
|
123 KLongSipUri) ); |
|
124 EUNIT_ASSERT_SPECIFIC_LEAVE( |
|
125 iCallEventMonitor->GetTelNumberL( telNumber, isSipUri ), KErrOverflow ); |
|
126 #endif |
|
127 } |
|
128 |
|
129 |
|
130 // TEST TABLE |
|
131 |
|
132 EUNIT_BEGIN_TEST_TABLE( |
|
133 UT_CMusAvaCallEventMonitor, |
|
134 "CMusAvaCallEventMonitor", |
|
135 "UNIT" ) |
|
136 |
|
137 EUNIT_TEST( |
|
138 "GetTelNumberL - test ", |
|
139 "CMusAvaCapability", |
|
140 "GetTelNumberL", |
|
141 "FUNCTIONALITY", |
|
142 SetupL, UT_CMusAvaCallEventMonitor_GetTelNumberLL, Teardown ) |
|
143 |
|
144 EUNIT_END_TEST_TABLE |
|
145 |
|
146 // END OF FILE |