summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonatan <jonatan.palsson@pelagicore.com>2014-02-04 11:22:24 +0100
committerJonatan <jonatan.palsson@pelagicore.com>2014-02-04 11:22:24 +0100
commit0cdd47d68d3f22215df5fa14bdf251ce36aa05b9 (patch)
tree0d404d51132fbee87b57040920d6e900cbdd8744
parent42a3f04658080715c2dfc4ef7007d8a4c6c72f6b (diff)
parent5cde0d2baea92aa1a7614a1f1b26c17efedb35ee (diff)
downloadbrowser-poc-0cdd47d68d3f22215df5fa14bdf251ce36aa05b9.tar.gz
Merge branch 'wpw_new_api' of /home/git/repositories/jpalsson/genivi-browser-poc
-rw-r--r--browser/browser.cpp18
-rw-r--r--browser/browserview.cpp84
-rw-r--r--browser/browserview.h25
-rw-r--r--browser/unit-tests/browserdbus/browserdbus.pro20
-rw-r--r--browser/unit-tests/browserdbus/testbrowserdbus.cpp181
-rw-r--r--browser/unit-tests/browserdbus/testbrowserdbus.h44
-rw-r--r--browser/unit-tests/browserdbus/webpagegenerator.h37
-rw-r--r--browser/unit-tests/browserview/testbrowser.cpp178
-rw-r--r--browser/unit-tests/browserview/testbrowser.h (renamed from browser/unit-tests/testbrowser.h)2
-rw-r--r--browser/unit-tests/testbrowser.cpp136
-rw-r--r--browser/unit-tests/unit-tests.pro13
-rw-r--r--browser/webpagewindow.cpp47
-rw-r--r--browser/webpagewindow.h23
-rw-r--r--common/IWebPageWindow.xml292
-rw-r--r--common/browserdbus.cpp104
-rw-r--r--common/browserdbus.h31
-rw-r--r--testapp/qml/testapp/WebPageWindow.qml109
17 files changed, 1049 insertions, 295 deletions
diff --git a/browser/browser.cpp b/browser/browser.cpp
index a8315d0..706e510 100644
--- a/browser/browser.cpp
+++ b/browser/browser.cpp
@@ -38,12 +38,20 @@ conn::brw::ERROR_IDS browser::createPageWindow(int a_eDeviceId, const conn::brw:
windowhash.insert(a_hPageWindowHandle, bvi->window());
wpw->webitem = bvi;
- connect(bvi, SIGNAL(pageLoadStarted()), wpw, SLOT(browserStartLoading()));
- connect(bvi, SIGNAL(pageLoadFinished(bool)), wpw, SIGNAL(onLoadFinished(bool)));
- connect(bvi, SIGNAL(pageLoadFinished(bool)), wpw, SLOT(getUrlTitle()));
+ connect(bvi, SIGNAL(pageLoadFinished(bool)), wpw, SLOT(getUrlTitle()));
+ connect(ui, SIGNAL(inputText(QString)), this, SLOT(inputText(QString)));
+ connect(bvi, SIGNAL(pageLoadStarted()), wpw, SLOT(browserStartLoading()));
+ connect(bvi, SIGNAL(onVisibilityChanged(bool)), wpw, SIGNAL(onVisibilityChanged(bool)));
+ connect(bvi, SIGNAL(pageLoadFinished(bool)), wpw, SIGNAL(onLoadFinished(bool)));
+ connect(bvi, SIGNAL(onUrlChanged(QString)), wpw, SIGNAL(onUrlChanged(QString)));
+ connect(bvi, SIGNAL(onTitleChanged(QString)), wpw, SIGNAL(onTitleChanged(QString)));
+ connect(bvi, SIGNAL(onLinkClicked(QString)), wpw, SIGNAL(onLinkClicked(QString)));
+ connect(bvi, SIGNAL(onSelectionChanged(void)), wpw, SIGNAL(onSelectionChanged(void)));
+ connect(bvi, SIGNAL(onStatusTextChanged(QString)), wpw, SIGNAL(onStatusTextChanged(QString)));
+ connect(bvi, SIGNAL(onZoomFactorChanged(double)), wpw, SIGNAL(onZoomFactorChanged(double)));
connect(bvi, SIGNAL(onInputText(QString, QString, int, int, int, int, int)), ui, SLOT(inputTextReceived(QString, QString, int, int, int, int, int)));
- connect(this, SIGNAL(onPageWindowDestroyed(qlonglong)), wpw, SIGNAL(onClose()));
- connect(ui, SIGNAL(inputText(QString)), this, SLOT(inputText(QString)));
+ connect(this,SIGNAL(onPageWindowDestroyed(qlonglong)), wpw, SIGNAL(onClose()));
+ connect(bvi, SIGNAL(onScrollPositionChanged(uint,uint)), wpw, SIGNAL(onScrollPositionChanged(uint,uint)));
QString *webpagewindowservice = new QString("/Browser/IWebPageWindow" + QString::number(a_hPageWindowHandle));
qDebug() << *webpagewindowservice;
diff --git a/browser/browserview.cpp b/browser/browserview.cpp
index d06ba0e..7d31ba0 100644
--- a/browser/browserview.cpp
+++ b/browser/browserview.cpp
@@ -13,6 +13,7 @@
#include <QDebug>
#include <QWebFrame>
+#include <QWebPage>
#include <QCoreApplication>
#include "browserview.h"
@@ -27,13 +28,24 @@ BrowserView::BrowserView()
this->load("http://www.bmw.com");
+ this->installEventFilter(this);
+
setWindowFlags(Qt::FramelessWindowHint);
+ m_webview.page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+
+ connect(&m_webview, SIGNAL (loadStarted()), this, SIGNAL (pageLoadStarted ()));
+ connect(&m_webview, SIGNAL (statusBarMessage(QString)), this, SIGNAL (onStatusTextChanged(QString)));
+ connect(&m_webview, SIGNAL (loadFinished(bool)), this, SLOT (loadFinished (bool)));
+ connect(&m_webview, SIGNAL (loadProgress(int)), this, SLOT (loadProgress(int)));
+ connect(&m_webview, SIGNAL (urlChanged(QUrl)), this, SLOT (urlChanged(QUrl)));
+ connect(&m_webview, SIGNAL (titleChanged(QString)), this, SLOT (titleChanged(QString)));
+ connect(&m_webview, SIGNAL (linkClicked(QUrl)), this, SLOT (linkClicked(QUrl)));
+
+ connect(m_webview.page(), SIGNAL (selectionChanged(void)), this, SIGNAL(onSelectionChanged(void)));
- connect(&m_webview, SIGNAL (loadStarted()), this, SIGNAL (pageLoadStarted ()));
- connect(&m_webview, SIGNAL (loadFinished(bool)), this, SLOT (loadFinished (bool)));
- connect(&m_webview, SIGNAL (loadProgress(int)), this, SLOT (loadProgress(int)));
connect(&m_inputHandler, SIGNAL (onInputText(QString, QString, int, int, int, int, int)),
this, SIGNAL (onInputText(QString, QString, int, int, int, int, int)));
+ connect(&m_inputHandler, SIGNAL(onScroll(uint,uint)), this, SLOT(scrollPositionChanged(uint,uint)));
}
bool BrowserView::load(const QString &a_Url)
@@ -60,6 +72,11 @@ void BrowserView::loadFinished(bool ok)
" window.inputHandler.setCurrentFocus(e.target);"
"}, true);");
+ m_webview.page()->mainFrame()->evaluateJavaScript(
+ "document.addEventListener('scroll', function(){"
+ " window.inputHandler.setScrollPosition(window.pageXOffset, window.pageYOffset);"
+ "}, true);");
+
emit pageLoadFinished (ok);
}
@@ -112,3 +129,64 @@ QSize BrowserView::contentSize()
{
return this->viewport()->size();
}
+
+void BrowserView::urlChanged (QUrl url)
+{
+ QString strUrl = url.toString();
+ if (strUrl.compare("") != 0)
+ emit onUrlChanged (strUrl);
+}
+
+void BrowserView::titleChanged (QString title)
+{
+ if (title.compare("") != 0)
+ emit onTitleChanged (title);
+}
+
+void BrowserView::linkClicked(QUrl url) {
+ QString strUrl = url.toString();
+ this->load(strUrl);
+ emit onLinkClicked(strUrl);
+}
+
+bool BrowserView::eventFilter(QObject *obj, QEvent *event)
+{
+ if (event->type() == QEvent::Show)
+ emit onVisibilityChanged(true);
+ else if (event->type() == QEvent::Hide)
+ emit onVisibilityChanged(false);
+
+ return QGraphicsView::eventFilter(obj, event);
+}
+
+void BrowserView::setZoomFactor(double factor)
+{
+ m_webview.setZoomFactor(factor);
+ emit onZoomFactorChanged (factor);
+}
+
+double BrowserView::getZoomFactor()
+{
+ return m_webview.zoomFactor();
+}
+
+void BrowserView::scrollPositionChanged(uint x, uint y)
+{
+ m_scrollPositionX = x;
+ m_scrollPositionY = y;
+ emit onScrollPositionChanged(x,y);
+}
+
+void BrowserView::setScrollPosition(uint x, uint y)
+{
+ QString cmd = QString("window.scrollTo(%1,%2);").arg(QString::number(x), QString::number(y));
+ m_webview.page()->mainFrame()->evaluateJavaScript(cmd);
+ m_scrollPositionX = x;
+ m_scrollPositionY = y;
+}
+
+void BrowserView::getScrollPosition(uint &x, uint &y)
+{
+ x = m_scrollPositionX;
+ y = m_scrollPositionY;
+}
diff --git a/browser/browserview.h b/browser/browserview.h
index e4cac45..32f9f9d 100644
--- a/browser/browserview.h
+++ b/browser/browserview.h
@@ -26,6 +26,9 @@
class InputHandler : public QObject {
Q_OBJECT
public slots:
+ void setScrollPosition (const int &x, const int &y) {
+ emit onScroll ((uint)x,(uint)y);
+ }
void setCurrentFocus (const QWebElement &elem) {
emit onInputText (elem.attribute("name"), elem.attribute("value"),
elem.attribute("type", "0").toInt(),
@@ -39,6 +42,7 @@ public slots:
signals:
void onInputText(QString name, QString value, int type, int maxlength,
int max, int min, int step);
+ void onScroll(uint x, uint y);
private:
QWebElement *m_elem;
@@ -51,7 +55,7 @@ public:
BrowserView();
bool load(const QString &a_Url);
int getProgress() { return m_currentProgress; }
- QString getURL() { return m_webview.url().toString(); }
+ QString getUrl() { return m_webview.url().toString(); }
const QString getTitle() { return m_webview.title(); }
void goBack() { m_webview.back(); }
void goForward() { m_webview.forward(); }
@@ -60,6 +64,10 @@ public:
void scroll (conn::brw::SCROLL_DIRECTION dir, conn::brw::SCROLL_TYPE type);
void inputText (QString input);
QSize contentSize();
+ void setZoomFactor(double);
+ double getZoomFactor();
+ void getScrollPosition(uint&, uint&);
+ void setScrollPosition(uint, uint);
signals:
void pageLoadStarted();
@@ -67,18 +75,33 @@ signals:
void pageLoadProgress(int);
void onInputText(QString name, QString value, int type, int maxlength,
int max, int min, int step);
+ void onUrlChanged(QString url);
+ void onTitleChanged(QString title);
+ void onLinkClicked(QString);
+ void onSelectionChanged();
+ void onStatusTextChanged(QString);
+ void onVisibilityChanged(bool);
+ void onScrollPositionChanged(uint,uint);
+ void onZoomFactorChanged(double);
protected:
virtual void resizeEvent (QResizeEvent *event);
+ virtual bool eventFilter (QObject *obj, QEvent *evt);
protected slots:
void loadProgress(int);
void loadFinished(bool);
+ void urlChanged(QUrl);
+ void titleChanged(QString);
+ void linkClicked(QUrl);
+ void scrollPositionChanged(uint x, uint y);
private:
QGraphicsWebView m_webview;
InputHandler m_inputHandler;
int m_currentProgress;
+ uint m_scrollPositionX;
+ uint m_scrollPositionY;
};
diff --git a/browser/unit-tests/browserdbus/browserdbus.pro b/browser/unit-tests/browserdbus/browserdbus.pro
new file mode 100644
index 0000000..dd1bd0e
--- /dev/null
+++ b/browser/unit-tests/browserdbus/browserdbus.pro
@@ -0,0 +1,20 @@
+######################################################################
+# Automatically generated by qmake (3.0) Mon Jan 20 12:56:16 2014
+######################################################################
+
+CONFIG += qtestlib debug qt
+TEMPLATE = app
+TARGET = browserdbus-tests
+INCLUDEPATH += . ../../../common/
+QT += dbus webkitwidgets
+
+my_dbus_interfaces.files += ../../../common/IBookmarkManager.xml \
+ ../../../common/IUserInput.xml \
+ ../../../common/IWebPageWindow.xml \
+ ../../../common/IBrowser.xml
+my_dbus_interfaces.header_flags = -i ../../../common/browserdefs.h
+DBUS_INTERFACES += my_dbus_interfaces
+
+# Input
+HEADERS += testbrowserdbus.h webpagegenerator.h ../../../common/browserdbus.h ../../../common/bookmark.h
+SOURCES += testbrowserdbus.cpp ../../../common/browserdbus.cpp ../../../common/bookmark.cpp
diff --git a/browser/unit-tests/browserdbus/testbrowserdbus.cpp b/browser/unit-tests/browserdbus/testbrowserdbus.cpp
new file mode 100644
index 0000000..393a3a7
--- /dev/null
+++ b/browser/unit-tests/browserdbus/testbrowserdbus.cpp
@@ -0,0 +1,181 @@
+/**
+ * Copyright (C) 2014, Pelagicore
+ *
+ * Author: Jonatan Palsson <jonatan.palsson@pelagicore.com>
+ *
+ * This file is part of the GENIVI project Browser Proof-Of-Concept
+ * For further information, see http://genivi.org/
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <QSignalSpy>
+#include <QDebug>
+#include <QProcess>
+
+#include "testbrowserdbus.h"
+
+//////////// Setup & teardown /////////////
+
+void TestBrowserDBus::initTestCase () {
+ m_bdb = new BrowserDbus (this);
+ m_bdb->connectdbussession("1");
+ m_pagefile = new QTemporaryFile("XXXXXX.html");
+ m_pagefile->open();
+ m_pagefile->write(WebPageGenerator::testPageContents());
+ m_pagefile->flush();
+}
+
+void TestBrowserDBus::cleanupTestCase() {
+ m_pagefile->remove();
+ delete m_pagefile;
+ delete m_bdb;
+}
+
+/////////////// Test cases ///////////////
+
+/* Verify that our dbus-functions give sane values even when the PageWindow has
+ * not yet been initialized */
+void TestBrowserDBus::testCallUninitialized() {
+ QVERIFY(m_bdb->connected());
+ QVERIFY (m_bdb->getUrl().compare("") == 0);
+ QVERIFY (m_bdb->getTitle().compare("") == 0);
+}
+
+void TestBrowserDBus::testGetTitle() {
+ QSignalSpy spy (m_bdb, SIGNAL (pageloadingChanged(void)));
+ m_bdb->createPageWindow(1,0,0,10,10);
+ spy.wait(1000);
+ QVERIFY (m_bdb->getTitle().compare("") != 0);
+}
+
+void TestBrowserDBus::testGetsNotifiedOnUrlChange() {
+ m_bdb->createPageWindow(1,0,0,10,10);
+ QSignalSpy spy (m_bdb, SIGNAL (urlChanged (QString)));
+ m_bdb->loadurl(testFileUrl());
+
+ spy.wait(1000);
+ QVERIFY(spy.value(0).value(0).toString().contains(testFileUrl()));
+}
+
+void TestBrowserDBus::testGetsNotifiedOnTitleChange() {
+ m_bdb->createPageWindow(1,0,0,10,10);
+ QSignalSpy spy (m_bdb, SIGNAL (titleChanged (QString)));
+ m_bdb->loadurl(testFileUrl());
+
+ spy.wait(10000);
+ qDebug() << spy.value(0).value(0).toString();
+ QVERIFY(spy.value(0).value(0).toString().contains("Browser PoC"));
+}
+
+void TestBrowserDBus::testGetsNotifiedWhenLinkIsClicked() {
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (linkClicked (QString)));
+ m_bdb->loadurl(testFileUrl());
+
+ QTest::qSleep(200);
+ QProcess::execute("xdotool mousemove 100 100");
+ QProcess::execute("xdotool click 1");
+ QVERIFY(spy.wait(10000));
+}
+
+void TestBrowserDBus::testGetsNotifiedWhenSelectionChanges() {
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (selectionChanged ()));
+ m_bdb->loadurl(testFileUrl());
+
+ QTest::qSleep(200);
+ QProcess::execute("xdotool mousemove 100 200");
+ QProcess::execute("xdotool mousedown 1");
+ QProcess::execute("xdotool mousemove 100 300");
+ QProcess::execute("xdotool mouseup 1");
+ QVERIFY(spy.wait(10000));
+}
+
+void TestBrowserDBus::testGetsNotifiedWhenStatusBarChanges() {
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (onStatusTextChanged (QString)));
+ m_bdb->loadurl(testFileUrl());
+ QTest::qSleep(200);
+ QProcess::execute("xdotool mousemove 100 400");
+ QProcess::execute("xdotool click 1");
+
+ bool success = false;
+ for (int i = 0; i < 10; i++){
+ spy.wait(1000);
+ if (spy.last().value(0).toString().contains("browser-poc")) {
+ success = true;
+ break;
+ }
+ }
+
+ QVERIFY(success);
+}
+
+void TestBrowserDBus::testGetsNotifiedWhenVisibilityChanges() {
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (onVisibilityChanged (bool)));
+ m_bdb->setVisible(false);
+ QVERIFY(spy.wait(1000));
+ QVERIFY(spy.last().value(0).toBool() == false);
+ m_bdb->setVisible(true);
+ QVERIFY(spy.wait(1000));
+ QVERIFY(spy.last().value(0).toBool() == true);
+}
+
+void TestBrowserDBus::testGetsNotifiedWhenScrollingChanges() {
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (onScrollPositionChanged (uint,uint)));
+ m_bdb->loadurl(testFileUrl());
+ QTest::qSleep(200);
+ QProcess::execute("xdotool mousemove 100 200");
+ QProcess::execute("xdotool click 1");
+ QProcess::execute("xdotool click 5");
+ QVERIFY(spy.wait(10000));
+ QProcess::execute("xdotool click 4");
+ QVERIFY(spy.wait(10000));
+}
+
+void TestBrowserDBus::testCanSetAndGetZoomFactor() {
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (onZoomFactorChanged (double)));
+ m_bdb->loadurl(testFileUrl());
+
+ m_bdb->setZoomFactor(2);
+ QVERIFY(m_bdb->getZoomFactor() == 2);
+ QVERIFY(spy.wait(10000));
+ QVERIFY(spy.last().value(0).toDouble() == 2);
+
+ m_bdb->setZoomFactor(1);
+ QVERIFY(m_bdb->getZoomFactor() == 1);
+ QVERIFY(spy.wait(10000));
+ QVERIFY(spy.last().value(0).toDouble() == 1);
+}
+
+void TestBrowserDBus::testCanSetAndGetScrollPosition() {
+ uint x = 0, y = 0;
+ uint setX = 0, setY = 0;
+ m_bdb->createPageWindow(1,0,0,800,600);
+ QSignalSpy spy (m_bdb, SIGNAL (onScrollPositionChanged (uint, uint)));
+ m_bdb->loadurl(testFileUrl());
+
+ QTest::qSleep(300);
+
+ setX = 0; setY = 30;
+ m_bdb->setScrollPosition(setX, setY);
+ m_bdb->getScrollPosition(x,y);
+ QVERIFY(y == 30);
+ QVERIFY(spy.wait(10000));
+ QVERIFY(spy.last().value(1).toUInt() == 30);
+
+ setX = 0; setY = 0;
+ m_bdb->setScrollPosition(setX, setY);
+ m_bdb->getScrollPosition(x,y);
+ QVERIFY(y == 0);
+ QVERIFY(spy.wait(10000));
+ QVERIFY(spy.last().value(1).toUInt() == 0);
+}
+
+QTEST_MAIN (TestBrowserDBus);
diff --git a/browser/unit-tests/browserdbus/testbrowserdbus.h b/browser/unit-tests/browserdbus/testbrowserdbus.h
new file mode 100644
index 0000000..d362402
--- /dev/null
+++ b/browser/unit-tests/browserdbus/testbrowserdbus.h
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2014, Pelagicore
+ *
+ * Author: Jonatan Palsson <jonatan.palsson@pelagicore.com>
+ *
+ * This file is part of the GENIVI project Browser Proof-Of-Concept
+ * For further information, see http://genivi.org/
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <QtTest/QtTest>
+#include "../../../common/browserdbus.h"
+#include "webpagegenerator.h"
+
+class TestBrowserDBus: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void testCallUninitialized();
+ void testGetTitle();
+ void testGetsNotifiedOnUrlChange();
+ void testGetsNotifiedOnTitleChange();
+ void testGetsNotifiedWhenLinkIsClicked();
+ void testGetsNotifiedWhenSelectionChanges();
+ void testGetsNotifiedWhenStatusBarChanges();
+ void testGetsNotifiedWhenVisibilityChanges();
+ void testGetsNotifiedWhenScrollingChanges();
+ void testCanSetAndGetZoomFactor();
+ void testCanSetAndGetScrollPosition();
+
+private:
+ QString testFileUrl() {
+ return (QString ("file://") + m_pagefile->fileName());
+ }
+ BrowserDbus *m_bdb = NULL;
+ QTemporaryFile *m_pagefile = NULL;
+};
diff --git a/browser/unit-tests/browserdbus/webpagegenerator.h b/browser/unit-tests/browserdbus/webpagegenerator.h
new file mode 100644
index 0000000..e656b45
--- /dev/null
+++ b/browser/unit-tests/browserdbus/webpagegenerator.h
@@ -0,0 +1,37 @@
+/**
+ * Copyright (C) 2014, Pelagicore
+ *
+ * Author: Jonatan Palsson <jonatan.palsson@pelagicore.com>
+ *
+ * This file is part of the GENIVI project Browser Proof-Of-Concept
+ * For further information, see http://genivi.org/
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+class WebPageGenerator {
+
+public:
+ static char *testPageContents()
+ {
+ return (
+ "<HTML>"
+ " <HEAD><TITLE>Browser PoC test page</TITLE></HEAD>"
+ " <BODY>"
+ " <A HREF='http://www.google.com'>"
+ " <DIV style='height:100; width:100; background-color:gray'>Go to google</DIV>"
+ " </A>"
+ " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ac dignissim leo. Vivamus euismod tortor eu varius molestie. Proin non egestas mauris. Suspendisse nec fringilla mauris, sed dapibus mi. Mauris suscipit rutrum turpis non venenatis. Nunc quis dolor id massa dignissim rutrum. Praesent pretium enim vitae metus placerat, sed sodales elit blandit. Sed volutpat magna neque, ac mollis velit ullamcorper et. Quisque lorem dolor, suscipit mattis mi vitae, euismod cursus magna. Proin at commodo tortor, vitae convallis ipsum. Suspendisse potenti. Vivamus leo metus, feugiat at elit eu, ultricies mattis ipsum. Ut eros risus, facilisis at scelerisque a, hendrerit id odio. Quisque sapien erat, tristique vitae erat non, venenatis elementum leo. Donec at nisi justo. Integer at fringilla ante, in scelerisque risus. Praesent a leo orci. Donec urna eros, molestie non erat ut, pellentesque faucibus odio. Proin in porttitor erat. Duis ac justo massa. Donec nec augue quis nibh feugiat vestibulum. Morbi tortor velit, malesuada nec nulla ac, semper vehicula"
+ " <DIV style='height:100; width:100; background-color:gray'"
+ " onClick=\"JavaScript:window.status='browser-poc';\" >"
+ " Set status bar text"
+ " </DIV>"
+ " <DIV style='height:900;width:900;'></DIV>"
+ " </BODY>"
+ "</HTML>"
+ );
+
+ }
+};
diff --git a/browser/unit-tests/browserview/testbrowser.cpp b/browser/unit-tests/browserview/testbrowser.cpp
new file mode 100644
index 0000000..7db92dc
--- /dev/null
+++ b/browser/unit-tests/browserview/testbrowser.cpp
@@ -0,0 +1,178 @@
+#include <QSignalSpy>
+#include <QDebug>
+#include <QMainWindow>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+
+#include "testbrowser.h"
+#include "../browserview.h"
+
+/////////////// Test cases ///////////////
+
+void TestBrowser::testCanCreate()
+{
+ BrowserView *bvi = new BrowserView();
+ QVERIFY (bvi);
+}
+
+void TestBrowser::testCanLoadWebpage()
+{
+ /*
+ FIXME: It seems like the pageLoadStarted signal is not triggered
+ correctly
+ */
+ BrowserView bvi;
+
+ bvi.show();
+
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadStarted()));
+ bvi.load("http://www.pelagicore.com");
+ QVERIFY (spy.wait(1000));
+}
+
+void TestBrowser::testCanFinishLoadingWebpage()
+{
+ BrowserView bvi;
+
+ bvi.show();
+
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ bvi.load("http://www.pelagicore.com");
+ QVERIFY (spy.wait(10000));
+}
+
+void TestBrowser::testProgressIncreases ()
+{
+ BrowserView bvi;
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadProgress(int)));
+
+ bvi.load("http://www.pelagicore.com");
+ bvi.show();
+
+ spy.wait(1000);
+ float prg = bvi.getProgress();
+ QVERIFY(prg > 0);
+}
+
+void TestBrowser::testBack ()
+{
+ BrowserView bvi;
+ bvi.show();
+
+ bvi.load("http://www.pelagicore.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(10000));
+ }
+
+ bvi.load("http://www.google.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+
+ bvi.goBack();
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+
+ QVERIFY(bvi.getUrl().contains("pelagicore"));
+}
+
+void TestBrowser::testForward ()
+{
+ BrowserView bvi;
+ bvi.show();
+
+ bvi.load("http://www.pelagicore.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+ QVERIFY(bvi.getUrl().contains("pelagicore"));
+
+ bvi.load("http://www.google.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+
+ bvi.goBack();
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+ bvi.goForward();
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+
+ QVERIFY(bvi.getUrl().contains("google"));
+}
+
+void TestBrowser::testReload ()
+{
+ BrowserView bvi;
+ bvi.show();
+
+ bvi.load("http://www.pelagicore.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+ bvi.pageReload();
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ QVERIFY(spy.wait(1000));
+ }
+
+ QVERIFY(bvi.getUrl().contains("pelagicore"));
+}
+
+//void TestBrowser::testStop () {} //FIXME: How should this be tested..?
+
+void TestBrowser::testGetTitle()
+{
+ BrowserView bvi;
+ QString before = "";
+ QString after = "";
+ bvi.show();
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ spy.wait(1000);
+ }
+
+ before = bvi.getTitle();
+ bvi.load("http://www.pelagicore.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ spy.wait(1000);
+ }
+ after = bvi.getTitle();
+ QVERIFY (before.compare(after) != 0);
+}
+
+void TestBrowser::testGetUrl()
+{
+ BrowserView bvi;
+ QString before = "";
+ QString after = "";
+ bvi.show();
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ spy.wait(1000);
+ }
+
+ before = bvi.getUrl();
+ bvi.load("http://www.pelagicore.com");
+ {
+ QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
+ spy.wait(1000);
+ }
+ after = bvi.getUrl();
+ QVERIFY (before.compare(after) != 0);
+}
+
+QTEST_MAIN (TestBrowser);
diff --git a/browser/unit-tests/testbrowser.h b/browser/unit-tests/browserview/testbrowser.h
index 271be7b..6d6cc54 100644
--- a/browser/unit-tests/testbrowser.h
+++ b/browser/unit-tests/browserview/testbrowser.h
@@ -12,4 +12,6 @@ private slots:
void testBack();
void testForward();
void testReload();
+ void testGetTitle();
+ void testGetUrl();
};
diff --git a/browser/unit-tests/testbrowser.cpp b/browser/unit-tests/testbrowser.cpp
deleted file mode 100644
index a2b98a0..0000000
--- a/browser/unit-tests/testbrowser.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#include <QSignalSpy>
-#include <QDebug>
-#include <QMainWindow>
-#include <QGraphicsScene>
-#include <QGraphicsView>
-
-#include "testbrowser.h"
-#include "../browserview.h"
-
-/////////////// Test cases ///////////////
-
-void TestBrowser::testCanCreate()
-{
- BrowserView *bvi = new BrowserView();
- QVERIFY (bvi);
-}
-
-void TestBrowser::testCanLoadWebpage()
-{
- /*
- FIXME: It seems like the pageLoadStarted signal is not triggered
- correctly
- */
- BrowserView bvi;
-
- bvi.show();
-
- QSignalSpy spy (&bvi, SIGNAL(pageLoadStarted()));
- bvi.load("http://www.pelagicore.com");
- QVERIFY (spy.wait(1000));
-}
-
-void TestBrowser::testCanFinishLoadingWebpage()
-{
- BrowserView bvi;
-
- bvi.show();
-
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- bvi.load("http://www.pelagicore.com");
- QVERIFY (spy.wait(10000));
-}
-
-void TestBrowser::testProgressIncreases ()
-{
- BrowserView bvi;
- QSignalSpy spy (&bvi, SIGNAL(pageLoadProgress(int)));
-
- bvi.load("http://www.pelagicore.com");
- bvi.show();
-
- spy.wait(1000);
- float prg = bvi.getProgress();
- QVERIFY(prg > 0);
-}
-
-void TestBrowser::testBack ()
-{
- BrowserView bvi;
- bvi.show();
-
- bvi.load("http://www.pelagicore.com");
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(10000));
- }
-
- bvi.load("http://www.google.com");
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
-
- bvi.goBack();
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
-
- QVERIFY(bvi.getURL().contains("pelagicore"));
-}
-
-void TestBrowser::testForward ()
-{
- BrowserView bvi;
- bvi.show();
-
- bvi.load("http://www.pelagicore.com");
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
- QVERIFY(bvi.getURL().contains("pelagicore"));
-
- bvi.load("http://www.google.com");
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
-
- bvi.goBack();
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
- bvi.goForward();
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
-
- QVERIFY(bvi.getURL().contains("google"));
-}
-
-void TestBrowser::testReload ()
-{
- BrowserView bvi;
- bvi.show();
-
- bvi.load("http://www.pelagicore.com");
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
- bvi.pageReload();
- {
- QSignalSpy spy (&bvi, SIGNAL(pageLoadFinished(bool)));
- QVERIFY(spy.wait(1000));
- }
-
- QVERIFY(bvi.getURL().contains("pelagicore"));
-}
-
-//void TestBrowser::testStop () {} //FIXME: How should this be tested..?
-
-QTEST_MAIN (TestBrowser);
diff --git a/browser/unit-tests/unit-tests.pro b/browser/unit-tests/unit-tests.pro
deleted file mode 100644
index 408a682..0000000
--- a/browser/unit-tests/unit-tests.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-######################################################################
-# Automatically generated by qmake (3.0) Mon Jan 20 12:56:16 2014
-######################################################################
-
-CONFIG += qtestlib
-TEMPLATE = app
-TARGET = unit-tests
-INCLUDEPATH += .
-QT += dbus webkitwidgets
-
-# Input
-HEADERS += testbrowser.h ../browserview.h
-SOURCES += testbrowser.cpp ../browserview.cpp
diff --git a/browser/webpagewindow.cpp b/browser/webpagewindow.cpp
index 6023ef3..b37fef6 100644
--- a/browser/webpagewindow.cpp
+++ b/browser/webpagewindow.cpp
@@ -27,6 +27,9 @@ void webpagewindow::browserStartLoading() {
qDebug() << __PRETTY_FUNCTION__;
emit onLoadStarted();
+ if (progresstimer)
+ delete progresstimer;
+
progresstimer = new QTimer(this);
connect(progresstimer, SIGNAL(timeout()), this, SLOT(reportprogress()));
progresstimer->start(250);
@@ -37,20 +40,28 @@ void webpagewindow::reportprogress() {
int progress;
progress = webitem->getProgress();
- qDebug() << progress;
emit onLoadProgress(progress);
if(progress >= 100)
progresstimer->stop();
+
}
void webpagewindow::getUrlTitle() {
- qDebug() << webitem->getURL() << webitem->getTitle();
+ qDebug() << webitem->getUrl() << webitem->getTitle();
- localurl = webitem->getURL();
+ localurl = webitem->getUrl();
localtitle = webitem->getTitle();
}
+conn::brw::ERROR_IDS webpagewindow::activate() {
+ return conn::brw::EID_NOT_IMPLEMENTED;
+}
+
+conn::brw::ERROR_IDS webpagewindow::getPageIcon(QString iconPath, QString iconFilePath) {
+ return conn::brw::EID_NOT_IMPLEMENTED;
+}
+
conn::brw::ERROR_IDS webpagewindow::back() {
qDebug() << __PRETTY_FUNCTION__;
@@ -161,7 +172,6 @@ conn::brw::ERROR_IDS webpagewindow::scroll(conn::brw::SCROLL_DIRECTION a_eScroll
emit setOutputWebview(message().path());
-
webitem->scroll(a_eScrollDirection, a_eScrollType);
return conn::brw::EID_NO_ERROR;
}
@@ -192,12 +202,33 @@ conn::brw::ERROR_IDS webpagewindow::stop() {
return conn::brw::EID_NO_ERROR;
}
-conn::brw::ERROR_IDS webpagewindow::getCurrentUrlTitle(QString &url, QString &title) {
+QString webpagewindow::getTitle() {
qDebug() << __PRETTY_FUNCTION__;
- url = localurl;
- title = localtitle;
-
emit urlTitleReady();
+ return webitem->getTitle();
+}
+
+QString webpagewindow::getUrl() {
+ return webitem->getUrl();
+}
+
+conn::brw::ERROR_IDS webpagewindow::select(){}
+
+double webpagewindow::getZoomFactor() {
+ return webitem->getZoomFactor();
+}
+conn::brw::ERROR_IDS webpagewindow::setZoomFactor(double &zoomFactor) {
+ webitem->setZoomFactor(zoomFactor);
+ return conn::brw::EID_NO_ERROR;
+}
+
+conn::brw::ERROR_IDS webpagewindow::getScrollPosition(uint &x, uint &y) {
+ webitem->getScrollPosition(x,y);
+ return conn::brw::EID_NO_ERROR;
+}
+
+conn::brw::ERROR_IDS webpagewindow::setScrollPosition(uint &x, uint &y) {
+ webitem->setScrollPosition(x,y);
return conn::brw::EID_NO_ERROR;
}
diff --git a/browser/webpagewindow.h b/browser/webpagewindow.h
index 2bbb83e..82abfdd 100644
--- a/browser/webpagewindow.h
+++ b/browser/webpagewindow.h
@@ -35,8 +35,17 @@ signals:
void onLoadStarted();
void onLoadFinished(bool a_fState);
void onLoadProgress(int a_i32Progress);
+ void onUrlChanged(QString);
void onClose();
void setOutputWebview(QString viewpath);
+ void onTitleChanged(QString);
+ void onLinkClicked(QString);
+ void onSelectionChanged(void);
+ void onStatusTextChanged(QString);
+ void onVisibilityChanged(bool);
+ void onScrollPositionChanged(uint,uint);
+ void onZoomFactorChanged(double);
+
public Q_SLOTS:
conn::brw::ERROR_IDS back();
@@ -51,14 +60,24 @@ public Q_SLOTS:
conn::brw::ERROR_IDS setGeometry(const conn::brw::Rect & a_sRect);
conn::brw::ERROR_IDS setVisible(bool a_bVisible);
conn::brw::ERROR_IDS stop();
- conn::brw::ERROR_IDS getCurrentUrlTitle(QString &url, QString &title);
+ conn::brw::ERROR_IDS activate();
+ conn::brw::ERROR_IDS getPageIcon(QString iconPath, QString iconFilePath);
+
+ conn::brw::ERROR_IDS getScrollPosition(uint &posX, uint &posY);
+ QString getTitle();
+ QString getUrl();
+
+ double getZoomFactor();
+ conn::brw::ERROR_IDS select();
+ conn::brw::ERROR_IDS setScrollPosition(uint &posX, uint &posY);
+ conn::brw::ERROR_IDS setZoomFactor(double &zoomFactor);
void browserStartLoading();
void reportprogress();
void getUrlTitle();
private:
- QTimer *progresstimer;
+ QTimer *progresstimer = NULL;
};
#endif // WEBPAGEWINDOW_H
diff --git a/common/IWebPageWindow.xml b/common/IWebPageWindow.xml
index fbd5fed..faf904c 100644
--- a/common/IWebPageWindow.xml
+++ b/common/IWebPageWindow.xml
@@ -1,105 +1,187 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-
-<node>
- <interface name="conn.brw.IWebPageWindow">
- <version>1.0.0</version>
-
- <doc>
- <line>Page view</line>
- </doc>
-
- <method name="getBrowserActionsState">
- <arg name="retval" type="(i)" direction="out"/>
- <arg name="a_browserActionsState" type="(yyyyyyy(yyyy)(yyyy)(yyyy))" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="conn::brw::BrowserActions" />
- </method>
-
- <method name="getContentSize">
- <arg name="retval" type="(i)" direction="out"/>
- <arg name="a_u32Width" type="u" direction="out"/>
- <arg name="a_u32Height" type="u" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="getGeometry">
- <arg name="retval" type="(i)" direction="out"/>
- <arg name="a_sRect" type="(iiii)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="conn::brw::Rect" />
- </method>
-
- <method name="setGeometry">
- <arg name="a_sRect" type="(iiii)" direction="in"/>
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="const conn::brw::Rect &amp;" />
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="getVisible">
- <arg name="retval" type="b" direction="out"/>
- </method>
-
- <method name="setVisible">
- <arg name="a_bVisible" type="b" direction="in"/>
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="load">
- <arg name="a_Url" type="s" direction="in"/>
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="back">
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="forward">
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="reload">
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="stop">
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="scroll">
- <arg name="a_eScrollDirection" type="(i)" direction="in"/>
- <arg name="a_eScrollType" type="(i)" direction="in"/>
- <arg name="retval" type="(i)" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="conn::brw::SCROLL_DIRECTION" />
- <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="conn::brw::SCROLL_TYPE" />
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <method name="getCurrentUrlTitle">
- <arg name="retval" type="(i)" direction="out"/>
- <arg name="strCurrentUrl" type="s" direction="out"/>
- <arg name="strCurrentTitle" type="s" direction="out"/>
- <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
- </method>
-
- <signal name="onLoadStarted">
- </signal>
-
- <signal name="onLoadProgress">
- <arg name="a_i32Progress" type="i"/>
- </signal>
-
- <signal name="onLoadFinished">
- <arg name="a_fState" type="b"/>
- </signal>
-
- <signal name="onClose"/>
-
- </interface>
-</node>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+
+<node>
+ <interface name="conn.brw.IWebPageWindow">
+ <version>1.0.0</version>
+
+ <doc>
+ <line>Page view</line>
+ </doc>
+
+ <method name="getBrowserActionsState">
+ <arg name="retval" type="(i)" direction="out"/>
+ <arg name="a_browserActionsState" type="(yyyyyyy(yyyy)(yyyy)(yyyy))" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="conn::brw::BrowserActions" />
+ </method>
+
+ <method name="getContentSize">
+ <arg name="retval" type="(i)" direction="out"/>
+ <arg name="a_u32Width" type="u" direction="out"/>
+ <arg name="a_u32Height" type="u" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="getGeometry">
+ <arg name="retval" type="(i)" direction="out"/>
+ <arg name="a_sRect" type="(iiii)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="conn::brw::Rect" />
+ </method>
+
+ <method name="setGeometry">
+ <arg name="a_sRect" type="(iiii)" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="const conn::brw::Rect &amp;" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="getScrollPosition">
+ <arg name="retval" type="(i)" direction="out"/>
+ <arg name="a_u32ScrollPosX" type="u" direction="out"/>
+ <arg name="a_u32ScrollPosY" type="u" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="setScrollPosition">
+ <arg name="a_u32ScrollPosX" type="u" direction="in"/>
+ <arg name="a_u32ScrollPosY" type="u" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="getPageIcon">
+ <arg name="a_strIconPath" type="s" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <arg name="a_strIconFilePath" type="s" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="activate">
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="getVisible">
+ <arg name="retval" type="b" direction="out"/>
+ </method>
+
+ <method name="setVisible">
+ <arg name="a_bVisible" type="b" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="getTitle">
+ <arg name="retval" type="s" direction="out"/>
+ </method>
+
+ <method name="getUrl">
+ <arg name="retval" type="s" direction="out"/>
+ </method>
+
+ <method name="getZoomFactor">
+ <arg name="retval" type="d" direction="out"/>
+ </method>
+
+ <method name="setZoomFactor">
+ <arg name="a_fZoomFactor" type="d" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="load">
+ <arg name="a_Url" type="s" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="back">
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="forward">
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="reload">
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="stop">
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="select">
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <method name="scroll">
+ <arg name="a_eScrollDirection" type="(i)" direction="in"/>
+ <arg name="a_eScrollType" type="(i)" direction="in"/>
+ <arg name="retval" type="(i)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="conn::brw::SCROLL_DIRECTION" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="conn::brw::SCROLL_TYPE" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="conn::brw::ERROR_IDS" />
+ </method>
+
+ <signal name="onActionStateChanged">
+ <arg name="a_u32BrowserActionsChanageMask" type="u"/>
+ </signal>
+
+ <signal name="onContentSizeChanged">
+ <arg name="a_u32Width" type="u"/>
+ <arg name="a_u32Height" type="u"/>
+ </signal>
+
+ <signal name="onScrollPositionChanged">
+ <arg name="a_u32ScrollPosX" type="u"/>
+ <arg name="a_u32ScrollPosY" type="u"/>
+ </signal>
+
+ <signal name="onVisibilityChanged">
+ <arg name="a_bVisibility" type="b"/>
+ </signal>
+
+ <signal name="onZoomFactorChanged">
+ <arg name="a_fZoomFactor" type="d"/>
+ </signal>
+
+ <signal name="onLinkClicked">
+ <arg name="a_strUrl" type="s"/>
+ </signal>
+
+ <signal name="onLoadStarted">
+ </signal>
+
+ <signal name="onLoadProgress">
+ <arg name="a_i32Progress" type="i"/>
+ </signal>
+
+ <signal name="onLoadFinished">
+ <arg name="a_fState" type="b"/>
+ </signal>
+
+ <signal name="onTitleChanged">
+ <arg name="a_strTitle" type="s"/>
+ </signal>
+
+ <signal name="onStatusTextChanged">
+ <arg name="a_strText" type="s"/>
+ </signal>
+
+ <signal name="onUrlChanged">
+ <arg name="a_strUrl" type="s"/>
+ </signal>
+
+ <signal name="onSelectionChanged"/>
+
+ <signal name="onClose"/>
+
+ </interface>
+</node>
diff --git a/common/browserdbus.cpp b/common/browserdbus.cpp
index 3b2d740..b574bdb 100644
--- a/common/browserdbus.cpp
+++ b/common/browserdbus.cpp
@@ -187,10 +187,18 @@ void BrowserDbus::createPageWindow(int deviceid, int x, int y, int width, int he
if(!actualtab->isValid())
qDebug() << "failed create object /Browser/IWebPageWindow*";
- connect(actualtab, SIGNAL(onLoadStarted()), this, SLOT(pageloadingstarted()));
- connect(actualtab, SIGNAL(onLoadFinished(bool)), this, SLOT(pageloadingfinished(bool)));
- connect(actualtab, SIGNAL(onLoadProgress(int)), this, SLOT(pageloadingprogress(int)));
- connect(actualtab, SIGNAL(onClose()), this, SLOT(WindowClosed()));
+ connect(actualtab, SIGNAL(onLoadStarted()), this, SLOT(pageloadingstarted()));
+ connect(actualtab, SIGNAL(onLoadFinished(bool)), this, SLOT(pageloadingfinished(bool)));
+ connect(actualtab, SIGNAL(onLoadProgress(int)), this, SLOT(pageloadingprogress(int)));
+ connect(actualtab, SIGNAL(onClose()), this, SLOT(WindowClosed()));
+ connect(actualtab, SIGNAL(onUrlChanged(QString)), this, SIGNAL(urlChanged(QString)));
+ connect(actualtab, SIGNAL(onTitleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ connect(actualtab, SIGNAL(onLinkClicked(QString)), this, SIGNAL(linkClicked(QString)));
+ connect(actualtab, SIGNAL(onSelectionChanged(void)), this, SIGNAL(selectionChanged(void)));
+ connect(actualtab, SIGNAL(onStatusTextChanged(QString)), this, SIGNAL(onStatusTextChanged(QString)));
+ connect(actualtab, SIGNAL(onVisibilityChanged(bool)), this, SIGNAL(onVisibilityChanged(bool)));
+ connect(actualtab, SIGNAL(onScrollPositionChanged(uint,uint)), this, SIGNAL(onScrollPositionChanged(uint,uint)));
+ connect(actualtab, SIGNAL(onZoomFactorChanged(double)), this, SIGNAL(onZoomFactorChanged(double)));
QString *userinputservice = new QString(*webpagewindowservice + "/IUserInput");
@@ -382,8 +390,8 @@ void BrowserDbus::pageloadingstarted() {
void BrowserDbus::pageloadingfinished(bool success) {
qDebug() << __PRETTY_FUNCTION__ << success;
if(success) {
- getCurrentUrlAndTitle();
- emit urlChanged();
+ getUrl();
+ getTitle();
qDebug() << __PRETTY_FUNCTION__ << url() << title();
}
setPageLoading(false);
@@ -505,16 +513,90 @@ void BrowserDbus::WindowClosed() {
qDebug() << __PRETTY_FUNCTION__;
}
-void BrowserDbus::getCurrentUrlAndTitle() {
+QString BrowserDbus::getUrl() {
qDebug() << __PRETTY_FUNCTION__;
+ if (!actualtab) {
+ qDebug() << "No browser window present";
+ return "";
+ }
+
+ QDBusPendingReply<QString> reply = actualtab->getUrl();
+ reply.waitForFinished();
+ if (reply.isValid()) {
+ setUrl(reply.value());
+ qDebug() << __PRETTY_FUNCTION__ << url();
+ }
+ return url();
+}
+
+QString BrowserDbus::getTitle() {
+ qDebug() << __PRETTY_FUNCTION__;
+ if (!actualtab) {
+ qDebug() << "No browser window present";
+ return "";
+ }
+
+ QDBusPendingReply<QString> reply = actualtab->getTitle();
+ reply.waitForFinished();
+ if (reply.isValid()) {
+ setTitle(reply.value());
+ qDebug() << __PRETTY_FUNCTION__ << title();
+ }
+ return title();
+}
+
+void BrowserDbus::setZoomFactor(double factor) {
+ qDebug() << __PRETTY_FUNCTION__ << factor;
- QDBusPendingReply<conn::brw::ERROR_IDS, QString, QString> reply = actualtab->getCurrentUrlTitle();
+ QDBusPendingReply<conn::brw::ERROR_IDS> reply = actualtab->setZoomFactor(factor);
reply.waitForFinished();
if(reply.isValid()) {
conn::brw::ERROR_IDS ret = reply.value();
- setUrl(reply.argumentAt<1>());
- setTitle(reply.argumentAt<2>());
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
- qDebug() << __PRETTY_FUNCTION__ << ret << url() << title();
+double BrowserDbus::getZoomFactor() {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QDBusPendingReply<double> reply = actualtab->getZoomFactor();
+ reply.waitForFinished();
+ if(reply.isValid()) {
+ double ret = reply.value();
+ return ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ return 0;
+ }
+}
+
+void BrowserDbus::getScrollPosition(uint &x, uint &y) {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QDBusReply<conn::brw::ERROR_IDS> reply = actualtab->getScrollPosition(x,y);
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
+ }
+}
+
+void BrowserDbus::setScrollPosition(uint &x, uint &y) {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ QDBusPendingReply<conn::brw::ERROR_IDS> reply = actualtab->setScrollPosition(x,y);
+ reply.waitForFinished();
+ if(reply.isValid()) {
+ conn::brw::ERROR_IDS ret = reply.value();
+ qDebug() << "ERROR_IDS " << ret;
+ } else {
+ QDBusError error = reply.error();
+ qDebug() << "ERROR " << error.name() << error.message();
}
}
diff --git a/common/browserdbus.h b/common/browserdbus.h
index 5e5e5c7..79e59cc 100644
--- a/common/browserdbus.h
+++ b/common/browserdbus.h
@@ -46,7 +46,6 @@ public:
Q_INVOKABLE void addBookmark(int type, QString folder, QString title, QString url, QString iconpath, QString thumbnailpath);
Q_INVOKABLE void deleteBookmark(int uid);
Q_INVOKABLE void deleteAllBookmarks(int type);
- Q_INVOKABLE void getCurrentUrlAndTitle();
Q_INVOKABLE void goRight(conn::brw::SCROLL_TYPE type);
Q_INVOKABLE void goLeft(conn::brw::SCROLL_TYPE type);
Q_INVOKABLE void goUp(conn::brw::SCROLL_TYPE type);
@@ -63,6 +62,12 @@ public:
Q_INVOKABLE void inputText(conn::brw::DIALOG_RESULT a_eResult, QString a_strInputValue);
Q_INVOKABLE void connectdbussession(QString id);
Q_INVOKABLE void selectTab(int tabnumber);
+ Q_INVOKABLE QString getUrl();
+ Q_INVOKABLE QString getTitle();
+ Q_INVOKABLE double getZoomFactor();
+ Q_INVOKABLE void setZoomFactor(double);
+ Q_INVOKABLE void getScrollPosition(uint &x, uint &y);
+ Q_INVOKABLE void setScrollPosition(uint &x, uint &y);
QString title() { return m_title; }
void setTitle(QString title) { m_title = title; }
@@ -77,11 +82,17 @@ public:
signals:
void bookmarkListChanged();
- void urlChanged();
- void titleChanged();
+ void urlChanged(QString);
+ void titleChanged(QString);
void pageloadingChanged();
void progressChanged();
void connectedChanged();
+ void linkClicked(QString);
+ void selectionChanged(void);
+ void onStatusTextChanged(QString);
+ void onVisibilityChanged(bool);
+ void onScrollPositionChanged(uint,uint);
+ void onZoomFactorChanged(double);
public slots:
void pageloadingstarted();
@@ -93,13 +104,13 @@ public slots:
void InputTextReceived(QString a_strInputName, QString a_strDefaultInputValue, conn::brw::INPUT_ELEMENT_TYPE a_i32InputValueType, int a_s32MaxLength, int a_s32Max, int a_s32Min, int a_s32Step);
private:
- conn::brw::IBookmarkManager *bookmark;
- conn::brw::IUserInput *userinput;
- conn::brw::IWebPageWindow *webpagewindow;
- conn::brw::IWebPageWindow *actualtab;
- conn::brw::IUserInput *actualuserinput;
+ conn::brw::IBookmarkManager *bookmark = NULL;
+ conn::brw::IUserInput *userinput = NULL;
+ conn::brw::IWebPageWindow *webpagewindow = NULL;
+ conn::brw::IWebPageWindow *actualtab = NULL;
+ conn::brw::IUserInput *actualuserinput = NULL;
QList<conn::brw::OBJECT_HANDLE> handlelist;
- conn::brw::IBrowser *browser;
+ conn::brw::IBrowser *browser = NULL;
QString m_title;
QString m_url;
QList<Bookmark*> m_bookmarkList;
@@ -107,7 +118,7 @@ private:
int m_progress;
QString m_instanceId;
bool m_isconnected;
- QString *dbusservicename;
+ QString *dbusservicename = NULL;
void scrollpage(conn::brw::SCROLL_DIRECTION direction, conn::brw::SCROLL_TYPE type);
void registertypes();
QHash<conn::brw::OBJECT_HANDLE, conn::brw::IWebPageWindow *> webpagehash;
diff --git a/testapp/qml/testapp/WebPageWindow.qml b/testapp/qml/testapp/WebPageWindow.qml
index 801d385..65dd840 100644
--- a/testapp/qml/testapp/WebPageWindow.qml
+++ b/testapp/qml/testapp/WebPageWindow.qml
@@ -89,10 +89,79 @@ Item {
}
GroupBox {
+ id: groupgeturl
+ x: 30
+ y: 198
+ width: 400 + 130 + 20 + 30
+ anchors.leftMargin: 0
+ anchors.top: groupload.bottom
+ anchors.topMargin: 10
+ title: "getUrl()"
+ Text {
+ id: inputfieldgeturl
+ width: 400
+ height: 40
+ text: ""
+ font.pixelSize: 16
+ anchors.leftMargin: 10
+ anchors.left: parent.left
+ }
+
+ Button {
+ width: 130
+ height: inputfieldgeturl.height
+ text: "Retrieve Url"
+ anchors.leftMargin: 20
+ anchors.top: inputfieldgeturl.top
+ anchors.left: inputfieldgeturl.right
+ onClicked: {
+ inputfieldgeturl.text = browserinterface.getUrl()
+ }
+ }
+ anchors.left: groupcontrolbuttons.left
+ }
+
+ GroupBox {
+ id: groupgettitle
+ x: 30
+ y: 290
+ width: 400 + 130 + 20 + 30
+ anchors.leftMargin: 0
+ anchors.top: groupgeturl.bottom
+ anchors.topMargin: 10
+ title: "getTitle()"
+ Text {
+ id: inputfieldgettitle
+ width: 400
+ height: 40
+ text: ""
+ font.pixelSize: 16
+ anchors.leftMargin: 10
+ anchors.left: parent.left
+ enabled: false
+ }
+
+ Button {
+ width: 130
+ height: inputfieldgettitle.height
+ text: "Retrieve title"
+ anchors.leftMargin: 20
+ anchors.top: inputfieldgettitle.top
+ anchors.left: inputfieldgettitle.right
+ onClicked: {
+ inputfieldgettitle.text = browserinterface.getTitle()
+ }
+ }
+ anchors.left: groupcontrolbuttons.left
+ }
+ GroupBox {
id: groupcontrolbuttons2
+ x: 30
+ y: 392
title: "getVisible()/getGeometry()/getContentSize()/getBrowserActionsState() "
width: 4 * 130 + 3 * 20 + 30
- anchors.top: groupload.bottom
+ anchors.leftMargin: 0
+ anchors.top: groupgettitle.bottom
anchors.topMargin: 10
anchors.left: groupload.left
@@ -325,6 +394,44 @@ Item {
anchors.left: scrolltype.left
}
}
+
+ GroupBox {
+ id: groupzoom
+ y: 6
+ anchors.left: groupscroll.right
+ anchors.leftMargin: 10
+ Button {
+ id: buttonZoomPlus
+ onClicked: {
+ browserinterface.setZoomFactor(
+ browserinterface.getZoomFactor() + 0.1)
+ }
+ text: "+"
+ }
+
+ Button {
+ id: buttonZoomMinus
+ anchors.leftMargin: 10
+ anchors.left: buttonZoomPlus.right
+ anchors.top: buttonZoomPlus.top
+ text: "-"
+ onClicked: {
+ browserinterface.setZoomFactor(
+ browserinterface.getZoomFactor() - 0.1)
+ }
+ }
+
+ Text {
+ text: "scroll type"
+ anchors.leftMargin: 0
+ anchors.topMargin: 0
+ anchors.left: parent.left
+ anchors.top: buttonZoomPlus.bottom
+ }
+ anchors.topMargin: 10
+ anchors.top: groupsetgeometry.bottom
+ title: "set/getZoomFactor(double)"
+ }
}