Пример #1
0
TEST(TestFileOperationJob, GetFunctions)
{
    XFILE::CFile *tmpfile;
    CStdString tmpfilepath, destpath, destfile;
    CFileItemList items;
    CFileOperationJob job;

    ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE("")));
    tmpfilepath = XBMC_TEMPFILEPATH(tmpfile);
    tmpfile->Close();

    CFileItemPtr item(new CFileItem(tmpfilepath));
    item->SetPath(tmpfilepath);
    item->m_bIsFolder = false;
    item->Select(true);
    items.Add(item);

    URIUtils::GetDirectory(tmpfilepath, destpath);
    destpath = URIUtils::AddFileToFolder(destpath, "getfunctions");
    destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath));
    ASSERT_FALSE(XFILE::CFile::Exists(destfile));

    job.SetFileOperation(CFileOperationJob::ActionCopy, items, destpath);
    EXPECT_EQ(CFileOperationJob::ActionCopy, job.GetAction());

    EXPECT_TRUE(job.DoWork());
    EXPECT_TRUE(XFILE::CFile::Exists(tmpfilepath));
    EXPECT_TRUE(XFILE::CFile::Exists(destfile));

    std::cout << "GetAverageSpeed(): " << job.GetAverageSpeed() << std::endl;
    std::cout << "GetCurrentOperation(): " << job.GetCurrentOperation() << std::endl;
    std::cout << "GetCurrentFile(): " << job.GetCurrentFile() << std::endl;
    EXPECT_FALSE(job.GetItems().IsEmpty());

    EXPECT_TRUE(XBMC_DELETETEMPFILE(tmpfile));
    EXPECT_TRUE(XFILE::CFile::Delete(destfile));
    EXPECT_TRUE(XFILE::CDirectory::Remove(destpath));
}