2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the test suite of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-19 12:28:29 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QtAlgorithms>
|
2012-05-11 20:58:15 +00:00
|
|
|
#include <QtPrintSupport/qprinterinfo.h>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2014-02-18 08:33:36 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#ifdef Q_OS_UNIX
|
|
|
|
# include <unistd.h>
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
class tst_QPrinterInfo : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2012-09-07 12:59:15 +00:00
|
|
|
public slots:
|
|
|
|
#ifdef QT_NO_PRINTER
|
|
|
|
void initTestCase();
|
|
|
|
void cleanupTestCase();
|
|
|
|
#else
|
2011-04-27 10:05:43 +00:00
|
|
|
private slots:
|
2012-09-07 12:59:15 +00:00
|
|
|
#ifndef Q_OS_WIN32
|
2011-04-27 10:05:43 +00:00
|
|
|
void testForDefaultPrinter();
|
|
|
|
void testForPrinters();
|
2012-09-07 12:59:15 +00:00
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
void testForPaperSizes();
|
|
|
|
void testConstructors();
|
|
|
|
void testAssignment();
|
2012-05-14 19:17:16 +00:00
|
|
|
void namedPrinter();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString getDefaultPrinterFromSystem();
|
|
|
|
QStringList getPrintersFromSystem();
|
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
#ifdef Q_OS_UNIX
|
2011-04-27 10:05:43 +00:00
|
|
|
QString getOutputFromCommand(const QStringList& command);
|
2012-05-11 20:58:15 +00:00
|
|
|
#endif // Q_OS_UNIX
|
2012-09-07 12:59:15 +00:00
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
2012-09-07 12:59:15 +00:00
|
|
|
|
|
|
|
#ifdef QT_NO_PRINTER
|
|
|
|
void tst_QPrinterInfo::initTestCase()
|
|
|
|
{
|
|
|
|
QSKIP("This test requires printing support");
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_QPrinterInfo::cleanupTestCase()
|
|
|
|
{
|
|
|
|
QSKIP("This test requires printing support");
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2011-04-27 10:05:43 +00:00
|
|
|
QString tst_QPrinterInfo::getDefaultPrinterFromSystem()
|
|
|
|
{
|
2012-05-11 20:58:15 +00:00
|
|
|
QString printer;
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// TODO "cscript c:\windows\system32\prnmngr.vbs -g"
|
|
|
|
#endif // Q_OS_WIN32
|
|
|
|
#ifdef Q_OS_UNIX
|
2011-04-27 10:05:43 +00:00
|
|
|
QStringList command;
|
|
|
|
command << "lpstat" << "-d";
|
|
|
|
QString output = getOutputFromCommand(command);
|
|
|
|
|
2019-06-10 07:27:43 +00:00
|
|
|
QRegularExpression noDefaultReg("[^:]*no .*default");
|
|
|
|
QRegularExpressionMatch match;
|
|
|
|
match = noDefaultReg.match(output);
|
|
|
|
if (match.hasMatch())
|
2011-04-27 10:05:43 +00:00
|
|
|
return QString();
|
|
|
|
|
2019-06-10 07:27:43 +00:00
|
|
|
QRegularExpression defaultReg("default.*: *([a-zA-Z0-9_-]+)");
|
|
|
|
match = defaultReg.match(output);
|
|
|
|
printer = match.captured(1);
|
2012-05-11 20:58:15 +00:00
|
|
|
#endif // Q_OS_UNIX
|
2011-04-27 10:05:43 +00:00
|
|
|
return printer;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList tst_QPrinterInfo::getPrintersFromSystem()
|
|
|
|
{
|
|
|
|
QStringList ans;
|
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// TODO "cscript c:\windows\system32\prnmngr.vbs -l"
|
|
|
|
#endif // Q_OS_WIN32
|
|
|
|
#ifdef Q_OS_UNIX
|
2011-04-27 10:05:43 +00:00
|
|
|
QStringList command;
|
|
|
|
command << "lpstat" << "-p";
|
|
|
|
QString output = getOutputFromCommand(command);
|
|
|
|
QStringList list = output.split(QChar::fromLatin1('\n'));
|
|
|
|
|
2019-06-10 07:27:43 +00:00
|
|
|
QRegularExpression reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)");
|
|
|
|
QRegularExpressionMatch match;
|
2011-04-27 10:05:43 +00:00
|
|
|
for (int c = 0; c < list.size(); ++c) {
|
2019-06-10 07:27:43 +00:00
|
|
|
match = reg.match(list[c]);
|
|
|
|
if (match.hasMatch()) {
|
|
|
|
QString printer = match.captured(1);
|
2011-04-27 10:05:43 +00:00
|
|
|
ans << printer;
|
|
|
|
}
|
|
|
|
}
|
2012-05-11 20:58:15 +00:00
|
|
|
#endif // Q_OS_UNIX
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
return ans;
|
|
|
|
}
|
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
#ifdef Q_OS_UNIX
|
2011-04-27 10:05:43 +00:00
|
|
|
// This function does roughly the same as the `command substitution` in
|
|
|
|
// the shell.
|
2017-08-21 13:54:24 +00:00
|
|
|
QString getOutputFromCommandInternal(const QStringList &command)
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
// The command execution does nothing on non-unix systems.
|
|
|
|
int pid;
|
|
|
|
int status = 0;
|
|
|
|
int pipePtr[2];
|
|
|
|
|
|
|
|
// Create a pipe that is shared between parent and child process.
|
|
|
|
if (pipe(pipePtr) < 0) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
pid = fork();
|
|
|
|
if (pid < 0) {
|
|
|
|
close(pipePtr[0]);
|
|
|
|
close(pipePtr[1]);
|
|
|
|
return QString();
|
|
|
|
} else if (pid == 0) {
|
|
|
|
// In child.
|
|
|
|
// Close the reading end.
|
|
|
|
close(pipePtr[0]);
|
|
|
|
// Redirect stdout to the pipe.
|
|
|
|
if (dup2(pipePtr[1], 1) < 0) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
char** argv = new char*[command.size()+1];
|
|
|
|
for (int c = 0; c < command.size(); ++c) {
|
|
|
|
argv[c] = new char[command[c].size()+1];
|
|
|
|
strcpy(argv[c], command[c].toLatin1().data());
|
|
|
|
}
|
|
|
|
argv[command.size()] = NULL;
|
|
|
|
execvp(argv[0], argv);
|
|
|
|
// Shouldn't get here, but it's possible if command is not found.
|
|
|
|
close(pipePtr[1]);
|
|
|
|
close(1);
|
|
|
|
for (int c = 0; c < command.size(); ++c) {
|
|
|
|
delete [] argv[c];
|
|
|
|
}
|
|
|
|
delete [] argv;
|
|
|
|
exit(1);
|
|
|
|
} else {
|
|
|
|
// In parent.
|
|
|
|
// Close the writing end.
|
|
|
|
close(pipePtr[1]);
|
|
|
|
|
|
|
|
QFile pipeRead;
|
|
|
|
if (!pipeRead.open(pipePtr[0], QIODevice::ReadOnly)) {
|
|
|
|
close(pipePtr[0]);
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
QByteArray array;
|
|
|
|
array = pipeRead.readAll();
|
|
|
|
pipeRead.close();
|
|
|
|
close(pipePtr[0]);
|
|
|
|
wait(&status);
|
|
|
|
return QString(array);
|
|
|
|
}
|
|
|
|
}
|
2017-08-21 13:54:24 +00:00
|
|
|
|
|
|
|
QString tst_QPrinterInfo::getOutputFromCommand(const QStringList &command)
|
|
|
|
{
|
|
|
|
// Forces the ouptut from the command to be in English
|
|
|
|
const QByteArray origSoftwareEnv = qgetenv("SOFTWARE");
|
|
|
|
qputenv("SOFTWARE", QByteArray());
|
|
|
|
QString output = getOutputFromCommandInternal(command);
|
|
|
|
qputenv("SOFTWARE", origSoftwareEnv);
|
|
|
|
return output;
|
|
|
|
}
|
2012-05-11 20:58:15 +00:00
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-07 12:59:15 +00:00
|
|
|
// Windows test support not yet implemented
|
|
|
|
#ifndef Q_OS_WIN32
|
2011-04-27 10:05:43 +00:00
|
|
|
void tst_QPrinterInfo::testForDefaultPrinter()
|
|
|
|
{
|
2012-05-11 20:58:15 +00:00
|
|
|
QString testPrinter = getDefaultPrinterFromSystem();
|
|
|
|
QString defaultPrinter = QPrinterInfo::defaultPrinter().printerName();
|
|
|
|
QString availablePrinter;
|
|
|
|
int availablePrinterDefaults = 0;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QList<QPrinterInfo> list = QPrinterInfo::availablePrinters();
|
|
|
|
for (int c = 0; c < list.size(); ++c) {
|
|
|
|
if (list[c].isDefault()) {
|
2012-05-11 20:58:15 +00:00
|
|
|
availablePrinter = list.at(c).printerName();
|
|
|
|
++availablePrinterDefaults;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
qDebug() << "Test believes Default Printer = " << testPrinter;
|
|
|
|
qDebug() << "QPrinterInfo::defaultPrinter() believes Default Printer = " << defaultPrinter;
|
|
|
|
qDebug() << "QPrinterInfo::availablePrinters() believes Default Printer = " << availablePrinter;
|
|
|
|
|
|
|
|
QCOMPARE(testPrinter, defaultPrinter);
|
|
|
|
QCOMPARE(testPrinter, availablePrinter);
|
|
|
|
if (!availablePrinter.isEmpty())
|
|
|
|
QCOMPARE(availablePrinterDefaults, 1);
|
2011-11-15 01:36:18 +00:00
|
|
|
}
|
2012-09-07 12:59:15 +00:00
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-09-07 12:59:15 +00:00
|
|
|
// Windows test support not yet implemented
|
|
|
|
#ifndef Q_OS_WIN32
|
2011-04-27 10:05:43 +00:00
|
|
|
void tst_QPrinterInfo::testForPrinters()
|
|
|
|
{
|
2012-05-11 20:58:15 +00:00
|
|
|
QStringList testPrinters = getPrintersFromSystem();
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
|
2012-05-11 20:58:15 +00:00
|
|
|
QStringList qtPrinters;
|
|
|
|
for (int i = 0; i < printers.size(); ++i)
|
|
|
|
qtPrinters.append(printers.at(i).printerName());
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2014-02-18 08:33:36 +00:00
|
|
|
std::sort(testPrinters.begin(), testPrinters.end());
|
|
|
|
std::sort(qtPrinters.begin(), qtPrinters.end());
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
qDebug() << "Test believes Available Printers = " << testPrinters;
|
|
|
|
qDebug() << "QPrinterInfo::availablePrinters() believes Available Printers = " << qtPrinters;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
QCOMPARE(qtPrinters.size(), testPrinters.size());
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
for (int i = 0; i < testPrinters.size(); ++i)
|
|
|
|
QCOMPARE(qtPrinters.at(i), testPrinters.at(i));
|
2011-11-15 01:36:18 +00:00
|
|
|
}
|
2012-09-07 12:59:15 +00:00
|
|
|
#endif
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
void tst_QPrinterInfo::testForPaperSizes()
|
|
|
|
{
|
2012-05-11 20:58:15 +00:00
|
|
|
// TODO Old PaperSize test dependent on physical printer installed, new generic test required
|
|
|
|
// In the meantime just exercise the code path and print-out for inspection.
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
|
2013-12-18 20:51:12 +00:00
|
|
|
for (int i = 0; i < printers.size(); ++i) {
|
|
|
|
qDebug() << "Printer : " << printers.at(i).printerName() << printers.at(i).defaultPageSize();
|
|
|
|
qDebug() << "Paper Sizes : " << printers.at(i).supportedPageSizes();
|
|
|
|
qDebug() << "Custom Sizes : " << printers.at(i).supportsCustomPageSizes();
|
|
|
|
qDebug() << "Physical Sizes: " << printers.at(i).minimumPhysicalPageSize()
|
|
|
|
<< printers.at(i).maximumPhysicalPageSize();
|
|
|
|
qDebug() << "";
|
|
|
|
}
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tst_QPrinterInfo::testConstructors()
|
|
|
|
{
|
2012-05-11 20:58:15 +00:00
|
|
|
QPrinterInfo null;
|
|
|
|
QCOMPARE(null.printerName(), QString());
|
|
|
|
QVERIFY(null.isNull());
|
|
|
|
|
2013-11-25 19:36:58 +00:00
|
|
|
QPrinterInfo null2(null);
|
|
|
|
QVERIFY(null2.isNull());
|
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
|
|
|
|
|
|
|
|
for (int i = 0; i < printers.size(); ++i) {
|
|
|
|
QPrinterInfo copy1(printers.at(i));
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy1.printerName(), printers.at(i).printerName());
|
|
|
|
QCOMPARE(copy1.description(), printers.at(i).description());
|
|
|
|
QCOMPARE(copy1.location(), printers.at(i).location());
|
|
|
|
QCOMPARE(copy1.makeAndModel(), printers.at(i).makeAndModel());
|
|
|
|
QCOMPARE(copy1.isNull(), printers.at(i).isNull());
|
|
|
|
QCOMPARE(copy1.isDefault(), printers.at(i).isDefault());
|
|
|
|
QCOMPARE(copy1.isRemote(), printers.at(i).isRemote());
|
|
|
|
QCOMPARE(copy1.state(), printers.at(i).state());
|
|
|
|
QCOMPARE(copy1.supportedPageSizes(), printers.at(i).supportedPageSizes());
|
|
|
|
QCOMPARE(copy1.defaultPageSize(), printers.at(i).defaultPageSize());
|
|
|
|
QCOMPARE(copy1.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes());
|
|
|
|
QCOMPARE(copy1.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
|
|
|
|
QCOMPARE(copy1.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
|
Tests: Fix some warnings about deprecated functions not under test
Fix warnings like:
baselineserver/shared/baselineprotocol.cpp:295:72: warning: ‘int QImage::byteCount() const’ is deprecated: Use sizeInBytes [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:17: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:39: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:8153:60: warning: ‘T* QWeakPointer<T>::data() const [with T = const QNetworkSession]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations].
...
st_qprinter.cpp:1318:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_qprinter.cpp:1362:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_largefile.cpp:492:85: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_largefile.cpp:498:91: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_qabstractitemmodel.cpp:312:25: warning: ‘void QAbstractItemModel::reset()’ is deprecated [-Wdeprecated-declarations]
...
tst_qabstractitemmodel.cpp:1793:28: warning: ‘void QAbstractItemModel::setRoleNames(const QHash<int, QByteArray>&)’ is deprecated [-Wdeprecated-declarations]
...
tst_qcolor.cpp:1425:33: warning: ‘QColor QColor::light(int) const’ is deprecated: Use QColor::lighter() instead [-Wdeprecated-declarations]
tst_qcolor.cpp:1432:31: warning: ‘QColor QColor::dark(int) const’ is deprecated: Use QColor::darker() instead [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:303:61: warning: 'QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const' is deprecated [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:304:65: warning: 'QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const' is deprecated [-Wdeprecated-declarations]
tst_qtextdocumentfragment.cpp:947:52: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2261:61: warning: ‘void QTextLayout::setAdditionalFormats(const QList<QTextLayout::FormatRange>&)’ is deprecated: Use setFormats() [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2330:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
tst_qitemselectionmodel.cpp:2214:37: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
...
tst_qtextlist.cpp:317:68: warning: 'bool QTextList::isEmpty() const' is deprecated: Use count() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:373:32: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:374:40: warning: ‘bool QPainter::matrixEnabled() const’ is deprecated: Use worldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:702:45: warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:1573:29: warning: ‘void QPainter::drawRoundRect(const QRect&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:76:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:81:41: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:105:30: warning: ‘virtual void QPdfWriter::setMargins(const QPagedPaintDevice::Margins&)’ is deprecated: Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:172:37: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:258:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp:3980:54: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
tst_qlocale.cpp:434:26: warning: 'QString::null' is deprecated: use QString() [-Wdeprecated-declarations]
...
Change-Id: I77c1a934b27119eedeb26a77c913686314a2a5c7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-05-23 11:55:23 +00:00
|
|
|
QCOMPARE(copy1.supportedPageSizes(), printers.at(i).supportedPageSizes());
|
2019-07-30 15:16:50 +00:00
|
|
|
#if QT_DEPRECATED_SINCE(5, 3)
|
Tests: Fix some warnings about deprecated functions not under test
Fix warnings like:
baselineserver/shared/baselineprotocol.cpp:295:72: warning: ‘int QImage::byteCount() const’ is deprecated: Use sizeInBytes [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:17: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:39: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:8153:60: warning: ‘T* QWeakPointer<T>::data() const [with T = const QNetworkSession]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations].
...
st_qprinter.cpp:1318:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_qprinter.cpp:1362:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_largefile.cpp:492:85: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_largefile.cpp:498:91: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_qabstractitemmodel.cpp:312:25: warning: ‘void QAbstractItemModel::reset()’ is deprecated [-Wdeprecated-declarations]
...
tst_qabstractitemmodel.cpp:1793:28: warning: ‘void QAbstractItemModel::setRoleNames(const QHash<int, QByteArray>&)’ is deprecated [-Wdeprecated-declarations]
...
tst_qcolor.cpp:1425:33: warning: ‘QColor QColor::light(int) const’ is deprecated: Use QColor::lighter() instead [-Wdeprecated-declarations]
tst_qcolor.cpp:1432:31: warning: ‘QColor QColor::dark(int) const’ is deprecated: Use QColor::darker() instead [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:303:61: warning: 'QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const' is deprecated [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:304:65: warning: 'QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const' is deprecated [-Wdeprecated-declarations]
tst_qtextdocumentfragment.cpp:947:52: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2261:61: warning: ‘void QTextLayout::setAdditionalFormats(const QList<QTextLayout::FormatRange>&)’ is deprecated: Use setFormats() [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2330:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
tst_qitemselectionmodel.cpp:2214:37: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
...
tst_qtextlist.cpp:317:68: warning: 'bool QTextList::isEmpty() const' is deprecated: Use count() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:373:32: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:374:40: warning: ‘bool QPainter::matrixEnabled() const’ is deprecated: Use worldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:702:45: warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:1573:29: warning: ‘void QPainter::drawRoundRect(const QRect&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:76:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:81:41: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:105:30: warning: ‘virtual void QPdfWriter::setMargins(const QPagedPaintDevice::Margins&)’ is deprecated: Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:172:37: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:258:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp:3980:54: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
tst_qlocale.cpp:434:26: warning: 'QString::null' is deprecated: use QString() [-Wdeprecated-declarations]
...
Change-Id: I77c1a934b27119eedeb26a77c913686314a2a5c7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-05-23 11:55:23 +00:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_DEPRECATED
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy1.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
|
Tests: Fix some warnings about deprecated functions not under test
Fix warnings like:
baselineserver/shared/baselineprotocol.cpp:295:72: warning: ‘int QImage::byteCount() const’ is deprecated: Use sizeInBytes [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:17: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:39: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:8153:60: warning: ‘T* QWeakPointer<T>::data() const [with T = const QNetworkSession]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations].
...
st_qprinter.cpp:1318:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_qprinter.cpp:1362:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_largefile.cpp:492:85: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_largefile.cpp:498:91: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_qabstractitemmodel.cpp:312:25: warning: ‘void QAbstractItemModel::reset()’ is deprecated [-Wdeprecated-declarations]
...
tst_qabstractitemmodel.cpp:1793:28: warning: ‘void QAbstractItemModel::setRoleNames(const QHash<int, QByteArray>&)’ is deprecated [-Wdeprecated-declarations]
...
tst_qcolor.cpp:1425:33: warning: ‘QColor QColor::light(int) const’ is deprecated: Use QColor::lighter() instead [-Wdeprecated-declarations]
tst_qcolor.cpp:1432:31: warning: ‘QColor QColor::dark(int) const’ is deprecated: Use QColor::darker() instead [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:303:61: warning: 'QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const' is deprecated [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:304:65: warning: 'QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const' is deprecated [-Wdeprecated-declarations]
tst_qtextdocumentfragment.cpp:947:52: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2261:61: warning: ‘void QTextLayout::setAdditionalFormats(const QList<QTextLayout::FormatRange>&)’ is deprecated: Use setFormats() [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2330:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
tst_qitemselectionmodel.cpp:2214:37: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
...
tst_qtextlist.cpp:317:68: warning: 'bool QTextList::isEmpty() const' is deprecated: Use count() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:373:32: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:374:40: warning: ‘bool QPainter::matrixEnabled() const’ is deprecated: Use worldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:702:45: warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:1573:29: warning: ‘void QPainter::drawRoundRect(const QRect&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:76:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:81:41: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:105:30: warning: ‘virtual void QPdfWriter::setMargins(const QPagedPaintDevice::Margins&)’ is deprecated: Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:172:37: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:258:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp:3980:54: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
tst_qlocale.cpp:434:26: warning: 'QString::null' is deprecated: use QString() [-Wdeprecated-declarations]
...
Change-Id: I77c1a934b27119eedeb26a77c913686314a2a5c7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-05-23 11:55:23 +00:00
|
|
|
QT_WARNING_POP
|
2019-07-30 15:16:50 +00:00
|
|
|
#endif
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy1.supportedResolutions(), printers.at(i).supportedResolutions());
|
2014-03-17 16:59:55 +00:00
|
|
|
QCOMPARE(copy1.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
|
|
|
|
QCOMPARE(copy1.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
|
2012-05-11 20:58:15 +00:00
|
|
|
|
|
|
|
QPrinter printer(printers.at(i));
|
|
|
|
QPrinterInfo copy2(printer);
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy2.printerName(), printers.at(i).printerName());
|
|
|
|
QCOMPARE(copy2.description(), printers.at(i).description());
|
|
|
|
QCOMPARE(copy2.location(), printers.at(i).location());
|
|
|
|
QCOMPARE(copy2.makeAndModel(), printers.at(i).makeAndModel());
|
|
|
|
QCOMPARE(copy2.isNull(), printers.at(i).isNull());
|
|
|
|
QCOMPARE(copy2.isDefault(), printers.at(i).isDefault());
|
|
|
|
QCOMPARE(copy2.isRemote(), printers.at(i).isRemote());
|
|
|
|
QCOMPARE(copy2.state(), printers.at(i).state());
|
|
|
|
QCOMPARE(copy2.supportedPageSizes(), printers.at(i).supportedPageSizes());
|
|
|
|
QCOMPARE(copy2.defaultPageSize(), printers.at(i).defaultPageSize());
|
|
|
|
QCOMPARE(copy2.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes());
|
|
|
|
QCOMPARE(copy2.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
|
|
|
|
QCOMPARE(copy2.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
|
Tests: Fix some warnings about deprecated functions not under test
Fix warnings like:
baselineserver/shared/baselineprotocol.cpp:295:72: warning: ‘int QImage::byteCount() const’ is deprecated: Use sizeInBytes [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:17: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:39: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:8153:60: warning: ‘T* QWeakPointer<T>::data() const [with T = const QNetworkSession]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations].
...
st_qprinter.cpp:1318:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_qprinter.cpp:1362:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_largefile.cpp:492:85: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_largefile.cpp:498:91: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_qabstractitemmodel.cpp:312:25: warning: ‘void QAbstractItemModel::reset()’ is deprecated [-Wdeprecated-declarations]
...
tst_qabstractitemmodel.cpp:1793:28: warning: ‘void QAbstractItemModel::setRoleNames(const QHash<int, QByteArray>&)’ is deprecated [-Wdeprecated-declarations]
...
tst_qcolor.cpp:1425:33: warning: ‘QColor QColor::light(int) const’ is deprecated: Use QColor::lighter() instead [-Wdeprecated-declarations]
tst_qcolor.cpp:1432:31: warning: ‘QColor QColor::dark(int) const’ is deprecated: Use QColor::darker() instead [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:303:61: warning: 'QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const' is deprecated [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:304:65: warning: 'QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const' is deprecated [-Wdeprecated-declarations]
tst_qtextdocumentfragment.cpp:947:52: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2261:61: warning: ‘void QTextLayout::setAdditionalFormats(const QList<QTextLayout::FormatRange>&)’ is deprecated: Use setFormats() [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2330:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
tst_qitemselectionmodel.cpp:2214:37: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
...
tst_qtextlist.cpp:317:68: warning: 'bool QTextList::isEmpty() const' is deprecated: Use count() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:373:32: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:374:40: warning: ‘bool QPainter::matrixEnabled() const’ is deprecated: Use worldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:702:45: warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:1573:29: warning: ‘void QPainter::drawRoundRect(const QRect&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:76:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:81:41: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:105:30: warning: ‘virtual void QPdfWriter::setMargins(const QPagedPaintDevice::Margins&)’ is deprecated: Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:172:37: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:258:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp:3980:54: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
tst_qlocale.cpp:434:26: warning: 'QString::null' is deprecated: use QString() [-Wdeprecated-declarations]
...
Change-Id: I77c1a934b27119eedeb26a77c913686314a2a5c7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-05-23 11:55:23 +00:00
|
|
|
QCOMPARE(copy2.supportedPageSizes(), printers.at(i).supportedPageSizes());
|
2019-07-30 15:16:50 +00:00
|
|
|
#if QT_DEPRECATED_SINCE(5, 3)
|
Tests: Fix some warnings about deprecated functions not under test
Fix warnings like:
baselineserver/shared/baselineprotocol.cpp:295:72: warning: ‘int QImage::byteCount() const’ is deprecated: Use sizeInBytes [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:17: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:39: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:8153:60: warning: ‘T* QWeakPointer<T>::data() const [with T = const QNetworkSession]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations].
...
st_qprinter.cpp:1318:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_qprinter.cpp:1362:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_largefile.cpp:492:85: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_largefile.cpp:498:91: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_qabstractitemmodel.cpp:312:25: warning: ‘void QAbstractItemModel::reset()’ is deprecated [-Wdeprecated-declarations]
...
tst_qabstractitemmodel.cpp:1793:28: warning: ‘void QAbstractItemModel::setRoleNames(const QHash<int, QByteArray>&)’ is deprecated [-Wdeprecated-declarations]
...
tst_qcolor.cpp:1425:33: warning: ‘QColor QColor::light(int) const’ is deprecated: Use QColor::lighter() instead [-Wdeprecated-declarations]
tst_qcolor.cpp:1432:31: warning: ‘QColor QColor::dark(int) const’ is deprecated: Use QColor::darker() instead [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:303:61: warning: 'QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const' is deprecated [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:304:65: warning: 'QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const' is deprecated [-Wdeprecated-declarations]
tst_qtextdocumentfragment.cpp:947:52: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2261:61: warning: ‘void QTextLayout::setAdditionalFormats(const QList<QTextLayout::FormatRange>&)’ is deprecated: Use setFormats() [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2330:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
tst_qitemselectionmodel.cpp:2214:37: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
...
tst_qtextlist.cpp:317:68: warning: 'bool QTextList::isEmpty() const' is deprecated: Use count() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:373:32: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:374:40: warning: ‘bool QPainter::matrixEnabled() const’ is deprecated: Use worldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:702:45: warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:1573:29: warning: ‘void QPainter::drawRoundRect(const QRect&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:76:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:81:41: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:105:30: warning: ‘virtual void QPdfWriter::setMargins(const QPagedPaintDevice::Margins&)’ is deprecated: Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:172:37: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:258:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp:3980:54: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
tst_qlocale.cpp:434:26: warning: 'QString::null' is deprecated: use QString() [-Wdeprecated-declarations]
...
Change-Id: I77c1a934b27119eedeb26a77c913686314a2a5c7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-05-23 11:55:23 +00:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_DEPRECATED
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy2.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
|
Tests: Fix some warnings about deprecated functions not under test
Fix warnings like:
baselineserver/shared/baselineprotocol.cpp:295:72: warning: ‘int QImage::byteCount() const’ is deprecated: Use sizeInBytes [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:17: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:1560:39: warning: ‘static QList<QSslCertificate> QSslSocket::defaultCaCertificates()’ is deprecated [-Wdeprecated-declarations]
tst_qnetworkreply.cpp:8153:60: warning: ‘T* QWeakPointer<T>::data() const [with T = const QNetworkSession]’ is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations].
...
st_qprinter.cpp:1318:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_qprinter.cpp:1362:74: warning: ‘QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const’ is deprecated [-Wdeprecated-declarations]
tst_largefile.cpp:492:85: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_largefile.cpp:498:91: warning: ‘bool qEqual(InputIterator1, InputIterator1, InputIterator2) [with InputIterator1 = char*; InputIterator2 = char*]’ is deprecated: Use std::equal [-Wdeprecated-declarations]
tst_qabstractitemmodel.cpp:312:25: warning: ‘void QAbstractItemModel::reset()’ is deprecated [-Wdeprecated-declarations]
...
tst_qabstractitemmodel.cpp:1793:28: warning: ‘void QAbstractItemModel::setRoleNames(const QHash<int, QByteArray>&)’ is deprecated [-Wdeprecated-declarations]
...
tst_qcolor.cpp:1425:33: warning: ‘QColor QColor::light(int) const’ is deprecated: Use QColor::lighter() instead [-Wdeprecated-declarations]
tst_qcolor.cpp:1432:31: warning: ‘QColor QColor::dark(int) const’ is deprecated: Use QColor::darker() instead [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:303:61: warning: 'QList<QPagedPaintDevice::PageSize> QPrinterInfo::supportedPaperSizes() const' is deprecated [-Wdeprecated-declarations]
tst_qprinterinfo.cpp:304:65: warning: 'QList<QPair<QString, QSizeF> > QPrinterInfo::supportedSizesWithNames() const' is deprecated [-Wdeprecated-declarations]
tst_qtextdocumentfragment.cpp:947:52: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2261:61: warning: ‘void QTextLayout::setAdditionalFormats(const QList<QTextLayout::FormatRange>&)’ is deprecated: Use setFormats() [-Wdeprecated-declarations]
tst_qtextlayout.cpp:2330:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
tst_qitemselectionmodel.cpp:2214:37: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
...
tst_qtextlist.cpp:317:68: warning: 'bool QTextList::isEmpty() const' is deprecated: Use count() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:373:32: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:374:40: warning: ‘bool QPainter::matrixEnabled() const’ is deprecated: Use worldMatrixEnabled() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:702:45: warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
tst_qpainter.cpp:1573:29: warning: ‘void QPainter::drawRoundRect(const QRect&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:76:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:81:41: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:105:30: warning: ‘virtual void QPdfWriter::setMargins(const QPagedPaintDevice::Margins&)’ is deprecated: Use setPageMargins(QMarginsF(l, t, r, b), QPageLayout::Millimeter) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:172:37: warning: ‘virtual void QPdfWriter::setPageSizeMM(const QSizeF&)’ is deprecated: Use setPageSize(QPageSize(size, QPageSize::Millimeter)) instead [-Wdeprecated-declarations]
tst_qpdfwriter.cpp:258:38: warning: ‘virtual void QPdfWriter::setPageSize(QPagedPaintDevice::PageSize)’ is deprecated: Use setPageSize(QPageSize(id)) instead [-Wdeprecated-declarations]
qsortfilterproxymodel_common/tst_qsortfilterproxymodel.cpp:3980:54: warning: ‘QModelIndex QModelIndex::child(int, int) const’ is deprecated: Use QAbstractItemModel::index [-Wdeprecated-declarations]
tst_qlocale.cpp:434:26: warning: 'QString::null' is deprecated: use QString() [-Wdeprecated-declarations]
...
Change-Id: I77c1a934b27119eedeb26a77c913686314a2a5c7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-05-23 11:55:23 +00:00
|
|
|
QT_WARNING_POP
|
2019-07-30 15:16:50 +00:00
|
|
|
#endif
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy2.supportedResolutions(), printers.at(i).supportedResolutions());
|
2014-03-17 16:59:55 +00:00
|
|
|
QCOMPARE(copy2.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
|
|
|
|
QCOMPARE(copy2.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_QPrinterInfo::testAssignment()
|
|
|
|
{
|
2013-11-25 19:36:58 +00:00
|
|
|
QPrinterInfo null;
|
|
|
|
QVERIFY(null.isNull());
|
|
|
|
QPrinterInfo null2;
|
|
|
|
null2 = null;
|
|
|
|
QVERIFY(null2.isNull());
|
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-05-11 20:58:15 +00:00
|
|
|
for (int i = 0; i < printers.size(); ++i) {
|
|
|
|
QPrinterInfo copy;
|
|
|
|
copy = printers.at(i);
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(copy.printerName(), printers.at(i).printerName());
|
|
|
|
QCOMPARE(copy.description(), printers.at(i).description());
|
|
|
|
QCOMPARE(copy.location(), printers.at(i).location());
|
|
|
|
QCOMPARE(copy.makeAndModel(), printers.at(i).makeAndModel());
|
|
|
|
QCOMPARE(copy.isNull(), printers.at(i).isNull());
|
|
|
|
QCOMPARE(copy.isDefault(), printers.at(i).isDefault());
|
|
|
|
QCOMPARE(copy.isRemote(), printers.at(i).isRemote());
|
|
|
|
QCOMPARE(copy.state(), printers.at(i).state());
|
|
|
|
QCOMPARE(copy.supportedPageSizes(), printers.at(i).supportedPageSizes());
|
|
|
|
QCOMPARE(copy.defaultPageSize(), printers.at(i).defaultPageSize());
|
|
|
|
QCOMPARE(copy.supportsCustomPageSizes(), printers.at(i).supportsCustomPageSizes());
|
|
|
|
QCOMPARE(copy.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
|
|
|
|
QCOMPARE(copy.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
|
|
|
|
QCOMPARE(copy.supportedResolutions(), printers.at(i).supportedResolutions());
|
2014-03-17 16:59:55 +00:00
|
|
|
QCOMPARE(copy.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
|
|
|
|
QCOMPARE(copy.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-14 19:17:16 +00:00
|
|
|
void tst_QPrinterInfo::namedPrinter()
|
|
|
|
{
|
|
|
|
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
|
|
|
|
|
|
|
|
QStringList printerNames;
|
|
|
|
|
|
|
|
foreach (const QPrinterInfo &pi, printers) {
|
|
|
|
QPrinterInfo pi2 = QPrinterInfo::printerInfo(pi.printerName());
|
2013-12-18 20:51:12 +00:00
|
|
|
QCOMPARE(pi2.printerName(), pi.printerName());
|
|
|
|
QCOMPARE(pi2.description(), pi.description());
|
|
|
|
QCOMPARE(pi2.location(), pi.location());
|
|
|
|
QCOMPARE(pi2.makeAndModel(), pi.makeAndModel());
|
|
|
|
QCOMPARE(pi2.isNull(), pi.isNull());
|
|
|
|
QCOMPARE(pi2.isDefault(), pi.isDefault());
|
|
|
|
QCOMPARE(pi2.isRemote(), pi.isRemote());
|
|
|
|
QCOMPARE(pi2.supportedPageSizes(), pi.supportedPageSizes());
|
|
|
|
QCOMPARE(pi2.defaultPageSize(), pi.defaultPageSize());
|
|
|
|
QCOMPARE(pi2.supportsCustomPageSizes(), pi.supportsCustomPageSizes());
|
|
|
|
QCOMPARE(pi2.minimumPhysicalPageSize(), pi.minimumPhysicalPageSize());
|
|
|
|
QCOMPARE(pi2.maximumPhysicalPageSize(), pi.maximumPhysicalPageSize());
|
|
|
|
QCOMPARE(pi2.supportedResolutions(), pi.supportedResolutions());
|
2014-03-17 16:59:55 +00:00
|
|
|
QCOMPARE(pi2.defaultDuplexMode(), pi.defaultDuplexMode());
|
|
|
|
QCOMPARE(pi2.supportedDuplexModes(), pi.supportedDuplexModes());
|
2012-05-14 19:17:16 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-07 12:59:15 +00:00
|
|
|
#endif // QT_NO_PRINTER
|
2012-05-14 19:17:16 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
QTEST_MAIN(tst_QPrinterInfo)
|
|
|
|
#include "tst_qprinterinfo.moc"
|