1 /* This file is part of the KDE project
2 Copyright (C) 2008 David Faure <faure@kde.org>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include <qtest_kde.h>
19 #include <konqmainwindow.h>
22 class KonqViewTest
: public QObject
29 // This is test for the bug "embed katepart and then type a website URL -> loaded into katepart"
30 // i.e. KonqView::changePart(), KonqView::ensureViewSupports()
32 KonqMainWindow mainWindow
;
33 // we specify the mimetype so that we don't have to wait for a KonqRun
34 KonqOpenURLRequest req
; req
.forceAutoEmbed
= true;
35 mainWindow
.openUrl(0, KUrl("data:text/plain, Hello World"), "text/plain", req
);
36 KonqView
* view
= mainWindow
.currentView();
38 QVERIFY(view
->part());
39 QVERIFY(QTest::kWaitForSignal(view
, SIGNAL(viewCompleted(KonqView
*)), 1000));
40 QCOMPARE(view
->serviceType(), QString("text/plain"));
41 const QString firstService
= view
->service()->entryPath();
42 qDebug() << firstService
;
43 QVERIFY(view
->supportsMimeType("text/html")); // it does, since that's a mimetype subclass
45 // Now open HTML, as if we typed a URL in the location bar.
46 KonqOpenURLRequest req2
; req2
.typedUrl
= "http://www.kde.org";
47 mainWindow
.openUrl(0, KUrl("data:text/html, <p>Hello World</p>"), "text/html", req2
);
48 qDebug() << view
->service()->entryPath();
49 QVERIFY(view
->service()->entryPath() != firstService
);
54 // Related to the previous test; ensure we keep the same viewmode when switching between folders
55 KonqMainWindow mainWindow
;
56 mainWindow
.openUrl(0, KUrl(QDir::homePath()));
57 KonqView
* view
= mainWindow
.currentView();
59 QPointer
<KParts::ReadOnlyPart
> part
= view
->part();
60 QVERIFY(view
->part());
61 QVERIFY(QTest::kWaitForSignal(view
, SIGNAL(viewCompleted(KonqView
*)), 1000));
62 QCOMPARE(view
->serviceType(), QString("inode/directory"));
63 qDebug() << view
->internalViewMode();
64 view
->setInternalViewMode("details");
65 QCOMPARE(view
->internalViewMode(), QString("details"));
67 mainWindow
.openUrl(0, KUrl("applications:/"));
68 QCOMPARE(static_cast<KParts::ReadOnlyPart
*>(part
), view
->part());
69 QCOMPARE(view
->internalViewMode(), QString("details"));
74 QTEST_KDEMAIN_WITH_COMPONENTNAME( KonqViewTest
, GUI
, "konqueror" )
76 #include "konqviewtest.moc"