2 * FreeRDP: A Remote Desktop Protocol Client
3 * Dynamic Virtual Channel Unit Tests
5 * Copyright 2011 Vic Lee
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <freerdp/freerdp.h>
24 #include <freerdp/constants.h>
25 #include <freerdp/channels/channels.h>
26 #include <freerdp/utils/event.h>
27 #include <freerdp/utils/hexdump.h>
28 #include <freerdp/utils/memory.h>
30 #include "test_drdynvc.h"
32 int init_drdynvc_suite(void)
34 freerdp_channels_global_init();
38 int clean_drdynvc_suite(void)
40 freerdp_channels_global_uninit();
44 int add_drdynvc_suite(void)
46 add_test_suite(drdynvc);
48 add_test_function(drdynvc);
53 static const uint8 test_capability_request_data[] =
55 "\x58\x00\x02\x00\x33\x33\x11\x11\x3D\x0A\xA7\x04"
58 static int data_received = 0;
60 static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, int data_size)
62 printf("chan_id %d data_size %d\n", chan_id, data_size);
63 freerdp_hexdump(data, data_size);
68 void test_drdynvc(void)
70 rdpChannels* chan_man;
71 rdpSettings settings = { 0 };
72 freerdp instance = { 0 };
74 settings.hostname = "testhost";
75 instance.settings = &settings;
76 instance.SendChannelData = test_rdp_channel_data;
78 chan_man = freerdp_channels_new();
80 freerdp_channels_load_plugin(chan_man, &settings, "../channels/drdynvc/drdynvc.so", NULL);
81 freerdp_channels_pre_connect(chan_man, &instance);
82 freerdp_channels_post_connect(chan_man, &instance);
84 /* server sends capability request PDU */
85 freerdp_channels_data(&instance, 0, (char*)test_capability_request_data, sizeof(test_capability_request_data) - 1,
86 CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, sizeof(test_capability_request_data) - 1);
88 /* drdynvc sends capability response PDU to server */
90 while (!data_received)
92 freerdp_channels_check_fds(chan_man, &instance);
95 freerdp_channels_close(chan_man, &instance);
96 freerdp_channels_free(chan_man);