mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Add utest for connection manager
This commit is contained in:
parent
72122c746a
commit
86a80396de
3 changed files with 42 additions and 10 deletions
|
@ -30,10 +30,32 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_app_rtc_source.hpp>
|
#include <srs_app_rtc_source.hpp>
|
||||||
#include <srs_app_rtc_conn.hpp>
|
#include <srs_app_rtc_conn.hpp>
|
||||||
#include <srs_kernel_codec.hpp>
|
#include <srs_kernel_codec.hpp>
|
||||||
|
#include <srs_app_conn.hpp>
|
||||||
|
|
||||||
|
#include <srs_utest_service.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
VOID TEST(KernelRTCTest, ConnectionManagerTest)
|
||||||
|
{
|
||||||
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
SrsConnectionManager manager;
|
||||||
|
HELPER_EXPECT_SUCCESS(manager.start());
|
||||||
|
EXPECT_EQ(0, manager.size()); EXPECT_TRUE(manager.empty());
|
||||||
|
|
||||||
|
MockSrsConnection* conn = new MockSrsConnection();
|
||||||
|
manager.add(conn);
|
||||||
|
EXPECT_EQ(1, manager.size()); EXPECT_FALSE(manager.empty());
|
||||||
|
|
||||||
|
manager.remove(conn);
|
||||||
|
srs_usleep(0); // Switch context for manager to dispose connections.
|
||||||
|
EXPECT_EQ(0, manager.size()); EXPECT_TRUE(manager.empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VOID TEST(KernelRTCTest, StringDumpHexTest)
|
VOID TEST(KernelRTCTest, StringDumpHexTest)
|
||||||
{
|
{
|
||||||
// Typical normal case.
|
// Typical normal case.
|
||||||
|
|
|
@ -42,17 +42,18 @@ using namespace std;
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
class MockSrsConnection : public ISrsConnection
|
MockSrsConnection::MockSrsConnection()
|
||||||
{
|
{
|
||||||
public:
|
}
|
||||||
MockSrsConnection() {
|
|
||||||
}
|
MockSrsConnection::~MockSrsConnection()
|
||||||
virtual ~MockSrsConnection() {
|
{
|
||||||
}
|
}
|
||||||
virtual std::string remote_ip() {
|
|
||||||
return "127.0.0.1";
|
std::string MockSrsConnection::remote_ip()
|
||||||
}
|
{
|
||||||
};
|
return "127.0.0.1";
|
||||||
|
}
|
||||||
|
|
||||||
VOID TEST(ServiceTimeTest, TimeUnit)
|
VOID TEST(ServiceTimeTest, TimeUnit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_utest.hpp>
|
#include <srs_utest.hpp>
|
||||||
|
|
||||||
#include <srs_app_st.hpp>
|
#include <srs_app_st.hpp>
|
||||||
|
#include <srs_service_conn.hpp>
|
||||||
|
|
||||||
|
class MockSrsConnection : public ISrsConnection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockSrsConnection();
|
||||||
|
virtual ~MockSrsConnection();
|
||||||
|
virtual std::string remote_ip();
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue