提交 59b81881 编写于 作者: X xdmal

Signed-off-by: xdmal <maxiaodong16@huawei.com>

 On branch master
 Your branch is up to date with 'origin/master'.
上级 9203af9f
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite'
import process from '@ohos.process'
describe('ChildProcessTest', function () {
/**
* @tc.name: testRunCmd001
* @tc.desc: Return a child process object and spawns a new ChildProcess to run the command.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testRunCmd001', 0, async function () {
var child = process.runCmd('echo abc')
child.wait()
var array = new Uint8Array([97, 98, 99, 10, 0])
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testRunCmd002
* @tc.desc: Return a child process object and spawns a new ChildProcess to run the command.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testRunCmd002', 0, async function () {
var child = process.runCmd('echo abc;', { maxBuffer : 2 })
child.wait()
var array = new Uint8Array([97, 98, 0])
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testRunCmd003
* @tc.desc: Return a child process object and spawns a new ChildProcess to run the command.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testRunCmd003', 0, async function () {
var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 })
child.wait()
var array = new Uint8Array([0])
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
expect(child.exitCode).assertEqual(0)
})
/**
* @tc.name: testRunCmd004
* @tc.desc: Return a child process object and spawns a new ChildProcess to run the command.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testRunCmd004', 0, async function ( ) {
var child = process.runCmd('sleep 2; echo abc;', { timeout : 9000, killSignal : 9 })
child.wait()
var array = new Uint8Array([97, 98, 99, 10, 0])
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
expect(child.exitCode).assertEqual(0)
})
/**
* @tc.name: testRunCmd005
* @tc.desc: Return a child process object and spawns a new ChildProcess to run the command.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testRunCmd005', 0, async function ( ) {
var child = process.runCmd('echo abc', { maxBuffer : 1000 })
child.wait()
var array = new Uint8Array([97, 98, 99, 10, 0])
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testGetOutput001
* @tc.desc: return it as 'Uint8Array' of the stdout until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetOutput001', 0, async function () {
var child = process.runCmd('echo bcd;')
var array = new Uint8Array([98, 99, 100, 10, 0])
child.wait();
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testGetOutput002
* @tc.desc: return it as 'Uint8Array' of the stdout until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetOutput002', 0, async function () {
var child = process.runCmd('echo 123;');
var array = new Uint8Array([49, 50, 51, 10, 0]);
child.wait();
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i]);
}
})
})
/**
* @tc.name: testGetOutput003
* @tc.desc: return it as 'Uint8Array' of the stdout until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetOutput003', 0, async function () {
var child = process.runCmd('echo helloWorld;');
var array = new Uint8Array([104, 101, 108, 108, 111, 87, 111, 114, 108, 100, 10, 0]);
child.wait();
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i]);
}
})
})
/**
* @tc.name: testGetOutput004
* @tc.desc: return it as 'Uint8Array' of the stdout until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetOutput004', 0, async function () {
var child = process.runCmd('echo 浣犲?');
var array = new Uint8Array([228, 189, 160, 229, 165, 189, 10, 0]);
child.wait();
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i]);
}
})
})
/**
* @tc.name: testGetOutput005
* @tc.desc: return it as 'Uint8Array' of the stdout until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetOutput005', 0, async function () {
var child = process.runCmd('echo ~_~;');
var array = new Uint8Array([126, 95, 126, 10, 0]);
child.wait();
child.getOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i]);
}
})
})
/**
* @tc.name: testGetErrorOutput001
* @tc.desc: return it as 'Uint8Array of the stderr until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetErrorOutput001', 0, async function () {
var child = process.runCmd('makdir 1.txt')
child.wait()
var array = new Uint8Array([115, 104, 58, 32, 109, 97, 107, 100, 105, 114, 58, 32, 105, 110, 97, 99, 99,
101, 115, 115, 105, 98, 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0])
child.getErrorOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testGetErrorOutput002
* @tc.desc: return it as 'Uint8Array of the stderr until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetErrorOutput002', 0, async function () {
var child = process.runCmd('echo "error" 1>&2')
child.wait()
var array = new Uint8Array([101, 114, 111, 114, 10, 0])
child.getErrorOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testGetErrorOutput003
* @tc.desc: return it as 'Uint8Array of the stderr until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetErrorOutput003', 0, async function () {
var child = process.runCmd('1')
child.wait()
var array = new Uint8Array([115, 104, 58, 32, 49, 58, 32, 105, 110, 97, 99, 99, 101, 115, 115, 105, 98,
108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0])
child.getErrorOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testGetErrorOutput004
* @tc.desc: return it as 'Uint8Array of the stderr until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetErrorOutput004', 0, async function () {
var child = process.runCmd('chmod 777 123')
var array = new Uint8Array([99, 104, 109, 111, 100, 58, 32, 49, 50, 51, 58, 32, 78, 111, 32, 115, 117, 99,
104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]);
child.wait();
child.getErrorOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testGetErrorOutput005
* @tc.desc: return it as 'Uint8Array of the stderr until EOF.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetErrorOutput005', 0, async function () {
var child = process.runCmd('cp ./1 ./2')
var array = new Uint8Array([99, 112, 58, 32, 98, 97, 100, 32, 39, 46, 47, 49, 39, 58, 32, 78, 111, 32, 115,
117, 99, 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0])
child.wait();
child.getErrorOutput().then(val=>{
for (var i = 0; i < array.length; i++) {
expect(val[i]).assertEqual(array[i])
}
})
})
/**
* @tc.name: testWait001
* @tc.desc: return 'number' is the targer process exit code.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testWait001', 0, async function () {
var child = process.runCmd('ls')
var status = child.wait()
status.then(val=>{
expect(val).assertEqual(0)
})
})
/**
* @tc.name: testWait002
* @tc.desc: return 'number' is the targer process exit code.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testWait002', 0, async function () {
var child = process.runCmd('ls; sleep 5;')
child.kill(9);
var status = child.wait()
status.then(val=>{
expect(val).assertEqual(9)
})
})
/**
* @tc.name: testWait003
* @tc.desc: return 'number' is the targer process exit code.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testWait003', 0, async function () {
var child = process.runCmd('echo helloWorld');
var status = child.wait();
status.then(val=>{
expect(val).assertEqual(0);
})
})
/**
* @tc.name: testWait004
* @tc.desc: return 'number' is the targer process exit code.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testWait004', 0, async function () {
var child = process.runCmd('mkdir 123');
var status = child.wait();
status.then(val=>{
expect(val).assertEqual(256);
})
})
/**
* @tc.name: testWait005
* @tc.desc: return 'number' is the targer process exit code.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testWait005', 0, async function () {
var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 });
var status = child.wait();
status.then(val=>{
expect(val).assertEqual(9);
})
})
/**
* @tc.name: testchildPid001
* @tc.desc: return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testchildPid001', 0, function () {
var child = process.runCmd('ls; sleep 5;')
child.wait()
var pid_ = child.pid
expect(pid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPid002
* @tc.desc: return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid002', 0, function () {
var child = process.runCmd('mkdir test.cpp')
child.wait()
var pid_ = child.pid
expect(pid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPid003
* @tc.desc: return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid003', 0, function () {
var child = process.runCmd('each abc')
child.wait()
var pid_ = child.pid
expect(pid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPid004
* @tc.desc: return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid004', 0, function () {
var child = process.runCmd('cd ..')
child.wait()
var pid_ = child.pid
expect(pid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPid005
* @tc.desc: return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid005', 0, function () {
var child = process.runCmd('adc')
child.wait()
var pid_ = child.pid
expect(pid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPpid001
* @tc.desc: return ppid is the pid of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid001', 0, function () {
var child = process.runCmd('ls; sleep 5;')
var status = child.wait()
var ppid_ = child.ppid
expect(ppid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPpid002
* @tc.desc: return ppid is the pid of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid002', 0, function () {
var child = process.runCmd('mkdir test.cpp')
child.wait()
var ppid_ = child.ppid
expect(ppid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPpid003
* @tc.desc: return ppid is the pid of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid003', 0, function () {
var child = process.runCmd('each abc')
child.wait()
var ppid_ = child.ppid
expect(ppid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPpid004
* @tc.desc: return ppid is the pid of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid004', 0, function () {
var child = process.runCmd('cd ..')
child.wait()
var ppid_ = child.ppid
expect(ppid_ > 0).assertEqual(true)
})
/**
* @tc.name: testPpid005
* @tc.desc: return ppid is the pid of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid005', 0, function () {
var child = process.runCmd('adc')
child.wait()
var ppid_ = child.ppid
expect(ppid_ > 0).assertEqual(true)
})
/**
* @tc.name: testKill001
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill001', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill(13)
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testKill002
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill002', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill(1)
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testKill003
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill003', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill('SIGHUP')
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testKill004
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill004', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill('ABC')
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testKill005
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill005', 0, function () {
var child = process.runCmd('ls')
child.wait()
var result = child.kill(9)
var temp = child.killed
expect(temp).assertEqual(false)
})
/**
* @tc.name: testClose001
* @tc.desc: close the target process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testClose001', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.close()
expect(child.exitCode).assertEqual(9)
})
/**
* @tc.name: testClose002
* @tc.desc: close the target process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testClose002', 0, function () {
var child = process.runCmd('ls')
function sleep(ms, callback) {
setTimeout(callback, ms)
}
sleep(1000, () => {} )
var result = child.close()
expect(child.exitCode === 0).assertEqual(false)
})
/**
* @tc.name: testClose003
* @tc.desc: close the target process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testClose003', 0, function () {
var child = process.runCmd('ls;')
var status = child.wait()
var result = child.close()
expect(child.exitCode).assertEqual(0)
})
/**
* @tc.name: testClose004
* @tc.desc: close the target process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testClose004', 0, function () {
var child = process.runCmd('ls')
var result = child.close()
expect(child.exitCode).assertEqual(9)
})
/**
* @tc.name: testClose005
* @tc.desc: close the target process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testClose005', 0, function () {
var child = process.runCmd('sleep 5; echo A')
var result = child.close()
var status = child.wait()
expect(child.exitCode).assertEqual(9)
})
/**
* @tc.name: testKilled001
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKilled001', 0, function () {
var child = process.runCmd('ls; sleep 1s;')
var result = child.kill(3)
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testKilled002
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKilled002', 0, function () {
var child = process.runCmd('ls; sleep 1s;')
var result = child.close()
var temp = child.killed
expect(temp).assertEqual(false)
})
/**
* @tc.name: testKilled003
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKilled003', 0, function () {
var child = process.runCmd('ls; sleep 1s;')
var status = child.wait()
var result = child.kill(9)
var temp = child.killed
expect(temp).assertEqual(false)
})
/**
* @tc.name: testKilled004
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKilled004', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill('SIGHUP')
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testKilled005
* @tc.desc: return boolean is whether the current process signal is sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKilled005', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var result = child.kill('1')
var temp = child.killed
expect(temp).assertEqual(true)
})
/**
* @tc.name: testExitCode001
* @tc.desc: return exitCode is the exit code of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testExitCode001', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
var temp = child.kill(9)
child.wait()
var result = child.exitCode
expect(result).assertEqual(9)
})
/**
* @tc.name: testExitCode002
* @tc.desc: return exitCode is the exit code of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testExitCode002', 0, function () {
var child = process.runCmd('ls;')
child.wait()
var result = child.exitCode
expect(result).assertEqual(0)
})
/**
* @tc.name: testExitCode003
* @tc.desc: return exitCode is the exit code of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testExitCode003', 0, function () {
var child = process.runCmd('ls; sleep 5s;')
child.close()
child.wait()
var result = child.exitCode
expect(result).assertEqual(9)
})
/**
* @tc.name: testExitCode004
* @tc.desc: return exitCode is the exit code of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testExitCode004', 0, function () {
var child = process.runCmd('ls')
var temp = child.kill('ABCD')
child.close()
var result = child.exitCode
expect(result).assertEqual(0)
})
/**
* @tc.name: testExitCode005
* @tc.desc: return exitCode is the exit code of the current child process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testExitCode005', 0, function () {
var child = process.runCmd('echo A')
var result= child.wait()
var status = child.close()
expect(child.exitCode).assertEqual(0)
})
/**
* @tc.name: testGetUid001
* @tc.desc: returns the digital user id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetUid001', 0, function () {
var result = process.uid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetUid002
* @tc.desc: returns the digital user id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetUid002', 0, function () {
for(var i = 0; i < 3; i++){
var result = process.uid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetUid003
* @tc.desc: returns the digital user id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetUid003', 0, function () {
for(var i = 0; i < 6; i++){
var result = process.uid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetUid004
* @tc.desc: returns the digital user id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetUid004', 0, function () {
for(var i = 0; i < 10; i++){
var result = process.uid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetUid005
* @tc.desc: returns the digital user id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetUid005', 0, function () {
for(var i = 0; i < 25; i++){
var result = process.uid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGid001
* @tc.desc: returns the numeric group id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGid001', 0, function () {
var result = process.gid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetGid002
* @tc.desc: returns the numeric group id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGid002', 0, function () {
for(var i = 0; i < 3; i++){
var result = process.gid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGid003
* @tc.desc: returns the numeric group id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGid003', 0, function () {
for(var i = 0; i < 5; i++){
var result = process.gid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGid004
* @tc.desc: returns the numeric group id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGid004', 0, function () {
for(var i = 0; i < 10; i++){
var result = process.gid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGid005
* @tc.desc: returns the numeric group id of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGid005', 0, function () {
for(var i = 0; i < 9; i++){
var result = process.gid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEuid001
* @tc.desc: return the numeric valid user identity of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEuid001', 0, function () {
var result = process.euid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetEuid002
* @tc.desc: return the numeric valid user identity of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEuid002', 0, function () {
for(var i = 0; i < 3; i++){
var result = process.euid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEuid003
* @tc.desc: return the numeric valid user identity of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEuid003', 0, function () {
for(var i = 0; i < 5; i++){
var result = process.euid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEuid004
* @tc.desc: return the numeric valid user identity of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEuid004', 0, function () {
for(var i = 0; i < 8; i++){
var result = process.euid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEuid005
* @tc.desc: return the numeric valid user identity of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEuid005', 0, function () {
for(var i = 0; i < 15; i++){
var result = process.euid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEgid001
* @tc.desc: returns the numeric valid group ID of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEgid001', 0, function () {
var result = process.egid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetEgid002
* @tc.desc: returns the numeric valid group ID of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEgid002', 0, function () {
for(var i = 0; i < 3; i++){
var result = process.egid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEgid003
* @tc.desc: returns the numeric valid group ID of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEgid003', 0, function () {
for(var i = 0; i < 5; i++){
var result = process.egid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEgid004
* @tc.desc: returns the numeric valid group ID of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEgid004', 0, function () {
for(var i = 0; i < 15; i++){
var result = process.egid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEgid005
* @tc.desc: returns the numeric valid group ID of the process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetEgid005', 0, function () {
for(var i = 0; i < 26; i++){
var result = process.egid
if(result != null) {
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGroups001
* @tc.desc: return an array with supplementary group id.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGroups001', 0, function () {
var result = process.groups
var len = result.length
if(len > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetGroups002
* @tc.desc: return an array with supplementary group id.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGroups002', 0, function () {
for(var i = 0; i < 3; i++){
var result = process.groups
if(result != null) {
var len = result.length
if(len > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGroups003
* @tc.desc: return an array with supplementary group id.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGroups003', 0, function () {
for(var i = 0; i < 5; i++){
var result = process.groups
if(result != null) {
var len = result.length
if(len > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGroups004
* @tc.desc: return an array with supplementary group id.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGroups004', 0, function () {
for(var i = 0; i < 18; i++){
var result = process.groups
if(result != null) {
var len = result.length
if(len > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetGroups005
* @tc.desc: return an array with supplementary group id.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testGetGroups005', 0, function () {
for(var i = 0; i < 28; i++){
var result = process.groups
if(result != null) {
var len = result.length
if(len > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testChdir001
* @tc.desc: Change current directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testChdir001', 0, function () {
var result = process.chdir('/system')
var result1 = process.cwd()
expect(result1).assertEqual('/system')
})
/**
* @tc.name: testChdir002
* @tc.desc: Change current directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testChdir002', 0, function () {
var result = process.chdir('/system/lib')
var result1 = process.cwd()
expect(result1).assertEqual('/system/lib')
})
/**
* @tc.name: testChdir003
* @tc.desc: Change current directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testChdir003', 0, function () {
var result = process.chdir('/..')
var result1 = process.cwd()
expect(result1).assertEqual('/')
})
/**
* @tc.name: testChdir004
* @tc.desc: Change current directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testChdir004', 0, function () {
var result = process.chdir('/system/app')
var result1 = process.cwd()
expect(result1).assertEqual('/system/app')
})
/**
* @tc.name: testChdir005
* @tc.desc: Change current directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testChdir005', 0, function () {
var result = process.chdir('/data')
var result1 = process.cwd()
expect(result1).assertEqual('/data')
})
/**
* @tc.name: testKill001
* @tc.desc: Return whether the signal was sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill001', 0, function () {
var result = process.kill(123, 3)
expect(result).assertEqual(false)
})
/**
* @tc.name: testKill002
* @tc.desc: Return whether the signal was sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill002', 0, function () {
var pres = process.pid
var result = process.kill(pres, 23)
expect(result).assertEqual(true)
})
/**
* @tc.name: testKill003
* @tc.desc: Return whether the signal was sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill003', 0, function () {
var pres = process.pid
var result = process.kill(pres, 28)
expect(result).assertEqual(true)
})
/**
* @tc.name: testKill004
* @tc.desc: Return whether the signal was sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill004', 0, function () {
var pres = process.pid
var result = process.kill(pres, 17)
expect(result).assertEqual(true)
})
/**
* @tc.name: testKill005
* @tc.desc: Return whether the signal was sent successfully.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testKill005', 0, function () {
var result = process.kill(113, 3)
expect(result).assertEqual(false)
})
/**
* @tc.name: testUptime001
* @tc.desc: Returns the running time of the system.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testUptime001', 0, function () {
var result1 = process.uptime()
function sleep(d){
while(process.uptime() - result1 <= d);
}
sleep(5);
var result2 = process.uptime() - 6
expect(result1).assertEqual(result2)
})
/**
* @tc.name: testUptime002
* @tc.desc: Returns the running time of the system.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testUptime002', 0, function () {
var result1 = process.uptime()
function sleep(d){
while(process.uptime() - result1 <= d);
}
sleep(8);
var result2 = process.uptime() - 9
expect(result1).assertEqual(result2)
})
/**
* @tc.name: testUptime003
* @tc.desc: Returns the running time of the system.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testUptime003', 0, function () {
var result1 = process.uptime()
function sleep(d){
while(process.uptime() - result1 <= d);
}
sleep(10);
var result2 = process.uptime() - 11
expect(result1).assertEqual(result2)
})
/**
* @tc.name: testUptime004
* @tc.desc: Returns the running time of the system.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testUptime004', 0, function () {
var result1 = process.uptime()
function sleep(d){
while(process.uptime() - result1 <= d);
}
sleep(7);
var result2 = process.uptime() - 8
expect(result1).assertEqual(result2)
})
/**
* @tc.name: testUptime005
* @tc.desc: Returns the running time of the system.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testUptime005', 0, function () {
var result1 = process.uptime()
function sleep(d){
while(process.uptime() - result1 <= d);
}
sleep(11);
var result2 = process.uptime() - 12
expect(result1).assertEqual(result2)
})
/**
* @tc.name: testPid001
* @tc.desc: Return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid001', 0, function () {
var result = process.pid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testPid002
* @tc.desc: Return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid002', 0, function () {
for(var i = 0; i < 3; i++)
{
var result = process.pid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPid003
* @tc.desc: Return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid003', 0, function () {
for(var i = 0; i < 5; i++)
{
var result = process.pid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPid004
* @tc.desc: Return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid004', 0, function () {
for(var i = 0; i < 10; i++)
{
var result = process.pid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPid005
* @tc.desc: Return pid is the pid of the current process.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPid005', 0, function () {
for(var i = 0; i < 28; i++)
{
var result = process.pid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPpid001
* @tc.desc: Return ppid is the pid of the current child process
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid001', 0, function () {
var result = process.ppid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testPpid002
* @tc.desc: Return ppid is the pid of the current child process
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid002', 0, function () {
for(var i = 0; i < 3; i++)
{
var result = process.ppid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPpid003
* @tc.desc: Return ppid is the pid of the current child process
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid003', 0, function () {
for(var i = 0; i < 5; i++)
{
var result = process.ppid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPpid004
* @tc.desc: Return ppid is the pid of the current child process
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid004', 0, function () {
for(var i = 0; i < 16; i++)
{
var result = process.ppid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testPpid005
* @tc.desc: Return ppid is the pid of the current child process
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testPpid005', 0, function () {
for(var i = 0; i < 28; i++)
{
var result = process.ppid
if(result > 0) {
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testCwd001
* @tc.desc: Return the current work directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testCwd001', 0, function () {
var cwdir = process.cwd()
if(cwdir){
var flag = true
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testCwd002
* @tc.desc: Return the current work directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testCwd002', 0, function () {
for(var i = 0; i < 3; i++)
{
var cwdir = process.cwd()
if(cwdir){
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testCwd003
* @tc.desc: Return the current work directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testCwd003', 0, function () {
for(var i = 0; i < 10; i++)
{
var cwdir = process.cwd()
if(cwdir){
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testCwd004
* @tc.desc: Return the current work directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testCwd004', 0, function () {
for(var i = 0; i < 18; i++)
{
var cwdir = process.cwd()
if(cwdir){
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testCwd005
* @tc.desc: Return the current work directory.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testCwd005', 0, function () {
for(var i = 0; i < 29; i++)
{
var cwdir = process.cwd()
if(cwdir){
var flag = true
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testOn001
* @tc.desc: Register for an event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOn001', 0, function () {
function add(){
var value = 3 + 2
}
var ontest = process.on(1, add)
expect(ontest).assertEqual(false)
})
/**
* @tc.name: testOn002
* @tc.desc: Register for an event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOn002', 0, function () {
function add1(num){
var value = num + 3
}
var on = process.on("add123", add1)
})
/**
* @tc.name: testOn003
* @tc.desc: Register for an event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOn003', 0, function () {
function add2(num0, num1){
var value = num0 + num1
}
var ontest = process.on(879, add2)
expect(ontest).assertEqual(false)
})
/**
* @tc.name: testOn004
* @tc.desc: Register for an event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOn004', 0, function () {
function add3(num0, num1){
var value = num0 + num1
}
var ontest = process.on(12345, add3)
expect(ontest).assertEqual(false)
})
/**
* @tc.name: testOn005
* @tc.desc: Register for an event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOn005', 0, function () {
function add4(num0, num1){
var value = num0 + num1
}
var ontest = process.on(1000, add4)
expect(ontest).assertEqual(false)
})
/**
* @tc.name: testOff001
* @tc.desc: Remove registered event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOff001', 0, function () {
function add1(num){
var value = num + 3
}
var on = process.on("add123", add1)
var offtest = process.off("add123")
expect(offtest).assertEqual(true)
})
/**
* @tc.name: testOff002
* @tc.desc: Remove registered event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOff002', 0, function () {
var offtest = process.off("123")
expect(offtest).assertEqual(false)
})
/**
* @tc.name: testOff003
* @tc.desc: Remove registered event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOff003', 0, function () {
var offtest = process.off("456")
expect(offtest).assertEqual(false)
})
/**
* @tc.name: testOff004
* @tc.desc: Remove registered event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOff004', 0, function () {
function add1(num){
var value = num + 3
}
var on = process.on("function_add1", add1)
var offtest = process.off("function_add1")
expect(offtest).assertEqual(true)
})
/**
* @tc.name: testOff005
* @tc.desc: Remove registered event.
* @tc.require: AR000GFB2S
* @tc.author: wangben
*/
it('testOff005', 0, function () {
function add1(num){
var value = num + 3
}
var on = process.on("add", add1)
var offtest = process.off("add")
expect(offtest).assertEqual(true)
})
/**
* @tc.name: testTid001
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid001', 0, function () {
var pres = process.tid
if(pres > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testTid002
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid002', 0, function () {
for(var i=0; i<10; i++)
{
var pres = process.tid
if(pres > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testTid003
* @tc.desc: Returns the tid of the current thread.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testTid003', 0, function () {
for(var i=0; i<1000; i++)
{
var pres = process.tid
if(pres > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testIsisolatedProcess001
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess001', 0, function () {
var pres = process.isIsolatedProcess()
expect(pres).assertEqual(false)
})
/**
* @tc.name: testIsisolatedProcess002
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess002', 0, function () {
for(var i=0; i<10; i++)
{
var pres =process.isIsolatedProcess()
expect(pres).assertEqual(false)
}
})
/**
* @tc.name: testIsisolatedProcess003
* @tc.desc: Returns a boolean whether the process is isolated.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsisolatedProcess003', 0, function () {
for(var i=0; i<1000; i++)
{
var pres =process.isIsolatedProcess()
expect(pres).assertEqual(false)
}
})
/**
* @tc.name: testIsappuid001
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid001', 0, function () {
var appUid = process.uid
var isorno = process.isAppUid(appUid)
expect(isorno).assertEqual(true)
})
/**
* @tc.name: testIsappuid002
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid002', 0, function () {
var isorno = process.isAppUid(123)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid003
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid003', 0, function () {
var isorno = process.isAppUid(80000)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid004
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid004', 0, function () {
var isorno = process.isAppUid(789)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIsappuid005
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIsappuid005', 0, function () {
var isorno = process.isAppUid(8569)
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIs64Bit001
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit001', 0, function () {
var isorno = process.is64Bit()
expect(isorno).assertEqual(false)
})
/**
* @tc.name: testIs64Bit002
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit002', 0, function () {
for(var i=0; i<10; i++)
{
var isorno = process.is64Bit()
expect(isorno).assertEqual(false)
}
})
/**
* @tc.name: testIs64Bit003
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testIs64Bit003', 0, function () {
for(var i=0; i<1000; i++)
{
var isorno = process.is64Bit()
expect(isorno).assertEqual(false)
}
})
/**
* @tc.name: testGetuidforname001
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname001',0, function () {
var pres = process.getUidForName("root")
if(pres != -1)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetuidforname002
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname002', 0, function () {
for(var i=0; i<10; i++)
{
var pres = process.getUidForName("12356")
expect(pres).assertEqual(-1)
}
})
/**
* @tc.name: testGetuidforname003
* @tc.desc: Returns the uid based on the specified user name.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetuidforname003', 0, function () {
for(var i=0; i<1000; i++)
{
var pres = process.getUidForName("12356")
expect(pres).assertEqual(-1)
}
})
/**
* @tc.name: testGetthreadpriority001
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority001', 0, function () {
var pres = process.tid
var pri = process.getThreadPriority(pres)
if(pri)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetthreadpriority002
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority002', 0, function () {
var pres = process.tid
for(var i=0; i<10; i++)
{
var pri = process.getThreadPriority(pres)
if(pri > 0)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetthreadpriority003
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetthreadpriority003', 0, function () {
var pres = process.tid
for(var i=0; i<1000; i++)
{
var pri = process.getThreadPriority(pres)
if(pri > 0)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetstartrealtime001
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime001', 0, function () {
for(var i=0; i<10; i++)
{
var pri = process.getStartRealtime()
if(pri !== null)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetstartrealtime002
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime002', 0, function () {
var pri = process.getStartRealtime()
if(pri !== null)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetstartrealtime003
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime003', 0, function () {
for(var i=0; i<100; i++)
{
var pri = process.getStartRealtime()
if(pri !== null)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetstartrealtime004
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetstartrealtime004', 0, function () {
for(var i=0; i<1000; i++)
{
var pri = process.getPastCputime()
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime001
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime001', 0, function () {
for(var i=0; i<10; i++)
{
var pri = process.getStartRealtime()
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime002
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime002', 0, function () {
var pri = process.getPastCputime()
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetpastCputime003
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime003', 0, function () {
for(var i=0; i<100; i++)
{
var pri = process.getPastCputime()
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetpastCputime004
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetpastCputime004', 0, function () {
for(var i=0; i<1000; i++)
{
var pri = process.getPastCputime()
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig001
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig001', 0, function () {
var _SC_ARG_MAX = 0
var pri = process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetSystemConfig002
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig002', 0, function () {
var _SC_ARG_MAX = 0
for(var i=0; i<10; i++)
{
var pri = process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig003
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig003', 0, function () {
var _SC_ARG_MAX = 0
for(var i=0; i<100; i++)
{
var pri = process.getSystemConfig(_SC_ARG_MAX)
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetSystemConfig004
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig004', 0, function () {
var _SC_OPEN_MAX = 4
var pri = process.getSystemConfig(_SC_OPEN_MAX)
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetSystemConfig005
* @tc.desc: Returns the system configuration at runtime.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetSystemConfig005', 0, function () {
var _SC_PAGESIZE = 8
var pri = process.getSystemConfig(_SC_PAGESIZE)
if(pri > 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetAvailableCores001
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores001', 0, function () {
var pri = process.getAvailableCores()
if(pri != null)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
})
/**
* @tc.name: testGetAvailableCores002
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores002', 0, function () {
for(var i=0; i<10; i++)
{
var pri = process.getAvailableCores()
if(pri != 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetAvailableCores003
* @tc.desc: Returns cpu cores available for the current process on a multi-core device.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetAvailableCores003', 0, function () {
for(var i=0; i<100; i++)
{
var pri = process.getAvailableCores()
if(pri != 0)
{
var flag = new Boolean(true)
}
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetEnvironmentVar001
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar001', 0, function () {
var pri = process.getEnvironmentVar("USER")
if(pri != null) {
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
})
/**
* @tc.name: testGetEnvironmentVar002
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar002', 0, function () {
for(var i=0; i<10; i++)
{
var pri = process.getEnvironmentVar("PATH")
if(pri != null)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEnvironmentVar003
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar003', 0, function () {
for(var i=0; i<100; i++)
{
var pri = process.getEnvironmentVar("PATH")
if(pri != null)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEnvironmentVar004
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar004', 0, function () {
for(var i=0; i<10; i++)
{
var pri = process.getEnvironmentVar("USER")
if(pri != null)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
}
})
/**
* @tc.name: testGetEnvironmentVar005
* @tc.desc: Returns the system value for environment variables.
* @tc.require: AR000GFB04
* @tc.author: liwenqiang
*/
it('testGetEnvironmentVar005', 0, function () {
for(var i=0; i<100; i++)
{
var pri = process.getEnvironmentVar("USER")
if(pri != null)
{
var flag = new Boolean(true)
expect(flag).assertEqual(true)
}
}
})
})
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite'
import Uri from '@ohos.uri'
describe('UriTest', function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor001', 0, function () {
try {
let that = new Uri.URI('#http://username:password@host:8080/directory/file?foo=1&bar=2');
} catch (err) {
expect(err).assertEqual("Error: #It can't be the first");
}
})
/**
* @tc.name: testConstructor002
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor002', 0, function () {
try {
let that = new Uri.URI({name: 'gaogao'});
} catch (err) {
expect(err).assertEqual("Error: input type err");
}
})
/**
* @tc.name: testConstructor003
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor003', 0, function () {
try {
let that = new Uri.URI('ht/tp://username:pas sword@host:8080/directory/file?foo=1&bar=2');
} catch (err) {
expect(err).assertEqual("Error: SpecialPath does not conform to the rule");
}
})
/**
* @tc.name: testConstructor004
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor004', 0, function () {
try {
let that = new Uri.URI('http://username:password@[::]:8080/directory/file?Query#gaogao faofao');
} catch (err) {
expect(err).assertEqual("Error: Fragment does not conform to the rule");
}
})
/**
* @tc.name: testConstructor005
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor005', 0, function () {
try {
let that = new Uri.URI('http://username:password@host:8080/directory/file?foo^=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: Query does not conform to the rule");
}
})
/**
* @tc.name: testConstructor006
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor006', 0, function () {
try {
let that = new Uri.URI('1http://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: Scheme the first character must be a letter");
}
})
/**
* @tc.name: testConstructor007
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor007', 0, function () {
try {
let that = new Uri.URI('ht@tp://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: scheme does not conform to the rule");
}
})
/**
* @tc.name: testConstructor008
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor008', 0, function () {
try {
let that = new Uri.URI('http://username:password@[::]:80r80/directory/file?foo=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: Prot does not conform to the rule");
}
})
/**
* @tc.name: testConstructor009
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor009', 0, function () {
try {
let that = new Uri.URI('http://username:password@[::12:55:8080/directory/file?foo=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: IPv6 is missing a closing bracket");
}
})
/**
* @tc.name: testConstructor010
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor010', 0, function () {
try {
let that = new Uri.URI('http://username:pa^ssword@[::12:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: userInfo does not conform to the rule");
}
})
/**
* @tc.name: testConstructor011
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor011', 0, function () {
try {
let that = new Uri.URI('http://username:password@[::1你2:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao');
} catch (err) {
expect(err).assertEqual("Error: ipv6 does not conform to the rule");
}
})
/**
* @tc.name: testConstructor012
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor012', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@www.baidu.com:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@www.baidu.com:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("www.baidu.com");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor013
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor013', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[1080::8:800:200C:417A]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[1080::8:800:200C:417A]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/66path1");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor014
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor014', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[::]:88/path/path66?foooo#gaogao');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[::]:88");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[::]:88/path/path66?foooo");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[::]");
expect(gaogao.port).assertEqual("88");
expect(gaogao.path).assertEqual("/path/path66");
expect(gaogao.query).assertEqual("foooo");
expect(gaogao.fragment).assertEqual("gaogao");
})
/**
* @tc.name: testConstructor015
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor015', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[1:0:0:1:2:1:2:1]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[1:0:0:1:2:1:2:1]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/66path1");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor016
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor016', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[::FFFF:129.144.52.38]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[::FFFF:129.144.52.38]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor017
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor017', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[::192.9.5.5]:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[::192.9.5.5]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[::192.9.5.5]:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[::192.9.5.5]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor018
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor018', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[22::22:2:2%ss]:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[22::22:2:2%ss]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[22::22:2:2%ss]:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[22::22:2:2%ss]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor019
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor019', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[fe80:0000:0001:0000:0440:44ff:1233:5678]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor020
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor020', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[fe80::0001:0000]:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@[fe80::0001:0000]:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@[fe80::0001:0000]:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("[fe80::0001:0000]");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor021
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor021', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("gg:gaogao@199.98.55.44:99");
expect(gaogao.ssp).assertEqual("//gg:gaogao@199.98.55.44:99/path/path?query");
expect(gaogao.userinfo).assertEqual("gg:gaogao");
expect(gaogao.host).assertEqual("199.98.55.44");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor022
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor022', 0, function () {
let gaogao = new Uri.URI('http://16.9.5.4:99/path/path?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("16.9.5.4:99");
expect(gaogao.ssp).assertEqual("//16.9.5.4:99/path/path?query");
expect(gaogao.userinfo).assertEqual("null");
expect(gaogao.host).assertEqual("16.9.5.4");
expect(gaogao.port).assertEqual("99");
expect(gaogao.path).assertEqual("/path/path");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor023
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor023', 0, function () {
let gaogao = new Uri.URI('http://49.99.54.12:50/path/path23?query#fagment');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("49.99.54.12:50");
expect(gaogao.ssp).assertEqual("//49.99.54.12:50/path/path23?query");
expect(gaogao.userinfo).assertEqual("null");
expect(gaogao.host).assertEqual("49.99.54.12");
expect(gaogao.port).assertEqual("50");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("fagment");
})
/**
* @tc.name: testConstructor024
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor024', 0, function () {
let gaogao = new Uri.URI('http://user@49.10pe8.54.12:80/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("user@49.10pe8.54.12:80");
expect(gaogao.ssp).assertEqual("//user@49.10pe8.54.12:80/path/path23?query");
expect(gaogao.userinfo).assertEqual("null");
expect(gaogao.host).assertEqual("null");
expect(gaogao.port).assertEqual("-1");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor025
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor025', 0, function () {
let gaogao = new Uri.URI('http://user@www.baidu.com/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("user@www.baidu.com");
expect(gaogao.ssp).assertEqual("//user@www.baidu.com/path/path23?query");
expect(gaogao.userinfo).assertEqual("user");
expect(gaogao.host).assertEqual("www.baidu.com");
expect(gaogao.port).assertEqual("-1");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor026
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor026', 0, function () {
let gaogao = new Uri.URI('http://user@www.hw.com:77/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("user@www.hw.com:77");
expect(gaogao.ssp).assertEqual("//user@www.hw.com:77/path/path23?query");
expect(gaogao.userinfo).assertEqual("user");
expect(gaogao.host).assertEqual("www.hw.com");
expect(gaogao.port).assertEqual("77");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor027
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor027', 0, function () {
let gaogao = new Uri.URI('ht2tp://user@www.h12343w.com:77/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("ht2tp");
expect(gaogao.authority).assertEqual("user@www.h12343w.com:77");
expect(gaogao.ssp).assertEqual("//user@www.h12343w.com:77/path/path23?query");
expect(gaogao.userinfo).assertEqual("user");
expect(gaogao.host).assertEqual("www.h12343w.com");
expect(gaogao.port).assertEqual("77");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor028
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor028', 0, function () {
let gaogao = new Uri.URI('ht2tp://user@www.1hw.1com:77/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("ht2tp");
expect(gaogao.authority).assertEqual("user@www.1hw.1com:77");
expect(gaogao.ssp).assertEqual("//user@www.1hw.1com:77/path/path23?query");
expect(gaogao.userinfo).assertEqual("null");
expect(gaogao.host).assertEqual("null");
expect(gaogao.port).assertEqual("-1");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor029
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor029', 0, function () {
let gaogao = new Uri.URI('http://user@hosthost/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("user@hosthost");
expect(gaogao.ssp).assertEqual("//user@hosthost/path/path23?query");
expect(gaogao.userinfo).assertEqual("user");
expect(gaogao.host).assertEqual("hosthost");
expect(gaogao.port).assertEqual("-1");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor030
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor030', 0, function () {
let gaogao = new Uri.URI('http://user@[::]/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("user@[::]");
expect(gaogao.ssp).assertEqual("//user@[::]/path/path23?query");
expect(gaogao.userinfo).assertEqual("user");
expect(gaogao.host).assertEqual("[::]");
expect(gaogao.port).assertEqual("-1");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testConstructor031
* @tc.desc: Constructs a URI by parsing the given string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testConstructor031', 0, function () {
let gaogao = new Uri.URI('http://[::192:0:5]/path/path23?query#qwer');
expect(gaogao.scheme).assertEqual("http");
expect(gaogao.authority).assertEqual("[::192:0:5]");
expect(gaogao.ssp).assertEqual("//[::192:0:5]/path/path23?query");
expect(gaogao.userinfo).assertEqual("null");
expect(gaogao.host).assertEqual("[::192:0:5]");
expect(gaogao.port).assertEqual("-1");
expect(gaogao.path).assertEqual("/path/path23");
expect(gaogao.query).assertEqual("query");
expect(gaogao.fragment).assertEqual("qwer");
})
/**
* @tc.name: testEquals001
* @tc.desc: Tests this URI for equality with another object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testEquals001', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let gaogao1 = gaogao;
let res = gaogao.equals(gaogao1);
expect(res).assertEqual(true);
})
/**
* @tc.name: testEquals002
* @tc.desc: Tests this URI for equality with another object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testEquals002', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let res = gaogao.equals(gaogao1);
expect(res).assertEqual(true);
})
/**
* @tc.name: testEquals003
* @tc.desc: Tests this URI for equality with another object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testEquals003', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment123');
let res = gaogao.equals(gaogao1);
expect(res).assertEqual(false);
})
/**
* @tc.name: testEquals004
* @tc.desc: Tests this URI for equality with another object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testEquals004', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@wwwaaa:99/path1?query#fagment');
let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment123');
let res = gaogao.equals(gaogao1);
expect(res).assertEqual(false);
})
/**
* @tc.name: testEquals005
* @tc.desc: Tests this URI for equality with another object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testEquals005', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
let gaogao1 = new Uri.URI('http://[1:0:0:1:2:1:2:1]/path1?query#fagment123');
let res = gaogao.equals(gaogao1);
expect(res).assertEqual(false);
})
/**
* @tc.name: testNormalize001
* @tc.desc: Normalizes this URI's path.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testNormalize001', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
let res = gaogao.normalize();
expect(res.path).assertEqual("/path/path1");
expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment");
})
/**
* @tc.name: testNormalize002
* @tc.desc: Normalizes this URI's path.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testNormalize002', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment');
let res = gaogao.normalize();
expect(res.path).assertEqual("/../../path");
expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment");
})
/**
* @tc.name: testNormalize003
* @tc.desc: Normalizes this URI's path.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testNormalize003', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
let res = gaogao.normalize();
expect(res.path).assertEqual("/../../../aa/bb/cc");
expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../../aa/bb/cc?query#fagment");
})
/**
* @tc.name: testNormalize004
* @tc.desc: Normalizes this URI's path.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testNormalize004', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../path/.././../aa/bb/cc?query');
let res = gaogao.normalize();
expect(res.path).assertEqual("/../../aa/bb/cc");
expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../aa/bb/cc?query");
})
/**
* @tc.name: testNormalize005
* @tc.desc: Normalizes this URI's path.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testNormalize005', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/./path/./aa/bb/cc?query#fagment');
let res = gaogao.normalize();
expect(res.path).assertEqual("/path/aa/bb/cc");
expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/aa/bb/cc?query#fagment");
})
/**
* @tc.name: testToString001
* @tc.desc: Returns the content of this URI as a US-ASCII string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testToString001', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
let res = gaogao.toString();
expect(res).assertEqual('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
})
/**
* @tc.name: testToString002
* @tc.desc: Returns the content of this URI as a US-ASCII string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testToString002', 0, function () {
let gaogao = new Uri.URI('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment');
let res = gaogao.toString();
expect(res).assertEqual('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment');
})
/**
* @tc.name: testToString003
* @tc.desc: Returns the content of this URI as a US-ASCII string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testToString003', 0, function () {
let gaogao = new Uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.toString();
expect(res).assertEqual('ftp://username:password@www.baidu.com:88/path?query#fagment');
})
/**
* @tc.name: testToString004
* @tc.desc: Returns the content of this URI as a US-ASCII string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testToString004', 0, function () {
let gaogao = new Uri.URI('http://gg:gao你好gao@199.98.55.44:99/path/p你好ath?qu你好ery#fag你好ment');
let res = gaogao.toString();
expect(res).assertEqual('http://gg:gao%E4%BD%A0%E5%A5%BDgao@199.98.55.44:99/path/' +
'p%E4%BD%A0%E5%A5%BDath?qu%E4%BD%A0%E5%A5%BDery#fag%E4%BD%A0%E5%A5%BDment');
})
/**
* @tc.name: testToString005
* @tc.desc: Returns the content of this URI as a US-ASCII string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testToString005', 0, function () {
let gaogao = new Uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
let res = gaogao.toString();
expect(res).assertEqual('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
})
/**
* @tc.name: testCheckIsAbsolute001
* @tc.desc: Tells whether or not this URI is absolute.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testCheckIsAbsolute001', 0, function () {
let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
expect(res).assertEqual(false);
})
/**
* @tc.name: testCheckIsAbsolute002
* @tc.desc: Tells whether or not this URI is absolute.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testCheckIsAbsolute002', 0, function () {
let gaogao = new Uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
expect(res).assertEqual(true);
})
/**
* @tc.name: testCheckIsAbsolute003
* @tc.desc: Tells whether or not this URI is absolute.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testCheckIsAbsolute003', 0, function () {
let gaogao = new Uri.URI('htt/p://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
expect(res).assertEqual(false);
})
/**
* @tc.name: testCheckIsAbsolute004
* @tc.desc: Tells whether or not this URI is absolute.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testCheckIsAbsolute004', 0, function () {
let gaogao = new Uri.URI('https://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
expect(res).assertEqual(true);
})
/**
* @tc.name: testCheckIsAbsolute005
* @tc.desc: Tells whether or not this URI is absolute.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testCheckIsAbsolute005', 0, function () {
let gaogao = new Uri.URI('http1://username:password@www.baidu.com:88/path?query#fagment');
let res = gaogao.checkIsAbsolute();
expect(res).assertEqual(true);
})
})
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite'
import Url from '@ohos.url'
describe('UrlFunTest', function () {
/**
* @tc.name: testUrlAppend001
* @tc.desc: Appends a specified key/value pair as a new search parameter.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlAppend001', 0, function () {
var that = new Url.URL('http://username:password@host:8080/directory/file?foo=1&bar=2');
var params = new Url.URLSearchParams(that.search);
params.append('ma','jk')
var result = params.toString()
expect(result).assertEqual('foo=1&bar=2&ma=jk')
})
/**
* @tc.name: testUrlAppend002
* @tc.desc: Appends a specified key/value pair as a new search parameter.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlAppend002', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2')
let params = new Url.URLSearchParams(that.search)
params.append("ma 大","jk¥")
var result = params.toString()
expect(result).assertEqual("foo=1&bar=2&ma+%E5%A4%A7=jk%EF%BF%A5")
})
/**
* @tc.name: testUrlAppend003
* @tc.desc: Appends a specified key/value pair as a new search parameter.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlAppend003', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2')
let params = new Url.URLSearchParams(that.search)
params.append("foo~!@#$%^&*()_+-=","jk")
var result = params.toString()
expect(result).assertEqual("foo=1&bar=2&foo%7E%21%40%23%24%25%5E%26*%28%29_%2B-%3D=jk")
})
/**
* @tc.name: testUrlAppend004
* @tc.desc: Appends a specified key/value pair as a new search parameter.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlAppend004', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2')
let params = new Url.URLSearchParams(that.search)
params.append("app","par")
var result = params.toString()
expect(result).assertEqual("foo=1&bar=2&app=par")
})
/**
* @tc.name: testUrlAppend005
* @tc.desc: Appends a specified key/value pair as a new search parameter.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlAppend005', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2')
let params = new Url.URLSearchParams(that.search)
params.append("123","456")
var result = params.toString()
expect(result).assertEqual("foo=1&bar=2&123=456")
})
/**
* @tc.name: testUrlDelete001
* @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlDelete001', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2')
let params = new Url.URLSearchParams(that.search)
params.delete("foo")
var result = params.toString()
expect(result).assertEqual("bar=2")
})
/**
* @tc.name: testUrlDelete002
* @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlDelete002', 0, function () {
let that = new Url.URL('https://example.com?foo大=1&bar=2');
let params = new Url.URLSearchParams(that.search);
params.delete('foo');
var result = params.toString();
expect(result).assertEqual("foo%E5%A4%A7=1&bar=2");
})
/**
* @tc.name: testUrlDelete003
* @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlDelete003', 0, function () {
let that = new Url.URL('https://example.com?foo大=1&bar=2');
let params = new Url.URLSearchParams(that.search);
params.delete("foo大");
var result = params.toString();
expect(result).assertEqual("bar=2")
})
/**
* @tc.name: testUrlDelete004
* @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlDelete004', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2');
let params = new Url.URLSearchParams(that.search);
params.delete('bar');
var result = params.toString();
expect(result).assertEqual("foo=1");
})
/**
* @tc.name: testUrlDelete005
* @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlDelete005', 0, function () {
let that = new Url.URL('https://example.com?foo=1&bar=2');
let params = new Url.URLSearchParams(that.search);
params.delete("faa");
var result = params.toString();
expect(result).assertEqual("foo=1&bar=2")
})
/**
* @tc.name: testUrlEntries001
* @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlEntries001', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2");
var i=0;
var arr={};
for(var pair of params.entries()) {
arr[i]=pair[0];
i++;
arr[i]=pair[1];
i++;
};
expect(arr[1]).assertEqual("value1");
})
/**
* @tc.name: testUrlEntries002
* @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlEntries002', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
var i=0;
var arr={};
for(var pair of params.entries()) {
arr[i]=pair[0];
i++;
arr[i]=pair[1];
i++;
}
expect(arr[2]).assertEqual("key2")
})
/**
* @tc.name: testUrlEntries003
* @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlEntries003', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
params.append("foo","jk")
var i=0;
var arr={};
for(var pair of params.entries()) {
arr[i]=pair[0];
i++;
arr[i]=pair[1];
i++;
}
expect(arr[5]).assertEqual("jk")
})
/**
* @tc.name: testUrlEntries004
* @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlEntries004', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
var i=0;
var arr={};
for(var pair of params.entries()) {
arr[i]=pair[0];
i++;
arr[i]=pair[1];
i++;
}
expect(arr[3]).assertEqual("value2")
})
/**
* @tc.name: testUrlEntries005
* @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlEntries005', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
params.append("jss","txt")
var i=0;
var arr={};
for(var pair of params.entries()) {
arr[i]=pair[0];
i++;
arr[i]=pair[1];
i++;
}
expect(arr[4]).assertEqual("jss")
})
/**
* @tc.name: testUrlForEach001
* @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlForEach001', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
var arr={};
var i = 0;
function func(value, key, SearchParams)
{
arr[i] = value + " " + key + " " + (params === SearchParams)
i++
}
params.forEach(func);
expect(arr[0]).assertEqual("value1 key1 true");
})
/**
* @tc.name: testUrlForEach002
* @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlForEach002', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2");
var arr={};
var i = 0;
function func(value, key, SearchParams)
{
arr[i] = value + " " + key + " " + (params === SearchParams)
i++
};
params.forEach(func);
expect(arr[1]).assertEqual("value2 key2 true");
})
/**
* @tc.name: testUrlForEach003
* @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlForEach003', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2");
params.append("foo","jk");
var arr={};
var i = 0;
function func(value, key, SearchParams)
{
arr[i] = value + " " + key + " " + (params === SearchParams)
i++
};
params.forEach(func);
expect(arr[2]).assertEqual("jk foo true");
})
/**
* @tc.name: testUrlForEach004
* @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlForEach004', 0, function () {
let params = new Url.URLSearchParams("foo=bar&jss=txt");
var arr={};
var i = 0;
function func(value, key, SearchParams)
{
arr[i] = value + " " + key + " " + (params === SearchParams)
i++
}
params.forEach(func);
expect(arr[1]).assertEqual("txt jss true");
})
/**
* @tc.name: testUrlForEach005
* @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object.
* @tc.require: AR000GFB2S
* @tc.author: jiangkai
*/
it('testUrlForEach005', 0, function () {
let params = new Url.URLSearchParams("foo=bar&jss=txt");
params.append("foo","jk");
var arr={};
var i = 0;
function func(value, key, SearchParams)
{
arr[i] = value + " " + key + " " + (params === SearchParams)
i++
};
params.forEach(func);
expect(arr[0]).assertEqual("bar foo true");
})
/**
* @tc.name: testUrlGet001
* @tc.desc: Returns the first value associated to the given search parameter.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlGet001', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
var result = params.get("1")
expect(result).assertEqual(undefined)
})
/**
* @tc.name: testUrlForEach002
* @tc.desc: Returns the first value associated to the given search parameter.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlForEach002', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
var result = params.get("key2")
expect(result).assertEqual("value2")
})
/**
* @tc.name: testUrlForEach003
* @tc.desc: Returns the first value associated to the given search parameter.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlForEach003', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
params.append("5","JKL")
var result = params.get("5")
expect(result).assertEqual("JKL")
})
/**
* @tc.name: testUrlForEach004
* @tc.desc: Returns the first value associated to the given search parameter.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlForEach004', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
var result = params.get("key1")
expect(result).assertEqual("value1")
})
/**
* @tc.name: testUrlForEach005
* @tc.desc: Returns the first value associated to the given search parameter.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlForEach005', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
params.append("jss","JL")
var result = params.get("jss")
expect(result).assertEqual("JL")
})
/**
* @tc.name: testUrlGetAll001
* @tc.desc: Returns all key-value pairs associated with a given search parameter as an array.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlGetAll001', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2")
params.append("key1","AAA")
var result = params.getAll("key1")
expect(result).assertEqual("value1,AAA")
})
/**
* @tc.name: testUrlGetAll002
* @tc.desc: Returns all key-value pairs associated with a given search parameter as an array.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlGetAll002', 0, function () {
let params = new Url.URLSearchParams("key1=value1&8=DEF")
params.append("8","A8A")
var result = params.getAll("8")
expect(result).assertEqual("DEF,A8A")
})
/**
* @tc.name: testUrlGetAll003
* @tc.desc: Returns all key-value pairs associated with a given search parameter as an array.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlGetAll003', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=da")
params.append("key3","A3A")
var result = params.getAll("key3")
expect(result).assertEqual("da,A3A")
})
/**
* @tc.name: testUrlGetAll004
* @tc.desc: Returns all key-value pairs associated with a given search parameter as an array.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlGetAll004', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大")
params.append("key3","A3A")
var result = params.getAll("key4")
expect(result).assertEqual('')
})
/**
* @tc.name: testUrlGetAll005
* @tc.desc: Returns all key-value pairs associated with a given search parameter as an array.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlGetAll005', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大")
params.append("key3","A3A")
var result = params.getAll("key2")
expect(result).assertEqual("value2")
})
/**
* @tc.name: testUrlHas001
* @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlHas001', 0, function () {
let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大")
var result = params.has("2")
expect(result).assertEqual(false)
})
/**
* @tc.name: testUrlHas002
* @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlHas002', 0, function () {
let params = new Url.URLSearchParams("小=value1&key2=value2&key3=大")
var result = params.has("小")
expect(result).assertEqual(true)
})
/**
* @tc.name: testUrlHas003
* @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlHas003', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大")
params.append("¥","ACA")
var result = params.has("¥")
expect(result).assertEqual(true)
})
/**
* @tc.name: testUrlHas004
* @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlHas004', 0, function () {
let params = new Url.URLSearchParams("小=value1&key2=value2&key3=大")
var result = params.has("无")
expect(result).assertEqual(false)
})
/**
* @tc.name: testUrlHas005
* @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlHas005', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大")
params.append("¥","ACA")
var result = params.has("¥11")
expect(result).assertEqual(false)
})
/**
* @tc.name: testUrlKeys001
* @tc.desc: Returns an iterator allowing to go through all keys contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlKeys001', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大");
var arr={};
var i = 0;
for(var key of params.keys()) {
arr[i] = key
i++
};
expect(arr[0]).assertEqual("小");
})
/**
* @tc.name: testUrlKeys002
* @tc.desc: Returns an iterator allowing to go through all keys contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlKeys002', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大");
var arr={};
var i = 0;
for(var key of params.keys()) {
arr[i] = key
i++
};
expect(arr[1]).assertEqual("¥");
})
/**
* @tc.name: testUrlKeys003
* @tc.desc: Returns an iterator allowing to go through all keys contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlKeys003', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大");
var arr={};
var i = 0;
for(var key of params.keys()) {
arr[i] = key
i++
};
expect(arr[2]).assertEqual("key3");
})
/**
* @tc.name: testUrlKeys004
* @tc.desc: Returns an iterator allowing to go through all keys contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlKeys004', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大&key4=六");
var arr={};
var i = 0;
for(var key of params.keys()) {
arr[i] = key
i++
};
expect(arr[3]).assertEqual("key4");
})
/**
* @tc.name: testUrlKeys005
* @tc.desc: Returns an iterator allowing to go through all keys contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlKeys005', 0, function () {
let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大&key4=六&key5=发");
var arr={};
var i = 0;
for(var key of params.keys()) {
arr[i] = key
i++
};
expect(arr[4]).assertEqual("key5");
})
/**
* @tc.name: testUrlSet001
* @tc.desc: Sets the value associated with a given search parameter to the given value.
* If there were several matching values, this method deletes the others.
* If the search parameter doesn't exist, this method creates it.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSet001', 0, function () {
let params = new Url.URLSearchParams("1=value1&2=value2&key3=3");
// params.append("11","ACA");
params.set("11","CCC");
var res = params.toString();
expect(res).assertEqual("1=value1&2=value2&key3=3&11=CCC");
})
/**
* @tc.name: testUrlSet002
* @tc.desc: Sets the value associated with a given search parameter to the given value.
* If there were several matching values, this method deletes the others.
* If the search parameter doesn't exist, this method creates it.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSet002', 0, function () {
let params = new Url.URLSearchParams("1=value1&2=value2&key3=3");
params.set('10','BBB');
var res = params.toString();
expect(res).assertEqual("1=value1&2=value2&key3=3&10=BBB");
})
/**
* @tc.name: testUrlSet003
* @tc.desc: Sets the value associated with a given search parameter to the given value.
* If there were several matching values, this method deletes the others.
* If the search parameter doesn't exist, this method creates it.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSet003', 0, function () {
let params = new Url.URLSearchParams("1=value1&2=value2&key3=3");
params.set("ma 大" ,"10¥");
var res = params.toString();
expect(res).assertEqual("1=value1&2=value2&key3=3&ma+%E5%A4%A7=10%EF%BF%A5");
})
/**
* @tc.name: testUrlSet004
* @tc.desc: Sets the value associated with a given search parameter to the given value.
* If there were several matching values, this method deletes the others.
* If the search parameter doesn't exist, this method creates it.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSet004', 0, function () {
let params = new Url.URLSearchParams("1=value1&2=value2&key3=3");
// params.append("1","ACA");
params.set("1","CCC");
var res = params.toString();
expect(res).assertEqual("1=CCC&2=value2&key3=3");
})
/**
* @tc.name: testUrlSet005
* @tc.desc: Sets the value associated with a given search parameter to the given value.
* If there were several matching values, this method deletes the others.
* If the search parameter doesn't exist, this method creates it.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSet005', 0, function () {
let params = new Url.URLSearchParams("1=value1&2=value2&key3=3");
params.set('12','BBB');
var res = params.toString();
expect(res).assertEqual("1=value1&2=value2&key3=3&12=BBB");
})
/**
* @tc.name: testUrlSort001
* @tc.desc: Sort all key/value pairs contained in this object in place and return undefined.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSort001', 0, function () {
let params = new Url.URLSearchParams("1=value1&3=value3&2=key2");
params.sort();
var res = params.toString();
expect(res).assertEqual("1=value1&2=key2&3=value3");
})
/**
* @tc.name: testUrlSort002
* @tc.desc: Sort all key/value pairs contained in this object in place and return undefined.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSort002', 0, function () {
let params = new Url.URLSearchParams("a=value1&c=value2&b=key2");
params.sort();
var res = params.toString();
expect(res).assertEqual("a=value1&b=key2&c=value2");
})
/**
* @tc.name: testUrlSort003
* @tc.desc: Sort all key/value pairs contained in this object in place and return undefined.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSort003', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=33");
params.append("a","ACA");
params.sort();
var res = params.toString();
expect(res).assertEqual("a=ACA&b=33&c=value2&d=value1");
})
/**
* @tc.name: testUrlSort004
* @tc.desc: Sort all key/value pairs contained in this object in place and return undefined.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSort004', 0, function () {
let params = new Url.URLSearchParams("1=value1&3=value3&2=key2&4=key4");
params.sort();
var res = params.toString();
expect(res).assertEqual("1=value1&2=key2&3=value3&4=key4");
})
/**
* @tc.name: testUrlSort005
* @tc.desc: Sort all key/value pairs contained in this object in place and return undefined.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlSort005', 0, function () {
let params = new Url.URLSearchParams("a=value1&c=value2&4=key4&b=key2");
params.sort();
var res = params.toString();
expect(res).assertEqual("4=key4&a=value1&b=key2&c=value2");
})
/**
* @tc.name: testUrlValues001
* @tc.desc: Returns an iterator allowing to go through all values contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlValues001', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大")
var arr={}
var i = 0
for(var value of params.values()) {
arr[i] = value
i++
}
expect(arr[0]).assertEqual("value1")
})
/**
* @tc.name: testUrlValues002
* @tc.desc: Returns an iterator allowing to go through all values contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlValues002', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大")
var arr={}
var i = 0
for(var value of params.values()) {
arr[i] = value
i++
}
expect(arr[1]).assertEqual("value2")
})
/**
* @tc.name: testUrlValues003
* @tc.desc: Returns an iterator allowing to go through all values contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlValues003', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大")
params.append("a","ACA")
var arr={}
var i = 0
for(var value of params.values()) {
arr[i] = value
i++
}
expect(arr[3]).assertEqual("ACA")
})
/**
* @tc.name: testUrlValues004
* @tc.desc: Returns an iterator allowing to go through all values contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlValues004', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大&4=key4")
var arr={}
var i = 0
for(var value of params.values()) {
arr[i] = value
i++
}
expect(arr[3]).assertEqual("key4")
})
/**
* @tc.name: testUrlValues005
* @tc.desc: Returns an iterator allowing to go through all values contained in this object.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlValues005', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大&4=key4&5=key5")
var arr={}
var i = 0
for(var value of params.values()) {
arr[i] = value
i++
}
expect(arr[4]).assertEqual("key5")
})
/**
* @tc.name: testUrlToString001
* @tc.desc: Returns a query string suitable for use in a URL.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlToString001', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大")
var result= params.toString()
expect(result).assertEqual("d=value1&c=value2&b=%E5%A4%A7")
})
/**
* @tc.name: testUrlToString002
* @tc.desc: Returns a query string suitable for use in a URL.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlToString002', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b= 大")
params.append("1 12","QQQ")
var result= params.toString()
expect(result).assertEqual("d=value1&c=value2&b=+%E5%A4%A7&1+12=QQQ")
})
/**
* @tc.name: testUrlToString003
* @tc.desc: Returns a query string suitable for use in a URL.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlToString003', 0, function () {
let params = new Url.URLSearchParams("¥=)")
params.delete("5")
var result= params.toString()
expect(result).assertEqual("%EF%BF%A5=%29")
})
/**
* @tc.name: testUrlToString004
* @tc.desc: Returns a query string suitable for use in a URL.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlToString004', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b=大&4=key4")
var result= params.toString()
expect(result).assertEqual("d=value1&c=value2&b=%E5%A4%A7&4=key4")
})
/**
* @tc.name: testUrlToString005
* @tc.desc: Returns a query string suitable for use in a URL.
* @tc.require: AR000GFB2S
* @tc.author: maxiaodong
*/
it('testUrlToString005', 0, function () {
let params = new Url.URLSearchParams("d=value1&c=value2&b= 大&4=key4&5=key5")
params.append("1 12","QQQ")
var result= params.toString()
expect(result).assertEqual("d=value1&c=value2&b=+%E5%A4%A7&4=key4&5=key5&1+12=QQQ")
})
/**
* @tc.name: testUrlSearchParamsConstruction001
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction001', 0, function () {
let params = new Url.URLSearchParams('?user=abc&query=xyz')
var result= params.toString()
expect(result).assertEqual("user=abc&query=xyz")
})
/**
* @tc.name: testUrlSearchParamsConstruction002
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction002', 0, function () {
let params = new Url.URLSearchParams({
user: 'abc',
query: ['first', 'second']
});
var result= params.toString()
expect(result).assertEqual("user=abc&query=first%2Csecond")
})
/**
* @tc.name: testUrlSearchParamsConstruction003
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction003', 0, function () {
let params = new Url.URLSearchParams([
['user', 'abc'],
['query', 'first'],
['query', 'second'],
]);
var result= params.toString()
expect(result).assertEqual("user=abc&query=first&query=second")
})
/**
* @tc.name: testUrlSearchParamsConstruction004
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction004', 0, function () {
const map = new Map();
map.set('user', 'abc');
map.set('query', 'xyz');
let params = new Url.URLSearchParams(map)
var result= params.toString()
expect(result).assertEqual("user=abc&query=xyz")
})
/**
* @tc.name: testUrlSearchParamsConstruction005
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction005', 0, function () {
function* getQueryPairs() {
yield ['user', 'abc'];
yield ['query', 'first'];
yield ['query', 'second'];
}
let params = new Url.URLSearchParams(getQueryPairs());
var result= params.toString()
expect(result).assertEqual("user=abc&query=first&query=second")
})
/**
* @tc.name: testUrlSearchParamsConstruction006
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction006', 0, function () {
let params = new Url.URLSearchParams()
params.append('abcde','fghki')
var paramsResult = params.toString()
expect(paramsResult).assertEqual('abcde=fghki')
})
/**
* @tc.name: testUrlSearchParamsConstruction007
* @tc.desc: A parameterized constructor used to create an URLSearchParams instance.
* @tc.require: AR000GFB2S
* @tc.author: zhangyouyou
*/
it('testUrlSearchParamsConstruction007', 0, function () {
let param
let params = new Url.URLSearchParams(param)
params.append('abcde','fghki')
var paramsResult = params.toString()
expect(paramsResult).assertEqual('abcde=fghki')
})
/**
* @tc.name: testUrlToString001
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToString001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.toString()
expect(result).assertEqual("http://username:password@host:8080/directory/file?query#fragment")
})
/**
* @tc.name: testUrlToString002
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToString002', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file')
var result= params.toString()
expect(result).assertEqual("http://username:password@host:8080/directory/file")
})
/**
* @tc.name: testUrlToString003
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToString003', 0, function () {
let params = new Url.URL('http://username:password@host:8080#fragment')
var result= params.toString()
expect(result).assertEqual("http://username:password@host:8080/#fragment")
})
/**
* @tc.name: testUrlToString004
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToString004', 0, function () {
let params = new Url.URL('http1://host/directory/file?query#fragment')
var result= params.toString()
expect(result).assertEqual("http1://host/directory/file?query#fragment")
})
/**
* @tc.name: testUrlToString005
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToString005', 0, function () {
let params = new Url.URL('http:host:8080/directory/file?query#fragment')
var result= params.toString()
expect(result).assertEqual("http://host:8080/directory/file?query#fragment")
})
/**
* @tc.name: testUrlHref001
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHref001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.href
expect(result).assertEqual("http://username:password@host:8080/directory/file?query#fragment")
})
/**
* @tc.name: testUrlHref002
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHref002', 0, function () {
let params = new Url.URL('http://host:8080/directory/file?query#fragment')
var result= params.href
expect(result).assertEqual("http://host:8080/directory/file?query#fragment")
})
/**
* @tc.name: testUrlHref003
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHref003', 0, function () {
let params = new Url.URL('http://username:password@host:8080')
var result= params.href
expect(result).assertEqual("http://username:password@host:8080/")
})
/**
* @tc.name: testUrlHref004
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHref004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.href = 'http1://myhost/path?sss=1#ff';
var result= params.href
expect(result).assertEqual("http1://myhost/path?sss=1#ff")
})
/**
* @tc.name: testUrlHref005
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHref005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.href = 'http://myhost:99/path#ff';
var result= params.href
expect(result).assertEqual("http://myhost:99/path#ff")
})
/**
* @tc.name: testUrlOrigin001
* @tc.desc: Gets the read-only serialization of the URL's origin.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlOrigin001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.origin
expect(result).assertEqual('http://host:8080')
})
/**
* @tc.name: testUrlOrigin002
* @tc.desc: Gets the read-only serialization of the URL's origin.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlOrigin002', 0, function () {
let params = new Url.URL('http://username:password@host:11/directory/file?query#fragment')
var result= params.origin
expect(result).assertEqual('http://host:11')
})
/**
* @tc.name: testUrlOrigin003
* @tc.desc: Gets the read-only serialization of the URL's origin.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlOrigin003', 0, function () {
let params = new Url.URL('http://username:password@host/directory/file?query#fragment')
var result= params.origin
expect(result).assertEqual('http://host')
})
/**
* @tc.name: testUrlOrigin004
* @tc.desc: Gets the read-only serialization of the URL's origin.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlOrigin004', 0, function () {
let params = new Url.URL('http://username:password@aaaasshost:212/directory/file?query#fragment')
var result= params.origin
expect(result).assertEqual('http://aaaasshost:212')
})
/**
* @tc.name: testUrlOrigin005
* @tc.desc: Gets the read-only serialization of the URL's origin.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlOrigin005', 0, function () {
let params = new Url.URL('http://username:password@host22:100#fragment')
var result= params.origin
expect(result).assertEqual('http://host22:100')
})
/**
* @tc.name: testUrlProtocol001
* @tc.desc: Gets and sets the protocol portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlProtocol001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.protocol
expect(result).assertEqual('http:')
})
/**
* @tc.name: testUrlProtocol002
* @tc.desc: Gets and sets the protocol portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlProtocol002', 0, function () {
let params = new Url.URL('http1://username:password@host:8080/directory/file?query#fragment')
var result= params.protocol
expect(result).assertEqual('http1:')
})
/**
* @tc.name: testUrlProtocol003
* @tc.desc: Gets and sets the protocol portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlProtocol003', 0, function () {
let params = new Url.URL('https://username:password@host:8080/directory/file?query#fragment')
var result= params.protocol
expect(result).assertEqual('https:')
})
/**
* @tc.name: testUrlProtocol004
* @tc.desc: Gets and sets the protocol portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlProtocol004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.protocol = 'https:';
var result= params.protocol
expect(result).assertEqual('https:')
})
/**
* @tc.name: testUrlProtocol005
* @tc.desc: Gets and sets the protocol portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlProtocol005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.protocol = 'ftp:';
var result= params.protocol
expect(result).assertEqual('ftp:')
})
/**
* @tc.name: testUrlUsername001
* @tc.desc: Gets and sets the username portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlUsername001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.username
expect(result).assertEqual('username')
})
/**
* @tc.name: testUrlUsername002
* @tc.desc: Gets and sets the username portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlUsername002', 0, function () {
let params = new Url.URL('http://zhao:password@host:8080/directory/file?query#fragment')
var result= params.username
expect(result).assertEqual('zhao')
})
/**
* @tc.name: testUrlUsername003
* @tc.desc: Gets and sets the username portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlUsername003', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.username = 'skk'
var result= params.username
expect(result).assertEqual('skk')
})
/**
* @tc.name: testUrlUsername004
* @tc.desc: Gets and sets the username portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlUsername004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.username = 'skp111'
var result= params.username
expect(result).assertEqual('skp111')
})
/**
* @tc.name: testUrlUsername005
* @tc.desc: Gets and sets the username portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlUsername005', 0, function () {
let params = new Url.URL('http://usme@host:8080/directory/file?query#fragment')
var result= params.username
expect(result).assertEqual('usme')
})
/**
* @tc.name: testUrlPassword001
* @tc.desc: Gets and sets the password portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPassword001', 0, function () {
let params = new Url.URL('http://username:11@host:8080/directory/file?query#fragment')
var result= params.password
expect(result).assertEqual('11')
})
/**
* @tc.name: testUrlPassword002
* @tc.desc: Gets and sets the password portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPassword002', 0, function () {
let params = new Url.URL('http://username:23aa@host:8080/directory/file?query#fragment')
var result= params.password
expect(result).assertEqual('23aa')
})
/**
* @tc.name: testUrlPassword003
* @tc.desc: Gets and sets the password portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPassword003', 0, function () {
let params = new Url.URL('http://username@host:8080/directory/file?query#fragment')
var result= params.password
expect(result).assertEqual('')
})
/**
* @tc.name: testUrlPassword004
* @tc.desc: Gets and sets the password portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPassword004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.password = '1234'
var result= params.password
expect(result).assertEqual('1234')
})
/**
* @tc.name: testUrlPassword005
* @tc.desc: Gets and sets the password portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPassword005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.password = '';
var result= params.password
expect(result).assertEqual('')
})
/**
* @tc.name: testUrlHost001
* @tc.desc: Gets and sets the host portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHost001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.host
expect(result).assertEqual('host:8080')
})
/**
* @tc.name: testUrlHost002
* @tc.desc: Gets and sets the host portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHost002', 0, function () {
let params = new Url.URL('http://username:password@hosthost/directory/file?query#fragment')
var result= params.host
expect(result).assertEqual('hosthost')
})
/**
* @tc.name: testUrlHost003
* @tc.desc: Gets and sets the host portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHost003', 0, function () {
let params = new Url.URL('http://username:password@host:199/directory/file?query#fragment')
var result= params.host
expect(result).assertEqual('host:199')
})
/**
* @tc.name: testUrlHost004
* @tc.desc: Gets and sets the host portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHost004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.host = 'jkjk'
var result= params.host
expect(result).assertEqual('jkjk:8080')
})
/**
* @tc.name: testUrlHost005
* @tc.desc: Gets and sets the host portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHost005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.host = 'jkjk:100'
var result= params.host
expect(result).assertEqual('jkjk:100')
})
/**
* @tc.name: testUrlHostname001
* @tc.desc: Gets and sets the host name portion of the URL,not include the port.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHostname001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.hostname
expect(result).assertEqual('host')
})
/**
* @tc.name: testUrlHostname002
* @tc.desc: Gets and sets the host name portion of the URL,not include the port.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHostname002', 0, function () {
let params = new Url.URL('http://username:password@host123:8080/directory/file?query#fragment')
var result= params.hostname
expect(result).assertEqual('host123')
})
/**
* @tc.name: testUrlHostname003
* @tc.desc: Gets and sets the host name portion of the URL,not include the port.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHostname003', 0, function () {
let params = new Url.URL('http://username:password@885ssa:8080/directory/file?query#fragment')
var result= params.hostname
expect(result).assertEqual('885ssa')
})
/**
* @tc.name: testUrlHostname004
* @tc.desc: Gets and sets the host name portion of the URL,not include the port.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHostname004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.hostname = 'sksk'
var result= params.hostname
expect(result).assertEqual('sksk')
})
/**
* @tc.name: testUrlHostname005
* @tc.desc: Gets and sets the host name portion of the URL,not include the port.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHostname005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.hostname = 'hosthost'
var result= params.hostname
expect(result).assertEqual('hosthost')
})
/**
* @tc.name: testUrlPort001
* @tc.desc: Gets and sets the port portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPort001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.port
expect(result).assertEqual('8080')
})
/**
* @tc.name: testUrlPort002
* @tc.desc: Gets and sets the port portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPort002', 0, function () {
let params = new Url.URL('http://username:password@host:100/directory/file?query#fragment')
var result= params.port
expect(result).assertEqual('100')
})
/**
* @tc.name: testUrlPort003
* @tc.desc: Gets and sets the port portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPort003', 0, function () {
let params = new Url.URL('http://username:password@host/directory/file?query#fragment')
var result= params.port
expect(result).assertEqual('')
})
/**
* @tc.name: testUrlPort004
* @tc.desc: Gets and sets the port portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPort004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.port = '99'
var result= params.port
expect(result).assertEqual('99')
})
/**
* @tc.name: testUrlPort005
* @tc.desc: Gets and sets the port portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPort005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.port = '123'
var result= params.port
expect(result).assertEqual('123')
})
/**
* @tc.name: testUrlPathname001
* @tc.desc: Gets and sets the path portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPathname001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
var result= params.pathname
expect(result).assertEqual('/directory/file')
})
/**
* @tc.name: testUrlPathname002
* @tc.desc: Gets and sets the path portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPathname002', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory?query#fragment')
var result= params.pathname
expect(result).assertEqual('/directory')
})
/**
* @tc.name: testUrlPathname003
* @tc.desc: Gets and sets the path portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPathname003', 0, function () {
let params = new Url.URL('http://username:password@host:8080?query#fragment')
var result= params.pathname
expect(result).assertEqual('/')
})
/**
* @tc.name: testUrlPathname004
* @tc.desc: Gets and sets the path portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPathname004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.pathname = 'path'
var result= params.pathname
expect(result).assertEqual('/path')
})
/**
* @tc.name: testUrlPathname005
* @tc.desc: Gets and sets the path portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlPathname005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment')
params.pathname = '/directory/file11'
var result= params.pathname
expect(result).assertEqual('/directory/file11')
})
/**
* @tc.name: testUrlSearch001
* @tc.desc: Gets and sets the serialized query portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlSearch001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq#fragment')
var result= params.search
expect(result).assertEqual('?query=qqqq')
})
/**
* @tc.name: testUrlSearch002
* @tc.desc: Gets and sets the serialized query portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlSearch002', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq&ll=pp#fragment')
var result= params.search
expect(result).assertEqual('?query=qqqq&ll=pp')
})
/**
* @tc.name: testUrlSearch003
* @tc.desc: Gets and sets the serialized query portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlSearch003', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?ppp9875=77#fragment')
var result= params.search
expect(result).assertEqual('?ppp9875=77')
})
/**
* @tc.name: testUrlSearch004
* @tc.desc: Gets and sets the serialized query portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlSearch004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq#fragment')
params.search = 'kk=99'
var result= params.search
expect(result).assertEqual('?kk=99')
})
/**
* @tc.name: testUrlSearch005
* @tc.desc: Gets and sets the serialized query portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlSearch005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq#fragment')
params.search = 'pppk=99'
var result= params.search
expect(result).assertEqual('?pppk=99')
})
/**
* @tc.name: testUrlHash001
* @tc.desc: Gets and sets the fragment portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHash001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#fragment')
var result= params.hash
expect(result).assertEqual('#fragment')
})
/**
* @tc.name: testUrlHash002
* @tc.desc: Gets and sets the fragment portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHash002', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#fragment')
params.hash = '123456'
var result= params.hash
expect(result).assertEqual('#123456')
})
/**
* @tc.name: testUrlHash003
* @tc.desc: Gets and sets the fragment portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHash003', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#poiu')
var result= params.hash
expect(result).assertEqual('#poiu')
})
/**
* @tc.name: testUrlHash004
* @tc.desc: Gets and sets the fragment portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHash004', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp')
var result= params.hash
expect(result).assertEqual('')
})
/**
* @tc.name: testUrlHash005
* @tc.desc: Gets and sets the fragment portion of the URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlHash005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#fragment')
params.hash = 'qwer'
var result= params.hash
expect(result).assertEqual('#qwer')
})
/**
* @tc.name: testUrlToJson001
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToJson001', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da')
var result= params.toJSON()
expect(result).assertEqual('http://username:password@host:8080/directory/file?query=pppppp#qwer=da')
})
/**
* @tc.name: testUrlToJson002
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToJson002', 0, function () {
let params = new Url.URL('http://host:8080/directory/file?query=pppppp#qwer=da')
var result= params.toJSON()
expect(result).assertEqual('http://host:8080/directory/file?query=pppppp#qwer=da')
})
/**
* @tc.name: testUrlToJson003
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToJson003', 0, function () {
let params = new Url.URL('http://username:password@host:8080')
var result= params.toJSON()
expect(result).assertEqual('http://username:password@host:8080/')
})
/**
* @tc.name: testUrlToJson004
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToJson004', 0, function () {
let params = new Url.URL('http11://username:password@host:8080?query=pppppp#qwer=da')
var result= params.toJSON()
expect(result).assertEqual('http11://username:password@host:8080?query=pppppp#qwer=da')
})
/**
* @tc.name: testUrlToJson005
* @tc.desc: Returns the serialized URL as a string.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlToJson005', 0, function () {
let params = new Url.URL('http://username:password@host:8080/directory')
var result= params.toJSON()
expect(result).assertEqual('http://username:password@host:8080/directory')
})
/**
* @tc.name: testUrlIPv6001
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlIPv6001', 0, function () {
let params = new Url.URL('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html')
var result= params.href
expect(result).assertEqual('http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html')
})
/**
* @tc.name: testUrlIPv6002
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlIPv6002', 0, function () {
let params = new Url.URL('http://[1080:0:0:0:8:800:200C:417A]/index.html')
var result= params.href
expect(result).assertEqual('http://[1080::8:800:200c:417a]/index.html')
})
/**
* @tc.name: testUrlIPv6003
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlIPv6003', 0, function () {
let params = new Url.URL('http://[::FFFF:129.144.52.38]:80/index.html')
var result= params.href
expect(result).assertEqual('http://[::ffff:8190:3426]/index.html')
})
/**
* @tc.name: testUrlIPv4001
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlIPv4001', 0, function () {
let params = new Url.URL('http://0377.0xff.255.1:80/index.html')
var result= params.href
expect(result).assertEqual('http://255.255.255.1/index.html')
})
/**
* @tc.name: testUrlIPv4002
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlIPv4002', 0, function () {
let params = new Url.URL('http://0377.0xff.255.g/index.html')
var result= params.href
expect(result).assertEqual('http://0377.0xff.255.g/index.html')
})
/**
* @tc.name: testUrlIPv4003
* @tc.desc: Gets and sets the serialized URL.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlIPv4003', 0, function () {
let params = new Url.URL('http://190.254.245.9:80/index.html')
var result= params.href
expect(result).assertEqual('http://190.254.245.9/index.html')
})
/**
* @tc.name: testUrlConstruction001
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction001', 0, function () {
let params = new Url.URL('https://developer.mozilla.org',)
var result= params.href
expect(result).assertEqual('https://developer.mozilla.org/')
})
/**
* @tc.name: testUrlConstruction002
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction002', 0, function () {
let params = new Url.URL('https://developer.mozilla.org','flie:/developer.mozilla.org')
var result= params.href
expect(result).assertEqual('https://developer.mozilla.org/')
})
/**
* @tc.name: testUrlConstruction003
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction003', 0, function () {
let params = new Url.URL('https://developer.mozilla.org','ftp://www.example.com')
var result= params.href
expect(result).assertEqual('https://developer.mozilla.org/')
})
/**
* @tc.name: testUrlConstruction004
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction004', 0, function () {
let params = new Url.URL(' ', 'http://www.example.com')
var result= params.href
expect(result).assertEqual('http://www.example.com/')
})
/**
* @tc.name: testUrlConstruction005
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction005', 0, function () {
let params = new Url.URL('.', 'http://www.example.com')
var result= params.href
expect(result).assertEqual('http://www.example.com/')
})
/**
* @tc.name: testUrlConstruction006
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction006', 0, function () {
let params = new Url.URL('../h:', 'http://www.example.com')
var result= params.href
expect(result).assertEqual('http://www.example.com/h:')
})
/**
* @tc.name: testUrlConstruction007
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction007', 0, function () {
let params = new Url.URL('/sca/./path/path/../scasa/jjjjj', 'http://www.example.com')
var result= params.href
expect(result).assertEqual('http://www.example.com/sca/path/scasa/jjjjj')
})
/**
* @tc.name: testUrlConstruction008
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction008', 0, function () {
let params = new Url.URL('/../sca/./path/path/../scasa/jjjjj', 'http://www.example.com')
var result= params.href
expect(result).assertEqual('http://www.example.com/sca/path/scasa/jjjjj')
})
/**
* @tc.name: testUrlConstruction009
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction009', 0, function () {
let params = new Url.URL( '/../sca/./path/path/../scasa/jjjjj', 'file://www.example.com')
var result= params.href
expect(result).assertEqual('file://www.example.com/sca/path/scasa/jjjjj')
})
/**
* @tc.name: testUrlConstruction010
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction010', 0, function () {
let params = new Url.URL('/../sca/./path/path/../scasa/jjjjj', 'file1://www.example.com')
var result= params.href
expect(result).assertEqual('file1://www.example.com/sca/path/scasa/jjjjj')
})
/**
* @tc.name: testUrlConstruction011
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction011', 0, function () {
let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy')
let params1 = new Url.URL('www.baidu.com/ssaa',params)
var result = params1.href
expect(result).assertEqual('htt1p://www.0902zy.cn/www.baidu.com/ssaa')
})
/**
* @tc.name: testUrlConstruction012
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction012', 0, function () {
let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy')
let params1 = new Url.URL('//www.baidu.com/ssaa',params)
var result = params1.href
expect(result).assertEqual('htt1p://www.baidu.com/ssaa')
})
/**
* @tc.name: testUrlConstruction013
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction013', 0, function () {
let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy')
let params1 = new Url.URL('',params)
var result = params1.href
expect(result).assertEqual('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy')
})
/**
* @tc.name: testUrlConstruction014
* @tc.desc: URL constructor, which is used to instantiate a URL object.
* @tc.require: AR000GFB2S
* @tc.author: zhaoduwei
*/
it('testUrlConstruction014', 0, function () {
let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy')
var result = params.searchParams.toString();
expect(result).assertEqual('abc=123&def=456')
})
})
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite'
import xml from '@ohos.xml'
describe('XmlSerializerXmlPullParserTest', function () {
/**
* @tc.name: testSetDeclaration001
* @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDeclaration001', 0, function () {
var arrayBuffer = new ArrayBuffer(2048);
var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
thatSer.setDeclaration();
var result = '<?xml version="1.0" encoding="utf-8"?>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDeclaration002
* @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDeclaration002', 0, function () {
var arrayBuffer = new ArrayBuffer(2048);
var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
thatSer.setDeclaration();
var result = '<?xml version="1.0" encoding="utf-8"?>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDeclaration003
* @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDeclaration003', 0, function () {
var arrayBuffer = new ArrayBuffer(2048);
var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8");
thatSer.setDeclaration();
var result = '<?xml version="1.0" encoding="utf-8"?>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDeclaration004
* @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDeclaration004', 0, function () {
var arrayBuffer = new ArrayBuffer(2048);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration();
var result = '<?xml version="1.0" encoding="utf-8"?>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDeclaration005
* @tc.desc: Writes xml declaration with encoding. For example: <?xml version="1.0" encoding="utf-8"?>.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDeclaration005', 0, function () {
var arrayBuffer = new ArrayBuffer(2048);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration();
var result = '<?xml version="1.0" encoding="utf-8"?>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testStartElement001
* @tc.desc: Writes a elemnet start tag with the given name.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testStartElement001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note1");
thatSer.endElement();
var result = '<note1/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testStartElement002
* @tc.desc: Writes a elemnet start tag with the given name.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testStartElement002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note1");
thatSer.endElement();
thatSer.startElement("note2");
thatSer.endElement();
var result = '<note1/>\r\n<note2/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testStartElement003
* @tc.desc: Writes a elemnet start tag with the given name.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testStartElement003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note1");
thatSer.startElement("note2");
thatSer.endElement();
thatSer.endElement();
var result = '<note1>\r\n <note2/>\r\n</note1>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testStartElement004
* @tc.desc: Writes a elemnet start tag with the given name.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testStartElement004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note1");
thatSer.startElement("note2");
thatSer.startElement("note3");
thatSer.endElement();
thatSer.endElement();
thatSer.endElement();
var result = '<note1>\r\n <note2>\r\n <note3/>\r\n </note2>\r\n</note1>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testStartElement005
* @tc.desc: Writes a elemnet start tag with the given name.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testStartElement005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note1");
thatSer.startElement("note2");
thatSer.endElement();
thatSer.startElement("note3");
thatSer.endElement();
thatSer.endElement();
var result = '<note1>\r\n <note2/>\r\n <note3/>\r\n</note1>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetAttributes001
* @tc.desc: Write an attribute.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetAttributes001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance1", "high1");
thatSer.endElement();
var result = '<note importance1="high1"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetAttributes002
* @tc.desc: Write an attribute.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetAttributes002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance1", "high1");
thatSer.setAttributes("importance2", "high2");
thatSer.endElement();
var result = '<note importance1="high1" importance2="high2"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetAttributes003
* @tc.desc: Write an attribute.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetAttributes003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance1", "high1");
thatSer.setAttributes("importance2", "high2");
thatSer.setAttributes("importance3", "high3");
thatSer.endElement();
var result = '<note importance1="high1" importance2="high2" importance3="high3"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetAttributes004
* @tc.desc: Write an attribute.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetAttributes004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance1", "high1");
thatSer.setAttributes("importance2", "high2");
thatSer.setAttributes("importance3", "high3");
thatSer.setAttributes("importance4", "high4");
thatSer.endElement();
var result = '<note importance1="high1" importance2="high2" importance3="high3" importance4="high4"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetAttributes005
* @tc.desc: Write an attribute.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetAttributes005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance1", "high1");
thatSer.setAttributes("importance2", "high2");
thatSer.setAttributes("importance3", "high3");
thatSer.setAttributes("importance5", "high5");
thatSer.endElement();
var result = '<note importance1="high1" importance2="high2" importance3="high3" importance5="high5"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testEndElement001
* @tc.desc: Writes end tag of the element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testEndElement001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.endElement();
var result = '<note/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testEndElement002
* @tc.desc: Writes end tag of the element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testEndElement002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance", "high");
thatSer.endElement();
var result = '<note importance="high"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testEndElement003
* @tc.desc: Writes end tag of the element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testEndElement003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("impo", "hi");
thatSer.endElement();
var result = '<note impo="hi"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testEndElement004
* @tc.desc: Writes end tag of the element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testEndElement004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note1");
thatSer.startElement("note2");
thatSer.endElement();
thatSer.endElement();
var result = '<note1>\r\n <note2/>\r\n</note1>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testEndElement005
* @tc.desc: Writes end tag of the element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testEndElement005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note2");
thatSer.setAttributes("importance", "high");
thatSer.endElement();
var result = '<note2 importance="high"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetText001
* @tc.desc: Writes the text.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetText001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy1");
thatSer.endElement();
var result = '<note importance="high">Happy1</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetText002
* @tc.desc: Writes the text.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetText002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy2");
thatSer.endElement();
var result = '<note importance="high">Happy2</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetText003
* @tc.desc: Writes the text.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetText003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy3");
thatSer.endElement();
var result = '<note importance="high">Happy3</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetText004
* @tc.desc: Writes the text.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetText004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy4");
thatSer.endElement();
var result = '<note importance="high">Happy4</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetText005
* @tc.desc: Writes the text.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetText005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setAttributes("importance", "high");
thatSer.setText("Happy5");
thatSer.endElement();
var result = '<note importance="high">Happy5</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testAddEmptyElement001
* @tc.desc: Add an empty element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testAddEmptyElement001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.addEmptyElement("a");
thatSer.endElement();
var result = '<note>\r\n <a/>\r\n</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testAddEmptyElement002
* @tc.desc: Add an empty element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testAddEmptyElement002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.endElement();
thatSer.addEmptyElement("b");
var result = '<note/>\r\n<b/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testAddEmptyElement003
* @tc.desc: Add an empty element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testAddEmptyElement003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.addEmptyElement("c");
thatSer.startElement("note");
thatSer.endElement();
var result = '<c/>\r\n<note/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testAddEmptyElement004
* @tc.desc: Add an empty element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testAddEmptyElement004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.addEmptyElement("d");
var result = '<d/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testAddEmptyElement005
* @tc.desc: Add an empty element.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testAddEmptyElement005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.addEmptyElement("c");
thatSer.addEmptyElement("d");
thatSer.endElement();
var result = '<note>\r\n <c/>\r\n <d/>\r\n</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetNamespace001
* @tc.desc: Writes the namespace of the current element tag.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetNamespace001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration();
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("note");
thatSer.endElement();
var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<h:note xmlns:h="http://www.w3.org/TR/html4/"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetNamespace002
* @tc.desc: Writes the namespace of the current element tag.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetNamespace002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration();
thatSer.setNamespace("b", "http://www.w3.org/TR/html4/");
thatSer.startElement("note");
thatSer.endElement();
var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<b:note xmlns:b="http://www.w3.org/TR/html4/"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetNamespace003
* @tc.desc: Writes the namespace of the current element tag.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetNamespace003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDeclaration();
thatSer.setNamespace("h", "http://www.111/");
thatSer.startElement("note");
thatSer.endElement();
var result = '<?xml version="1.0" encoding="utf-8"?>\r\n<h:note xmlns:h="http://www.111/"/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetNamespace004
* @tc.desc: Writes the namespace of the current element tag.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetNamespace004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("note1");
thatSer.startElement("note2");
thatSer.endElement();
thatSer.endElement();
var result = '<h:note1 xmlns:h="http://www.w3.org/TR/html4/">\r\n <h:note2/>\r\n</h:note1>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetNamespace005
* @tc.desc: Writes the namespace of the current element tag.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetNamespace005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setNamespace("h", "http://www.w3.org/TR/html4/");
thatSer.startElement("note1");
thatSer.startElement("note2");
thatSer.endElement();
thatSer.endElement();
var result = '<h:note1 xmlns:h="http://www.w3.org/TR/html4/">\r\n <h:note2/>\r\n</h:note1>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCommnet001
* @tc.desc: Writes the commnet.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCommnet001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setCommnet("Hi!");
thatSer.endElement();
var result = '<note>\r\n <!--Hi!-->\r\n</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCommnet002
* @tc.desc: Writes the commnet.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCommnet002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setCommnet("Hello, World!");
thatSer.endElement();
var result = '<note>\r\n <!--Hello, World!-->\r\n</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCommnet003
* @tc.desc: Writes the commnet.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCommnet003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCommnet("Hello, World!");
var result = '<!--Hello, World!-->';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCommnet004
* @tc.desc: Writes the commnet.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCommnet004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCommnet("Hello, World!");
var result = '<!--Hello, World!-->';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCommnet005
* @tc.desc: Writes the commnet.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCommnet005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCommnet("Hello, World!");
thatSer.startElement("note");
thatSer.endElement();
var result = '<!--Hello, World!-->\r\n<note/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDocType001
* @tc.desc: Writes the DOCTYPE.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDocType001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDocType('root SYSTEM');
var result = '<!DOCTYPE root SYSTEM>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDocType002
* @tc.desc: Writes the DOCTYPE.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDocType002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
var result = '<!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDocType003
* @tc.desc: Writes the DOCTYPE.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDocType003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.endElement();
thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
var result = '<note/>\r\n<!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDocType004
* @tc.desc: Writes the DOCTYPE.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDocType004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
thatSer.startElement("note");
thatSer.endElement();
var result = '<!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">\r\n<note/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetDocType005
* @tc.desc: Writes the DOCTYPE.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetDocType005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"');
thatSer.endElement();
var result = '<note>\r\n <!DOCTYPE root SYSTEM "http://www.test.org/test.dtd">\r\n</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCData001
* @tc.desc: Writes the CDATA.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCData001', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCData('root SYSTEM')
var result = '<![CDATA[root SYSTEM]]>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCData002
* @tc.desc: Writes the CDATA.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCData002', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"')
var result = '<![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCData003
* @tc.desc: Writes the CDATA.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCData003', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.endElement();
thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"')
var result = '<note/>\r\n<![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCData004
* @tc.desc: Writes the CDATA.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCData004', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"')
thatSer.startElement("note");
thatSer.endElement();
var result = '<![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>\r\n<note/>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testSetCData005
* @tc.desc: Writes the CDATA.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testSetCData005', 0, function () {
const myMAX = 2048;
var arrayBuffer = new ArrayBuffer(m_MAX);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"')
thatSer.endElement();
var result = '<note>\r\n <![CDATA[root SYSTEM "http://www.test.org/test.dtd"]]>\r\n</note>';
var view = new Uint8Array(arrayBuffer);
var view1 = "";
for (var i = 0; i < result.length; ++i) {
view1 = view1 + String.fromCodePoint(view[i]);
}
expect(view1).assertEqual(result);
})
/**
* @tc.name: testParse001
* @tc.desc: Starts parsing the XML file.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testParse001', 0, function () {
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
'<note importance="high" logged="true">' +
' <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
' <!--Hello, World!-->' +
' <company>John &amp; Hans</company>' +
' <title>Happy</title>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
' <?go there?>' +
' <a><b/></a>' +
' <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
' <h:tr>' +
' <h:td>Apples</h:td>' +
' <h:td>Bananas</h:td>' +
' </h:tr>' +
' </h:table>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8');
var arr = {};
var i = 0;
function func3(key, info){
arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() +
info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() +
info.isEmptyElementTag()+ info.isWhitespace();
i++;
return true;
}
var options = {supportDoctype:true, ignoreNameSpace:false, tokenValueCallbackFunction:func3}
that.parse(options);
var str = '';
for(var j = 0; j < i; ++j) {
str = str + arr[j];
}
var str1 = 'key:00110falsetruekey:702220 note [\n<!ENTITY foo "baa">]falsefalsekey:216022notefalsefalsekey:' +
'1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 ' +
'falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 John ' +
'falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 ' +
'falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 ' +
'falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 ' +
'falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 ' +
'falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 ' +
'falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:' +
'2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223870table ' +
'http://www.w3.org/TR/html4/hfalsefalsekey:10224670 ' +
'falsetruekey:2325270tr http://www.w3.org/TR/html4/hfalsetruekey:10326470 ' +
'falsetruekey:2427070td http://www.w3.org/TR/html4/hfalsetruekey:4427670 Applesfalsefalsekey:3428370td ' +
'http://www.w3.org/TR/html4/hfalsetruekey:10329570 ' +
'falsetruekey:2430170td http://www.w3.org/TR/html4/hfalsetruekey:4430870 Bananasfalsefalsekey:3431570td ' +
'http://www.w3.org/TR/html4/hfalsetruekey:10332370 falsetruekey:3333070tr ' +
'http://www.w3.org/TR/html4/hfalsetruekey:10233470 falsetruekey:3234470table ' +
'http://www.w3.org/TR/html4/hfalsetruekey:3135170notefalsetruekey:10351130falsetrue';
expect(str).assertEqual(str1);
})
/**
* @tc.name: testParse002
* @tc.desc: Starts parsing the XML file.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testParse002', 0, function () {
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
'<note importance="high" logged="true">' +
' <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
' <!--Hello, World!-->' +
' <company>John &amp; Hans</company>' +
' <title>Happy</title>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
' <?go there?>' +
' <a><b/></a>' +
' <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
' <h:tr>' +
' <h:td>Apples</h:td>' +
' <h:td>Bananas</h:td>' +
' </h:tr>' +
' </h:table>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer);
var arr = {};
var i = 0;
function func3(key, info){
arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() +
info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() +
info.isEmptyElementTag()+ info.isWhitespace();
i++;
return true;
}
var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func3}
that.parse(options);
var str = '';
for(var j = 0; j < i; ++j) {
str = str + arr[j];
}
var str1 = 'key:00110falsetruekey:702220 note [\n<!ENTITY foo "baa">]falsefalsekey:216022notefalsefalsekey:' +
'1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 ' +
'falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 ' +
'John falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070' +
' falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 ' +
'falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 ' +
'falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 ' +
'falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 ' +
'falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:' +
'2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:' +
'2223871h:tablefalsefalsekey:10224670 falsetruekey:2325270h:trfalsetruekey:10326470 ' +
'falsetruekey:2427070h:tdfalsetruekey:4427670 Applesfalsefalsekey:3428370h:tdfalsetruekey:' +
'10329570 falsetruekey:2430170h:tdfalsetruekey:4430870 Bananasfalsefalsekey:3431570h:' +
'tdfalsetruekey:10332370 falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:' +
'tablefalsetruekey:3135170notefalsetruekey:10351130falsetrue'
expect(str).assertEqual(str1)
})
/**
* @tc.name: testParse003
* @tc.desc: Starts parsing the XML file.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testParse003', 0, function () {
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
'<note importance="high" logged="true">' +
' <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
' <!--Hello, World!-->' +
' <company>John &amp; Hans</company>' +
' <title>Happy</title>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
' <?go there?>' +
' <a><b/></a>' +
' <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
' <h:tr>' +
' <h:td>Apples</h:td>' +
' <h:td>Bananas</h:td>' +
' </h:tr>' +
' </h:table>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8');
var arr = {};
var i = 0;
function func3(key, info){
arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() +
info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() +
info.isEmptyElementTag()+ info.isWhitespace();
i++;
return true;
}
var options = {supportDoctype:false, ignoreNameSpace:true, tokenValueCallbackFunction:func3}
that.parse(options);
var str = '';
for(var j = 0; j < i; ++j) {
str = str + arr[j];
}
var str1 = 'key:00110falsetruekey:216022notefalsefalsekey:1016420 falsetruekey:51470\r\nfuncrion ' +
'matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 falsetruekey:612870Hello, World!falsetruekey' +
':1013270 falsetruekey:224170companyfalsetruekey:424670 John falsefalsekey:925170amp;amp;falsetruekey' +
':425670Hansfalsefalsekey:326670companyfalsetruekey:1017070 falsetruekey:227770titlefalsetruekey:428270' +
' Happyfalsefalsekey:329070titlefalsetruekey:1019470 falsetruekey:2210170titlefalsetruekey:4210670 ' +
'Happyfalsefalsekey:3211470titlefalsetruekey:10111870 falsetruekey:2212470todofalsetruekey:4212870 ' +
'Workfalsefalsekey:3213570todofalsetruekey:10113970 falsetruekey:2214570todofalsetruekey:4214970 ' +
'Playfalsefalsekey:3215670todofalsetruekey:10116070 falsetruekey:8117270go therefalsetruekey' +
':10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey:3318370bfalsetruekey' +
':3218770afalsetruekey:10119170 falsetruekey:2223871h:tablefalsefalsekey:10224670 ' +
'falsetruekey:2325270h:trfalsetruekey:10326470falsetruekey:' +
'2427070h:tdfalsetruekey:4427670 Applesfalsefalsekey:3428370h:tdfalsetruekey:10329570 ' +
'falsetruekey:2430170h:tdfalsetruekey:4430870 Bananasfalsefalsekey:3431570h:tdfalsetruekey:10332370 ' +
' falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:tablefalsetruekey:' +
'3135170notefalsetruekey:10351130falsetrue'
expect(str).assertEqual(str1);
})
/**
* @tc.name: testParse004
* @tc.desc: Starts parsing the XML file.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testParse004', 0, function () {
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
'<note importance="high" logged="true">' +
' <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
' <!--Hello, World!-->' +
' <company>John &amp; Hans</company>' +
' <title>Happy</title>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
' <?go there?>' +
' <a><b/></a>' +
' <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
' <h:tr>' +
' <h:td>Apples</h:td>' +
' <h:td>Bananas</h:td>' +
' </h:tr>' +
' </h:table>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8');
var str = '';
function func2(name, value){
str += name+':'+value;
return true;
}
var options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction:func2}
that.parse(options);
var str1= 'importance: highxmlns:h: http://www.w3.org/TR/html4/'
expect(str).assertEqual(str1);
})
/**
* @tc.name: testParse005
* @tc.desc: Starts parsing the XML file.
* @tc.require: AR000GGRB8
* @tc.author: lihucheng
*/
it('testParse005', 0, function () {
var strXml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<!DOCTYPE note [\n<!ENTITY foo "baa">]>' +
'<note importance="high" logged="true">' +
' <![CDATA[\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\n]]>' +
' <!--Hello, World!-->' +
' <company>John &amp; Hans</company>' +
' <title>Happy</title>' +
' <title>Happy</title>' +
' <todo>Work</todo>' +
' <todo>Play</todo>' +
' <?go there?>' +
' <a><b/></a>' +
' <h:table xmlns:h="http://www.w3.org/TR/html4/">' +
' <h:tr>' +
' <h:td>Apples</h:td>' +
' <h:td>Bananas</h:td>' +
' </h:tr>' +
' </h:table>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
bufView[i] = strXml.charCodeAt(i);
}
var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8');
var str1 = '';
function func1(name, value){
str1 += name+':'+value;
return true;
}
var options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func1}
that.parse(options);
var str3 = 'note:company:title:title:todo:todo:a:b:h:table:h:tr:h:td:h:td:'
expect(str1).assertEqual(str3)
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册