Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
89c83dae
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看板
提交
89c83dae
编写于
1月 22, 2022
作者:
Y
y00314596
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cases by yangqing3@huawei.com
Signed-off-by:
N
y00314596
<
yangqing3@huawei.com
>
上级
71fa5a8e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
413 addition
and
1 deletion
+413
-1
global/i18n_standard/intljs/src/main/js/default/test/Lang.test.js
...18n_standard/intljs/src/main/js/default/test/Lang.test.js
+411
-0
global/i18n_standard/intljs/src/main/js/default/test/List.test.js
...18n_standard/intljs/src/main/js/default/test/List.test.js
+2
-1
未找到文件。
global/i18n_standard/intljs/src/main/js/default/test/Lang.test.js
0 → 100755
浏览文件 @
89c83dae
/*
* 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
I18n
from
'
@ohos.i18n
'
import
Intl
from
'
@ohos.intl
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
LangTest
'
,
function
()
{
console
.
log
(
'
*************start LangTest*************
'
);
let
initPreferredLang
=
I18n
.
getPreferredLanguageList
();
let
initLen
=
initPreferredLang
.
length
;
function
getCurrentPreferredLang
(){
let
value
=
I18n
.
getPreferredLanguageList
();
return
value
;
}
function
isContainLang
(
langList
,
lang
){
let
len
=
langList
.
length
;
for
(
let
i
=
0
;
i
<
len
;
i
++
){
if
(
langList
[
i
]
==
lang
){
return
true
}
}
return
false
}
function
clearLang
(
langList
){
let
len
=
langList
.
length
;
while
(
len
>
0
){
console
.
log
(
'
i18n_test_preferredlanguage_clearLang
'
+
len
);
let
par
=
len
-
1
;
console
.
log
(
'
i18n_test_preferredlanguage_clearLang
'
+
par
);
let
value
=
I18n
.
removePreferredLanguage
(
par
);
console
.
log
(
'
i18n_test_preferredlanguage_clearLang
'
+
value
);
len
--
;
}
console
.
log
(
'
i18n_test_preferredlanguage_clearLang
'
+
I18n
.
getPreferredLanguageList
());
}
function
restoreLang
(){
for
(
let
j
=
0
;
j
<
initLen
;
j
++
){
let
value
=
I18n
.
addPreferredLanguage
(
initPreferredLang
[
j
]);
console
.
log
(
'
i18n_test_preferredlanguage_restoreLang
'
+
value
);
expect
(
value
).
assertTrue
();
}
}
beforeEach
(
function
(){
console
.
log
(
'
i18n_test_preferredlanguage_beforeEach
'
+
getCurrentPreferredLang
());
})
afterEach
(
function
(){
let
currLang
=
getCurrentPreferredLang
();
console
.
log
(
'
i18n_test_preferredlanguage_afterEach
'
+
currLang
);
clearLang
(
currLang
);
restoreLang
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_CLOCK_0100
* @tc.name test the is24HourClock interface
* @tc.desc check the value of is24HourClock method
*/
it
(
'
i18n_test_clock_0100
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_clock_0100
'
+
'
start
'
);
let
value
=
I18n
.
is24HourClock
();
console
.
log
(
'
i18n_test_clock_0100
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_CLOCK_0200
* @tc.name test the set24HourClock interface with false param
* @tc.desc check the value of set24HourClock method
*/
it
(
'
i18n_test_clock_0200
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_clock_0200
'
+
'
start
'
);
let
value
=
I18n
.
set24HourClock
(
false
);
console
.
log
(
'
i18n_test_clock_0200
'
+
value
);
expect
(
value
).
assertTrue
();
let
value2
=
I18n
.
is24HourClock
();
console
.
log
(
'
i18n_test_clock_0200
'
+
value2
);
expect
(
value2
).
assertFalse
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_CLOCK_0300
* @tc.name test the set24HourClock interface with true param
* @tc.desc check the value of set24HourClock method
*/
it
(
'
i18n_test_clock_0300
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_clock_0300
'
+
'
start
'
);
let
value
=
I18n
.
set24HourClock
(
true
);
console
.
log
(
'
i18n_test_clock_0300
'
+
value
);
expect
(
value
).
assertTrue
();
let
value2
=
I18n
.
is24HourClock
();
console
.
log
(
'
i18n_test_clock_0300
'
+
value2
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_CLOCK_0400
* @tc.name test the set24HourClock and datetime interface
* @tc.desc check the value of set24HourClock method
*/
it
(
'
i18n_test_clock_0400
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_clock_0400
'
+
'
start
'
);
let
value
=
I18n
.
set24HourClock
(
true
);
console
.
log
(
'
i18n_test_clock_0400
'
+
value
);
expect
(
value
).
assertTrue
();
let
date
=
new
Date
(
2021
,
11
,
17
,
3
,
24
,
0
);
let
datefmt
=
new
Intl
.
DateTimeFormat
(
'
en
'
);
console
.
log
(
'
i18n_test_clock_0400
'
+
datefmt
.
format
(
date
));
expect
(
datefmt
.
format
(
date
)).
assertEqual
(
'
12/17/21
'
);
expect
(
datefmt
.
resolvedOptions
().
hour12
).
assertFalse
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0100
* @tc.name test the getPreferredLanguageList interface
* @tc.desc check the value of getPreferredLanguageList method
*/
it
(
'
i18n_test_preferredlanguage_0100
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0100
'
+
'
start
'
);
let
value
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0100
'
+
value
);
expect
(
value
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0200
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0200
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0200
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
zh
'
);
console
.
log
(
'
i18n_test_preferredlanguage_0200
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0200
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0220
* @tc.name test the addPreferredLanguage interface with abc param
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0220
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0220
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
abc
'
);
console
.
log
(
'
i18n_test_preferredlanguage_0220
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0220
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0300
* @tc.name test the addPreferredLanguage interface with en and 0 param
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0300
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0300
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
en
'
,
0
);
console
.
log
(
'
i18n_test_preferredlanguage_0300
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0300
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0320
* @tc.name test the addPreferredLanguage interface with abc and index 0 param
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0320
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0320
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
abc
'
,
0
);
console
.
log
(
'
i18n_test_preferredlanguage_0320
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0320
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0340
* @tc.name test the addPreferredLanguage interface with en and index 1.5 param
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0340
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0340
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
en
'
,
1.5
);
console
.
log
(
'
i18n_test_preferredlanguage_0340
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0340
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0400
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0400
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0400
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
en
'
,
1
);
console
.
log
(
'
i18n_test_preferredlanguage_0400
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0400
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0500
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0500
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0500
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
ja
'
,
-
1
);
console
.
log
(
'
i18n_test_preferredlanguage_0500
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0500
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0600
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0600
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0600
'
+
'
start
'
);
let
value
=
I18n
.
addPreferredLanguage
(
'
ko
'
,
100
);
console
.
log
(
'
i18n_test_preferredlanguage_0600
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0600
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0700
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0700
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0700
'
+
'
start
'
);
let
value
=
I18n
.
removePreferredLanguage
(
0
);
console
.
log
(
'
i18n_test_preferredlanguage_0700
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0700
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0720
* @tc.name test the removePreferredLanguage interface with 0.5 param
* @tc.desc check the value of removePreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0720
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0720
'
+
'
start
'
);
let
value
=
I18n
.
removePreferredLanguage
(
0.5
);
console
.
log
(
'
i18n_test_preferredlanguage_0720
'
+
value
);
expect
(
value
).
assertFalse
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0720
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0800
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0800
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0800
'
+
'
start
'
);
let
value
=
I18n
.
removePreferredLanguage
(
-
1
);
console
.
log
(
'
i18n_test_preferredlanguage_0800
'
+
value
);
expect
(
value
).
assertTrue
();
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0800
'
+
list
);
expect
(
list
.
length
).
assertLarger
(
0
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0900
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0900
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0900
'
+
'
start
'
);
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0900
'
+
list
);
let
len
=
list
.
length
;
console
.
log
(
'
i18n_test_preferredlanguage_0900
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
let
parm
=
len
-
1
;
let
value
=
I18n
.
removePreferredLanguage
(
parm
);
console
.
log
(
'
i18n_test_preferredlanguage_0900
'
+
value
);
expect
(
value
).
assertTrue
();
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0920
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0920
'
,
0
,
function
()
{
console
.
log
(
'
i18n_test_preferredlanguage_0920
'
+
'
start
'
);
let
list
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0920
'
+
list
);
let
isContain
=
isContainLang
(
list
,
'
it
'
)
console
.
log
(
'
i18n_test_preferredlanguage_0920
'
+
isContain
);
let
len
=
list
.
length
;
console
.
log
(
'
i18n_test_preferredlanguage_0920
'
+
len
);
expect
(
len
).
assertLarger
(
0
);
if
(
!
isContain
)
{
let
value
=
I18n
.
addPreferredLanguage
(
'
it
'
);
console
.
log
(
'
i18n_test_preferredlanguage_0920
'
+
value
);
expect
(
value
).
assertTrue
();
}
let
list2
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0920
'
+
list2
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_0940
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
it
(
'
i18n_test_preferredlanguage_0940
'
,
0
,
function
()
{
let
value
=
I18n
.
addPreferredLanguage
(
'
it
'
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
value
);
expect
(
value
).
assertTrue
();
let
value2
=
I18n
.
addPreferredLanguage
(
'
ko
'
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
value2
);
expect
(
value2
).
assertTrue
();
let
value3
=
I18n
.
addPreferredLanguage
(
'
en
'
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
value3
);
expect
(
value3
).
assertTrue
();
let
list1
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
list1
);
let
value4
=
I18n
.
addPreferredLanguage
(
'
it
'
,
3
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
value4
);
expect
(
value4
).
assertTrue
();
let
value5
=
I18n
.
addPreferredLanguage
(
'
ko
'
,
2
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
value5
);
expect
(
value5
).
assertTrue
();
let
value6
=
I18n
.
addPreferredLanguage
(
'
en
'
,
1
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
value6
);
expect
(
value6
).
assertTrue
();
let
list2
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
list2
);
expect
(
list2
[
1
]).
assertEqual
(
'
en
'
);
expect
(
list2
[
2
]).
assertEqual
(
'
ko
'
);
expect
(
list2
[
3
]).
assertEqual
(
'
it
'
);
let
remove1
=
I18n
.
removePreferredLanguage
(
1
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
remove1
);
expect
(
remove1
).
assertTrue
();
let
list3
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
list3
);
expect
(
list3
[
1
]).
assertEqual
(
'
ko
'
);
expect
(
list3
[
2
]).
assertEqual
(
'
it
'
);
let
remove2
=
I18n
.
removePreferredLanguage
(
1
);
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
remove2
);
expect
(
remove2
).
assertTrue
();
let
list4
=
I18n
.
getPreferredLanguageList
();
console
.
log
(
'
i18n_test_preferredlanguage_0940
'
+
list4
);
expect
(
list4
[
1
]).
assertEqual
(
'
it
'
);
})
/* *
* @tc.number SUB_GLOBAL_I18N_JS_PREFERREDLANGUAGE_1000
* @tc.name test the addPreferredLanguage interface
* @tc.desc check the value of addPreferredLanguage method
*/
// it('i18n_test_preferredlanguage_1000', 0, function () {
// console.log('i18n_test_preferredlanguage_1000 ' + 'start');
// let value = I18n.getFirstPreferredLanguage();
// console.log('i18n_test_preferredlanguage_1000 ' + value);
// expect(value).assertEqual('en');
// let list = I18n.getPreferredLanguageList();
// console.log('i18n_test_preferredlanguage_1000 ' + list);
// expect(list.length).assertLarger(0);
// })
console
.
log
(
'
*************end LangTest*************
'
);
})
\ No newline at end of file
global/i18n_standard/intljs/src/main/js/default/test/List.test.js
浏览文件 @
89c83dae
...
@@ -13,4 +13,5 @@
...
@@ -13,4 +13,5 @@
* limitations under the License.
* limitations under the License.
*/
*/
require
(
'
./I18n.test.js
'
)
require
(
'
./I18n.test.js
'
)
require
(
'
./Intl.test.js
'
)
require
(
'
./Intl.test.js
'
)
\ No newline at end of file
require
(
'
./Lang.test.js
'
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录