コード例 #1
0
/**
 On entering new state performs certain operations
*/
void CTestStepVidPlayerARN0701::OnStateEntry()
	{
	TInt err = KErrNone;
	switch(iCurrentState)
		{
	case EStart: //to begin, open the video
		TRAP(err,iPlayer->OpenFileL(iFileName));
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iPlayer->OpenFileL(iFileName):%d"),err);
			FailTest();
			}
		break;
		
	case EVideoOpen: //prepare video
		iVideoOpen = ETrue;
		iPlayer->Prepare();
		break;
		
		//register for audio notification on Video; open audio stream-B
	case EVideoPrepare:
		err = iPlayer->RegisterAudioResourceNotification(*iVidClientArnCallback,KMMFEventCategoryAudioResourceAvailable);
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error:iPlayer->RegisterAudioResourceNotification():%d"),err);
			FailTest();
			break;
			}
		iAudStreamB->Open(NULL);
		break;
		
	case EVideoRegisterAudBOpen:
		iPlayer->Play(); //play video
		err = iPlayer->CancelRegisterAudioResourceNotification(KMMFEventCategoryAudioResourceAvailable);
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error:iPlayer->CancelRegisterAudioResourceNotification():%d"),err);
			FailTest();
			break;	
			}
		TRAP(err,iAudStreamB->WriteL(iBuffer));//start high priority audio	
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iAudStreamB->WriteL(iBuffer):%d"),err);
			FailTest();
			}
		iTestSimulationComplete = ETrue;
		break;
		
	case EVideoInterrupted:
		break;
		
	case EFailureOnNotification:
		iPlayer->Close();
		FailTest();
		break;
		}	
	}
コード例 #2
0
/**
 On entering new state performs certain operations
*/
void CTestStepVidPlayerARN0700::OnStateEntry()
	{
	TInt err = KErrNone;
	switch(iCurrentState)
		{
	case EStart: //to begin, open the video
		TRAP(err,iPlayer->OpenFileL(iFileName));
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iPlayer->OpenFileL(iFileName):%d"),err);
			FailTest();
			}
		break;
		
	case EVideoOpen: //prepare video
		iVideoOpen = ETrue;
		iPlayer->Prepare();
		break;
		
		//register for audio notification on Video; open audio stream-B
	case EVideoPrepare:
		err = iPlayer->RegisterAudioResourceNotification(*iVidClientArnCallback,KMMFEventCategoryAudioResourceAvailable);
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error:iPlayer->RegisterAudioResourceNotification():%d"),err);
			FailTest();
			break;
			}
		iPlayer->Play(); //play video
		iAudStreamB->Open(NULL);
		break;
		
	case EVideoPlayingAudBOpen:	
		TRAP(err,iAudStreamB->WriteL(iBuffer));//start high priority audio	
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iAudStreamB->WriteL(iBuffer):%d"),err);
			FailTest();		
			}
		break;
	
	case EVideoInterrupted: //do nothing on state entry
		break;
		
	case ETestEnd:
		iTestStepResult = EPass;
		iPlayer->Close();
		INFO_PRINTF1(_L("Video:Got audio resource notification"));
		CActiveScheduler::Stop();
		break;
		}
	}
コード例 #3
0
/**
 On entering new state performs certain operations
*/
void CTestStepVidPlayerARN0703::OnStateEntry()
	{
	TInt err = KErrNone;
	switch(iCurrentState)
		{
	case EStart: //to begin, open the video
		TRAP(err,iPlayer->OpenFileL(iFileName));
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iPlayer->OpenFileL(iFileName):%d"),err);
			FailTest();
			}
		break;
		
	case EVideoOpen: //prepare video
		iPlayer->Prepare();
		break;
		
		//register for audio notification on Video; open audio stream-B
	case EVideoPrepare:
		TInt err = iPlayer->RegisterAudioResourceNotification(*iVidClientArnCallback,KMMFEventCategoryAudioResourceAvailable);
		if(err == KErrArgument)
			{
			iTestStepResult = EPass;
			INFO_PRINTF1(_L("iPlayer->RegisterAudioResourceNotification() - returned - KErrArgument"));	
			}
		iPlayer->Close();
		CActiveScheduler::Stop();
		break;
		}
	}
