Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
45361ea5
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
45361ea5
编写于
2月 14, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1889 新增窗口JS 接口XTS用例
Merge pull request !1889 from 夏易凡/xts2022021211
上级
b57f5b09
6e30a941
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
1005 addition
and
1 deletion
+1005
-1
graphic/windowstandard/Test.json
graphic/windowstandard/Test.json
+1
-1
graphic/windowstandard/src/main/js/default/test/List.test.js
graphic/windowstandard/src/main/js/default/test/List.test.js
+2
-0
graphic/windowstandard/src/main/js/default/test/display.screenshot.api.js
...andard/src/main/js/default/test/display.screenshot.api.js
+438
-0
graphic/windowstandard/src/main/js/default/test/window.api.part1.js
...ndowstandard/src/main/js/default/test/window.api.part1.js
+564
-0
未找到文件。
graphic/windowstandard/Test.json
浏览文件 @
45361ea5
...
...
@@ -2,7 +2,7 @@
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
12
0000"
,
"test-timeout"
:
"
60
0000"
,
"package"
:
"com.test.window"
,
"shell-timeout"
:
"60000"
},
...
...
graphic/windowstandard/src/main/js/default/test/List.test.js
浏览文件 @
45361ea5
...
...
@@ -12,5 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require
(
'
./window.api.part1.js
'
)
require
(
'
./window.test.js
'
)
require
(
'
./window.parameter.js
'
)
require
(
'
./display.screenshot.api.js
'
)
graphic/windowstandard/src/main/js/default/test/display.screenshot.api.js
0 → 100644
浏览文件 @
45361ea5
/*
* * Copyright (C) 2022 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
app
from
'
@system.app
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
display
from
'
@ohos.display
'
import
screenshot
from
'
@ohos.screenshot
'
import
image
from
'
@ohos.multimedia.image
'
describe
(
'
screenshot_test
'
,
function
()
{
const
TRUE_FLAG
=
true
;
const
FALSE_FLAG
=
false
;
beforeAll
(
function
()
{
})
beforeEach
(
function
()
{
})
afterEach
(
function
()
{
})
afterAll
(
function
()
{
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_001
* @tc.name Test screenShotSaveTest1
* @tc.desc Set the screenshot area to be larger than the screen width and height
*/
it
(
'
screenShotSaveTest1
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest1 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest1 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
10000
,
height
:
10000
,
},
imageSize
:
{
width
:
300
,
height
:
300
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest1 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest1 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest1 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_002
* @tc.name Test screenShotSaveTest2
* @tc.desc Set the size of the screenshot area and the generated image to be larger than the screen width and height
*/
it
(
'
screenShotSaveTest2
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest2 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest2 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
10000
,
height
:
10000
,
},
imageSize
:
{
width
:
3000
,
height
:
3000
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest2 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest2 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest2 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
()
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_003
* @tc.name Test screenShotSaveTest3
* @tc.desc Set the screenshot area and the size of the generated image to be smaller than the screen width and height
*/
it
(
'
screenShotSaveTest3
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest3 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest3 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
100
,
height
:
100
,
},
imageSize
:
{
width
:
300
,
height
:
300
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest3 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest3 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest3 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_004
* @tc.name Test screenShotSaveTest4
* @tc.desc Set the size of the generated image to be smaller than the screen width and height
*/
it
(
'
screenShotSaveTest4
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest4 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest4 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
100
,
height
:
100
,
},
imageSize
:
{
width
:
3000
,
height
:
3000
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest4 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
()
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest4 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest4 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_005
* @tc.name Test screenShotSaveTest5
* @tc.desc Set the screenshot area to a negative value
*/
it
(
'
screenShotSaveTest5
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest5 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest5 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
-
50
,
top
:
-
50
,
width
:
-
100
,
height
:
-
100
,
},
imageSize
:
{
width
:
300
,
height
:
300
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest5 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest5 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest5 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_006
* @tc.name Test screenShotSaveTest6
* @tc.desc Set the screenshot area to 0
*/
it
(
'
screenShotSaveTest6
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest6 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest6 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
0
,
height
:
0
,
},
imageSize
:
{
width
:
300
,
height
:
300
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest6 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
()
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest6 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
()
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest6 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_007
* @tc.name Test screenShotSaveTest7
* @tc.desc Set the generated image size to a negative value
*/
it
(
'
screenShotSaveTest7
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest7 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest7 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
100
,
height
:
100
,
},
imageSize
:
{
width
:
-
300
,
height
:
-
300
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest7 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest7 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest7 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_008
* @tc.name Test screenShotSaveTest8
* @tc.desc Set the generated image size to 0
*/
it
(
'
screenShotSaveTest8
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest8 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest8 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
100
,
height
:
100
,
},
imageSize
:
{
width
:
0
,
height
:
0
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest8 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
()
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest8 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest8 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_009
* @tc.name Test screenShotSaveTest9
* @tc.desc Set the screenshot area and the size of the generated image to be equal to the screen width and height
*/
it
(
'
screenShotSaveTest9
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest9 begin
'
);
display
.
getDefaultDisplay
().
then
((
dsp
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest9 display.getDefaultDisplay success, dsp :
'
+
JSON
.
stringify
(
dsp
));
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
dsp
.
width
,
height
:
dsp
.
height
},
imageSize
:
{
width
:
dsp
.
width
,
height
:
dsp
.
height
},
displayId
:
dsp
.
id
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest9 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
()
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest9 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest9 display.getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_010
* @tc.name Test screenShotSaveTest10
* @tc.desc Take a screenshot of a screen that doesn't exist
*/
it
(
'
screenShotSaveTest10
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest10 begin
'
);
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
100
,
height
:
100
,
},
imageSize
:
{
width
:
300
,
height
:
300
},
displayId
:
null
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest10 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
()
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest10 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_SCREENSHOT_SAVE_JSAPI_011
* @tc.name Test screenShotSaveTest11
* @tc.desc Test screenshot.save API function test11.
*/
it
(
'
screenShotSaveTest11
'
,
0
,
function
(
done
)
{
console
.
log
(
'
jsunittest screenShotSaveTest11 begin
'
);
var
screenshotOptions
=
{
screenRect
:
{
left
:
0
,
top
:
0
,
width
:
100
,
height
:
100
,
},
imageSize
:
{
width
:
300
,
height
:
300
},
displayId
:
1000
};
screenshot
.
save
(
screenshotOptions
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest11 screenshot.save success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest screenShotSaveTest11 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
})
})
graphic/windowstandard/src/main/js/default/test/window.api.part1.js
0 → 100644
浏览文件 @
45361ea5
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录