Skip to content
Snippets Groups Projects
Unverified Commit 3e3dbbab authored by Sébastien Blin's avatar Sébastien Blin
Browse files

test: check if manager is initialized

Change-Id: I7fd07a370f5a7f0562eea785bea74d2d44ae21f2
parent 49a1d617
Branches
No related tags found
No related merge requests found
...@@ -32,18 +32,20 @@ ...@@ -32,18 +32,20 @@
using namespace DRing::Account; using namespace DRing::Account;
namespace jami { namespace test { namespace jami {
namespace test {
class ConnectionManagerTest : public CppUnit::TestFixture { class ConnectionManagerTest : public CppUnit::TestFixture
{
public: public:
ConnectionManagerTest() { ConnectionManagerTest()
{
// Init daemon // Init daemon
DRing::init(DRing::InitFlag(DRing::DRING_FLAG_DEBUG | DRing::DRING_FLAG_CONSOLE_LOG)); DRing::init(DRing::InitFlag(DRing::DRING_FLAG_DEBUG | DRing::DRING_FLAG_CONSOLE_LOG));
if (not Manager::instance().initialized)
CPPUNIT_ASSERT(DRing::start("dring-sample.yml")); CPPUNIT_ASSERT(DRing::start("dring-sample.yml"));
} }
~ConnectionManagerTest() { ~ConnectionManagerTest() { DRing::fini(); }
DRing::fini();
}
static std::string name() { return "ConnectionManager"; } static std::string name() { return "ConnectionManager"; }
void setUp(); void setUp();
void tearDown(); void tearDown();
...@@ -88,7 +90,7 @@ ConnectionManagerTest::setUp() ...@@ -88,7 +90,7 @@ ConnectionManagerTest::setUp()
details[ConfProperties::TYPE] = "RING"; details[ConfProperties::TYPE] = "RING";
details[ConfProperties::DISPLAYNAME] = "ALICE"; details[ConfProperties::DISPLAYNAME] = "ALICE";
details[ConfProperties::ALIAS] = "ALICE"; details[ConfProperties::ALIAS] = "ALICE";
details[ConfProperties::UPNP_ENABLED] = "false"; details[ConfProperties::UPNP_ENABLED] = "true";
details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PASSWORD] = "";
details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PIN] = "";
details[ConfProperties::ARCHIVE_PATH] = ""; details[ConfProperties::ARCHIVE_PATH] = "";
...@@ -98,42 +100,60 @@ ConnectionManagerTest::setUp() ...@@ -98,42 +100,60 @@ ConnectionManagerTest::setUp()
details[ConfProperties::TYPE] = "RING"; details[ConfProperties::TYPE] = "RING";
details[ConfProperties::DISPLAYNAME] = "BOB"; details[ConfProperties::DISPLAYNAME] = "BOB";
details[ConfProperties::ALIAS] = "BOB"; details[ConfProperties::ALIAS] = "BOB";
details[ConfProperties::UPNP_ENABLED] = "false"; details[ConfProperties::UPNP_ENABLED] = "true";
details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PASSWORD] = "";
details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PIN] = "";
details[ConfProperties::ARCHIVE_PATH] = ""; details[ConfProperties::ARCHIVE_PATH] = "";
bobId = Manager::instance().addAccount(details); bobId = Manager::instance().addAccount(details);
JAMI_INFO("Initialize account...");
auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId);
auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId);
std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>> confHandlers;
std::mutex mtx;
std::unique_lock<std::mutex> lk {mtx};
std::condition_variable cv;
auto accountsReady = 0;
confHandlers.insert(
DRing::exportable_callback<DRing::ConfigurationSignal::VolatileDetailsChanged>(
[&](const std::string&, const std::map<std::string, std::string>&) {
bool ready = false; bool ready = false;
auto idx = 0;
while(!ready && idx < 100) {
auto details = aliceAccount->getVolatileAccountDetails(); auto details = aliceAccount->getVolatileAccountDetails();
auto daemonStatus = details[DRing::Account::ConfProperties::Registration::STATUS]; auto daemonStatus = details[DRing::Account::ConfProperties::Registration::STATUS];
ready = (daemonStatus == "REGISTERED"); ready = (daemonStatus == "REGISTERED");
details = bobAccount->getVolatileAccountDetails(); details = bobAccount->getVolatileAccountDetails();
daemonStatus = details[DRing::Account::ConfProperties::Registration::STATUS]; daemonStatus = details[DRing::Account::ConfProperties::Registration::STATUS];
ready &= (daemonStatus == "REGISTERED"); ready &= (daemonStatus == "REGISTERED");
if (!ready) { }));
idx += 1; DRing::registerSignalHandlers(confHandlers);
std::this_thread::sleep_for(std::chrono::milliseconds(100)); cv.wait_for(lk, std::chrono::seconds(30));
} DRing::unregisterSignalHandlers();
}
} }
void void
ConnectionManagerTest::tearDown() ConnectionManagerTest::tearDown()
{ {
JAMI_INFO("Remove created accounts...");
std::map<std::string, std::shared_ptr<DRing::CallbackWrapperBase>> confHandlers;
std::mutex mtx;
std::unique_lock<std::mutex> lk {mtx};
std::condition_variable cv;
auto currentAccSize = Manager::instance().getAccountList().size(); auto currentAccSize = Manager::instance().getAccountList().size();
confHandlers.insert(
DRing::exportable_callback<DRing::ConfigurationSignal::AccountsChanged>([&]() {
if (Manager::instance().getAccountList().size() <= currentAccSize - 2) {
cv.notify_one();
}
}));
DRing::registerSignalHandlers(confHandlers);
Manager::instance().removeAccount(aliceId, true); Manager::instance().removeAccount(aliceId, true);
Manager::instance().removeAccount(bobId, true); Manager::instance().removeAccount(bobId, true);
// Because cppunit is not linked with dbus, just poll if removed // Because cppunit is not linked with dbus, just poll if removed
for (int i = 0; i < 40; ++i) { cv.wait_for(lk, std::chrono::seconds(30));
if (Manager::instance().getAccountList().size() <= currentAccSize - 2) break;
std::this_thread::sleep_for(std::chrono::milliseconds(100)); DRing::unregisterSignalHandlers();
}
} }
void void
...@@ -148,24 +168,29 @@ ConnectionManagerTest::testConnectDevice() ...@@ -148,24 +168,29 @@ ConnectionManagerTest::testConnectDevice()
std::mutex mtx; std::mutex mtx;
std::unique_lock<std::mutex> lk {mtx}; std::unique_lock<std::mutex> lk {mtx};
std::condition_variable cv; std::condition_variable cv, cvReceive;
bool successfullyConnected = false; bool successfullyConnected = false;
bool successfullyReceive = false; bool successfullyReceive = false;
bobAccount->connectionManager().onChannelRequest( bobAccount->connectionManager().onChannelRequest(
[&successfullyReceive](const std::string&, const std::string& name) { [&successfullyReceive, &cvReceive](const std::string&, const std::string& name) {
successfullyReceive = name == "git://*"; successfullyReceive = name == "git://*";
cvReceive.notify_one();
return true; return true;
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(10)); cvReceive.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyReceive);
cv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
} }
...@@ -193,19 +218,23 @@ ConnectionManagerTest::testAcceptConnection() ...@@ -193,19 +218,23 @@ ConnectionManagerTest::testAcceptConnection()
}); });
bobAccount->connectionManager().onConnectionReady( bobAccount->connectionManager().onConnectionReady(
[&receiverConnected](const std::string&, const std::string& name, std::shared_ptr<ChannelSocket> socket) { [&receiverConnected](const std::string&,
const std::string& name,
std::shared_ptr<ChannelSocket> socket) {
receiverConnected = socket && (name == "git://*"); receiverConnected = socket && (name == "git://*");
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyReceive); CPPUNIT_ASSERT(successfullyReceive);
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
CPPUNIT_ASSERT(receiverConnected); CPPUNIT_ASSERT(receiverConnected);
...@@ -229,33 +258,38 @@ ConnectionManagerTest::testMultipleChannels() ...@@ -229,33 +258,38 @@ ConnectionManagerTest::testMultipleChannels()
int receiverConnected = 0; int receiverConnected = 0;
bobAccount->connectionManager().onChannelRequest( bobAccount->connectionManager().onChannelRequest(
[](const std::string&, const std::string&) { [](const std::string&, const std::string&) { return true; });
return true;
});
bobAccount->connectionManager().onConnectionReady( bobAccount->connectionManager().onConnectionReady(
[&receiverConnected](const std::string&, const std::string&, std::shared_ptr<ChannelSocket> socket) { [&receiverConnected](const std::string&,
if (socket) receiverConnected += 1; const std::string&,
std::shared_ptr<ChannelSocket> socket) {
if (socket)
receiverConnected += 1;
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
cv.notify_one(); cv.notify_one();
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "sip://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected2](std::shared_ptr<ChannelSocket> socket) { "sip://*",
[&cv, &successfullyConnected2](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected2 = true; successfullyConnected2 = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
CPPUNIT_ASSERT(successfullyConnected2); CPPUNIT_ASSERT(successfullyConnected2);
CPPUNIT_ASSERT(receiverConnected == 2); CPPUNIT_ASSERT(receiverConnected == 2);
...@@ -279,17 +313,20 @@ ConnectionManagerTest::testMultipleChannelsSameName() ...@@ -279,17 +313,20 @@ ConnectionManagerTest::testMultipleChannelsSameName()
int receiverConnected = 0; int receiverConnected = 0;
bobAccount->connectionManager().onChannelRequest( bobAccount->connectionManager().onChannelRequest(
[](const std::string&, const std::string&) { [](const std::string&, const std::string&) { return true; });
return true;
});
bobAccount->connectionManager().onConnectionReady( bobAccount->connectionManager().onConnectionReady(
[&receiverConnected](const std::string&, const std::string&, std::shared_ptr<ChannelSocket> socket) { [&receiverConnected](const std::string&,
if (socket) receiverConnected += 1; const std::string&,
std::shared_ptr<ChannelSocket> socket) {
if (socket)
receiverConnected += 1;
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
...@@ -297,16 +334,18 @@ ConnectionManagerTest::testMultipleChannelsSameName() ...@@ -297,16 +334,18 @@ ConnectionManagerTest::testMultipleChannelsSameName()
}); });
// We can open two sockets with the same name, it will be two different channel // We can open two sockets with the same name, it will be two different channel
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected2](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected2](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected2 = true; successfullyConnected2 = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
CPPUNIT_ASSERT(successfullyConnected2); CPPUNIT_ASSERT(successfullyConnected2);
CPPUNIT_ASSERT(receiverConnected == 2); CPPUNIT_ASSERT(receiverConnected == 2);
...@@ -326,7 +365,8 @@ ConnectionManagerTest::testSendReceiveData() ...@@ -326,7 +365,8 @@ ConnectionManagerTest::testSendReceiveData()
std::unique_lock<std::mutex> lk {mtx}; std::unique_lock<std::mutex> lk {mtx};
std::condition_variable cv; std::condition_variable cv;
std::atomic_int events(0); std::atomic_int events(0);
bool successfullyConnected = false, successfullyConnected2 = false, successfullyReceive = false, receiverConnected = false; bool successfullyConnected = false, successfullyConnected2 = false, successfullyReceive = false,
receiverConnected = false;
const uint8_t buf_other[] = {0x64, 0x65, 0x66, 0x67}; const uint8_t buf_other[] = {0x64, 0x65, 0x66, 0x67};
const uint8_t buf_test[] = {0x68, 0x69, 0x70, 0x71}; const uint8_t buf_test[] = {0x68, 0x69, 0x70, 0x71};
bool dataOk = false, dataOk2 = false; bool dataOk = false, dataOk2 = false;
...@@ -356,7 +396,8 @@ ConnectionManagerTest::testSendReceiveData() ...@@ -356,7 +396,8 @@ ConnectionManagerTest::testSendReceiveData()
} }
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "test", aliceAccount->connectionManager().connectDevice(bobDeviceId,
"test",
[&](std::shared_ptr<ChannelSocket> socket) { [&](std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
...@@ -367,7 +408,8 @@ ConnectionManagerTest::testSendReceiveData() ...@@ -367,7 +408,8 @@ ConnectionManagerTest::testSendReceiveData()
cv.notify_one(); cv.notify_one();
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "other", aliceAccount->connectionManager().connectDevice(bobDeviceId,
"other",
[&](std::shared_ptr<ChannelSocket> socket) { [&](std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected2 = true; successfullyConnected2 = true;
...@@ -386,7 +428,6 @@ ConnectionManagerTest::testSendReceiveData() ...@@ -386,7 +428,6 @@ ConnectionManagerTest::testSendReceiveData()
CPPUNIT_ASSERT(receiverConnected); CPPUNIT_ASSERT(receiverConnected);
CPPUNIT_ASSERT(dataOk); CPPUNIT_ASSERT(dataOk);
CPPUNIT_ASSERT(dataOk2); CPPUNIT_ASSERT(dataOk2);
} }
void void
...@@ -413,19 +454,23 @@ ConnectionManagerTest::testDeclineConnection() ...@@ -413,19 +454,23 @@ ConnectionManagerTest::testDeclineConnection()
}); });
bobAccount->connectionManager().onConnectionReady( bobAccount->connectionManager().onConnectionReady(
[&receiverConnected](const std::string&, const std::string&, std::shared_ptr<ChannelSocket> socket) { [&receiverConnected](const std::string&,
const std::string&,
std::shared_ptr<ChannelSocket> socket) {
if (socket) if (socket)
receiverConnected = true; receiverConnected = true;
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyReceive); CPPUNIT_ASSERT(successfullyReceive);
CPPUNIT_ASSERT(!successfullyConnected); CPPUNIT_ASSERT(!successfullyConnected);
CPPUNIT_ASSERT(!receiverConnected); CPPUNIT_ASSERT(!receiverConnected);
...@@ -447,26 +492,31 @@ ConnectionManagerTest::testAcceptsICERequest() ...@@ -447,26 +492,31 @@ ConnectionManagerTest::testAcceptsICERequest()
bool successfullyReceive = false; bool successfullyReceive = false;
bool receiverConnected = false; bool receiverConnected = false;
bobAccount->connectionManager().onChannelRequest([](const std::string&, const std::string&) { return true; }); bobAccount->connectionManager().onChannelRequest(
[](const std::string&, const std::string&) { return true; });
bobAccount->connectionManager().onICERequest([&](const std::string&) { bobAccount->connectionManager().onICERequest([&](const std::string&) {
successfullyReceive = true; successfullyReceive = true;
return true; return true;
}); });
bobAccount->connectionManager().onConnectionReady( bobAccount->connectionManager().onConnectionReady(
[&receiverConnected](const std::string&, const std::string& name, std::shared_ptr<ChannelSocket> socket) { [&receiverConnected](const std::string&,
const std::string& name,
std::shared_ptr<ChannelSocket> socket) {
receiverConnected = socket && (name == "git://*"); receiverConnected = socket && (name == "git://*");
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(10)); cv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(successfullyReceive); CPPUNIT_ASSERT(successfullyReceive);
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
CPPUNIT_ASSERT(receiverConnected); CPPUNIT_ASSERT(receiverConnected);
...@@ -488,27 +538,31 @@ ConnectionManagerTest::testDeclineICERequest() ...@@ -488,27 +538,31 @@ ConnectionManagerTest::testDeclineICERequest()
bool successfullyReceive = false; bool successfullyReceive = false;
bool receiverConnected = false; bool receiverConnected = false;
bobAccount->connectionManager().onChannelRequest([](const std::string&, const std::string&) { return true; }); bobAccount->connectionManager().onChannelRequest(
[](const std::string&, const std::string&) { return true; });
bobAccount->connectionManager().onICERequest([&](const std::string&) { bobAccount->connectionManager().onICERequest([&](const std::string&) {
successfullyReceive = true; successfullyReceive = true;
return false; return false;
}); });
bobAccount->connectionManager().onConnectionReady( bobAccount->connectionManager().onConnectionReady(
[&receiverConnected](const std::string&, const std::string& name, std::shared_ptr<ChannelSocket> socket) { [&receiverConnected](const std::string&,
const std::string& name,
std::shared_ptr<ChannelSocket> socket) {
receiverConnected = socket && (name == "git://*"); receiverConnected = socket && (name == "git://*");
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
[&cv, &successfullyConnected](std::shared_ptr<ChannelSocket> socket) { "git://*",
[&cv, &successfullyConnected](
std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
} }
cv.notify_one(); cv.notify_one();
}); });
cv.wait_for(lk, std::chrono::seconds(30));
cv.wait_for(lk, std::chrono::seconds(10));
CPPUNIT_ASSERT(successfullyReceive); CPPUNIT_ASSERT(successfullyReceive);
CPPUNIT_ASSERT(!successfullyConnected); CPPUNIT_ASSERT(!successfullyConnected);
CPPUNIT_ASSERT(!receiverConnected); CPPUNIT_ASSERT(!receiverConnected);
...@@ -545,7 +599,8 @@ ConnectionManagerTest::testChannelRcvShutdown() ...@@ -545,7 +599,8 @@ ConnectionManagerTest::testChannelRcvShutdown()
socket->shutdown(); socket->shutdown();
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
"git://*",
[&](std::shared_ptr<ChannelSocket> socket) { [&](std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
socket->onShutdown([&]() { socket->onShutdown([&]() {
...@@ -556,8 +611,8 @@ ConnectionManagerTest::testChannelRcvShutdown() ...@@ -556,8 +611,8 @@ ConnectionManagerTest::testChannelRcvShutdown()
} }
}); });
rcv.wait_for(lk, std::chrono::seconds(10)); rcv.wait_for(lk, std::chrono::seconds(30));
scv.wait_for(lk, std::chrono::seconds(10)); scv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(shutdownReceived); CPPUNIT_ASSERT(shutdownReceived);
CPPUNIT_ASSERT(successfullyReceive); CPPUNIT_ASSERT(successfullyReceive);
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
...@@ -599,7 +654,8 @@ ConnectionManagerTest::testChannelSenderShutdown() ...@@ -599,7 +654,8 @@ ConnectionManagerTest::testChannelSenderShutdown()
receiverConnected = socket && (name == "git://*"); receiverConnected = socket && (name == "git://*");
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
"git://*",
[&](std::shared_ptr<ChannelSocket> socket) { [&](std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
successfullyConnected = true; successfullyConnected = true;
...@@ -608,8 +664,8 @@ ConnectionManagerTest::testChannelSenderShutdown() ...@@ -608,8 +664,8 @@ ConnectionManagerTest::testChannelSenderShutdown()
} }
}); });
rcv.wait_for(lk, std::chrono::seconds(10)); rcv.wait_for(lk, std::chrono::seconds(30));
scv.wait_for(lk, std::chrono::seconds(10)); scv.wait_for(lk, std::chrono::seconds(30));
CPPUNIT_ASSERT(shutdownReceived); CPPUNIT_ASSERT(shutdownReceived);
CPPUNIT_ASSERT(successfullyReceive); CPPUNIT_ASSERT(successfullyReceive);
CPPUNIT_ASSERT(successfullyConnected); CPPUNIT_ASSERT(successfullyConnected);
...@@ -651,7 +707,8 @@ ConnectionManagerTest::testCloseConnectionWithDevice() ...@@ -651,7 +707,8 @@ ConnectionManagerTest::testCloseConnectionWithDevice()
receiverConnected = socket && (name == "git://*"); receiverConnected = socket && (name == "git://*");
}); });
aliceAccount->connectionManager().connectDevice(bobDeviceId, "git://*", aliceAccount->connectionManager().connectDevice(bobDeviceId,
"git://*",
[&](std::shared_ptr<ChannelSocket> socket) { [&](std::shared_ptr<ChannelSocket> socket) {
if (socket) { if (socket) {
socket->onShutdown([&]() { socket->onShutdown([&]() {
...@@ -663,7 +720,7 @@ ConnectionManagerTest::testCloseConnectionWithDevice() ...@@ -663,7 +720,7 @@ ConnectionManagerTest::testCloseConnectionWithDevice()
} }
}); });
rcv.wait_for(lk, std::chrono::seconds(10)); rcv.wait_for(lk, std::chrono::seconds(30));
// This should trigger onShutdown // This should trigger onShutdown
aliceAccount->connectionManager().closeConnectionsWith(bobDeviceId); aliceAccount->connectionManager().closeConnectionsWith(bobDeviceId);
auto expiration = std::chrono::system_clock::now() + std::chrono::seconds(10); auto expiration = std::chrono::system_clock::now() + std::chrono::seconds(10);
...@@ -674,6 +731,7 @@ ConnectionManagerTest::testCloseConnectionWithDevice() ...@@ -674,6 +731,7 @@ ConnectionManagerTest::testCloseConnectionWithDevice()
CPPUNIT_ASSERT(receiverConnected); CPPUNIT_ASSERT(receiverConnected);
} }
}} // namespace test } // namespace test
} // namespace jami
RING_TEST_RUNNER(jami::test::ConnectionManagerTest::name()) RING_TEST_RUNNER(jami::test::ConnectionManagerTest::name())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment