Changeset - ee2e261f6b2b
[Not reviewed]
0 1 0
Vitaly Takmazov - 8 years ago 2017-11-07 13:15:21
vitalyster@gmail.com
using boost::thread::sleep, fixes tests under MSVC
1 file changed with 4 insertions and 5 deletions:
0 comments (0 inline, 0 general)
tests/libtransport/HTTPRequest.cpp
Show inline comments
 
#include <boost/thread/thread.hpp>
 
#include <cppunit/TestFixture.h>
 
#include <cppunit/extensions/HelperMacros.h>
 
#include <Swiften/Swiften.h>
 
#include <Swiften/EventLoop/DummyEventLoop.h>
 
#include <Swiften/Server/Server.h>
 
#include <Swiften/Network/DummyNetworkFactories.h>
 
@@ -17,16 +18,12 @@
 
using namespace Transport;
 

	
 
#if !HAVE_SWIFTEN_3
 
#define get_value_or(X) substr()
 
#endif
 

	
 
#ifdef _MSC_VER
 
#define sleep Sleep
 
#endif
 

	
 
class HTTPRequestTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
	CPPUNIT_TEST_SUITE(HTTPRequestTest);
 
	CPPUNIT_TEST(GETThreadPool);
 
	CPPUNIT_TEST_SUITE_END();
 

	
 
	public:
 
@@ -58,13 +55,15 @@ class HTTPRequestTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
	void GETThreadPool() {
 
		HTTPRequest *req = new HTTPRequest(tp, HTTPRequest::Get, "http://spectrum.im/params.json", boost::bind(&HTTPRequestTest::handleResult, this, _1, _2, _3, _4));
 
		req->execute();
 

	
 
		int i = 0;
 
		while (result == false && i < 5) {
 
			sleep(1);
 
			boost::system_time time = boost::get_system_time();
 
			time += boost::posix_time::seconds(1);
 
			boost::thread::sleep(time);
 
			loop->processEvents();
 
			i++;
 
		}
 
		CPPUNIT_ASSERT(result);
 
	}
 

	
0 comments (0 inline, 0 general)