--- a/mmsharing/mmshindicator/tsrc/ut_indicator/src/ut_cmusindicatorapi.cpp Thu Aug 19 09:51:39 2010 +0300
+++ b/mmsharing/mmshindicator/tsrc/ut_indicator/src/ut_cmusindicatorapi.cpp Tue Aug 31 15:12:07 2010 +0300
@@ -28,8 +28,134 @@
// Next row is to disable warning emerging from EUnit code.
#pragma warn_illtokenpasting off
+static TInt stubStatus = KErrNone;
+static TRequestStatus* rstatus = NULL;
+// ======== CAknGlobalMsgQuery stub ========
+
+
+CAknGlobalMsgQuery* CAknGlobalMsgQuery::NewL()
+ {
+ CAknGlobalMsgQuery* self = CAknGlobalMsgQuery::NewLC();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+
+CAknGlobalMsgQuery* CAknGlobalMsgQuery::NewLC()
+ {
+ CAknGlobalMsgQuery* self = new (ELeave) CAknGlobalMsgQuery();
+ CleanupStack::PushL( self );
+ return self;
+ }
+
+CAknGlobalMsgQuery::CAknGlobalMsgQuery()
+ {
+ }
+
+CAknGlobalMsgQuery::~CAknGlobalMsgQuery()
+ {
+ CancelMsgQuery();
+ iNotify.Close();
+ }
+
+void CAknGlobalMsgQuery::ShowMsgQueryL(
+ TRequestStatus& aStatus,
+ const TDesC& /*aMsgText*/,
+ TInt /*aSoftkeys*/,
+ const TDesC& /*HeaderText*/,
+ const TDesC& /*HeaderImageFile*/,
+ TInt /*aImageId*/,
+ TInt /*aImageMaskId*/,
+ CAknQueryDialog::TTone /*aTone*/)
+ {
+ if ( stubStatus == KErrNone )
+ {
+ aStatus = KRequestPending;
+ rstatus = &aStatus;
+ }
+ else
+ {
+ User::Leave( stubStatus );
+ }
+ }
+
+void CAknGlobalMsgQuery::CancelMsgQuery()
+ {
+ if ( rstatus )
+ {
+ User::RequestComplete( rstatus, KErrCancel );
+ rstatus = NULL;
+ }
+ }
+
+
+// ======== CAknGlobalConfirmationQuery stub ========
+
+CAknGlobalConfirmationQuery* CAknGlobalConfirmationQuery::NewL()
+ {
+ CAknGlobalConfirmationQuery* self = CAknGlobalConfirmationQuery::NewLC();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+
+CAknGlobalConfirmationQuery* CAknGlobalConfirmationQuery::NewLC()
+ {
+ CAknGlobalConfirmationQuery* self = new (ELeave) CAknGlobalConfirmationQuery();
+ CleanupStack::PushL( self );
+ return self;
+ }
+
+CAknGlobalConfirmationQuery::CAknGlobalConfirmationQuery()
+ {
+ }
+
+
+CAknGlobalConfirmationQuery::~CAknGlobalConfirmationQuery()
+ {
+ CancelConfirmationQuery();
+ iNotify.Close();
+ }
+
+
+
+
+void CAknGlobalConfirmationQuery::ShowConfirmationQueryL(
+ TRequestStatus& aStatus,
+ const TDesC& /*aPrompt*/,
+ TInt /*aSoftkeys*/,
+ TInt /*aAnimation*/,
+ const TDesC& /*aImageFile*/,
+ TInt /*aImageId*/,
+ TInt /*aImageMaskId*/,
+ CAknQueryDialog::TTone /*aTone*/,
+ TBool /*aDismissWithAllKeys*/ )
+
+ {
+ if ( stubStatus == KErrNone )
+ {
+ TRequestStatus* stat = &aStatus;
+ User::RequestComplete( stat, EAknSoftkeyYes );
+ // rstatus = &aStatus;
+ }
+ else
+ {
+ User::Leave( stubStatus );
+ }
+
+ }
+
+void CAknGlobalConfirmationQuery::CancelConfirmationQuery()
+ {
+ if ( rstatus )
+ {
+ User::RequestComplete( rstatus, KErrCancel );
+ rstatus = NULL;
+ }
+ }
+
// ======== MEMBER FUNCTIONS ========
@@ -78,6 +204,8 @@
void UT_CMusIndicatorApi::SetupL()
{
iIndicatorApi = CMusIndicatorApi::NewL( *this );
+ rstatus = NULL;
+ stubStatus = KErrNone;
iStartLiveSharingLCalled = EFalse;
}
@@ -89,6 +217,7 @@
void UT_CMusIndicatorApi::Teardown()
{
delete iIndicatorApi;
+ iIndicatorApi = NULL;
PropertyHelper::Close();
}
@@ -119,6 +248,19 @@
// ----------------------------------------------------------------------------
+// @TODO: Can this be tested without a dialog?
+// ----------------------------------------------------------------------------
+//
+void UT_CMusIndicatorApi::UT_CMusIndicatorApi_ConfirmationQueryLL()
+ {
+ TBool ret = iIndicatorApi->ConfirmationQueryL(
+ CMusIndicatorApi::EVsRoamingActivationQuery );
+
+ EUNIT_ASSERT( ret );
+ }
+
+
+// ----------------------------------------------------------------------------
// Dummy test. @TODO: Can this be tested?
// ----------------------------------------------------------------------------
//
@@ -134,16 +276,24 @@
//
void UT_CMusIndicatorApi::UT_CMusIndicatorApi_RunLL()
{
- User::LeaveIfError( RProperty::Define(
- KPSUidCoreApplicationUIs,
- KCoreAppUIsVideoSharingIndicator,
- RProperty::EInt,
- 0 ) );
+ /* NOTE: EUnit reports leak for this test due AVKON resource reservation,
+ * which is not released by AVKON at end of test. Resource reservation
+ * happend in contruction of indicator(dsa)
+ */
+ TRAPD( error, RProperty::Define(
+ KPSUidCoreApplicationUIs,
+ KCoreAppUIsVideoSharingIndicator,
+ RProperty::EInt,
+ 0 ) );
+ if ( error == KErrNoMemory ) User::Leave( error );
+ EUNIT_ASSERT ( error == KErrNone );
- User::LeaveIfError( RProperty::Set(
- KPSUidCoreApplicationUIs,
- KCoreAppUIsVideoSharingIndicator,
- ( TInt ) ECoreAppUIsVideoSharingIndicatorOn ) );
+ TRAP( error, RProperty::Set(
+ KPSUidCoreApplicationUIs,
+ KCoreAppUIsVideoSharingIndicator,
+ ( TInt ) ECoreAppUIsVideoSharingIndicatorOn ) );
+ if ( error == KErrNoMemory ) User::Leave( error );
+ EUNIT_ASSERT ( error == KErrNone );
iIndicatorApi->Cancel();
iIndicatorApi->iStatus = KErrNotFound;
@@ -153,18 +303,42 @@
iIndicatorApi->Cancel();
iIndicatorApi->iStatus = KErrNone;
iIndicatorApi->RunL();
- EUNIT_ASSERT( iStartLiveSharingLCalled );
+ EUNIT_ASSERT( iStartLiveSharingLCalled );
+ EUNIT_ASSERT( !iIndicatorApi->iQuery );
+
+ delete iIndicatorApi->iLiveSharingQueryTimeout;
+ iIndicatorApi->iLiveSharingQueryTimeout = NULL;
+ iIndicatorApi->iLiveSharingQueryTimeout =
+ CPeriodic::NewL( CActive::EPriorityStandard );
+
+ iIndicatorApi->RunL();
+ EUNIT_ASSERT( !iIndicatorApi->iLiveSharingQueryTimeout );
+ EUNIT_ASSERT( !iIndicatorApi->IsSubscriber() );
+
+ iIndicatorApi->iObserver = NULL;
+ EUNIT_ASSERT( iIndicatorApi->IsSubscriber() );
+ iIndicatorApi->Indicator( ETrue );
+
+ iIndicatorApi->Cancel();
+
+ iIndicatorApi->RunL();
+
+ TRequestStatus& status = iIndicatorApi->iStatus;
+ rstatus = &status;
+ //User::RequestComplete( rstatus, KErrCancel );
}
// ----------------------------------------------------------------------------
-// Asserts that DoCancel removes current activity.
+// Asserts that DoCancel removes current activity and deletes used resources.
// ----------------------------------------------------------------------------
//
void UT_CMusIndicatorApi::UT_CMusIndicatorApi_DoCancelL()
{
+ iIndicatorApi->ShowLiveSharingQueryL( EFalse );
iIndicatorApi->Cancel();
+ EUNIT_ASSERT( !iIndicatorApi->iQuery );
EUNIT_ASSERT( !iIndicatorApi->IsActive() );
}
@@ -207,6 +381,62 @@
}
+// ----------------------------------------------------------------------------
+// Asserts that a note text is generated.
+// ----------------------------------------------------------------------------
+//
+void UT_CMusIndicatorApi::UT_CMusIndicatorApi_NoteTextLCL()
+ {
+ HBufC* tmp = iIndicatorApi->NoteTextLC(
+ CMusIndicatorApi::EVsRoamingActivationQuery );
+ EUNIT_ASSERT( tmp );
+ EUNIT_ASSERT( tmp->Length() );
+ CleanupStack::PopAndDestroy();
+ }
+
+
+// ----------------------------------------------------------------------------
+// Asserts that method creates a query and calls CActive::SetActive.
+// ----------------------------------------------------------------------------
+//
+void UT_CMusIndicatorApi::UT_CMusIndicatorApi_ShowLiveSharingQueryLL()
+ {
+
+ iIndicatorApi->ShowLiveSharingQueryL( EFalse );
+ EUNIT_ASSERT( iIndicatorApi->iQuery );
+ EUNIT_ASSERT( iIndicatorApi->IsActive() );
+
+ iIndicatorApi->Cancel();
+ EUNIT_ASSERT( !iIndicatorApi->iQuery );
+ EUNIT_ASSERT( !iIndicatorApi->IsActive() );
+
+ stubStatus = KErrNotFound;
+ iIndicatorApi->ShowLiveSharingQueryL( EFalse );
+ EUNIT_ASSERT( !iIndicatorApi->iQuery );
+ EUNIT_ASSERT( !iIndicatorApi->IsActive() );
+
+
+ }
+
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+//
+void UT_CMusIndicatorApi::UT_CMusIndicatorApi_LiveSharingQueryTimeoutL()
+ {
+ iIndicatorApi->ShowLiveSharingQueryL( EFalse );
+ EUNIT_ASSERT( iIndicatorApi->iQuery );
+ EUNIT_ASSERT( iIndicatorApi->IsActive() );
+
+ EUNIT_ASSERT( CMusIndicatorApi::LiveSharingQueryTimeout( iIndicatorApi ) == KErrNone );
+
+ EUNIT_ASSERT( !iIndicatorApi->iQuery );
+ EUNIT_ASSERT( !iIndicatorApi->IsActive() );
+
+
+ }
+
+
+
// ======== EUNIT TEST TABLE ========
@@ -223,6 +453,13 @@
SetupL, UT_CMusIndicatorApi_NewLL, Teardown )
EUNIT_TEST(
+ "ConfirmationQueryL - test ",
+ "CMusIndicatorApi",
+ "ConfirmationQueryL",
+ "FUNCTIONALITY",
+ SetupL, UT_CMusIndicatorApi_ConfirmationQueryLL, Teardown )
+
+EUNIT_TEST(
"IndicateAvailabilityL - test ",
"CMusIndicatorApi",
"IndicateAvailabilityL",
@@ -264,6 +501,27 @@
"FUNCTIONALITY",
SetupL, UT_CMusIndicatorApi_PlayToneLL, Teardown )
+EUNIT_TEST(
+ "NoteTextLC - test ",
+ "CMusIndicatorApi",
+ "NoteTextLC",
+ "FUNCTIONALITY",
+ SetupL, UT_CMusIndicatorApi_NoteTextLCL, Teardown )
+
+EUNIT_TEST(
+ "ShowLiveSharingQueryL - test ",
+ "CMusIndicatorApi",
+ "ShowLiveSharingQueryL",
+ "FUNCTIONALITY",
+ SetupL, UT_CMusIndicatorApi_ShowLiveSharingQueryLL, Teardown )
+
+EUNIT_TEST(
+ "LiveSharingQueryTimeout - test ",
+ "CMusIndicatorApi",
+ "LiveSharingQueryTimeout",
+ "FUNCTIONALITY",
+ SetupL, UT_CMusIndicatorApi_LiveSharingQueryTimeoutL, Teardown )
+
EUNIT_END_TEST_TABLE