1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Copyright (C) 2016 - 2017 Leslie Zhai <lesliezhai@llvm.org.cn>
*
* This file is part of the K3b project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/
#include <QTest>
#include "k3bexternalbinmanagertest.h"
#include "k3bcore.h"
#include "k3bjob.h"
#include "k3bexternalbinmanager.h"
#include "k3bburnprogressdialog.h"
#include "k3bdefaultexternalprograms.h"
class MyBurnJob : public K3b::BurnJob
{
Q_OBJECT
public:
MyBurnJob(K3b::JobHandler* hdl, QObject* parent = Q_NULLPTR)
: K3b::BurnJob(hdl, parent)
{
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__;
const K3b::ExternalBin* cdrecordBin = k3bcore->externalBinManager()->binObject("cdrecord");
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << cdrecordBin;
}
~MyBurnJob() override
{
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__;
}
public Q_SLOTS:
void start() override { jobStarted(); jobFinished(true); }
void cancel() override { emit canceled(); }
private:
bool prepareWriter()
{
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__;
const K3b::ExternalBin* cdrecordBin = k3bcore->externalBinManager()->binObject("cdrecord");
if (!cdrecordBin)
qWarning() << "ERROR:" << __PRETTY_FUNCTION__ << cdrecordBin;
return true;
}
};
QTEST_GUILESS_MAIN(ExternalBinManagerTest)
ExternalBinManagerTest::ExternalBinManagerTest()
: QObject()
, m_core(new K3b::Application::Core(this))
{
}
void ExternalBinManagerTest::testBinObject()
{
K3b::ExternalBinManager* binManager = new K3b::ExternalBinManager;
K3b::addDefaultPrograms(binManager);
binManager->search();
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << binManager->foundBin("cdrecord");
if (binManager->binObject("ooo") && binManager->binObject("ooo")->hasFeature("fff")) {
qDebug() << __PRETTY_FUNCTION__ << "it *NEVER* happened!";
}
// ooo binObject directly return 0
// then hasFeature will segfault!
// there are a lot of *unchecking* binObject is nullptr issue in k3b-2.0.3!!!
//if (binManager->binObject("ooo")->hasFeature("fff")) {
//}
}
void ExternalBinManagerTest::testMyBurnJob()
{
QSKIP("currently segfaulting");
K3b::BurnProgressDialog* dlg = new K3b::BurnProgressDialog;
MyBurnJob* job = new MyBurnJob(dlg, this);
dlg->setJob(job);
// TODO: it needs CdrskinWritter for job->setWritingApp
dlg->startJob(job);
}
#include "k3bexternalbinmanagertest.moc"
|