2011-07-08 17:57:01 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* Channel Manager Unit Tests
|
|
|
|
*
|
|
|
|
* Copyright 2011 Vic Lee
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <freerdp/freerdp.h>
|
2011-07-10 18:24:47 +04:00
|
|
|
#include <freerdp/constants.h>
|
2011-08-15 22:33:04 +04:00
|
|
|
#include <freerdp/chanman/chanman.h>
|
2011-07-11 08:04:13 +04:00
|
|
|
#include <freerdp/utils/event.h>
|
2011-07-08 17:57:01 +04:00
|
|
|
|
|
|
|
#include "test_chanman.h"
|
|
|
|
|
|
|
|
int init_chanman_suite(void)
|
|
|
|
{
|
|
|
|
freerdp_chanman_global_init();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int clean_chanman_suite(void)
|
|
|
|
{
|
|
|
|
freerdp_chanman_global_uninit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int add_chanman_suite(void)
|
|
|
|
{
|
|
|
|
add_test_suite(chanman);
|
|
|
|
|
|
|
|
add_test_function(chanman);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-28 09:04:01 +04:00
|
|
|
static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, int data_size)
|
2011-07-10 18:24:47 +04:00
|
|
|
{
|
|
|
|
printf("chan_id %d data_size %d\n", chan_id, data_size);
|
2011-08-07 22:37:26 +04:00
|
|
|
return 0;
|
2011-07-10 18:24:47 +04:00
|
|
|
}
|
|
|
|
|
2011-07-08 17:57:01 +04:00
|
|
|
void test_chanman(void)
|
|
|
|
{
|
|
|
|
rdpChanMan* chan_man;
|
|
|
|
rdpSettings settings = { 0 };
|
2011-07-28 09:04:01 +04:00
|
|
|
freerdp instance = { 0 };
|
2011-08-18 01:28:26 +04:00
|
|
|
RDP_EVENT* event;
|
2011-07-10 18:24:47 +04:00
|
|
|
|
|
|
|
settings.hostname = "testhost";
|
2011-07-28 09:04:01 +04:00
|
|
|
instance.settings = &settings;
|
2011-08-02 22:12:08 +04:00
|
|
|
instance.SendChannelData = test_rdp_channel_data;
|
2011-07-08 17:57:01 +04:00
|
|
|
|
|
|
|
chan_man = freerdp_chanman_new();
|
|
|
|
|
2011-07-10 18:24:47 +04:00
|
|
|
freerdp_chanman_load_plugin(chan_man, &settings, "../channels/rdpdbg/rdpdbg.so", NULL);
|
2011-07-28 09:04:01 +04:00
|
|
|
freerdp_chanman_pre_connect(chan_man, &instance);
|
|
|
|
freerdp_chanman_post_connect(chan_man, &instance);
|
2011-07-10 18:24:47 +04:00
|
|
|
|
2011-07-28 09:04:01 +04:00
|
|
|
freerdp_chanman_data(&instance, 0, "testdata", 8, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 8);
|
|
|
|
freerdp_chanman_data(&instance, 0, "testdata1", 9, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 9);
|
|
|
|
freerdp_chanman_data(&instance, 0, "testdata11", 10, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 10);
|
|
|
|
freerdp_chanman_data(&instance, 0, "testdata111", 11, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, 11);
|
2011-07-10 18:24:47 +04:00
|
|
|
|
2011-08-18 01:28:26 +04:00
|
|
|
event = freerdp_event_new(RDP_EVENT_CLASS_DEBUG, 0, NULL, NULL);
|
2011-08-11 07:36:10 +04:00
|
|
|
freerdp_chanman_send_event(chan_man, event);
|
2011-07-10 19:56:52 +04:00
|
|
|
|
2011-07-12 16:52:08 +04:00
|
|
|
while ((event = freerdp_chanman_pop_event(chan_man)) == NULL)
|
|
|
|
{
|
2011-07-28 09:04:01 +04:00
|
|
|
freerdp_chanman_check_fds(chan_man, &instance);
|
2011-07-12 16:52:08 +04:00
|
|
|
}
|
2011-07-11 08:21:55 +04:00
|
|
|
printf("responded event_type %d\n", event->event_type);
|
|
|
|
freerdp_event_free(event);
|
|
|
|
|
2011-07-28 09:04:01 +04:00
|
|
|
freerdp_chanman_close(chan_man, &instance);
|
2011-07-08 17:57:01 +04:00
|
|
|
freerdp_chanman_free(chan_man);
|
|
|
|
}
|