コード例 #4
0
TEST(SubroutineAsserts, Test) {
	Foo(3);

	if (HasFatalFailure())
		return FailTest();

	ASSERT_TRUE(false);
}
コード例 #5
0
void Foo(int number) {
	Bar();

	if (::testing::Test::HasFatalFailure())
		return FailTest();

	ASSERT_TRUE(number != 3);
}
コード例 #6
0
void CTestStepVidPlayerARN0700::EndTest()
	{
	if(iVideoOpen)
		{
		//no need of iVideoOpen = ETrue;there won't be further callbacks.
		iPlayer->Close();
		}
	FailTest();
	}
コード例 #7
0
ファイル: FIL_Vista_File.c プロジェクト: KoraST/ft_BIU-1
static VBoolean WriteString (FILE *f, const char *str)
{
    const char *cp;
    int ch;

    /* Test for the presence of funny characters in the string value: */
    for (cp = str; (ch = *cp) != 0; cp++)
	if (! isalnum (ch) && ch != '.' && ch != '-' && ch != '+' && ch != '_')
	    break;

    /* If funny characters are present, output the string in quotes: */
    if (ch) {
	FailTest (fputc ('"', f));
	for (cp = (char *) str; (ch = *cp) != 0; cp++)
	    switch (ch) {

	    case '\n':
		FailTest (fputs ("\\n\\\n", f));
		break;

	    case '"':
		FailTest (fputs ("\\\"", f));
		break;

	    default:
		FailTest (fputc (ch, f));
	    }
	FailTest (fputc ('"', f));
    } else FailTest (fputs (str, f));
    return TRUE;

Fail:
    VWarning ("VWriteFile: Write to stream failed");
    return FALSE;
}
コード例 #8
0
/**
Takes input from the clients with the event and error. Calls  AnalyseInput(). 
If new state is entered, it calls OnStateEntry().
@param	aClient
		a client which gives transition input
@param	aEvent
		event from the client
@param	aError
		error associated with the event		
 */				
void CTestStepVidPlayerARN::Fsm(TClient aClient, TTestEvent aEvent, TInt aError)
	{
	TInt result = AnalyseInput(aClient,aEvent,aError);
	if(result == -1) //unexpected event/error - hence end test with fail
		{
		FailTest();
		return;		
		}	
	if(result == 1) //if moved to new state
		{
		OnStateEntry();
		}	
	}
コード例 #9
0
ファイル: FIL_Vista_File.c プロジェクト: KoraST/ft_BIU-1
static VBoolean WriteAttrList (FILE *f, VAttrList list, int indent, VList *data_list, long *offset)
{
    VAttrListPosn posn;
    int i;

    /* Write the { marking the beginning of the attribute list: */
    FailTest (fputs ("{\n", f));

    /* Write each attribute in the list: */
    for (VFirstAttr (list, & posn); VAttrExists (& posn); VNextAttr (& posn))
	if (! WriteAttr (f, & posn, indent, data_list, offset))
	    return FALSE;

    /* Write the } marking the end of the attribute list: */
    for (i = indent - 1; i > 0; i--)
	FailTest (fputc ('\t', f));
    FailTest (fputc ('}', f));
    return TRUE;

Fail:
    VWarning ("VWriteFile: Write to stream failed");
    return FALSE;
}
コード例 #10
0
ファイル: extkey_tests.cpp プロジェクト: MOIN/moin
#include <boost/assign/list_of.hpp>

// test_shadow --log_level=all  --run_test=bip32_tests,extkey_tests

namespace ba = boost::assign;

class FailTest
{
public:
    FailTest(std::string _sTest, int _rv) : sTest(_sTest), rv(_rv) {};
    std::string sTest;
    int rv;
};

