TEST(TestFileOperationJob, ActionMove) { 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, "move"); destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath)); ASSERT_FALSE(XFILE::CFile::Exists(destfile)); ASSERT_TRUE(XFILE::CDirectory::Create(destpath)); job.SetFileOperation(CFileOperationJob::ActionMove, items, destpath); EXPECT_EQ(CFileOperationJob::ActionMove, job.GetAction()); EXPECT_TRUE(job.DoWork()); EXPECT_FALSE(XFILE::CFile::Exists(tmpfilepath)); EXPECT_TRUE(XFILE::CFile::Exists(destfile)); EXPECT_TRUE(XFILE::CFile::Delete(destfile)); EXPECT_TRUE(XFILE::CDirectory::Remove(destpath)); }
void CGUIWindowFileManager::OnJobProgress(unsigned int jobID, unsigned int progress, unsigned int total, const CJob *job) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ if (m_dlgProgress->IsCanceled()) { CJobManager::GetInstance().CancelJob(jobID); m_dlgProgress->SetLine(0, 1040); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); Refresh(); m_dlgProgress->Close(); } else { CFileOperationJob *fileJob = (CFileOperationJob *)job; m_dlgProgress->SetLine(0, fileJob->GetCurrentOperation()); m_dlgProgress->SetLine(1, fileJob->GetCurrentFile()); m_dlgProgress->SetLine(2, fileJob->GetAverageSpeed()); if (total > 0) m_dlgProgress->SetPercentage((int)((float)progress * 100.0f / (float)total)); } }
// This test will fail until ActionCreateFolder has a proper implementation TEST(TestFileOperationJob, ActionCreateFolder) { XFILE::CFile *tmpfile; CStdString tmpfilepath, destpath; CFileItemList items; CFileOperationJob job; ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE(""))); tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); tmpfile->Close(); destpath = tmpfilepath; destpath += ".createfolder"; ASSERT_FALSE(XFILE::CFile::Exists(destpath)); CFileItemPtr item(new CFileItem(destpath)); item->SetPath(destpath); item->m_bIsFolder = true; item->Select(true); items.Add(item); job.SetFileOperation(CFileOperationJob::ActionCreateFolder, items, destpath); EXPECT_EQ(CFileOperationJob::ActionCreateFolder, job.GetAction()); EXPECT_TRUE(job.DoWork()); EXPECT_TRUE(XFILE::CDirectory::Exists(destpath)); EXPECT_TRUE(XBMC_DELETETEMPFILE(tmpfile)); EXPECT_TRUE(XFILE::CDirectory::Remove(destpath)); }
TEST(TestFileOperationJob, ActionMove) { XFILE::CFile *tmpfile; CStdString tmpfilepath, destpath; CFileItemList items; CFileOperationJob job; ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE(""))); tmpfilepath = XBMC_TEMPFILEPATH(tmpfile); CFileItemPtr item(new CFileItem(tmpfilepath)); item->SetPath(tmpfilepath); item->m_bIsFolder = false; item->Select(true); items.Add(item); destpath = tmpfilepath; destpath += ".move"; ASSERT_FALSE(XFILE::CFile::Exists(destpath)); job.SetFileOperation(CFileOperationJob::ActionMove, items, destpath); EXPECT_EQ(CFileOperationJob::ActionMove, job.GetAction()); EXPECT_TRUE(job.DoWork()); EXPECT_FALSE(XFILE::CFile::Exists(tmpfilepath)); EXPECT_TRUE(XFILE::CFile::Exists(destpath)); EXPECT_TRUE(XFILE::CFile::Delete(destpath)); }
void CGUIWindowFileManager::OnJobComplete(unsigned int jobID, bool success, CJob *job) { if(!success) { CFileOperationJob* fileJob = (CFileOperationJob*)job; CGUIDialogOK::ShowAndGetInput(fileJob->GetHeading(), fileJob->GetLine(), 16200, 0); } if (IsActive()) { CGUIMessage msg(GUI_MSG_NOTIFY_ALL, GetID(), 0, GUI_MSG_UPDATE); CApplicationMessenger::Get().SendGUIMessage(msg, GetID(), false); } CJobQueue::OnJobComplete(jobID, success, job); }
void CGUIWindowFileManager::OnJobComplete(unsigned int jobID, bool success, CJob *job) { if(!success) { CFileOperationJob* fileJob = static_cast<CFileOperationJob*>(job); HELPERS::ShowOKDialogLines(CVariant{fileJob->GetHeading()}, CVariant{fileJob->GetLine()}, CVariant{16200}, CVariant{0}); } if (IsActive()) { CGUIMessage msg(GUI_MSG_NOTIFY_ALL, GetID(), 0, GUI_MSG_UPDATE); CApplicationMessenger::GetInstance().SendGUIMessage(msg, GetID(), false); } CJobQueue::OnJobComplete(jobID, success, job); }
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)); }