Example #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// Test suite for Wide2LxAscii().
///
//static
void DevLXNano::Wide2LxAsciiTest()
{
  static const TCHAR* suite = _T("Wide2LxAscii");

  static const TCHAR uc0[] = {0};

  static const TCHAR uc1[] = {0x0001, 0x001F, 0x0020, 0x0041, 0x007E, 0x007F, 0x00A5, 0x00D9, 0x010E, 0x024F, 0x0250, 0};
  static const char* ch1a  = "?? A~?YUDy?";
  static const char* ch1b  = "?? A";

  static const TCHAR uc2[] = {0xD800, 0xDC00, 0xDBFF, 0xDFFF, 0xE000, 0x007A, 0};
  static const char* ch2   = "???z";

  char tmp[200] = { 'x' };

  LogTestResult(suite, _T("0 output"), Wide2LxAscii(uc1, 0, NULL) == false);

  LogTestResult(suite, _T("0 input"), Wide2LxAscii(uc0, 1, tmp) == true);
  LogTestResult(suite, _T("0 input/chk"), tmp[0] == '\0');

  LogTestResult(suite, _T("1 output"), Wide2LxAscii(uc1, 1, tmp) == false);
  LogTestResult(suite, _T("1 output/chk"), tmp[0] == '\0');

  LogTestResult(suite, _T("5 output"), Wide2LxAscii(uc1, 5, tmp) == false);
  LogTestResult(suite, _T("5 output/chk"), strcmp(tmp, ch1b) == 0);

  LogTestResult(suite, _T("uc1"), Wide2LxAscii(uc1, sizeof(tmp), tmp) == true);
  LogTestResult(suite, _T("uc1/chk"), strcmp(tmp, ch1a) == 0);

  LogTestResult(suite, _T("uc2"), Wide2LxAscii(uc2, sizeof(tmp), tmp) == true);
  LogTestResult(suite, _T("uc2/chk"), strcmp(tmp, ch2) == 0);

} // Wide2LxAsciiTest()
// start operations in notification thread
// this is the main function called in the thread,
// it creates notification watcher, requests notification, and check test result
void CNotifyOperator::StartOperationL()
	{
	CNotifyWatcher* notifyWatcher = CNotifyWatcher::NewL(iNumFiles, iOption, *iCurrentOp, iLogger);
	CleanupStack::PushL(notifyWatcher);
	CTestStopper* stopper = new(ELeave) CTestStopper();
	CleanupStack::PushL(stopper);
	
	CActiveScheduler::Add(notifyWatcher);
	CActiveScheduler::Add(stopper);
	
	while (*iCurrentOp != EOpEnd)
		{
		iSmphW->Wait();	// wait for file thread finishing preparation for the current file operation.
		
		notifyWatcher->FullDirectoryScanL(notifyWatcher->iEntries);
		notifyWatcher->RequestNotification();
		stopper->StartWaitingForFile();
		
		iSmphS->Signal();	// Signal file thread that the notifications are requested, ready to receive
		
		CActiveScheduler::Start();
		////////////////////////////////
		// receiving notifications... //
		////////////////////////////////
		
		notifyWatcher->HandleNotification(ETrue); // handle for the last time
		
		LogTestResult(notifyWatcher->iCounter, notifyWatcher->iMeanCounter, notifyWatcher->iOverflowCounter);
		
		if(iOption & EReportChg)
		    {
			TestChangeReport(notifyWatcher->iRecords.Count());
		    }
		
		if (!gPerfMeasure)
		    {
		    TInt id = iOption & KNotifyTreadIdMask;
            if (iOption & EMultiNoti2)
                {
                if ( *iCurrentOp == EOpCreate ||
                    (id % 4 == 0 && (*iCurrentOp == EOpRename || *iCurrentOp == EOpReplace)) ||
                    (id % 4 == 1 && *iCurrentOp == EOpChgAttr) || 
                    (id % 4 == 2 && (*iCurrentOp == EOpResize || *iCurrentOp == EOpWrite)) ||
                    (id % 4 == 3 && *iCurrentOp == EOpDelete))
                    {
                    SAFETEST2(notifyWatcher->iCounter, iNumFiles, id);
                    }
                }
            else
                {
                SAFETEST2(notifyWatcher->iCounter, iNumFiles, id);
                }
		    }
		
		iSmphS->Signal();	// Signal file thread that all notifications are received
		
		iCurrentOp++;
		
		notifyWatcher->Reset(*iCurrentOp);
		if ((*iCurrentOp == EOpManyFiles) || (*iCurrentOp == EOpManyChanges))
			{
			iNumFiles += 1000;
			}
		else if (*iCurrentOp == EOpMixed)
		    {
		    iNumFiles += 50;
		    }
		}

	CleanupStack::PopAndDestroy(2);
	
	}