Browse Source

styled with astyle

cl-refactor
arkpar 10 years ago
parent
commit
34e0f03e57
  1. 1
      mix/QVariableDefinition.cpp
  2. 68
      mix/test/TestService.cpp
  3. 82
      mix/web.qrc

1
mix/QVariableDefinition.cpp

@ -26,6 +26,7 @@ namespace dev
{ {
namespace mix namespace mix
{ {
QString QVariableDefinition::encodeValueAsString() QString QVariableDefinition::encodeValueAsString()
{ {
return QString::fromStdString(dev::toHex(encodeValue())); return QString::fromStdString(dev::toHex(encodeValue()));

68
mix/test/TestService.cpp

@ -35,21 +35,22 @@ namespace mix
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDoubleClick, MouseMove }; enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDoubleClick, MouseMove };
static void mouseEvent(MouseAction _action, QWindow* _window, QObject* _item, Qt::MouseButton _button, Qt::KeyboardModifiers _stateKey, QPointF _pos, int _delay=-1) static void mouseEvent(MouseAction _action, QWindow* _window, QObject* _item, Qt::MouseButton _button, Qt::KeyboardModifiers _stateKey, QPointF _pos, int _delay = -1)
{ {
if (_delay == -1 || _delay < 30) if (_delay == -1 || _delay < 30)
_delay = 30; _delay = 30;
if (_delay > 0) if (_delay > 0)
QTest::qWait(_delay); QTest::qWait(_delay);
if (_action == MouseClick) { if (_action == MouseClick)
{
mouseEvent(MousePress, _window, _item, _button, _stateKey, _pos); mouseEvent(MousePress, _window, _item, _button, _stateKey, _pos);
mouseEvent(MouseRelease, _window, _item, _button, _stateKey, _pos); mouseEvent(MouseRelease, _window, _item, _button, _stateKey, _pos);
return; return;
} }
QPoint pos = _pos.toPoint(); QPoint pos = _pos.toPoint();
QQuickItem *sgitem = qobject_cast<QQuickItem *>(_item); QQuickItem* sgitem = qobject_cast<QQuickItem*>(_item);
if (sgitem) if (sgitem)
pos = sgitem->mapToScene(_pos).toPoint(); pos = sgitem->mapToScene(_pos).toPoint();
@ -58,26 +59,26 @@ static void mouseEvent(MouseAction _action, QWindow* _window, QObject* _item, Qt
QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, _button, _stateKey); QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, _button, _stateKey);
switch (_action) switch (_action)
{ {
case MousePress: case MousePress:
me = QMouseEvent(QEvent::MouseButtonPress, pos, _window->mapToGlobal(pos), _button, _button, _stateKey); me = QMouseEvent(QEvent::MouseButtonPress, pos, _window->mapToGlobal(pos), _button, _button, _stateKey);
break; break;
case MouseRelease: case MouseRelease:
me = QMouseEvent(QEvent::MouseButtonRelease, pos, _window->mapToGlobal(pos), _button, 0, _stateKey); me = QMouseEvent(QEvent::MouseButtonRelease, pos, _window->mapToGlobal(pos), _button, 0, _stateKey);
break; break;
case MouseDoubleClick: case MouseDoubleClick:
me = QMouseEvent(QEvent::MouseButtonDblClick, pos, _window->mapToGlobal(pos), _button, _button, _stateKey); me = QMouseEvent(QEvent::MouseButtonDblClick, pos, _window->mapToGlobal(pos), _button, _button, _stateKey);
break; break;
case MouseMove: case MouseMove:
// with move event the _button is NoButton, but 'buttons' holds the currently pressed buttons // with move event the _button is NoButton, but 'buttons' holds the currently pressed buttons
me = QMouseEvent(QEvent::MouseMove, pos, _window->mapToGlobal(pos), Qt::NoButton, _button, _stateKey); me = QMouseEvent(QEvent::MouseMove, pos, _window->mapToGlobal(pos), Qt::NoButton, _button, _stateKey);
break; break;
default: default:
break; break;
} }
QSpontaneKeyEvent::setSpontaneous(&me); QSpontaneKeyEvent::setSpontaneous(&me);
if (!qApp->notify(_window, &me)) { if (!qApp->notify(_window, &me))
static const char *mouseActionNames[] = {
{ "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" }; static const char* mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" };
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window"); QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window");
QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(_action)])).toLatin1().data()); QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(_action)])).toLatin1().data());
} }
@ -85,21 +86,20 @@ static void mouseEvent(MouseAction _action, QWindow* _window, QObject* _item, Qt
bool TestService::waitForSignal(QObject* _item, QString _signalName, int _timeout) bool TestService::waitForSignal(QObject* _item, QString _signalName, int _timeout)
{ {
QSignalSpy spy(_item, ("2" + _signalName.toStdString()).c_str()); QSignalSpy spy(_item, ("2" + _signalName.toStdString()).c_str());
QMetaObject const* mo = _item->metaObject(); QMetaObject const* mo = _item->metaObject();
QStringList methods; QStringList methods;
for(int i = mo->methodOffset(); i < mo->methodCount(); ++i) { for (int i = mo->methodOffset(); i < mo->methodCount(); ++i)
if (mo->method(i).methodType() == QMetaMethod::Signal) { if (mo->method(i).methodType() == QMetaMethod::Signal)
methods << QString::fromLatin1(mo->method(i).methodSignature()); methods << QString::fromLatin1(mo->method(i).methodSignature());
}
}
QElapsedTimer timer; QElapsedTimer timer;
timer.start(); timer.start();
while (!spy.size()) { while (!spy.size())
{
int remaining = _timeout - int(timer.elapsed()); int remaining = _timeout - int(timer.elapsed());
if (remaining <= 0) if (remaining <= 0)
break; break;
@ -113,42 +113,42 @@ bool TestService::waitForSignal(QObject* _item, QString _signalName, int _timeou
bool TestService::keyPress(QObject* _item, int _key, int _modifiers, int _delay) bool TestService::keyPress(QObject* _item, int _key, int _modifiers, int _delay)
{ {
QWindow *window = eventWindow(_item); QWindow* window = eventWindow(_item);
QTest::keyPress(window, Qt::Key(_key), Qt::KeyboardModifiers(_modifiers), _delay); QTest::keyPress(window, Qt::Key(_key), Qt::KeyboardModifiers(_modifiers), _delay);
return true; return true;
} }
bool TestService::keyRelease(QObject* _item, int _key, int _modifiers, int _delay) bool TestService::keyRelease(QObject* _item, int _key, int _modifiers, int _delay)
{ {
QWindow *window = eventWindow(_item); QWindow* window = eventWindow(_item);
QTest::keyRelease(window, Qt::Key(_key), Qt::KeyboardModifiers(_modifiers), _delay); QTest::keyRelease(window, Qt::Key(_key), Qt::KeyboardModifiers(_modifiers), _delay);
return true; return true;
} }
bool TestService::keyClick(QObject* _item, int _key, int _modifiers, int _delay) bool TestService::keyClick(QObject* _item, int _key, int _modifiers, int _delay)
{ {
QWindow *window = eventWindow(_item); QWindow* window = eventWindow(_item);
QTest::keyClick(window, Qt::Key(_key), Qt::KeyboardModifiers(_modifiers), _delay); QTest::keyClick(window, Qt::Key(_key), Qt::KeyboardModifiers(_modifiers), _delay);
return true; return true;
} }
bool TestService::keyPressChar(QObject* _item, QString const& _character, int _modifiers, int _delay) bool TestService::keyPressChar(QObject* _item, QString const& _character, int _modifiers, int _delay)
{ {
QWindow *window = eventWindow(_item); QWindow* window = eventWindow(_item);
QTest::keyPress(window, _character[0].toLatin1(), Qt::KeyboardModifiers(_modifiers), _delay); QTest::keyPress(window, _character[0].toLatin1(), Qt::KeyboardModifiers(_modifiers), _delay);
return true; return true;
} }
bool TestService::keyReleaseChar(QObject* _item, QString const& _character, int _modifiers, int _delay) bool TestService::keyReleaseChar(QObject* _item, QString const& _character, int _modifiers, int _delay)
{ {
QWindow *window = eventWindow(_item); QWindow* window = eventWindow(_item);
QTest::keyRelease(window, _character[0].toLatin1(), Qt::KeyboardModifiers(_modifiers), _delay); QTest::keyRelease(window, _character[0].toLatin1(), Qt::KeyboardModifiers(_modifiers), _delay);
return true; return true;
} }
bool TestService::keyClickChar(QObject* _item, QString const& _character, int _modifiers, int _delay) bool TestService::keyClickChar(QObject* _item, QString const& _character, int _modifiers, int _delay)
{ {
QWindow *window = eventWindow(_item); QWindow* window = eventWindow(_item);
QTest::keyClick(window, _character[0].toLatin1(), Qt::KeyboardModifiers(_modifiers), _delay); QTest::keyClick(window, _character[0].toLatin1(), Qt::KeyboardModifiers(_modifiers), _delay);
return true; return true;
} }
@ -172,7 +172,7 @@ void TestService::setTargetWindow(QObject* _window)
QWindow* TestService::eventWindow(QObject* _item) QWindow* TestService::eventWindow(QObject* _item)
{ {
QQuickItem* item = qobject_cast<QQuickItem *>(_item); QQuickItem* item = qobject_cast<QQuickItem*>(_item);
if (item && item->window()) if (item && item->window())
return item->window(); return item->window();

82
mix/web.qrc

@ -1,44 +1,44 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>qml/WebPreview.qml</file>
<file>qml/html/WebContainer.html</file>
<file>qml/html/cm/active-line.js</file>
<file>qml/html/codeeditor.html</file>
<file>qml/html/cm/codemirror.css</file>
<file>qml/html/cm/codemirror.js</file>
<file>qml/html/cm/javascript.js</file>
<file>qml/html/cm/matchbrackets.js</file>
<file>qml/WebCodeEditor.qml</file> <file>qml/WebCodeEditor.qml</file>
<file>qml/html/codeeditor.js</file> <file>qml/WebPreview.qml</file>
<file>qml/html/cm/fullscreen.css</file> <file>qml/html/WebContainer.html</file>
<file>qml/html/cm/fullscreen.js</file> <file>qml/html/cm/acorn.js</file>
<file>qml/html/cm/solarized.css</file> <file>qml/html/cm/acorn_loose.js</file>
<file>qml/html/cm/xml.js</file> <file>qml/html/cm/active-line.js</file>
<file>qml/html/cm/htmlmixed.js</file> <file>qml/html/cm/anyword-hint.js</file>
<file>qml/html/cm/css.js</file> <file>qml/html/cm/closebrackets.js</file>
<file>qml/html/cm/solidity.js</file> <file>qml/html/cm/codemirror.css</file>
<file>qml/html/cm/dialog.css</file> <file>qml/html/cm/codemirror.js</file>
<file>qml/html/cm/dialog.js</file> <file>qml/html/cm/comment.js</file>
<file>qml/html/cm/search.js</file> <file>qml/html/cm/css.js</file>
<file>qml/html/cm/searchcursor.js</file> <file>qml/html/cm/def.js</file>
<file>qml/html/cm/anyword-hint.js</file> <file>qml/html/cm/dialog.css</file>
<file>qml/html/cm/show-hint.js</file> <file>qml/html/cm/dialog.js</file>
<file>qml/html/cm/show-hint.css</file> <file>qml/html/cm/doc_comment.js</file>
<file>qml/html/cm/closebrackets.js</file> <file>qml/html/cm/ecma5spec.js</file>
<file>qml/html/cm/solidityToken.js</file> <file>qml/html/cm/errorannotation.js</file>
<file>qml/html/cm/javascript-hint.js</file> <file>qml/html/cm/fullscreen.css</file>
<file>qml/html/cm/errorannotation.js</file> <file>qml/html/cm/fullscreen.js</file>
<file>qml/html/cm/tern.js</file> <file>qml/html/cm/htmlmixed.js</file>
<file>qml/html/cm/ecma5spec.js</file> <file>qml/html/cm/infer.js</file>
<file>qml/html/cm/comment.js</file> <file>qml/html/cm/javascript-hint.js</file>
<file>qml/html/cm/def.js</file> <file>qml/html/cm/javascript.js</file>
<file>qml/html/cm/doc_comment.js</file> <file>qml/html/cm/mark-selection.js</file>
<file>qml/html/cm/infer.js</file> <file>qml/html/cm/matchbrackets.js</file>
<file>qml/html/cm/signal.js</file> <file>qml/html/cm/search.js</file>
<file>qml/html/cm/ternserver.js</file> <file>qml/html/cm/searchcursor.js</file>
<file>qml/html/cm/acorn.js</file> <file>qml/html/cm/show-hint.css</file>
<file>qml/html/cm/acorn_loose.js</file> <file>qml/html/cm/show-hint.js</file>
<file>qml/html/cm/walk.js</file> <file>qml/html/cm/signal.js</file>
<file>qml/html/cm/mark-selection.js</file> <file>qml/html/cm/solarized.css</file>
</qresource> <file>qml/html/cm/solidity.js</file>
<file>qml/html/cm/solidityToken.js</file>
<file>qml/html/cm/tern.js</file>
<file>qml/html/cm/ternserver.js</file>
<file>qml/html/cm/walk.js</file>
<file>qml/html/cm/xml.js</file>
<file>qml/html/codeeditor.html</file>
<file>qml/html/codeeditor.js</file>
</qresource>
</RCC> </RCC>

Loading…
Cancel
Save