FailTest failTests[] = {
    FailTest("", 3),
    FailTest("  ", 4),
    FailTest("abcd", 4),
    FailTest("M/3h/1111111111111111111111", 5),
    FailTest("0/8/0/0", 6),
    FailTest("/1/1", 7),
    FailTest("0/1/1/", 7),
    FailTest("0/1//1", 7),
    FailTest("m/2147483648h", 8),
    FailTest("m/4294967296", 5),
    FailTest("m/4294967297", 5),
    FailTest("0b0012", 4),
    FailTest("0x3Dg", 4),
    FailTest("m/4294967296", 5),
};
コード例 #11
0
/**
 On entering new state performs certain operations
*/
void CTestStepVidPlayerARN0702::OnStateEntry()
	{
	TInt err = KErrNone;
	switch(iCurrentState)
		{
	case EStart: //to begin, open the video
		TRAP(err,iPlayer->OpenFileL(iFileName));
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iPlayer->OpenFileL(iFileName):%d"),err);
			FailTest();
			}
		break;
		
	case EVideoOpen: //prepare video
		iVideoOpen = ETrue;
		iPlayer->Prepare();
		break;
		
		//register for audio notification on Video; open audio stream-B
	case EVideoPrepare:
		//open the audio streams and register for audio resource notification
		iAudStreamA->Open(NULL);
		err = iAudStreamA->RegisterAudioResourceNotification(*iAudClientAArnCallback,KMMFEventCategoryAudioResourceAvailable);
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error:iAudStreamA->RegisterAudioResourceNotification():%d"),err);
			FailTest();
			break;
			}
		iAudStreamB->Open(NULL);
		err = iAudStreamB->RegisterAudioResourceNotification(*iAudClientBArnCallback,KMMFEventCategoryAudioResourceAvailable);
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error: iAudStreamB->RegisterAudioResourceNotification():%d"),err);
			FailTest();
			break;
			}
		break;
		
	case EAudABOpenRegister:
		//start playing video; then start Audio streams A and B
		iPlayer->Play(); //start video play	
		TRAP(err,iAudStreamA->WriteL(iBuffer)) //start low priority audio
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iAudStreamA->WriteL(iBuffer):%d"),err);
			FailTest();
			break;	
			}
		TRAP(err,iAudStreamB->WriteL(iBuffer));//start high priority audio
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Leave error:iAudStreamB->WriteL(iBuffer):%d"),err);		
			FailTest();
			break;
			}
		break;
		
		
	case EVideoAudAThrownoff:
		err = iPlayer->RegisterAudioResourceNotification(*iVidClientArnCallback,KMMFEventCategoryAudioResourceAvailable);
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error:iPlayer->RegisterAudioResourceNotification():%d"),err);		
			FailTest();
			}
		break;
		
	case EVideoNotified:
		err = iPlayer->WillResumePlay();
		if(err != KErrNone)
			{
			INFO_PRINTF2(_L("Error:WillResumePlay():%d"),err);
			FailTest();	
			}
		break;
		
	case EFailureOnAudioANotification:
		iPlayer->Close();
		INFO_PRINTF1(_L("Audio stream-A got notification"));
		FailTest();
		break;
		}	
	}
