void CreateDirectoriesTestCase::onDirCreated(QString dirPath)
{
    deltaEvents[dirPath] = QDateTime::currentMSecsSinceEpoch() - selfCreateEvents[dirPath];
    selfCreateEvents.remove(dirPath);
    createEvents++;
    if (!selfCreateEvents.count())
    {
        //test has already passed.
        disconnect(this, SLOT(stopTest()));
        timeout.stop();
        stopTest();
    }
}
Пример #2
0
void RecThread::startTest()
{
    QTextStream out(stdout);
    out << "Start test\n";
    isTesting = true;
    inputAudio->start(m_audioInfo->start());
    QTimer::singleShot(1000,this, SLOT(stopTest()));
}
Пример #3
0
/*!
  Function telling what to do after each frame.
  Calls customframeEnded() and see if the program is to be stopped.
  \param evt : Frame event to process.
  \return True if everything went well.
*/
bool vpAROgre::frameEnded(const Ogre::FrameEvent& evt)
{
  // custom method telling what to do at the end of each frame
  bool result = customframeEnded(evt);

  // See if we have to stop rendering
  if(result) return stopTest(evt);
  else return result;
}
Пример #4
0
void MainWindow::on_stopButton_clicked()
{
    if(timer->isActive()){
        timer->stop();
        stopTest();
    }else{
        ui->statusLabel->setText("STOPPING...");
        stopRequested = true;
    }
}
Пример #5
0
RTGPUTestBench::RTGPUTestBench(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	m_thread = new RTGPUTestThread();
	m_thread->resumeThread();

	layoutWindow();

	connect(this, SIGNAL(startTest(RTGPU_SETTINGS *)), m_thread, SLOT(startTest(RTGPU_SETTINGS *)));
	connect(m_thread, SIGNAL(displayImage(QImage, int)), this, SLOT(displayImage(QImage, int)));
	connect(m_thread, SIGNAL(displayStatus(QString)), this, SLOT(displayStatus(QString)));

	connect(m_runOnce, SIGNAL(clicked()), this, SLOT(onRunOnce()));
	connect(m_runCont, SIGNAL(clicked()), this, SLOT(onRunCont()));
	connect(m_stopTest, SIGNAL(clicked()), this, SLOT(onStopTest()));
	connect(this, SIGNAL(stopTest()), m_thread, SLOT(stopTest()));
	
	connect(m_testSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(onTestChanged(int)));
}
Пример #6
0
/*!
  Function telling what to do before each frame.
  Calls customframeStarted() and see if the program has to be stopped.

  This function is called before every frame is rendered by Ogre.

  \param evt : Frame event to process.
  \return True if everything went well.
*/
bool vpAROgre::frameStarted(const Ogre::FrameEvent& evt)
{
  // custom method telling what to do at the beginning of each frame
  bool result = customframeStarted(evt);

  // Listen to the window
  Ogre::WindowEventUtilities::messagePump();
  processInputEvent(evt);

  // See if we have to stop rendering
  if(result) return stopTest(evt);
  else return result;
}
Пример #7
0
void MainWindow::iperfFinished(int exitCode, QProcess::ExitStatus status){
    qDebug()<<"process (throughput) finished with exitCode"<<exitCode;
    //update graph
    updatePlot();
    if(stopRequested){
        //enable start
        stopRequested = false;
        stopTest();
    }else{ //setup a timer to run the test again with given interval.
        timer->start(getInterval());
        ui->statusLabel->setText("WAITING");
    }
    qDebug()<<"test finished properly";
}
Пример #8
0
Co2Mgr::Co2Mgr(LinkMgr* pLinkMgr):BasicMgr(pLinkMgr,CO2_CLIENT)
{
    memset(&m_tStartTimer,0,sizeof(m_tStartTimer));

    if(State::getInstance()->getStateData(CO2_TEST)){
        startTest();
    }else{
        stopTest();
    }
    setShowDataSign(State::getInstance()->getStateData(CO2_SHOWDATA));
    startSendData(State::getInstance()->getStateData(CO2_SENDDATA));

    gettimeofday(&m_tStartTimer,NULL);
}
Пример #9
0
bool TestFramework::eventFilter(QObject* obj, QEvent* e) 
{
	if (test_running_)
	{
//   		if (e == last_event_) return false;
//   		last_event_ = e;

		bool stop = false;
		if (e->type() == QEvent::KeyPress)
		{
			QKeyEvent* ke = dynamic_cast<QKeyEvent*>(e);
			// pause macro if pause key is pressed
			if (ke->key() == Qt::Key_Pause) stop = true;
			else if (ke->key() == Qt::Key_X && ke->modifiers() == Qt::AltModifier)
			{
				// if a user presses Alt-X: quit immediately
				abortTest();
				getMainControl()->quit(0);
				return true;
			}
		}
		else if (e->type() == QEvent::MouseButtonPress ||
						 e->type() == QEvent::MouseButtonRelease)
		{
			// abort macro if user presses mouse button:
			if (!RTTI::isKindOf<MyMouseEvent>(*e) && e->spontaneous())
			{
 				stop = true;
			}
		}
		else
		{
			return false;
		}

		if (stop)
		{
			abortTest();
			qApp->installEventFilter(this);
			return true;
		}

		return false;
	}
	
	// if test is paused and pause key is pressed->resume macro
	if (!recording_ && e->type() == QEvent::KeyPress && lines_.size() > 0)
	{
		QKeyEvent* ke = dynamic_cast<QKeyEvent*>(e);
		if (ke->key() == Qt::Key_Pause)
		{
			processEvent_();
			timer_.reset();
			timer_.start();
			test_running_ = true;
			thread_.start();
			return true;
		}

		return false;
	}

	if (!recording_) return false;

	if (!RTTI::isKindOf<QKeyEvent>(*e) &&
			!RTTI::isKindOf<QMouseEvent>(*e) &&
			!RTTI::isKindOf<QShortcutEvent>(*e))
	{
		return false;
	}

	if (e->type() == QEvent::ShortcutOverride) return false;
 	if (e->type() == QEvent::KeyRelease) return false;
	QMouseEvent* 		me = dynamic_cast<QMouseEvent*>(e);
	QKeyEvent* 			ke = dynamic_cast<QKeyEvent*>(e);
	QShortcutEvent* se = dynamic_cast<QShortcutEvent*>(e);

	if (ke != 0 && 
			ke->type() == QEvent::KeyPress &&
			ke->key() == Qt::Key_Pause)
	{
		stopTest();
		return false;
	}

	///////////////////////////////////////////////////////
	// uniquely identify the active widget:
	// walk up the QObject tree and collect all names of QWidgets
	///////////////////////////////////////////////////////
	
	// take the sending object
 	QObject* o = obj;
	QObject* parent = 0;
	x_ = y_ = 0;

	// for mouse events: take widget under the mouse cursor
	if (me != 0) 
	{
		widget_ = qApp->widgetAt(me->globalPos());
		if (widget_ == 0) return false;
		if (widget_->objectName() == "" &&
				widget_->actions().size() == 0)
		{
			widget_ = dynamic_cast<QWidget*>(widget_->parent());
			if (widget_ == 0 || widget_->objectName() == "") return false;
		}
		o = widget_;

		QPoint global = me->globalPos();
		// if we can not get local coordinates: abort
 		QPoint local = widget_->mapFromGlobal(global);
		if (local.x() < 0 || local.y() < 0 ||
				local.x() >= widget_->width() || local.y() >= widget_->height()) 
		{
			return false;
		}

		// for menus: take the position of the action under the cursor
		QMenu* menu = dynamic_cast<QMenu*>(o);
		if (menu)
		{
			QAction* action = menu->actionAt(local);
			if (action != 0)
			{
				o = action;
				parent = menu;
				QRect rect = menu->actionGeometry(action);
				local.rx() -= rect.x();
				local.ry() -= rect.y();

				if (rect.width() == 0 || rect.height() == 0) return false;
				x_ = local.x();
				y_ = local.y();
			}
		}

		if (x_ == 0 && y_ == 0)
		{
			// take the position as percent of the widget's actual size
			if (widget_->width() == 0 || widget_->height() == 0) return false;
			x_ = local.x();
			y_ = local.y();
		}
	}

	String names;
	while (o != 0)
	{
		String name = ascii(o->objectName());
		if (name == "")
		{
			QWidget* widget = dynamic_cast<QWidget*>(o);
			if (widget != 0)
			{
				QList<QAction*> actions = widget->actions();
				if (actions.size() == 1)
				{
					name = ascii((**actions.begin()).objectName());
				}
			}
		}
		else
		{
			// if a parent has more childs with the same name: add a suffix with the number
			if (!parent) parent = o->parent();
			if (parent != 0)
			{
				QList<QWidget*> childs = parent->findChildren<QWidget*>(name.c_str());
				if (childs.size() > 1)
				{
					Position pos = 0;
					QList<QWidget*>::iterator wit = childs.begin();
					for (; wit != childs.end(); wit++)
					{
						if (*wit == o)
						{
							name += "#";
							name += String(pos);
							break;
						}

						pos++;
					}
				}
			}
		}

		if (name != "") names = name + "|" + names;
		o = o->parent();
	}


	String event_string;
	event_string += String((int)e->type()) + "|";
	event_string += String(getMainControl()->isBusy()) + "|";

	if (me != 0)
	{
		if (me->button() == Qt::NoButton &&
				!switch_move->isChecked() && 
				me->type() == QEvent::MouseMove &&	
				widget_ == last_widget_)
		{
			return false;
		}

 		last_widget_ = widget_;

		event_string += String((int)MOUSE) + "|";
		event_string += String((int) me->modifiers()) + "|";
		event_string += String((int) me->button()) + "|";
		event_string += String((int) me->buttons()) + "|";
		event_string += String(x_) + "|";
		event_string += String(y_) + "|";

		// prevent mouse move events with same position
		if (event_string == last_event_string_ &&
				names 			 == last_names_)
		{
			return false;
		}
	}
	else if (ke != 0)
	{
		// prevent accepting key events that are resend further up in the widget tree
		if (timer_.getClockTime() < 0.01) return false;

		int m = (int) ke->modifiers();
		// sometimes Qt sends nonsense Key messages
		if (m > (int)(Qt::AltModifier | Qt::ControlModifier | Qt::ShiftModifier)) return false;

		event_string += String((int)KEY) + "|";
		event_string += String(m);
		event_string += "|";
		event_string += String(ke->key()) + "|";
	}
	else if (se != 0)
	{
		event_string += String((int)SHORTCUT) + "|";
		event_string += String(se->shortcutId()) + "|";
		event_string += ascii(se->key().toString()) + "|";
	}

	float time = timer_.getClockTime();
	timer_.reset();

	outfile_ << "I°"
					 << time << "°"
					 << names << "°"
					 << event_string << std::endl;

	last_event_string_ = event_string;
	last_names_  			 = names;

	return false;
}
Пример #10
0
 void testFinished()
 {
     stopTest();
     startTestButton.setEnabled (true);
     logMessage (newLine + "*** Tests finished ***");
 }
