1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine kbps more testable

This commit is contained in:
winlin 2018-12-23 20:30:12 +08:00
parent 16fa4c588a
commit 4c40370986
9 changed files with 144 additions and 14 deletions

View file

@ -212,6 +212,69 @@ srs_error_t MockBufferIO::read(void* buf, size_t size, ssize_t* nread)
return srs_success;
}
MockStatistic::MockStatistic()
{
in = out = 0;
}
MockStatistic::~MockStatistic()
{
}
int64_t MockStatistic::get_recv_bytes()
{
return in;
}
int64_t MockStatistic::get_send_bytes()
{
return out;
}
MockStatistic* MockStatistic::set_in(int64_t v)
{
in = v;
return this;
}
MockStatistic* MockStatistic::set_out(int64_t v)
{
out = v;
return this;
}
MockStatistic* MockStatistic::add_in(int64_t v)
{
in += v;
return this;
}
MockStatistic* MockStatistic::add_out(int64_t v)
{
out += v;
return this;
}
MockWallClock::MockWallClock()
{
clock = 0;
}
MockWallClock::~MockWallClock()
{
}
int64_t MockWallClock::time_ms()
{
return clock;
}
MockWallClock* MockWallClock::set_clock(int64_t ms)
{
clock = ms;
return this;
}
#ifdef ENABLE_UTEST_PROTOCOL
// verify the sha256
@ -5622,5 +5685,9 @@ VOID TEST(ProtocolHTTPTest, ParseHTTPMessage)
}
}
VOID TEST(ProtocolKbpsTest, ParseHTTPMessage)
{
}
#endif

View file

@ -109,5 +109,36 @@ public:
virtual srs_error_t read(void* buf, size_t size, ssize_t* nread);
};
class MockStatistic : public ISrsProtocolStatistic
{
private:
int64_t in;
int64_t out;
public:
MockStatistic();
virtual ~MockStatistic();
public:
virtual int64_t get_recv_bytes();
virtual int64_t get_send_bytes();
public:
MockStatistic* set_in(int64_t v);
MockStatistic* set_out(int64_t v);
MockStatistic* add_in(int64_t v);
MockStatistic* add_out(int64_t v);
};
class MockWallClock
{
private:
int64_t clock;
public:
MockWallClock();
virtual MockWallClock();
public:
virtual int64_t time_ms();
public:
virtual MockWallClock* set_clock(int64_t ms);
};
#endif