зеркало из https://github.com/mozilla/gecko-dev.git
Bug 853715 - 0006. Xpcshell test cases for SI and SL PDU helper. r=vicamo
This commit is contained in:
Родитель
8fbe6af03a
Коммит
7b01469db1
|
@ -0,0 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
|
||||
let subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader);
|
|
@ -0,0 +1,162 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
let SI = {};
|
||||
subscriptLoader.loadSubScript("resource://gre/modules/SiPduHelper.jsm", SI);
|
||||
SI.debug = do_print;
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* SI in Plain text
|
||||
*/
|
||||
add_test(function test_si_parse_plain_text() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "text/vnd.wap.si";
|
||||
data.array = [0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65,
|
||||
0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x27, 0x31,
|
||||
0x2E, 0x30, 0x27, 0x3F, 0x3E, 0x0A, 0x3C, 0x73,
|
||||
0x69, 0x3E, 0x3C, 0x69, 0x6E, 0x64, 0x69, 0x63,
|
||||
0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3D, 0x27, 0x68, 0x74, 0x74, 0x70,
|
||||
0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x6F,
|
||||
0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x27, 0x3E, 0x43, 0x68, 0x65, 0x63,
|
||||
0x6B, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x77,
|
||||
0x65, 0x62, 0x73, 0x69, 0x74, 0x65, 0x3C, 0x2F,
|
||||
0x69, 0x6E, 0x64, 0x69, 0x63, 0x61, 0x74, 0x69,
|
||||
0x6F, 0x6E, 0x3E, 0x3C, 0x2F, 0x73, 0x69, 0x3E];
|
||||
data.offset = 0;
|
||||
let result = "<?xml version='1.0'?>\n<si><indication href='http://www.oreilly.com'>Check this website</indication></si>";
|
||||
SI.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* Empty SI compressed by WBXML
|
||||
*/
|
||||
add_test(function test_si_parse_wbxml_empty() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.sic";
|
||||
data.array = [0x02, 0x05, 0x6A, 0x00, 0x05];
|
||||
data.offset = 0;
|
||||
let result = "<si/>";
|
||||
SI.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* Empty SI compressed by WBXML, with public ID stored in string table
|
||||
*/
|
||||
add_test(function test_si_parse_wbxml_empty_public_id_string_table() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.sic";
|
||||
data.array = [0x02, 0x00, 0x00, 0x6A, 0x1C, 0x2D, 0x2F, 0x2F,
|
||||
0x57, 0x41, 0x50, 0x46, 0x4F, 0x52, 0x55, 0x4D,
|
||||
0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x53, 0x49,
|
||||
0x20, 0x31, 0x2E, 0x30, 0x2F, 0x2F, 0x45, 0x4E,
|
||||
0x00, 0x05];
|
||||
data.offset = 0;
|
||||
let result = "<si/>";
|
||||
SI.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* SI compressed by WBXML with href attribute
|
||||
*/
|
||||
add_test(function test_si_parse_wbxml_with_href() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.sic";
|
||||
data.array = [0x02, 0x05, 0x6A, 0x00, 0x45, 0xC6, 0x0D, 0x03,
|
||||
0x6F, 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x00,
|
||||
0x85, 0x01, 0x03, 0x43, 0x68, 0x65, 0x63, 0x6B,
|
||||
0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x65,
|
||||
0x62, 0x73, 0x69, 0x74, 0x65, 0x00, 0x01, 0x01];
|
||||
data.offset = 0;
|
||||
let result = "<si><indication href=\"http://www.oreilly.com/\">" +
|
||||
"Check this website</indication></si>";
|
||||
SI.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* SI compressed by WBXML with href and date attribute
|
||||
*/
|
||||
add_test(function test_si_parse_wbxml_with_href_date() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.sic";
|
||||
data.array = [0x02, 0x05, 0x6A, 0x00, 0x45, 0xC6, 0x0D, 0x03,
|
||||
0x78, 0x79, 0x7A, 0x00, 0x85, 0x03, 0x65, 0x6D,
|
||||
0x61, 0x69, 0x6C, 0x2F, 0x31, 0x32, 0x33, 0x2F,
|
||||
0x61, 0x62, 0x63, 0x2E, 0x77, 0x6D, 0x6C, 0x00,
|
||||
0x0A, 0xC3, 0x07, 0x19, 0x99, 0x06, 0x25, 0x15,
|
||||
0x23, 0x15, 0x10, 0xC3, 0x04, 0x19, 0x99, 0x06,
|
||||
0x30, 0x01, 0x03, 0x59, 0x6F, 0x75, 0x20, 0x68,
|
||||
0x61, 0x76, 0x65, 0x20, 0x34, 0x20, 0x6E, 0x65,
|
||||
0x77, 0x20, 0x65, 0x6D, 0x61, 0x69, 0x6C, 0x73,
|
||||
0x00, 0x01, 0x01];
|
||||
data.offset = 0;
|
||||
let result = "<si><indication href=\"http://www.xyz.com/email/123/abc.wml\"" +
|
||||
" created=\"1999-06-25T15:23:15Z\" si-expires=\"1999-06-30T00:00:00Z\">" +
|
||||
"You have 4 new emails</indication></si>";
|
||||
SI.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* SI compressed by WBXML with attributes and string table
|
||||
*/
|
||||
add_test(function test_si_parse_wbxml_with_attr_string_table() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.sic";
|
||||
data.array = [0x02, 0x05, 0x6A, 0x28, 0x65, 0x6D, 0x61, 0x69,
|
||||
0x6C, 0x2F, 0x31, 0x32, 0x33, 0x2F, 0x61, 0x62,
|
||||
0x63, 0x2E, 0x77, 0x6D, 0x6C, 0x00, 0x59, 0x6F,
|
||||
0x75, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x34,
|
||||
0x20, 0x6E, 0x65, 0x77, 0x20, 0x65, 0x6D, 0x61,
|
||||
0x69, 0x6C, 0x73, 0x00, 0x45, 0xC6, 0x0D, 0x03,
|
||||
0x78, 0x79, 0x7A, 0x00, 0x85, 0x83, 0x00, 0x0A,
|
||||
0xC3, 0x07, 0x19, 0x99, 0x06, 0x25, 0x15, 0x23,
|
||||
0x15, 0x10, 0xC3, 0x04, 0x19, 0x99, 0x06, 0x30,
|
||||
0x01, 0x83, 0x12, 0x01, 0x01];
|
||||
data.offset = 0;
|
||||
let result = "<si><indication href=\"http://www.xyz.com/email/123/abc.wml\"" +
|
||||
" created=\"1999-06-25T15:23:15Z\" si-expires=\"1999-06-30T00:00:00Z\">" +
|
||||
"You have 4 new emails</indication></si>";
|
||||
SI.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
|
@ -0,0 +1,98 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
let SL = {};
|
||||
subscriptLoader.loadSubScript("resource://gre/modules/SlPduHelper.jsm", SL);
|
||||
SL.debug = do_print;
|
||||
|
||||
function run_test() {
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
/**
|
||||
* SL in plain text
|
||||
*/
|
||||
add_test(function test_sl_parse_plain_text() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "text/vnd.wap.sl";
|
||||
data.array = [0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65,
|
||||
0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x27, 0x31,
|
||||
0x2E, 0x30, 0x27, 0x3F, 0x3E, 0x0A, 0x3C, 0x73,
|
||||
0x6C, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3D, 0x27,
|
||||
0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x77,
|
||||
0x77, 0x77, 0x2E, 0x6F, 0x72, 0x65, 0x69, 0x6C,
|
||||
0x6C, 0x79, 0x2E, 0x63, 0x6F, 0x6D, 0x27, 0x2F,
|
||||
0x3E];
|
||||
data.offset = 0;
|
||||
let result = "<?xml version='1.0'?>\n<sl href='http://www.oreilly.com'/>";
|
||||
SL.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* SL compressed by WBXML
|
||||
*/
|
||||
add_test(function test_sl_parse_wbxml() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.slc";
|
||||
data.array = [0x03, 0x06, 0x6A, 0x00, 0x85, 0x0A, 0x03, 0x6F,
|
||||
0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x00, 0x85,
|
||||
0x01];
|
||||
data.offset = 0;
|
||||
let result = "<sl href=\"http://www.oreilly.com/\"/>";
|
||||
SL.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* SL compressed by WBXML, with public ID stored in string table
|
||||
*/
|
||||
add_test(function test_sl_parse_wbxml_public_id_string_table() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.slc";
|
||||
data.array = [0x03, 0x00, 0x00, 0x6A, 0x1C, 0x2D, 0x2F, 0x2F,
|
||||
0x57, 0x41, 0x50, 0x46, 0x4F, 0x52, 0x55, 0x4D,
|
||||
0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x53, 0x4C,
|
||||
0x20, 0x31, 0x2E, 0x30, 0x2F, 0x2F, 0x45, 0x4E,
|
||||
0x00, 0x85, 0x0A, 0x03, 0x6F, 0x72, 0x65, 0x69,
|
||||
0x6C, 0x6C, 0x79, 0x00, 0x85, 0x01];
|
||||
data.offset = 0;
|
||||
let result = "<sl href=\"http://www.oreilly.com/\"/>";
|
||||
SL.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
/**
|
||||
* SL compressed by WBXML with string table
|
||||
*/
|
||||
add_test(function test_sl_parse_wbxml_with_string_table() {
|
||||
let msg = {};
|
||||
let contentType = "";
|
||||
let data = {};
|
||||
|
||||
contentType = "application/vnd.wap.slc";
|
||||
data.array = [0x03, 0x06, 0x6A, 0x08, 0x6F, 0x72, 0x65, 0x69,
|
||||
0x6C, 0x6C, 0x79, 0x00, 0x85, 0x0A, 0x83, 0x00,
|
||||
0x85, 0x01];
|
||||
data.offset = 0;
|
||||
let result = "<sl href=\"http://www.oreilly.com/\"/>";
|
||||
SL.PduHelper.parse(data, contentType, msg);
|
||||
do_check_eq(msg.content, result);
|
||||
|
||||
run_next_test();
|
||||
});
|
|
@ -1,3 +1,6 @@
|
|||
[DEFAULT]
|
||||
head =
|
||||
head = header_helpers.js
|
||||
tail =
|
||||
|
||||
[test_si_pdu_helper.js]
|
||||
[test_sl_pdu_helper.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче