mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
Cover protocol stack RTMP. 3.0.63
This commit is contained in:
parent
1583f6cc3f
commit
cf9a6b4f48
1 changed files with 75 additions and 1 deletions
|
@ -22,7 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
*/
|
||||
#include <srs_utest_protostack.hpp>
|
||||
|
||||
using namespace std;
|
||||
#include <srs_utest_protocol.hpp>
|
||||
|
||||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
|
@ -36,6 +36,8 @@ using namespace std;
|
|||
#include <srs_service_http_conn.hpp>
|
||||
#include <srs_kernel_buffer.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MockErrorPacket : public SrsPacket
|
||||
{
|
||||
protected:
|
||||
|
@ -75,3 +77,75 @@ VOID TEST(ProtoStackTest, PacketEncode)
|
|||
}
|
||||
}
|
||||
|
||||
VOID TEST(ProtoStackTest, ManualFlush)
|
||||
{
|
||||
srs_error_t err;
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
// Always response ACK message.
|
||||
HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1));
|
||||
|
||||
// Default is auto response.
|
||||
HELPER_EXPECT_SUCCESS(p.response_acknowledgement_message());
|
||||
EXPECT_EQ(12+4, io.out_buffer.length());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
// Always response ACK message.
|
||||
HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1));
|
||||
|
||||
p.set_auto_response(true);
|
||||
HELPER_EXPECT_SUCCESS(p.response_acknowledgement_message());
|
||||
EXPECT_EQ(12+4, io.out_buffer.length());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
// Always response ACK message.
|
||||
HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1));
|
||||
|
||||
// When not auto response, need to flush it manually.
|
||||
p.set_auto_response(false);
|
||||
HELPER_EXPECT_SUCCESS(p.response_acknowledgement_message());
|
||||
EXPECT_EQ(0, io.out_buffer.length());
|
||||
|
||||
HELPER_EXPECT_SUCCESS(p.manual_response_flush());
|
||||
EXPECT_EQ(12+4, io.out_buffer.length());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
// Always response ACK message.
|
||||
HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1));
|
||||
|
||||
HELPER_EXPECT_SUCCESS(p.response_ping_message(1024));
|
||||
EXPECT_EQ(12+6, io.out_buffer.length());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockBufferIO io;
|
||||
SrsProtocol p(&io);
|
||||
|
||||
// Always response ACK message.
|
||||
HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1));
|
||||
|
||||
// When not auto response, need to flush it manually.
|
||||
p.set_auto_response(false);
|
||||
HELPER_EXPECT_SUCCESS(p.response_ping_message(1024));
|
||||
EXPECT_EQ(0, io.out_buffer.length());
|
||||
|
||||
HELPER_EXPECT_SUCCESS(p.manual_response_flush());
|
||||
EXPECT_EQ(12+6, io.out_buffer.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue