diff options
author | Jonatan Pålsson <jonatan.palsson@pelagicore.com> | 2014-02-19 11:23:54 +0100 |
---|---|---|
committer | Jonatan Pålsson <jonatan.palsson@pelagicore.com> | 2014-02-19 11:23:54 +0100 |
commit | b76617aa6cde293efb2e3ef539855ec6cfcc47ab (patch) | |
tree | 1526fde70be6ce73b98b524b204e02f948e7b609 | |
parent | 44ded91b14b37101fb7291a8fff3f39ae6019791 (diff) | |
download | browser-poc-b76617aa6cde293efb2e3ef539855ec6cfcc47ab.tar.gz |
Added faulty implementation of onSelect
-rw-r--r-- | browser/browser.cpp | 2 | ||||
-rw-r--r-- | browser/browser.h | 1 | ||||
-rw-r--r-- | browser/browserview.cpp | 2 | ||||
-rw-r--r-- | browser/browserview.h | 35 | ||||
-rw-r--r-- | browser/unit-tests/browserdbus/testbrowserdbus.cpp | 18 | ||||
-rw-r--r-- | browser/unit-tests/browserdbus/testbrowserdbus.h | 1 | ||||
-rw-r--r-- | browser/unit-tests/browserdbus/webpagegenerator.h | 2 | ||||
-rw-r--r-- | browser/userinput.cpp | 2 | ||||
-rw-r--r-- | browser/userinput.h | 2 | ||||
-rw-r--r-- | common/browserdbus.cpp | 1 | ||||
-rw-r--r-- | common/browserdbus.h | 1 | ||||
-rw-r--r-- | common/browserdefs.h | 1 |
12 files changed, 59 insertions, 9 deletions
diff --git a/browser/browser.cpp b/browser/browser.cpp index c9e75e2..96ab0f4 100644 --- a/browser/browser.cpp +++ b/browser/browser.cpp @@ -59,6 +59,8 @@ conn::brw::ERROR_IDS browser::createPageWindow(int a_eDeviceId, const conn::brw: connect(bvi, SIGNAL(onFaviconReceived()), wpw, SIGNAL(onFaviconReceived())); connect(m_userInput, SIGNAL(inputText(QString)), this, SLOT(inputText(QString))); + connect(bvi, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool)), + m_userInput, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool))); QString *webpagewindowservice = new QString("/Browser/IWebPageWindow" + QString::number(a_hPageWindowHandle)); qDebug() << *webpagewindowservice; diff --git a/browser/browser.h b/browser/browser.h index 5fb64ba..ec4b707 100644 --- a/browser/browser.h +++ b/browser/browser.h @@ -48,7 +48,6 @@ public Q_SLOTS: void inputText(QString input); void setView(QString viewpath); - private: QHash<conn::brw::OBJECT_HANDLE, QWidget*> windowhash; QHash<QString, BrowserView *> webviewhash; diff --git a/browser/browserview.cpp b/browser/browserview.cpp index d455deb..593d0af 100644 --- a/browser/browserview.cpp +++ b/browser/browserview.cpp @@ -63,6 +63,8 @@ BrowserView::BrowserView(cachemanager *cm, userinput *uip) 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))); + connect(&m_inputHandler, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool)), this, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool))); + } bool BrowserView::load(const QString &a_Url) diff --git a/browser/browserview.h b/browser/browserview.h index 12ec1df..28ba18a 100644 --- a/browser/browserview.h +++ b/browser/browserview.h @@ -42,12 +42,33 @@ public slots: emit onScroll ((uint)x,(uint)y); } void setCurrentFocus (const QWebElement &elem) { - emit onInputText (elem.attribute("name"), elem.attribute("value"), - elem.attribute("type", "0").toInt(), - elem.attribute("maxlength", "0").toInt(), - elem.attribute("max", "0").toInt(), - elem.attribute("min","0").toInt(), - elem.attribute("step","0").toInt()); + if (elem.tagName().compare("INPUT", Qt::CaseInsensitive) == 0){ + emit onInputText (elem.attribute("name"), elem.attribute("value"), + elem.attribute("type", "0").toInt(), + elem.attribute("maxlength", "0").toInt(), + elem.attribute("max", "0").toInt(), + elem.attribute("min","0").toInt(), + elem.attribute("step","0").toInt()); + } else if (elem.tagName().compare("SELECT", Qt::CaseInsensitive) == 0){ + conn::brw::SelectableOptionList options; + QList<QWebElement> elems; + QWebElement first = elem.firstChild(); + QWebElement last = elem.lastChild(); + + conn::brw::SelectableOption o; + o.strValue = first.toPlainText(); + options.append(o); + elems.append(first); + while (elems.last() != last) { + conn::brw::SelectableOption o; + o.strValue = elems.last().toPlainText(); + elems.append(elems.last().nextSibling()); + options.append(o); + } + + qDebug() << "Options:" << options.size(); + emit onSelect(elem.attribute("name", ""), options, true); + } } const QWebElement *currentFocus () { return m_elem; } @@ -55,6 +76,7 @@ signals: void onInputText(QString name, QString value, int type, int maxlength, int max, int min, int step); void onScroll(uint x, uint y); + void onSelect(const QString &, const conn::brw::SelectableOptionList &, bool); private: QWebElement *m_elem; @@ -103,6 +125,7 @@ signals: void onActionStateChanged(uint); void onContentSizeChanged(uint, uint); void onFaviconReceived(); + void onSelect(const QString &, const conn::brw::SelectableOptionList &, bool); protected: virtual void resizeEvent (QResizeEvent *event); diff --git a/browser/unit-tests/browserdbus/testbrowserdbus.cpp b/browser/unit-tests/browserdbus/testbrowserdbus.cpp index eba617e..76b4c1f 100644 --- a/browser/unit-tests/browserdbus/testbrowserdbus.cpp +++ b/browser/unit-tests/browserdbus/testbrowserdbus.cpp @@ -252,6 +252,7 @@ void TestBrowserDBus::testConfirmDialog() { QSignalSpy spy (m_bdb, SIGNAL(onConfirmDialog(QString))); m_bdb->createPageWindow(1,0,0,800,600); m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); QProcess::execute("xdotool mousemove 150 500"); QProcess::execute("xdotool click 1"); QVERIFY(spy.wait(1000)); @@ -263,6 +264,7 @@ void TestBrowserDBus::testCancelConfirmDialog() { QSignalSpy spy2 (m_bdb, SIGNAL(onDialogCanceled(void))); m_bdb->createPageWindow(1,0,0,800,600); m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); QProcess::execute("xdotool mousemove 150 500"); QProcess::execute("xdotool click 1"); QVERIFY(spy.wait(1000)); @@ -274,6 +276,7 @@ void TestBrowserDBus::testPromptDialog() { QSignalSpy spy (m_bdb, SIGNAL(onPromptDialog(QString,QString))); m_bdb->createPageWindow(1,0,0,800,600); m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); QProcess::execute("xdotool mousemove 250 500"); QProcess::execute("xdotool click 1"); QVERIFY(spy.wait(1000)); @@ -285,6 +288,7 @@ void TestBrowserDBus::testCancelPromptDialog() { QSignalSpy spy2 (m_bdb, SIGNAL(onDialogCanceled(void))); m_bdb->createPageWindow(1,0,0,800,600); m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); QProcess::execute("xdotool mousemove 250 500"); QProcess::execute("xdotool click 1"); QVERIFY(spy.wait(1000)); @@ -296,6 +300,7 @@ void TestBrowserDBus::testAlertDialog() { QSignalSpy spy (m_bdb, SIGNAL(onAlertDialog(QString))); m_bdb->createPageWindow(1,0,0,800,600); m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); QProcess::execute("xdotool mousemove 50 500"); QProcess::execute("xdotool click 1"); QVERIFY(spy.wait(1000)); @@ -305,6 +310,7 @@ void TestBrowserDBus::testAlertDialog() { void TestBrowserDBus::testGetPrevEnteredValues() { m_bdb->createPageWindow(1,0,0,800,600); m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); QProcess::execute("xdotool mousemove 200 375"); QProcess::execute("xdotool click 1"); QTest::qSleep(300); @@ -313,4 +319,16 @@ void TestBrowserDBus::testGetPrevEnteredValues() { QStringList list = m_bdb->getPrevEnteredValues("input", "", conn::brw::IET_TEXT); QVERIFY(list.contains("Hello world")); } + +void TestBrowserDBus::testGetsNotifiedWhenSelectIsSelected() { + QSignalSpy spy (m_bdb, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool))); + m_bdb->createPageWindow(1,0,0,800,600); + m_bdb->loadurl(testFileUrl()); + QTest::qSleep(300); + QProcess::execute("xdotool mousemove 320 375"); + QProcess::execute("xdotool click 1"); + QTest::qSleep(300); + QProcess::execute("xdotool click 1"); + QVERIFY(spy.wait(1000)); +} QTEST_MAIN (TestBrowserDBus); diff --git a/browser/unit-tests/browserdbus/testbrowserdbus.h b/browser/unit-tests/browserdbus/testbrowserdbus.h index ca808c2..faaceeb 100644 --- a/browser/unit-tests/browserdbus/testbrowserdbus.h +++ b/browser/unit-tests/browserdbus/testbrowserdbus.h @@ -48,6 +48,7 @@ private slots: void testCancelPromptDialog(); void testAlertDialog(); void testGetPrevEnteredValues(); + void testGetsNotifiedWhenSelectIsSelected(); private: QString testFileUrl() { diff --git a/browser/unit-tests/browserdbus/webpagegenerator.h b/browser/unit-tests/browserdbus/webpagegenerator.h index 8168f16..ebb8d28 100644 --- a/browser/unit-tests/browserdbus/webpagegenerator.h +++ b/browser/unit-tests/browserdbus/webpagegenerator.h @@ -29,6 +29,7 @@ public: " Set status bar text" " </DIV>" " <INPUT type='text' name='input' style='float:left;'></INPUT>" + " <SELECT style='float:left'><OPTION>1</OPTION><OPTION>2</OPTION><OPTION>3</OPTION></SELECT>" " <DIV style='height:100; width:100; background-color:gray; float: left; clear:left'" " onClick=\"JavaScript:alert('browser-poc');\" >" " Trigger alert" @@ -45,6 +46,5 @@ public: " </BODY>" "</HTML>" ); - } }; diff --git a/browser/userinput.cpp b/browser/userinput.cpp index 5ffc0b1..9035912 100644 --- a/browser/userinput.cpp +++ b/browser/userinput.cpp @@ -88,7 +88,7 @@ conn::brw::ERROR_IDS userinput::closePromptDialog(QString resultStr, conn::brw:: conn::brw::ERROR_IDS userinput::getPrevEnteredValues (const QString &a_strInputName, const QString &a_strInputValue, conn::brw::INPUT_ELEMENT_TYPE a_i32InputType, QStringList &a_oInputVariants) { for (int i = 0; i < m_inputHistory->size(); i++){ - struct inputStruct s = m_inputHistory->at(0);; + struct inputStruct s = m_inputHistory->at(0); qDebug() << s.value; if (s.type == a_i32InputType && s.name.compare(a_strInputName) == 0) { diff --git a/browser/userinput.h b/browser/userinput.h index b5cdbe0..814bd1e 100644 --- a/browser/userinput.h +++ b/browser/userinput.h @@ -16,6 +16,7 @@ #include <QObject> #include <QDBusContext> +#include <QDebug> #include "../common/browserdefs.h" @@ -37,6 +38,7 @@ signals: void onPromptDialog(QString,QString); void onAlertDialog(QString); void onDialogCanceled(void); + void onSelect(const QString &a_strSelectName, const conn::brw::SelectableOptionList & a_oOptions, bool a_bMultiSelectionAllowed); // Internal void doCloseAlertDialog(void); diff --git a/common/browserdbus.cpp b/common/browserdbus.cpp index 3e53fe1..330fd67 100644 --- a/common/browserdbus.cpp +++ b/common/browserdbus.cpp @@ -217,6 +217,7 @@ void BrowserDbus::createPageWindow(int deviceid, int x, int y, int width, int he connect(actualuserinput, SIGNAL(onConfirmDialog(QString)), this, SIGNAL(onConfirmDialog(QString))); connect(actualuserinput, SIGNAL(onPromptDialog(QString,QString)),this, SIGNAL(onPromptDialog(QString,QString))); connect(actualuserinput, SIGNAL(onDialogCanceled(void)), this, SIGNAL(onDialogCanceled())); + connect(actualuserinput, SIGNAL(onSelect(const QString &, const conn::brw::SelectableOptionList &, bool)), this, SIGNAL (onSelect(const QString &, const conn::brw::SelectableOptionList &, bool))); if(!actualuserinput->isValid()) qDebug() << "failed create object /Browser/IWebPageWindow*/IUserInput"; diff --git a/common/browserdbus.h b/common/browserdbus.h index b746344..65d7a04 100644 --- a/common/browserdbus.h +++ b/common/browserdbus.h @@ -110,6 +110,7 @@ signals: void onPromptDialog(QString,QString); void onAlertDialog(QString); void onDialogCanceled(void); + void onSelect(const QString &, const conn::brw::SelectableOptionList &, bool); public slots: void pageloadingstarted(); diff --git a/common/browserdefs.h b/common/browserdefs.h index 8499904..d2ce3c1 100644 --- a/common/browserdefs.h +++ b/common/browserdefs.h @@ -673,6 +673,7 @@ Q_DECLARE_METATYPE(conn::brw::BrowserActions) Q_DECLARE_METATYPE(conn::brw::OBJECT_HANDLE) Q_DECLARE_METATYPE(conn::brw::ObjectHandleList) Q_DECLARE_METATYPE(conn::brw::SelectableOption); +Q_DECLARE_METATYPE(conn::brw::SelectableOptionList); Q_DECLARE_METATYPE(conn::brw::CACHE_POLICY); Q_DECLARE_METATYPE(conn::brw::ErrorItemList); Q_DECLARE_METATYPE(conn::brw::ErrorItem); |