Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
f304dbe4
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看板
未验证
提交
f304dbe4
编写于
6月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3657 release分支新增用例
Merge pull request !3657 from qigongming/release_0621
上级
8c29313a
4f76b5eb
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
337 addition
and
0 deletion
+337
-0
startup/startup_standard/deviceinfo/src/main/js/default/test/List.test.js
...standard/deviceinfo/src/main/js/default/test/List.test.js
+1
-0
startup/startup_standard/deviceinfo/src/main/js/default/test/SystemDeviceApi.test.js
...viceinfo/src/main/js/default/test/SystemDeviceApi.test.js
+336
-0
未找到文件。
startup/startup_standard/deviceinfo/src/main/js/default/test/List.test.js
浏览文件 @
f304dbe4
...
...
@@ -15,3 +15,4 @@
require
(
'
./DeviceInfoJsUnit.test.js
'
)
require
(
'
./ParametersJsUnit.test.js
'
)
require
(
'
./SystemDeviceApi.test.js
'
)
\ No newline at end of file
startup/startup_standard/deviceinfo/src/main/js/default/test/SystemDeviceApi.test.js
0 → 100644
浏览文件 @
f304dbe4
/*
* 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.
*/
// @ts-nocheck
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
;
import
device
from
'
@system.device
'
;
import
deviceInfo
from
'
@ohos.deviceInfo
'
;
describe
(
'
SystemDeviceTest
'
,
function
()
{
let
brandInfo
=
''
;
let
manufactureInfo
=
''
;
let
deviceModelInfo
=
''
;
let
deviceProductInfo
=
''
;
let
deviceTypeInfo
=
''
;
let
languageInfo
=
''
;
let
regionInfo
=
''
;
let
screenShapeInfo
=
''
;
let
apiVersionInfo
=
0
;
let
windowWidthInfo
=
0
;
let
windowHeightInfo
=
0
;
let
screenDensityInfo
=
0
;
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll: Prerequisites at the test suite level,
\
which are executed before the test suite is executed.
'
);
device
.
getInfo
({
success
:
function
(
data
)
{
console
.
log
(
'
getInfo success:
'
+
JSON
.
stringify
(
data
));
brandInfo
=
data
.
brand
;
manufactureInfo
=
data
.
manufacturer
;
deviceModelInfo
=
data
.
model
;
deviceProductInfo
=
data
.
product
;
apiVersionInfo
=
data
.
apiVersion
;
deviceTypeInfo
=
data
.
deviceType
;
languageInfo
=
data
.
language
;
regionInfo
=
data
.
region
;
windowWidthInfo
=
data
.
windowWidth
;
windowHeightInfo
=
data
.
windowHeight
;
screenDensityInfo
=
data
.
screenDensity
;
screenShapeInfo
=
data
.
screenShape
;
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
getInfo failed.Error code:
'
+
code
+
'
;Error information:
'
+
JSON
.
stringify
(
data
));
brandInfo
=
data
.
brand
;
manufactureInfo
=
data
.
manufacturer
;
deviceModelInfo
=
data
.
model
;
deviceProductInfo
=
data
.
product
;
apiVersionInfo
=
data
.
apiVersion
;
deviceTypeInfo
=
data
.
deviceType
;
languageInfo
=
data
.
language
;
regionInfo
=
data
.
region
;
windowWidthInfo
=
data
.
windowWidth
;
windowHeightInfo
=
data
.
windowHeight
;
screenDensityInfo
=
data
.
screenDensity
;
screenShapeInfo
=
data
.
screenShape
;
},
complete
:
function
()
{
console
.
log
(
'
getInfo complete
'
);
}
});
})
beforeEach
(
function
()
{
console
.
info
(
'
beforeEach: Prerequisites at the test case level,
\
which are executed before each test case is executed.
'
);
})
afterEach
(
function
()
{
console
.
info
(
'
afterEach: Test case-level clearance conditions,
\
which are executed after each test case is executed.
'
);
})
afterAll
(
function
()
{
console
.
info
(
'
afterAll: Test suite-level cleanup condition,
\
which is executed after the test suite is executed
'
);
})
console
.
info
(
'
start################################start
'
);
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_001
* @tc.name testDeviceBrand01
* @tc.desc Get the device brand represented by a string and the return value is not null.
*/
it
(
'
testDeviceBrand01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceBrand01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo brand is :
'
+
brandInfo
);
expect
(
brandInfo
).
assertInstanceOf
(
'
String
'
);
if
(
brandInfo
!=
""
&&
brandInfo
!=
null
&&
brandInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
let
str
=
/^
[
A-Za-z
]
+$/g
;
let
arr
=
brandInfo
.
match
(
str
);
let
bufferstr
=
arr
.
join
(
''
);
console
.
info
(
'
the value of the bufferstr is :
'
+
bufferstr
);
expect
(
brandInfo
).
assertEqual
(
bufferstr
);
console
.
info
(
'
testDeviceBrand01 :end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_002
* @tc.name testDeviceManufacture01
* @tc.desc Get the manufacture name represented by a string and the return value is not null.
*/
it
(
'
testDeviceManufacture01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceManufacture01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo manufacture is :
'
+
manufactureInfo
);
expect
(
manufactureInfo
).
assertInstanceOf
(
'
String
'
);
if
(
manufactureInfo
!=
""
&&
manufactureInfo
!=
null
&&
manufactureInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
let
str
=
/^
[
A-Za-z
]
+$/g
;
let
arr
=
manufactureInfo
.
match
(
str
);
let
bufferstr
=
arr
.
join
(
''
);
console
.
info
(
'
the value of the bufferstr is :
'
+
bufferstr
);
expect
(
manufactureInfo
).
assertEqual
(
bufferstr
);
console
.
info
(
'
testDeviceManufacture01 :end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_003
* @tc.name testDeviceModel01
* @tc.desc Get the internal software sub-model represented by a string and the return value is not null.
*/
it
(
'
testDeviceModel01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceModel01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo model is :
'
+
deviceModelInfo
);
expect
(
deviceModelInfo
).
assertInstanceOf
(
'
String
'
);
if
(
deviceModelInfo
!=
""
&&
deviceModelInfo
!=
null
&&
deviceModelInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
console
.
info
(
'
testDeviceModel01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_004
* @tc.name testDeviceProduct01
* @tc.desc Get the product represented by a string and the return value is not null.
*/
it
(
'
testDeviceProduct01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceProduct01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo product is :
'
+
deviceProductInfo
);
expect
(
deviceProductInfo
).
assertInstanceOf
(
'
String
'
);
if
(
deviceProductInfo
!=
""
&&
deviceProductInfo
!=
null
&&
deviceProductInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
console
.
info
(
'
testDeviceProduct01 :end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_005
* @tc.name testDeviceApiVersion01
* @tc.desc Get the API version number, which return value type is number.
*/
it
(
'
testDeviceApiVersion01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceApiVersion01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo sdkApiVersion is :
'
+
apiVersionInfo
);
expect
(
apiVersionInfo
).
assertInstanceOf
(
'
Number
'
);
if
(
apiVersionInfo
>=
0
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
console
.
info
(
'
testDeviceApiVersion01 :end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_006
* @tc.name testDeviceType01
* @tc.desc Get a string representing the device type and the return value is not null.
*/
it
(
'
testDeviceType01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceType01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo deviceType is :
'
+
deviceTypeInfo
);
expect
(
deviceTypeInfo
).
assertInstanceOf
(
'
String
'
);
if
(
deviceTypeInfo
!=
""
&&
deviceTypeInfo
!=
null
&&
deviceTypeInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
()
console
.
info
(
'
testDeviceType01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_007
* @tc.name testDeviceLanguage01
* @tc.desc Get a string representing the device language and the return value is not null.
*/
it
(
'
testDeviceLanguage01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceLanguage01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo language is :
'
+
languageInfo
);
expect
(
languageInfo
).
assertInstanceOf
(
'
String
'
);
if
(
languageInfo
!=
""
&&
languageInfo
!=
null
&&
languageInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
()
console
.
info
(
'
testDeviceLanguage01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_008
* @tc.name testDeviceRegion01
* @tc.desc Get a string representing the device region and the return value is not null.
*/
it
(
'
testDeviceRegion01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceRegion01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo region is :
'
+
regionInfo
);
expect
(
regionInfo
).
assertInstanceOf
(
'
String
'
);
if
(
regionInfo
!=
""
&&
regionInfo
!=
null
&&
regionInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
()
console
.
info
(
'
testDeviceRegion01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_009
* @tc.name testDeviceWindowWidth01
* @tc.desc Get a number representing the device window width and return value is greater than 0.
*/
it
(
'
testDeviceWindowWidth01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceWindowWidth01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo window width is :
'
+
windowWidthInfo
);
expect
(
windowWidthInfo
).
assertInstanceOf
(
'
Number
'
);
if
(
windowWidthInfo
>=
0
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
console
.
info
(
'
testDeviceWindowWidth01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_010
* @tc.name testDeviceWindowHeight01
* @tc.desc Get a number representing the device window height and return value is greater than 0.
*/
it
(
'
testDeviceWindowHeight01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceWindowHeight01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo window height is :
'
+
windowHeightInfo
);
expect
(
windowHeightInfo
).
assertInstanceOf
(
'
Number
'
);
if
(
windowHeightInfo
>=
0
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
console
.
info
(
'
testDeviceWindowHeight01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_011
* @tc.name testDeviceScreenDensity01
* @tc.desc Get a number representing the screen density and return value is greater than 0.
*/
it
(
'
testDeviceScreenDensity01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceScreenDensity01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo screen density is :
'
+
screenDensityInfo
);
expect
(
screenDensityInfo
).
assertInstanceOf
(
'
Number
'
);
if
(
screenDensityInfo
>=
0
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
();
console
.
info
(
'
testDeviceScreenDensity01 : end
'
);
})
/**
* @tc.number SUB_STARTUP_SYSTEM_DEVICE_012
* @tc.name testDeviceScreenShape01
* @tc.desc Get a string representing the device screen shape and the return value is not null.
*/
it
(
'
testDeviceScreenShape01
'
,
0
,
function
()
{
console
.
info
(
'
testDeviceScreenShape01 start
'
);
let
ret
=
false
;
console
.
info
(
'
the value of the deviceinfo screenShape is :
'
+
screenShapeInfo
);
expect
(
screenShapeInfo
).
assertInstanceOf
(
'
String
'
);
if
(
screenShapeInfo
!=
""
&&
screenShapeInfo
!=
null
&&
screenShapeInfo
!=
undefined
)
{
ret
=
true
;
}
expect
(
ret
).
assertTrue
()
console
.
info
(
'
testDeviceScreenShape01 : end
'
);
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录