diff options
Diffstat (limited to 'Source/WebKit/qt/tests/hybridPixmap')
-rw-r--r-- | Source/WebKit/qt/tests/hybridPixmap/test.html | 99 | ||||
-rw-r--r-- | Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp | 52 | ||||
-rw-r--r-- | Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc | 5 | ||||
-rw-r--r-- | Source/WebKit/qt/tests/hybridPixmap/widget.cpp | 126 | ||||
-rw-r--r-- | Source/WebKit/qt/tests/hybridPixmap/widget.h | 74 | ||||
-rw-r--r-- | Source/WebKit/qt/tests/hybridPixmap/widget.ui | 95 |
6 files changed, 0 insertions, 451 deletions
diff --git a/Source/WebKit/qt/tests/hybridPixmap/test.html b/Source/WebKit/qt/tests/hybridPixmap/test.html deleted file mode 100644 index a6cbed1fb..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/test.html +++ /dev/null @@ -1,99 +0,0 @@ -<html> - <head> - <style> - img { display: block; border-style: groove} - </style> - <script> - function testImageData() { - var obj = myWidget.image; - var pxm = myWidget.pixmap; - - function compareImageDataSize(o, imageData) { - myWidget.compare(imageData.height, o.height); - myWidget.compare(imageData.width, o.width); - } - compareImageDataSize(obj, obj.toImageData()); - compareImageDataSize(pxm, pxm.toImageData()); - - function compareImageDataPixel(o, imageData) { - compareImageDataSize(o, imageData); - // Make sure pixels are 0xAABBCCFF - var data = imageData.data; - for (var i = 0; i < data.length; i += 4) { - myWidget.compare(data[i], 0xaa); // R - myWidget.compare(data[i+1], 0xbb); // G - myWidget.compare(data[i+2], 0xcc); // B - myWidget.compare(data[i+3], 0xff); // A - } - } - var objARGB32 = myWidget.abcImage(5); - compareImageDataPixel(objARGB32, objARGB32.toImageData()); - var objRGB32 = myWidget.abcImage(4); - compareImageDataPixel(objRGB32, objRGB32.toImageData()); - var objRGB888 = myWidget.abcImage(13); - compareImageDataPixel(objRGB888, objRGB888.toImageData()); - var objRGB444 = myWidget.abcImage(14); - compareImageDataPixel(objRGB444, objRGB444.toImageData()); - } - - function startTest() - { - testImageData(); - - var obj = myWidget.image; - var pxm = myWidget.pixmap; - - var img = new Image; - obj.assignToHTMLImageElement(img); - var img1 = document.getElementById("img1"); - var img2 = document.getElementById("img2"); - var img3 = document.getElementById("img3"); - var img4 = document.getElementById("img4"); - document.body.appendChild(img); - obj.assignToHTMLImageElement(img3); - pxm.assignToHTMLImageElement(img4); - myWidget.compare(pxm.width, img4.width); - myWidget.compare(obj.width, img3.width); - var signalsFired = 0; - myWidget.compare(obj.toString(),"[Qt Native Pixmap "+obj.width+","+obj.height+"]"); - myWidget.compare(String(pxm),"[Qt Native Pixmap "+pxm.width+","+pxm.height+"]"); - - // this shouldn't work but shouldn't crash - myWidget.randomSlot("foobar"); - - myWidget.pixmapSignal.connect(function(imgFromSignal) { - myWidget.compare(imgFromSignal.height, img2.height); - if (++signalsFired == 2) - myWidget.completeTest(); - }); - - myWidget.imageSignal.connect(function(imgFromSignal) { - myWidget.compare(pxm.height, img2.height); - if (++signalsFired == 2) - myWidget.completeTest(); - }); - - function continueTestAfterImagesAreLoaded() - { - if (img1.complete && img2.complete) { - myWidget.compare(pxm.height, img2.height); - myWidget.pixmapSlot(img); - myWidget.imageSlot(pxm); - } - } - img1.onload = continueTestAfterImagesAreLoaded; - img2.onload = continueTestAfterImagesAreLoaded; - img1.src = obj.toDataUrl(); - img2.src = myWidget.pixmap.toDataUrl(); - myWidget.image = pxm; - myWidget.pixmap = img; - } - </script> - </head> - <body onload="startTest()"> - <img id="img1" /> - <img id="img2" /> - <img id="img3" /> - <img id="img4" /> - </body> -</html> diff --git a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp b/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp deleted file mode 100644 index 84891580a..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2009 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 Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "../util.h" - -#include "widget.h" -#include <QtTest/QtTest> - -class tst_hybridPixmap : public QObject { - Q_OBJECT - -public: - tst_hybridPixmap(QObject* o = 0) : QObject(o) {} - -public Q_SLOTS: - void init() - { - } - - void cleanup() - { - } - -private Q_SLOTS: - void hybridPixmap() - { - Widget widget; - widget.show(); - widget.start(); - waitForSignal(&widget, SIGNAL(testComplete())); - } -}; - -QTEST_MAIN(tst_hybridPixmap) - -#include <tst_hybridPixmap.moc> diff --git a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc b/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc deleted file mode 100644 index 5fd47e32d..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/tst_hybridPixmap.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>test.html</file> - </qresource> -</RCC> diff --git a/Source/WebKit/qt/tests/hybridPixmap/widget.cpp b/Source/WebKit/qt/tests/hybridPixmap/widget.cpp deleted file mode 100644 index 6c4d2cd49..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/widget.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2009 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 Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "widget.h" - -#include "qwebelement.h" -#include "qwebframe.h" -#include "ui_widget.h" -#include <QPainter> -#include <QtTest/QtTest> - -Widget::Widget(QWidget* parent) : - QWidget(parent), - ui(new Ui::Widget), - abcFilledImage(32, 32, QImage::Format_ARGB32) -{ - ui->setupUi(this); - abcFilledImage.fill(qRgba(0xaa, 0xbb, 0xcc, 0xff)); -} - -void Widget::refreshJS() -{ - ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("myWidget", this); -} -void Widget::start() -{ - ui->webView->load(QUrl("qrc:///test.html")); - connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(refreshJS())); - ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("myWidget", this); -} - -void Widget::completeTest() -{ - QCOMPARE(ui->lbl1->pixmap()->size(), ui->lbl2->size()); - QCOMPARE(ui->lbl3->size(), ui->lbl4->pixmap()->size()); - QCOMPARE(ui->lbl2->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img1").evaluateJavaScript("this.width").toInt()); - QCOMPARE(ui->lbl3->size().width(), ui->webView->page()->mainFrame()->findFirstElement("#img2").evaluateJavaScript("this.width").toInt()); - emit testComplete(); -} - -void Widget::setPixmap(const QPixmap& p) -{ - ui->lbl1->setPixmap(p); -} -QPixmap Widget::pixmap() const -{ - QPixmap px(ui->lbl3->size()); - { - QPainter p(&px); - ui->lbl3->render(&p); - } - return px; -} -void Widget::setImage(const QImage& img) -{ - ui->lbl4->setPixmap(QPixmap::fromImage(img)); -} - -QImage Widget::image() const -{ - QImage img(ui->lbl2->size(), QImage::Format_ARGB32); - { - QPainter p(&img); - ui->lbl2->render(&p); - } - return img; -} - -QImage Widget::abcImage(int format) -{ - return abcFilledImage.convertToFormat(static_cast<QImage::Format>(format)); -} - -Widget::~Widget() -{ - delete ui; -} - -void Widget::changeEvent(QEvent* e) -{ - QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} -void Widget::compare(const QVariant& a, const QVariant& b) -{ - QCOMPARE(a, b); -} - -void Widget::imageSlot(const QImage& img) -{ - QCOMPARE(img.size(), ui->lbl3->size()); - emit pixmapSignal(QPixmap::fromImage(img)); -} - -void Widget::pixmapSlot(const QPixmap& pxm) -{ - QCOMPARE(pxm.size(), ui->lbl2->size()); - emit imageSignal(ui->lbl4->pixmap()->toImage()); -} - -void Widget::randomSlot(const QPixmap& pxm) -{ - QVERIFY(pxm.isNull()); -} diff --git a/Source/WebKit/qt/tests/hybridPixmap/widget.h b/Source/WebKit/qt/tests/hybridPixmap/widget.h deleted file mode 100644 index b78df8b5e..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/widget.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2009 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 Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef widget_h -#define widget_h - -#include <QImage> -#include <QPixmap> -#include <QWidget> -#include "qwebview.h" - -typedef QWebView WebView; - -QT_BEGIN_NAMESPACE -namespace Ui { -class Widget; -} -QT_END_NAMESPACE - -class Widget : public QWidget { - Q_OBJECT - Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) - Q_PROPERTY(QImage image READ image WRITE setImage) - -public: - Widget(QWidget* parent = 0); - ~Widget(); - void setPixmap(const QPixmap&); - QPixmap pixmap() const; - void setImage(const QImage&); - QImage image() const; - -private Q_SLOTS: - void refreshJS(); - -public Q_SLOTS: - void completeTest(); - void start(); - void compare(const QVariant& a, const QVariant& b); - void imageSlot(const QImage&); - void pixmapSlot(const QPixmap&); - void randomSlot(const QPixmap&); - QImage abcImage(int format); - -Q_SIGNALS: - void testComplete(); - void imageSignal(const QImage&); - void pixmapSignal(const QPixmap&); - -protected: - void changeEvent(QEvent* e); - -private: - Ui::Widget* ui; - QImage abcFilledImage; -}; - -#endif // widget_h diff --git a/Source/WebKit/qt/tests/hybridPixmap/widget.ui b/Source/WebKit/qt/tests/hybridPixmap/widget.ui deleted file mode 100644 index 272d6a71f..000000000 --- a/Source/WebKit/qt/tests/hybridPixmap/widget.ui +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Widget</class> - <widget class="QWidget" name="Widget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>400</height> - </rect> - </property> - <property name="windowTitle"> - <string notr="true">Widget</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="WebView" name="webView" native="true"> - <property name="url" stdset="0"> - <url> - <string notr="true">about:blank</string> - </url> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="lbl1"> - <property name="text"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="lbl2"> - <property name="minimumSize"> - <size> - <width>120</width> - <height>30</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>120</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string notr="true">Image from Qt to HTML</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="lbl3"> - <property name="text"> - <string notr="true">Pixmap from Qt to HTML</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="lbl4"> - <property name="text"> - <string notr="true"/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11"/> - <customwidgets> - <customwidget> - <class>WebView</class> - <extends>QWidget</extends> - <header>widget.h</header> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> |