diff options
Diffstat (limited to 'tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp')
-rw-r--r-- | tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 7e684a35a..1c5461fa7 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -1,21 +1,30 @@ -/* - Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ #include "testwindow.h" #include "util.h" @@ -62,6 +71,7 @@ private Q_SLOTS: void inputMethodHints(); void basicRenderingSanity(); void setZoomFactor(); + void printToPdf(); void stopSettingFocusWhenDisabled(); void stopSettingFocusWhenDisabled_data(); void inputEventForwardingDisabledWhenActiveFocusOnPressDisabled(); @@ -485,6 +495,29 @@ void tst_QQuickWebEngineView::setZoomFactor() QVERIFY(qFuzzyCompare(view->zoomFactor(), 2.5)); } +void tst_QQuickWebEngineView::printToPdf() +{ + QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX"); + QVERIFY(tempDir.isValid()); + QQuickWebEngineView *view = webEngineView(); + view->setUrl(urlFromTestPath("html/basic_page.html")); + QVERIFY(waitForLoadSucceeded(view)); + + QString path = tempDir.path() + "/print_success.pdf"; + view->printToPdf(path, QQuickWebEngineView::A4, QQuickWebEngineView::Portrait); + QTest::qWait(500); + QVERIFY(QFile::exists(path)); + +#if !defined(Q_OS_WIN) + path = tempDir.path() + "/print_//fail.pdf"; +#else + path = tempDir.path() + "/print_|fail.pdf"; +#endif // #if !defined(Q_OS_WIN) + view->printToPdf(path, QQuickWebEngineView::A4, QQuickWebEngineView::Portrait); + QTest::qWait(500); + QVERIFY(!QFile::exists(path)); +} + void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled() { QFETCH(bool, viewEnabled); |