示例#1
0
void CNsIFile::OnStartTests(UINT nMenuID)
{
	// Calls  all or indivdual test cases on the basis of the 
	// option selected from menu.

   nsCOMPtr<nsILocalFile> theTestFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
   nsCOMPtr<nsILocalFile> theFileOpDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));

    if (!theTestFile)
 	{
		QAOutput("File object doesn't exist. No File tests performed.", 2);
		return;
	}

	if (!theFileOpDir)
 	{
		QAOutput("File object doesn't exist. No File tests performed.", 2);
		return;
	}

	switch(nMenuID)
	{		
		case ID_INTERFACES_NSIFILE_RUNALLTESTS	:
			QAOutput("Begin nsIFile tests.", 1);
			RunAllTests(theTestFile,theFileOpDir);
			QAOutput("End nsIFile tests.", 1);
			break ;

		case ID_INTERFACES_NSIFILE_INITWITHPATH	:
			InitWithPathTest(theTestFile, 2);
			break ;

		case ID_INTERFACES_NSIFILE_APPENDRELATICEPATH :
			AppendRelativePathTest(theTestFile, 2);
			break ;

		case ID_INTERFACES_NSIFILE_EXISTS :
			FileCreateTest(theTestFile, 2);
			break ;

		case ID_INTERFACES_NSIFILE_CREATE :
			FileExistsTest(theTestFile, 2);
			break ;

		case ID_INTERFACES_NSIFILE_COPYTO :
			FileCopyTest(theTestFile, theFileOpDir, 2);	
			break ;

		case ID_INTERFACES_NSIFILE_MOVETO :
			FileMoveTest(theTestFile, theFileOpDir, 2);	
			break ;
	}
}
示例#2
0
void CTests::OnTestsCreateFile()
{
   	//nsresult rv;

	PRBool exists;
    nsCOMPtr<nsILocalFile> theTestFile(do_GetService(NS_LOCAL_FILE_CONTRACTID));

    if (!theTestFile)
	{
		QAOutput("File object doesn't exist. No File tests performed.", 2);
		return;
	}


	QAOutput("Start Create File test.", 2);

	rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\theFile.txt"));
	rv = theTestFile->Exists(&exists);
	QAOutput("File (theFile.txt) doesn't exist. We'll create it.\r\n", 1);

	rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
	RvTestResult(rv, "File Create() test", 2);
}