Пример #11
0
 ~UnitTestsDemo()
 {
     stopTest();
 }
Пример #12
0
void RTGPUTestBench::onStopTest()
{
	emit stopTest();
	m_runCont->setDisabled(false);
	m_stopTest->setDisabled(true);
}
Пример #13
0
UnitTestsWidget::UnitTestsWidget(QWidget *parent)
    : QDialog(parent), m_test(XMLTest::tests()), m_isAborted(false)
{
    setWindowTitle(tr("Unit tests"));
    setModal(true);

    webView = new QWebView();
    webView->page()->setNetworkAccessManager(new QNetworkAccessManager());
    webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
    webView->setMinimumSize(200, 200);

    logWidget = new LogWidget(this);
    logWidget->setMemoryLabelVisible(false);

    trvTests = new QTreeWidget(this);
    trvTests->setMouseTracking(true);
    trvTests->setColumnCount(1);
    trvTests->setIndentation(15);
    trvTests->setIconSize(QSize(24, 24));
    trvTests->setHeaderHidden(true);
    trvTests->setMinimumWidth(360);
    trvTests->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(trvTests, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(doContextMenu(const QPoint &)));
    // connect(trvTests, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(doItemDoubleClicked(QTreeWidgetItem *, int)));
    // connect(trvTests, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(doItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));

    btnRunTests = new QPushButton(tr("Run tests"));
    connect(btnRunTests, SIGNAL(clicked()), this, SLOT(runTestsFromSuite()));

    // dialog buttons
    btnScenarios = new QPushButton(tr("Scenarios..."));
    btnUncheckTests = new QPushButton(tr("Uncheck tests"));
    connect(btnUncheckTests, SIGNAL(clicked()), this, SLOT(uncheckTests()));
    btnStopTest = new QPushButton(tr("Stop"));
    btnStopTest->setEnabled(false);
    connect(btnStopTest, SIGNAL(clicked()), this, SLOT(stopTest()));

    QGridLayout *leftLayout = new QGridLayout();
    leftLayout->setContentsMargins(0, 0, 0, 0);
    leftLayout->addWidget(trvTests, 0, 0, 1, 5);
    leftLayout->addWidget(btnScenarios, 1, 0);
    leftLayout->addWidget(btnUncheckTests, 1, 1);
    leftLayout->setColumnStretch(2, 1);
    leftLayout->addWidget(btnStopTest, 1, 3);
    leftLayout->addWidget(btnRunTests, 1, 4);

    QWidget *leftWidget = new QWidget();
    leftWidget->setLayout(leftLayout);

    QVBoxLayout *rightLayout = new QVBoxLayout();
    rightLayout->addWidget(webView, 3);
    rightLayout->addWidget(logWidget, 1);

    QWidget *rightWidget = new QWidget();
    rightWidget->setLayout(rightLayout);

    splitter = new QSplitter(this);
    splitter->setOrientation(Qt::Horizontal);
    splitter->addWidget(leftWidget);
    splitter->addWidget(rightWidget);

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(doAccept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(doReject()));

    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(splitter, 1);
    layout->addStretch();
    layout->addWidget(buttonBox);

    setLayout(layout);

    QSettings settings;
    splitter->restoreState(settings.value("UnitTestsWidget/SplitterState").toByteArray());
    splitter->restoreGeometry(settings.value("UnitTestsWidget/SplitterGeometry").toByteArray());
    restoreGeometry(settings.value("UnitTestsWidget/Geometry", saveGeometry()).toByteArray());

    // init ctemplate
    // stylesheet
    std::string style;
    ctemplate::TemplateDictionary stylesheet("style");
    stylesheet.SetValue("FONTFAMILY", htmlFontFamily().toStdString());
    stylesheet.SetValue("FONTSIZE", (QString("%1").arg(htmlFontSize() + 1).toStdString()));

    ctemplate::ExpandTemplate(compatibleFilename(datadir() + TEMPLATEROOT + "/panels/style_results.css").toStdString(), ctemplate::DO_NOT_STRIP, &stylesheet, &style);
    m_cascadeStyleSheet = QString::fromStdString(style);

    // read tests from test_suite
    readTestsFromSuite();
    readScenariosFromSuite();

    // read last test
    QDir dirUser(QString("%1/tests").arg(userDataDir()));
    if (!dirUser.exists())
        QDir(userDataDir()).mkpath(dirUser.absolutePath());

    dirUser.setFilter(QDir::Files | QDir::NoSymLinks);
    if (!dirUser.entryInfoList().isEmpty())
    {
        QString file = QString("%1").arg(dirUser.entryInfoList().last().absoluteFilePath());
        readTestFromDisk(file);
    }
}
Пример #14
0
JNIEXPORT void JNICALL Java_com_jamol_udpclient_app_MainActivity_stopTest(JNIEnv *env, jclass clazz)
{
    stopTest();
    waitTest();
    LOGI("test stopped");
}
Пример #15
0
void TestWindow::stop()
{
    stopTest();
}