File indexing completed on 2024-11-10 12:20:33

0001 /* This file is part of the KDE project
0002  *
0003  * Copyright (C) 2007 Germain Garand <germain@ebooksfrance.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #define QT_GUI_LIB 1
0022 #define QT_WIDGETS_LIB 1
0023 
0024 #include <khtml_part.h>
0025 #include <QTest>
0026 #include <khtmlview.h>
0027 #include "khtmlparttest.h"
0028 #include <csignal>
0029 #include <cstdlib>
0030 
0031 QTEST_MAIN(KHTMLPartTest)
0032 
0033 void __abort(int)
0034 {
0035     std::signal(SIGABRT, SIG_DFL);
0036     std::signal(SIGSEGV, SIG_DFL);
0037     QVERIFY(false);
0038 }
0039 
0040 void KHTMLPartTest::initTestCase()
0041 {
0042     std::signal(SIGABRT, &__abort);
0043     std::signal(SIGSEGV, &__abort);
0044 }
0045 
0046 class MyKHTMLPart : public KHTMLPart
0047 {
0048 public:
0049     MyKHTMLPart() : KHTMLPart(new KHTMLView(this, nullptr)) {}
0050 };
0051 
0052 void KHTMLPartTest::testConstructKHTMLViewFromInitList()
0053 {
0054     // test that KHTMLView can be built from a derived KHTMLPart's initialization list
0055     KHTMLPart *aPart = new MyKHTMLPart();
0056     QVERIFY(true);
0057     QVERIFY(aPart->view()->part() == aPart);
0058     delete aPart;
0059 }
0060 
0061 void KHTMLPartTest::testConstructKHTMLViewBeforePart()
0062 {
0063     // test that a KHTMLView can be constructed before a KHTMLPart
0064     KHTMLView *view = new KHTMLView(nullptr, nullptr);
0065     KHTMLPart *part = new KHTMLPart(view);
0066     QVERIFY(true);
0067     QVERIFY(view->part() == part);
0068     delete part;
0069 }
0070 
0071 #include "moc_khtmlparttest.cpp"