Browse Source

fixed tests, style

cl-refactor
arkpar 10 years ago
parent
commit
0749818092
  1. 6
      mix/CodeModel.cpp
  2. 6
      mix/CodeModel.h
  3. 8
      mix/test/TestService.cpp
  4. 4
      mix/test/qml/TestMain.qml
  5. 4
      mix/test/qml/js/TestTutorial.js

6
mix/CodeModel.cpp

@ -220,7 +220,7 @@ QVariantMap CodeModel::contracts() const
return result;
}
CompiledContract* CodeModel::contractByDocumentId(QString _documentId) const
CompiledContract* CodeModel::contractByDocumentId(QString const& _documentId) const
{
Guard l(x_contractMap);
for (ContractMap::const_iterator c = m_contractMap.cbegin(); c != m_contractMap.cend(); ++c)
@ -229,7 +229,7 @@ CompiledContract* CodeModel::contractByDocumentId(QString _documentId) const
return nullptr;
}
CompiledContract const& CodeModel::contract(QString _name) const
CompiledContract const& CodeModel::contract(QString const& _name) const
{
Guard l(x_contractMap);
CompiledContract* res = m_contractMap.value(_name);
@ -238,7 +238,7 @@ CompiledContract const& CodeModel::contract(QString _name) const
return *res;
}
CompiledContract const* CodeModel::tryGetContract(QString _name) const
CompiledContract const* CodeModel::tryGetContract(QString const& _name) const
{
Guard l(x_contractMap);
CompiledContract* res = m_contractMap.value(_name);

6
mix/CodeModel.h

@ -142,13 +142,13 @@ public:
dev::bytes const& getStdContractCode(QString const& _contractName, QString const& _url);
/// Get contract by name
/// Throws if not found
CompiledContract const& contract(QString _name) const;
CompiledContract const& contract(QString const& _name) const;
/// Get contract by name
/// @returns nullptr if not found
CompiledContract const* tryGetContract(QString _name) const;
CompiledContract const* tryGetContract(QString const& _name) const;
/// Find a contract by document id
/// @returns CompiledContract object or null if not found
Q_INVOKABLE CompiledContract* contractByDocumentId(QString _documentId) const;
Q_INVOKABLE CompiledContract* contractByDocumentId(QString const& _documentId) const;
/// Reset code model
Q_INVOKABLE void reset() { reset(QVariantMap()); }
/// Convert solidity type info to mix type

8
mix/test/TestService.cpp

@ -20,6 +20,7 @@
* Ethereum IDE client.
*/
#include <iostream>
#include "TestService.h"
#include <QtTest/QSignalSpy>
#include <QElapsedTimer>
@ -162,6 +163,7 @@ bool TestService::keyClickChar(QObject* _item, QString const& _character, int _m
bool TestService::mouseClick(QObject* _item, qreal _x, qreal _y, int _button, int _modifiers, int _delay)
{
QWindow* window = qobject_cast<QWindow*>(_item);
QMetaObject const* mo = _item->metaObject();
if (!window)
window = eventWindow(_item);
mouseEvent(MouseClick, window, _item, Qt::MouseButton(_button), Qt::KeyboardModifiers(_modifiers), QPointF(_x, _y), _delay);
@ -176,18 +178,22 @@ void TestService::setTargetWindow(QObject* _window)
window->requestActivate();
}
QWindow* TestService::eventWindow(QObject* _item)
{
QQuickItem* item = qobject_cast<QQuickItem*>(_item);
if (item && item->window())
return item->window();
QQuickWindow* window = qobject_cast<QQuickWindow*>(_item);
QWindow* window = qobject_cast<QQuickWindow*>(_item);
if (!window && _item->parent())
window = eventWindow(_item->parent());
if (!window)
window = qobject_cast<QQuickWindow*>(m_targetWindow);
if (window)
{
window->requestActivate();
std::cout << window->title().toStdString();
return window;
}
item = qobject_cast<QQuickItem*>(m_targetWindow);

4
mix/test/qml/TestMain.qml

@ -16,6 +16,8 @@ TestCase
{
if (el === undefined)
el = mainApplication;
if (el.contentItem) //for dialgos
el = el.contentItem
for (var c in str)
{
@ -60,6 +62,8 @@ TestCase
function clickElement(el, x, y)
{
if (el.contentItem)
el = el.contentItem;
ts.mouseClick(el, x, y, Qt.LeftButton, Qt.NoModifier, 10)
}

4
mix/test/qml/js/TestTutorial.js

@ -50,9 +50,9 @@ function test_tutorial()
var transactionDialog = mainApplication.projectModel.stateDialog.transactionDialog;
ts.waitForRendering(transactionDialog, 3000);
transactionDialog.selectFunction("setRating");
clickElement(transactionDialog, 180, 310);
clickElement(transactionDialog, 200, 310);
ts.typeString("Titanic", transactionDialog);
clickElement(transactionDialog, 180, 330);
clickElement(transactionDialog, 200, 330);
ts.typeString("2", transactionDialog);
transactionDialog.acceptAndClose();
mainApplication.projectModel.stateDialog.acceptAndClose();

Loading…
Cancel
Save