Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c57948b6
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c57948b6
编写于
7月 06, 2023
作者:
C
chenghuan
提交者:
tang
7月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add xts
Signed-off-by:
N
tang
<
tanglizhen2@huawei.com
>
Change-Id: Ib1bc070bc62104afcaea9f83097cfc476fd78ad6
上级
f489e7c3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
420 addition
and
7 deletion
+420
-7
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
+169
-2
arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets
...napi_test/entry/src/main/ets/test/NativeApiStringTest.ets
+251
-5
未找到文件。
arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp
浏览文件 @
c57948b6
...
...
@@ -669,6 +669,33 @@ static napi_value createAndGetStringUtf8(napi_env env, napi_callback_info info)
return
output
;
}
static
napi_value
StringUtf8OfLengthLeZero
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
1
,
"Expects one argument."
);
napi_valuetype
valueType
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valueType
));
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"Wrong type of argment. Expects a string."
);
char
buffer
[
128
];
size_t
bufferSize
=
128
;
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_utf8
(
env
,
args
[
0
],
buffer
,
bufferSize
,
&
copied
));
napi_value
output
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
buffer
,
-
1
,
&
output
));
return
output
;
}
static
napi_value
CreateAndGetStringUtf16
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
...
...
@@ -684,7 +711,7 @@ static napi_value CreateAndGetStringUtf16(napi_env env, napi_callback_info info)
char16_t
buffer
[
128
];
// 128: char16_t type of element size
size_t
bufferSize
=
128
;
// 128: char16_t type of element size
size_t
copied
=
0
;
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
bufferSize
,
&
copied
));
...
...
@@ -720,6 +747,52 @@ static napi_value StringUtf16OfCase(napi_env env, napi_callback_info info)
return
result
;
}
static
napi_value
StringUtf16OfLengthLeZero
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
1
,
"Expects one argument."
);
napi_valuetype
valueType
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valueType
));
NAPI_ASSERT
(
env
,
valueType
==
napi_string
,
"Expects a string."
);
char16_t
buffer
[
128
];
size_t
bufferSize
=
128
;
size_t
copied
=
0
;
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
bufferSize
,
&
copied
));
napi_value
result
;
NAPI_CALL
(
env
,
napi_create_string_utf16
(
env
,
buffer
,
-
1
,
&
result
));
return
result
;
}
static
napi_value
StringUtf16OfLengthEqOne
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
1
,
"Expects one argument."
);
char16_t
buffer
[
128
];
size_t
bufferSize
=
1
;
size_t
copied
=
1
;
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
bufferSize
,
&
copied
));
napi_value
value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
copied
,
&
value
));
return
value
;
}
static
const
napi_type_tag
typeTags
[
NUMBER_FIVE
]
=
{
{
0xdaf987b3cc62481a
,
0xb745b0497f299531
},
{
0xbb7936c374084d9b
,
0xa9548d0762eeedb9
},
...
...
@@ -825,7 +898,7 @@ static napi_value getTypedArrayInfo(napi_env env, napi_callback_info info)
size_t
byteOffset
=
-
1
;
NAPI_CALL
(
env
,
napi_get_typedarray_info
(
env
,
result
,
&
type
,
&
length
,
&
data
,
&
retArrayBuffer
,
&
byteOffset
));
NAPI_ASSERT
(
env
,
type
==
napi_int32_array
,
"napi_get_typedarray_info success 0"
);
NAPI_ASSERT
(
env
,
length
==
arrayBufferSize
,
"napi_get_typedarray_info success 1"
);
NAPI_ASSERT
(
env
,
length
==
typedArrayLength
,
"napi_get_typedarray_info success 1"
);
NAPI_ASSERT
(
env
,
data
==
arrayBufferPtr
,
"napi_get_dataview_info success 2"
);
bool
retIsArrayBuffer
=
false
;
...
...
@@ -1556,6 +1629,21 @@ static napi_value MyConstructor(napi_env env, napi_callback_info info)
return
thisVar
;
}
static
napi_value
NewTargetTest
(
napi_env
env
,
napi_callback_info
info
)
{
bool
isConstructor
=
true
;
napi_value
constructor
=
nullptr
;
napi_get_new_target
(
env
,
info
,
&
constructor
);
if
(
constructor
==
nullptr
)
{
napi_throw_error
(
env
,
nullptr
,
"is not new instance"
);
isConstructor
=
false
;
}
napi_value
value
;
NAPI_CALL
(
env
,
napi_get_boolean
(
env
,
isConstructor
,
&
value
));
return
value
;
}
static
napi_value
wrap
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
testClass
=
nullptr
;
...
...
@@ -1749,6 +1837,60 @@ static napi_value TestLatin1(napi_env env, napi_callback_info info)
return
output
;
}
static
napi_value
TestUtf8
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
1
,
"Expects one argument."
);
napi_valuetype
valuetype
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype
));
NAPI_ASSERT
(
env
,
valuetype
==
napi_string
,
"Wrong type of argment. Expects a string."
);
char
buffer
[
128
];
size_t
bufferSize
=
128
;
size_t
copied
;
NAPI_CALL
(
env
,
napi_get_value_string_utf8
(
env
,
args
[
0
],
buffer
,
bufferSize
,
&
copied
));
napi_value
output
;
NAPI_CALL
(
env
,
napi_create_string_utf8
(
env
,
buffer
,
copied
,
&
output
));
return
output
;
}
static
napi_value
TestUtf16
(
napi_env
env
,
napi_callback_info
info
)
{
size_t
argc
=
1
;
napi_value
args
[
1
];
NAPI_CALL
(
env
,
napi_get_cb_info
(
env
,
info
,
&
argc
,
args
,
nullptr
,
nullptr
));
NAPI_ASSERT
(
env
,
argc
==
1
,
"Expects one argument."
);
napi_valuetype
valuetype
;
NAPI_CALL
(
env
,
napi_typeof
(
env
,
args
[
0
],
&
valuetype
));
NAPI_ASSERT
(
env
,
valuetype
==
napi_string
,
"Wrong type of argment. Expects a string."
);
char16_t
buffer
[
128
];
size_t
bufferSize
=
128
;
size_t
copied
;
NAPI_CALL
(
env
,
napi_get_value_string_utf16
(
env
,
args
[
0
],
buffer
,
bufferSize
,
&
copied
));
napi_value
output
;
NAPI_CALL
(
env
,
napi_create_string_utf16
(
env
,
buffer
,
copied
,
&
output
));
return
output
;
}
// test the napi function
static
napi_value
napCreateArrayBuffer
(
napi_env
env
,
napi_callback_info
info
)
{
...
...
@@ -2028,6 +2170,24 @@ static napi_value napiCreateFunction(napi_env env, napi_callback_info info)
return
funcValue
;
}
static
napi_value
NapiCreateFunctionTwo
(
napi_env
env
,
napi_callback_info
info
)
{
napi_value
resultValue
=
nullptr
;
napi_status
status
=
napi_create_function
(
env
,
nullptr
,
NAPI_AUTO_LENGTH
,
SayHello
,
nullptr
,
&
resultValue
);
if
(
resultValue
==
nullptr
)
{
napi_throw_error
(
env
,
nullptr
,
"napi_create_function fail"
);
return
nullptr
;
}
if
(
status
!=
napi_ok
)
{
napi_throw_error
(
env
,
nullptr
,
"napi_create_function fail"
);
return
nullptr
;
}
napi_value
value
;
NAPI_CALL
(
env
,
napi_create_int32
(
env
,
1
,
&
value
));
return
resultValue
;
}
static
napi_value
napiRefthreadSafeFunction
(
napi_env
env
,
napi_callback_info
info
)
{
napi_threadsafe_function
tsFunc
=
nullptr
;
...
...
@@ -2706,6 +2866,8 @@ static napi_value Init(napi_env env, napi_value exports)
DECLARE_NAPI_FUNCTION
(
"resolveAndRejectDeferred"
,
resolveAndRejectDeferred
),
DECLARE_NAPI_FUNCTION
(
"isPromise"
,
isPromise
),
DECLARE_NAPI_FUNCTION
(
"TestLatin1"
,
TestLatin1
),
DECLARE_NAPI_FUNCTION
(
"TestUtf16"
,
TestUtf16
),
DECLARE_NAPI_FUNCTION
(
"TestUtf8"
,
TestUtf8
),
DECLARE_NAPI_FUNCTION
(
"runScript"
,
runScript
),
DECLARE_NAPI_FUNCTION
(
"getUvEventLoop"
,
getUvEventLoop
),
DECLARE_NAPI_FUNCTION
(
"napCreateArrayBuffer"
,
napCreateArrayBuffer
),
...
...
@@ -2729,6 +2891,7 @@ static napi_value Init(napi_env env, napi_value exports)
{
"testAsyncWork"
,
nullptr
,
testAsyncWork
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"testPromise"
,
nullptr
,
testPromise
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"napiCreateFunction"
,
nullptr
,
napiCreateFunction
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"NapiCreateFunctionTwo"
,
nullptr
,
NapiCreateFunctionTwo
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
DECLARE_NAPI_FUNCTION
(
"getGlobal"
,
getGlobal
),
DECLARE_NAPI_FUNCTION
(
"callFunction"
,
callFunction
),
DECLARE_NAPI_FUNCTION
(
"ThreadSafeTest"
,
ThreadSafeTest
),
...
...
@@ -2749,6 +2912,10 @@ static napi_value Init(napi_env env, napi_value exports)
DECLARE_NAPI_FUNCTION
(
"External"
,
External
),
DECLARE_NAPI_FUNCTION
(
"DetachTest"
,
DetachTest
),
DECLARE_NAPI_FUNCTION
(
"IsDetachedTest"
,
IsDetachedTest
),
DECLARE_NAPI_FUNCTION
(
"stringUtf16OfLengthLeZero"
,
StringUtf16OfLengthLeZero
),
DECLARE_NAPI_FUNCTION
(
"stringUtf16OfLengthEqOne"
,
StringUtf16OfLengthEqOne
),
DECLARE_NAPI_FUNCTION
(
"stringUtf8OfLengthLeZero"
,
StringUtf8OfLengthLeZero
),
DECLARE_NAPI_FUNCTION
(
"NewTargetTest"
,
NewTargetTest
),
};
NAPI_CALL
(
env
,
napi_define_properties
(
env
,
exports
,
sizeof
(
properties
)
/
sizeof
(
properties
[
0
]),
properties
));
...
...
arkui/ace_napi_test/entry/src/main/ets/test/NativeApiStringTest.ets
浏览文件 @
c57948b6
...
...
@@ -670,9 +670,10 @@ export default function nativeApiStringJsunit() {
*/
it
(
'aceNapiTest047'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest047 START'
);
value
=
napitest
.
coerceToString
(
123
);
let
number
=
123
;
value
=
napitest
.
coerceToString
(
number
);
console
.
info
(
'aceNapiTest047 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'123'
);
expect
(
value
)
.
assertEqual
(
number
.
toString
()
);
done
();
});
...
...
@@ -1135,9 +1136,9 @@ export default function nativeApiStringJsunit() {
expect
(
result
<
0
)
.
assertTrue
();
done
();
}
);
);
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0080
* @tc.name aceNapiTest080
...
...
@@ -1151,7 +1152,7 @@ export default function nativeApiStringJsunit() {
expect
(
value
===
1
)
.
assertTrue
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0081
* @tc.name aceNapiTest081
...
...
@@ -1365,7 +1366,10 @@ export default function nativeApiStringJsunit() {
console
.
info
(
'aceNapiTest094 START'
);
let
valueeEmpty
=
napitest
.
createAndGetStringUtf16
(
' '
);
console
.
info
(
'aceNapiTest094 testString result is: '
+
valueeEmpty
+
"--"
+
JSON
.
stringify
(
valueeEmpty
));
let
value
=
napitest
.
createAndGetStringUtf16
(
'中文'
);
console
.
info
(
'aceNapiTest094 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
valueeEmpty
)
.
assertEqual
(
' '
);
expect
(
value
)
.
assertEqual
(
'中文'
);
done
();
});
...
...
@@ -1423,5 +1427,247 @@ export default function nativeApiStringJsunit() {
expect
(
isTag4
)
.
assertFalse
();
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0097
* @tc.name aceNapiTest097
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest097'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest097 START'
);
value
=
napitest
.
coerceToString
(
'String Test'
);
console
.
info
(
'aceNapiTest097 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'String Test'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0098
* @tc.name aceNapiTest098
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest098'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest098 START'
);
value
=
napitest
.
coerceToString
(
false
);
console
.
info
(
'aceNapiTest098 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'false'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0099
* @tc.name aceNapiTest099
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest099'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest099 START'
);
value
=
napitest
.
coerceToString
(
undefined
);
console
.
info
(
'aceNapiTest099 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'undefined'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0100
* @tc.name aceNapiTest100
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest100'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest100 START'
);
value
=
napitest
.
coerceToString
(
null
);
console
.
info
(
'aceNapiTest100 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'null'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0101
* @tc.name aceNapiTest101
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest101'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest101 START'
);
value
=
napitest
.
coerceToString
(
true
);
console
.
info
(
'aceNapiTest101 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'true'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0102
* @tc.name aceNapiTest102
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest102'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest102 START'
);
let
bigintNum
=
napitest
.
napiCreateBigintInt64
();
value
=
napitest
.
coerceToString
(
bigintNum
);
console
.
info
(
'aceNapiTest102 testString result is: '
+
JSON
.
stringify
(
bigintNum
));
console
.
info
(
'aceNapiTest102 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
bigintNum
.
toString
());
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0103
* @tc.name aceNapiTest103
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest103'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest103 START'
);
const
arr
=
[
1
,
2
,
3
];
value
=
napitest
.
coerceToString
(
arr
);
console
.
info
(
'aceNapiTest103 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
arr
.
toString
());
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0104
* @tc.name aceNapiTest104
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest104'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest104 START'
);
let
value
=
napitest
.
stringUtf16OfLengthLeZero
(
'string utf16 test'
);
console
.
info
(
'aceNapiTest104 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'string utf16 test'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0105
* @tc.name aceNapiTest105
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest105'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest105 START'
);
let
copied
=
napitest
.
stringUtf16OfLengthEqOne
(
'string utf16 test1'
);
console
.
info
(
'aceNapiTest105 testString result is: '
+
copied
+
"--"
+
JSON
.
stringify
(
copied
));
expect
(
copied
)
.
assertEqual
(
0
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0106
* @tc.name aceNapiTest106
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest106'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest106 START'
);
let
value
=
napitest
.
stringUtf8OfLengthLeZero
(
'string utf8 test'
);
console
.
info
(
'aceNapiTest106 testString result is: '
+
value
+
"--"
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
'string utf8 test'
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0107
* @tc.name aceNapiTest107
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest107'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest107 START'
);
function
InputString
()
{
const
boolInput
=
true
;
napitest
.
TestUtf8
(
boolInput
);
}
expect
(
InputString
)
.
assertThrowError
(
"assertion (valuetype == napi_string) failed: Wrong type of argment. Expects a string."
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0108
* @tc.name aceNapiTest108
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest108'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest108 START'
);
function
InputString
()
{
const
numberInput
=
123
;
napitest
.
TestUtf16
(
numberInput
);
}
expect
(
InputString
)
.
assertThrowError
(
"assertion (valuetype == napi_string) failed: Wrong type of argment. Expects a string."
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0109
* @tc.name aceNapiTest109
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest109'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest109 START'
);
function
InputString
()
{
const
numberInput
=
123
;
napitest
.
TestLatin1
(
numberInput
);
}
expect
(
InputString
)
.
assertThrowError
(
"assertion (valuetype == napi_string) failed: Wrong type of argment. Expects a string."
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0110
* @tc.name aceNapiTest110
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest110'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest110 START'
);
let
func
=
napitest
.
NapiCreateFunctionTwo
();
value
=
func
();
console
.
info
(
'aceNapiTest111 testString result is: '
+
JSON
.
stringify
(
value
));
expect
(
value
)
.
assertEqual
(
666
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0111
* @tc.name aceNapiTest111
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest111'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest111 START'
);
function
testFunc
()
{
napitest
.
NewTargetTest
();
}
expect
(
testFunc
)
.
assertThrowError
(
"InstanceOf error when type of target is not Object"
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0112
* @tc.name aceNapiTest112
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest112'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest112 START'
);
function
testFunc
()
{
throw
new
Error
(
'error'
);
}
function
testCall
()
{
napitest
.
callFunction
(
testFunc
);
}
expect
(
testCall
)
.
assertThrowError
(
"error"
);
done
();
});
/**
* @tc.number SUB_ACE_BASIC_ETS_NAPI_0113
* @tc.name aceNapiTest113
* @tc.desc aceNapiEtsTest
*/
it
(
'aceNapiTest113'
,
0
,
async
function
(
done
)
{
console
.
info
(
'aceNapiTest113 START'
);
function
testFunc
()
{
return
'hello'
;
}
value
=
napitest
.
callFunction
(
testFunc
);
console
.
info
(
'aceNapiTest114 testString result is: '
+
JSON
.
stringify
(
value
));
expect
(
value
.
toString
()
===
'hello'
)
.
assertTrue
();
done
();
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录