nsc: add CUnit test.
authorVic Lee <llyzs@163.com>
Tue, 6 Mar 2012 10:55:54 +0000 (18:55 +0800)
committerVic Lee <llyzs@163.com>
Tue, 6 Mar 2012 10:55:54 +0000 (18:55 +0800)
cunit/CMakeLists.txt
cunit/test_freerdp.c
cunit/test_nsc.c [new file with mode: 0644]
cunit/test_nsc.h [new file with mode: 0644]

index 5d80931..628e4b9 100644 (file)
@@ -62,6 +62,8 @@ add_executable(test_freerdp
        test_drdynvc.h
        test_rfx.c
        test_rfx.h
+       test_nsc.c
+       test_nsc.h
        test_sspi.c
        test_sspi.h
        test_freerdp.c
index 9b17500..8656b51 100644 (file)
@@ -37,6 +37,7 @@
 #include "test_cliprdr.h"
 #include "test_drdynvc.h"
 #include "test_rfx.h"
+#include "test_nsc.h"
 #include "test_freerdp.h"
 #include "test_rail.h"
 #include "test_pcap.h"
@@ -138,6 +139,7 @@ static test_suite suites[] =
        { "per", add_per_suite },
        { "rail", add_rail_suite },
        { "rfx", add_rfx_suite },
+       { "nsc", add_nsc_suite },
        { "sspi", add_sspi_suite },
        { "stream", add_stream_suite },
        { "utils", add_utils_suite },
diff --git a/cunit/test_nsc.c b/cunit/test_nsc.c
new file mode 100644 (file)
index 0000000..6cf2c85
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * NSCodec Library Unit Tests
+ *
+ * Copyright 2012 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.
+ */
+
+/**
+ * The sample data comes from [MS-RDPRFX] 4.2.3, which is decoded into three
+ * vertical bands in red (21x64), green (23x64) and blue(20x64) color.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <freerdp/types.h>
+#include <freerdp/utils/print.h>
+#include <freerdp/utils/memory.h>
+#include <freerdp/utils/hexdump.h>
+#include <freerdp/codec/nsc.h>
+
+#include "test_nsc.h"
+
+static const uint8 nsc_data[] =
+{
+       0x71, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+       0x03, 0x01, 0x00, 0x00, 0x63, 0x63, 0x01, 0x64, 0x64, 0x00, 0x63, 0x63, 0x02, 0x64, 0x64, 0x00,
+       0x63, 0x63, 0x00, 0x64, 0x64, 0x01, 0x63, 0x63, 0x01, 0x64, 0x64, 0x01, 0x63, 0x63, 0x01, 0x64,
+       0x64, 0x00, 0x63, 0x63, 0x00, 0x64, 0x64, 0x01, 0x63, 0x63, 0x00, 0x64, 0x64, 0x0c, 0x63, 0x63,
+       0x00, 0x64, 0x64, 0x0c, 0x63, 0x63, 0x00, 0x64, 0x64, 0x0c, 0x63, 0x63, 0x00, 0x64, 0x64, 0x0c,
+       0x63, 0x64, 0x64, 0x04, 0x63, 0x64, 0x63, 0x63, 0x00, 0x64, 0x64, 0x03, 0x63, 0x64, 0x64, 0x03,
+       0x63, 0x63, 0x00, 0x64, 0x63, 0x63, 0x00, 0x64, 0x64, 0x03, 0x65, 0x63, 0x64, 0x64, 0x01, 0x63,
+       0x64, 0x64, 0x00, 0x65, 0x64, 0x64, 0x06, 0x63, 0x64, 0x64, 0x00, 0x63, 0x63, 0x00, 0x64, 0x64,
+       0x04, 0x64, 0x65, 0x65, 0x65, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x37, 0x37, 0x19, 0x36,
+       0x37, 0x37, 0x06, 0x37, 0x37, 0x37, 0x37, 0xff, 0xff, 0x90, 0xff, 0xff, 0xff, 0xff
+};
+
+int init_nsc_suite(void)
+{
+       return 0;
+}
+
+int clean_nsc_suite(void)
+{
+       return 0;
+}
+
+int add_nsc_suite(void)
+{
+       add_test_suite(nsc);
+
+       add_test_function(nsc_decode);
+       add_test_function(nsc_encode);
+
+       return 0;
+}
+
+void test_nsc_decode(void)
+{
+       NSC_CONTEXT* context;
+
+       context = nsc_context_new();
+       nsc_process_message(context, 32, 15, 10, (uint8*) nsc_data, sizeof(nsc_data));
+       /*freerdp_hexdump(context->bmpdata, 15 * 10 * 4);*/
+       nsc_context_free(context);
+}
+
+void test_nsc_encode(void)
+{
+}
diff --git a/cunit/test_nsc.h b/cunit/test_nsc.h
new file mode 100644 (file)
index 0000000..6f4f867
--- /dev/null
@@ -0,0 +1,27 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Client
+ * NSCodec Library Unit Tests
+ *
+ * Copyright 2012 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 "test_freerdp.h"
+
+int init_nsc_suite(void);
+int clean_nsc_suite(void);
+int add_nsc_suite(void);
+
+void test_nsc_decode(void);
+void test_nsc_encode(void);