コード例 #12
0
ファイル: FIL_Vista_File.c プロジェクト: KoraST/ft_BIU-1
VBoolean VWriteFile (FILE *f, VAttrList list)
{
    DataBlock *db;
    VBundle b;
    VTypeMethods *methods;
    VRepnKind repn;
    VPointer value, ptr;
    VBoolean result, free_it;
    VList data_list;

    /* Write the FIL_Vista data file header, attribute list, and delimeter
       while queuing on data_list any binary data blocks to be written: */
    long offset = 0;
    data_list = VListCreate ();
    FailTest (fprintf (f, "%s %d ", VFileHeader, VFileVersion));
    if (! WriteAttrList (f, list, 1, &data_list, &offset)) {
	VListDestroy (data_list, VFree);
	return FALSE;
    }
    FailTest (fputs ("\n" VFileDelimiter, f));
    fflush (f);

    /* Traverse data_list to write the binary data blocks: */
    for (db = VListFirst (data_list); db; db = VListNext (data_list)) {
	repn = VGetAttrRepn (& db->posn);
	if (repn == VBundleRepn) {

	    /* A typed value includes its binary data block explicitly: */
	    VGetAttrValue (& db->posn, NULL, VBundleRepn, & b);
	    ptr = b->data;
	    free_it = FALSE;

	} else {

	    /* For any other representation, obtain the binary data block
	       from its encode_data method: */
	    VGetAttrValue (& db->posn, NULL, repn, & value);
	    methods = VRepnMethods (repn);
	    ptr = (methods->encode_data)
		(value, db->list, db->length, & free_it);
	    if (! ptr)
		goto Fail;
	}

	/* Write the binary data and free the buffer containing it if it was
	   allocated temporarily by an encode_data method: */
	if (db->length > 0) {
	    result = fwrite (ptr, 1, db->length, f) == db->length;
	    if (free_it)
		VFree (ptr);
	    if (! result)
		goto Fail;
	}
    }
    VListDestroy (data_list, VFree);
    return TRUE;

Fail:
    VWarning ("VWriteFile: Write to stream failed");
    VListDestroy (data_list, VFree);
    return FALSE;
}
コード例 #13
0
ファイル: FIL_Vista_File.c プロジェクト: KoraST/ft_BIU-1
static VBoolean WriteAttr (FILE *f, VAttrListPosn *posn, int indent, VList *data_list, long *offset)
{
    int i;
    char *str;
    VRepnKind repn;
    VAttrList sublist;
    VBundle b;
    DataBlock *db;
    VTypeMethods *methods;
    size_t length;
    VPointer value;
    VBoolean result;
    VAttrListPosn subposn;

    /* Indent by the specified amount: */
    for (i = 0; i < indent; i++)
	FailTest (fputc ('\t', f));
    indent++;

    /* Output the attribute's name: */
    FailTest (fprintf (f, "%s: ", VGetAttrName (posn)));

    /* Ouput its value: */
    switch (repn = VGetAttrRepn (posn)) {

    case VAttrListRepn:
	VGetAttrValue (posn, NULL, VAttrListRepn, (VPointer) & sublist);
	result = WriteAttrList (f, sublist, indent, data_list, offset);
	break;

    case VBundleRepn:
	VGetAttrValue (posn, NULL, VBundleRepn, (VBundle) & b);
	if (! WriteString (f, b->type_name))
	    return FALSE;
	FailTest (fputc (' ', f));

	/* If it's a typed value with binary data... */
	if (b->length > 0) {

	    /* Include "data" and "length" attributes in its attribute list: */
	    VPrependAttr (b->list, VLengthAttr, NULL, VLongRepn,
			  (VLong) b->length);
	    VPrependAttr (b->list, VDataAttr, NULL, VLongRepn,
			  (VLong) *offset);

	    /* Add it to the queue of binary data blocks to be written: */
	    *offset += b->length;
	    db = VNew (DataBlock);
	    db->posn = *posn;
	    db->list = b->list;
	    db->length = b->length;
	    VListAppend (*data_list, db);
	}

	/* Write the typed value's attribute list: */
	result = WriteAttrList (f, b->list, indent, data_list, offset);

	/* Remove the "data" and "length" attributes added earlier: */
	if (b->length > 0) {
	    VFirstAttr (b->list, & subposn);
	    VDeleteAttr (& subposn);
	    VDeleteAttr (& subposn);
	}
	break;

    case VStringRepn:
	VGetAttrValue (posn, NULL, VStringRepn, (VPointer) & str);
	result = WriteString (f, str);
	break;

    default:
	if (! (methods = VRepnMethods (repn)) ||
	    ! methods->encode_attr || ! methods->encode_data) {
	    VWarning ("VWriteFile: "
		      "%s attribute has unwriteable representation: %s",
		      VGetAttrName (posn), VRepnName (repn));
	    return FALSE;
	}

	/* Write the type name: */
	if (! WriteString (f, VRepnName (repn)))
	    return FALSE;
	FailTest (fputc (' ', f));

	/* Invoke the object type's encode_attr method to obtain an
	   attribute list: */
	VGetAttrValue (posn, NULL, repn, & value);
	sublist = (methods->encode_attr) (value, & length);

	/* If binary data is indicated... */
	if (length > 0) {

	    /* Include "data" and "length" attributes in the attr list: */
	    VPrependAttr (sublist, VLengthAttr, NULL, VLongRepn,
			  (VLong) length);
	    VPrependAttr (sublist, VDataAttr, NULL, VLongRepn,
			  (VLong) *offset);

	    *offset += length;
	}

	/* Add the object to the queue of binary data blocks to be written: */
	db = VNew (DataBlock);
	db->posn = *posn;
	db->list = sublist;
	db->length = length;
	VListAppend (*data_list, db);

	/* Write the typed value's attribute list: */
	result = WriteAttrList (f, sublist, indent, data_list, offset);

	/* Remove the "data" and "length" attributes added earlier: */
	if (length > 0) {
	    VFirstAttr (sublist, & subposn);
	    VDeleteAttr (& subposn);
	    VDeleteAttr (& subposn);
	}
    }

    /* Output a trailing newline: */
    if (result)
	FailTest (fputc ('\n', f));
    return result;

Fail:
    VWarning ("VWriteFile: Write to stream failed");
    return FALSE;
}
コード例 #14
0
ファイル: fileio.c プロジェクト: gerddie/vistaio
EXPORT_VISTA VistaIOBoolean VistaIOWriteFile (FILE * f, VistaIOAttrList list)
{
	DataBlock *db;
	VistaIOBundle b;
	VistaIOTypeMethods *methods;
	VistaIORepnKind repn;
	VistaIOPointer value, ptr;
	VistaIOBoolean free_it;
	VistaIOBoolean result = 0;

	/* Write the Vista data file header, attribute list, and delimeter
	   while queuing on data_list any binary data blocks to be written: */
	offset = 0;
	data_list = VistaIOListCreate ();
	FailTest (fprintf (f, "%s %d ", VistaIOFileHeader, VistaIOFileVersion));
	if (!WriteAttrList (f, list, 1)) {
		VistaIOListDestroy (data_list, VistaIOFree);
		return FALSE;
	}
	FailTest (fputs ("\n" VistaIOFileDelimiter, f));
	fflush (f);

	/* Traverse data_list to write the binary data blocks: */
	for (db = VistaIOListFirst (data_list); db; db = VistaIOListNext (data_list)) {
		repn = VistaIOGetAttrRepn (&db->posn);
		if (repn == VistaIOBundleRepn) {

			/* A typed value includes its binary data block explicitly: */
			VistaIOGetAttrValue (&db->posn, NULL, VistaIOBundleRepn, &b);
			ptr = b->data;
			free_it = FALSE;

		} else {

			/* For any other representation, obtain the binary data block
			   from its encode_data method: */
			VistaIOGetAttrValue (&db->posn, NULL, repn, &value);
			methods = VistaIORepnMethods (repn);
			ptr = (methods->encode_data)
				(value, db->list, db->length, &free_it);
			if (!ptr)
				goto Fail;
		}

		/* Write the binary data and free the buffer containing it if it was
		   allocated temporarily by an encode_data method: */
		if (db->length > 0) {
			int togo = db->length; 
			int pos = 0; 
			while (togo) {
				size_t write_length = togo < 100000  ? togo: 100000;
				result = fwrite (((char *)ptr) + pos, 1, write_length, f) == write_length;
				pos += write_length;
				togo -= write_length;
				VistaIOShowWriteProgress(pos, db->length, VistaIOProgressData);
			}
			if (free_it)
				VistaIOFree (ptr);
			if (!result)
				goto Fail;
		}
	}
	VistaIOListDestroy (data_list, VistaIOFree);
	return TRUE;

      Fail:
	VistaIOWarning ("VistaIOWriteFile: Write to stream failed");
	VistaIOListDestroy (data_list, VistaIOFree);
	return FALSE;
}