Loading...
Searching...
No Matches
WebProgressListener_impl.h
Go to the documentation of this file.
/*
* Robot Testing Framework
*
* Copyright (C) 2015-2019 Istituto Italiano di Tecnologia (IIT)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ROBOTTESTINGFRAMEWORK_WEBPROGRESSLISTENER_IMPL_H
#define ROBOTTESTINGFRAMEWORK_WEBPROGRESSLISTENER_IMPL_H
#include <robottestingframework/TestListener.h>
#include <mongoose.h>
#include <mutex>
#include <thread>
namespace robottestingframework {
class WebProgressListenerImpl
{
public:
static WebProgressListenerImpl& create(unsigned int port = 8080,
bool verbose = false);
virtual ~WebProgressListenerImpl();
virtual void addReport(const Test* test, TestMessage msg);
virtual void addError(const Test* test, TestMessage msg);
virtual void addFailure(const Test* test, TestMessage msg);
virtual void startTest(const Test* test);
virtual void endTest(const Test* test);
virtual void startTestSuite(const Test* test);
virtual void endTestSuite(const Test* test);
virtual void startTestRunner();
virtual void endTestRunner();
public:
struct mg_server* server;
std::mutex critical;
bool shouldStop;
std::string result;
std::string suite_name;
std::size_t suite_size;
enum class TestStatus
{
NotRun = 0,
Running = 1,
Failed = 2,
Success = 3
};
std::vector<TestStatus> testStatus;
private:
WebProgressListenerImpl(WebProgressListenerImpl const&) = delete;
void operator=(WebProgressListenerImpl const&) = delete;
WebProgressListenerImpl(unsigned int port,
bool verbose);
std::string encode(const std::string& data);
static void update(void* param);
static int handler(struct mg_connection* conn,
enum mg_event ev);
private:
std::thread* updater;
bool verbose;
unsigned int port;
};
} // namespace robottestingframework
#endif // ROBOTTESTINGFRAMEWORK_WEBPROGRESSLISTENER_IMPL_H
TestListener.h
robottestingframework::TestMessage
A formated message with details.
Definition TestMessage.h:33
robottestingframework::Test
The simplest form of a test unit.
Definition Test.h:35
robottestingframework::WebProgressListenerImpl
Singleton class WebProgressListenerImpl listens to any messages reported by the tests during the test...
Definition WebProgressListener_impl.h:42
robottestingframework::WebProgressListenerImpl::handler
static int handler(struct mg_connection *conn, enum mg_event ev)
robottestingframework::WebProgressListenerImpl::port
unsigned int port
Definition WebProgressListener_impl.h:147
robottestingframework::WebProgressListenerImpl::updater
std::thread * updater
Definition WebProgressListener_impl.h:145
robottestingframework::WebProgressListenerImpl::suite_name
std::string suite_name
Definition WebProgressListener_impl.h:120
robottestingframework::WebProgressListenerImpl::endTestSuite
virtual void endTestSuite(const Test *test)
This is called when a TestSuite is finished.
robottestingframework::WebProgressListenerImpl::encode
std::string encode(const std::string &data)
robottestingframework::WebProgressListenerImpl::addError
virtual void addError(const Test *test, TestMessage msg)
This is called when an error occurred during test run.
robottestingframework::WebProgressListenerImpl::startTestSuite
virtual void startTestSuite(const Test *test)
This is called when a TestSuite is started.
robottestingframework::WebProgressListenerImpl::result
std::string result
Definition WebProgressListener_impl.h:119
robottestingframework::WebProgressListenerImpl::server
struct mg_server * server
Definition WebProgressListener_impl.h:116
robottestingframework::WebProgressListenerImpl::operator=
void operator=(WebProgressListenerImpl const &)=delete
robottestingframework::WebProgressListenerImpl::WebProgressListenerImpl
WebProgressListenerImpl(unsigned int port, bool verbose)
robottestingframework::WebProgressListenerImpl::addFailure
virtual void addFailure(const Test *test, TestMessage msg)
This is called when a failure occurred during test run.
robottestingframework::WebProgressListenerImpl::endTest
virtual void endTest(const Test *test)
This is called when a Test is finished.
robottestingframework::WebProgressListenerImpl::TestStatus
TestStatus
Definition WebProgressListener_impl.h:124
robottestingframework::WebProgressListenerImpl::TestStatus::Success
@ Success
robottestingframework::WebProgressListenerImpl::TestStatus::Running
@ Running
robottestingframework::WebProgressListenerImpl::TestStatus::NotRun
@ NotRun
robottestingframework::WebProgressListenerImpl::TestStatus::Failed
@ Failed
robottestingframework::WebProgressListenerImpl::critical
std::mutex critical
Definition WebProgressListener_impl.h:117
robottestingframework::WebProgressListenerImpl::create
static WebProgressListenerImpl & create(unsigned int port=8080, bool verbose=false)
create Creates an instance of WebProgressListenerImpl class
robottestingframework::WebProgressListenerImpl::addReport
virtual void addReport(const Test *test, TestMessage msg)
This is called to report any arbitrary message from tests.
robottestingframework::WebProgressListenerImpl::WebProgressListenerImpl
WebProgressListenerImpl(WebProgressListenerImpl const &)=delete
robottestingframework::WebProgressListenerImpl::suite_size
std::size_t suite_size
Definition WebProgressListener_impl.h:121
robottestingframework::WebProgressListenerImpl::endTestRunner
virtual void endTestRunner()
This is called when the TestRunner is finished.
robottestingframework::WebProgressListenerImpl::~WebProgressListenerImpl
virtual ~WebProgressListenerImpl()
WebProgressListenerImpl destructor.
robottestingframework::WebProgressListenerImpl::testStatus
std::vector< TestStatus > testStatus
Definition WebProgressListener_impl.h:131
robottestingframework::WebProgressListenerImpl::startTest
virtual void startTest(const Test *test)
This is called when a Test is started.
robottestingframework::WebProgressListenerImpl::startTestRunner
virtual void startTestRunner()
This is called when the TestRunner is started.
robottestingframework::WebProgressListenerImpl::update
static void update(void *param)
robottestingframework::WebProgressListenerImpl::verbose
bool verbose
Definition WebProgressListener_impl.h:146
robottestingframework::WebProgressListenerImpl::shouldStop
bool shouldStop
Definition WebProgressListener_impl.h:118
robottestingframework
Definition Arguments.h:25