Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
aa56b29c
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看板
提交
aa56b29c
编写于
3月 19, 2022
作者:
L
liziqiang
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the xts interface
Signed-off-by:
N
liziqiang
<
liziqiang8@huawei.com
>
上级
7d9ad525
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
1965 addition
and
2550 deletion
+1965
-2550
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
+1
-4
graphic/windowstandard/src/main/js/default/test/display.test.js
...c/windowstandard/src/main/js/default/test/display.test.js
+118
-0
graphic/windowstandard/src/main/js/default/test/screenshot.test.js
...indowstandard/src/main/js/default/test/screenshot.test.js
+1
-1
graphic/windowstandard/src/main/js/default/test/window.api.part1.js
...ndowstandard/src/main/js/default/test/window.api.part1.js
+0
-564
graphic/windowstandard/src/main/js/default/test/window.api.part2.js
...ndowstandard/src/main/js/default/test/window.api.part2.js
+0
-1077
graphic/windowstandard/src/main/js/default/test/window.parameter.js
...ndowstandard/src/main/js/default/test/window.parameter.js
+0
-258
graphic/windowstandard/src/main/js/default/test/window.promise.js
...windowstandard/src/main/js/default/test/window.promise.js
+0
-501
graphic/windowstandard/src/main/js/default/test/window.test.js
...ic/windowstandard/src/main/js/default/test/window.test.js
+1844
-144
未找到文件。
graphic/windowstandard/Test.json
浏览文件 @
aa56b29c
...
...
@@ -2,7 +2,7 @@
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
6
00000"
,
"test-timeout"
:
"
8
00000"
,
"package"
:
"com.test.window"
,
"shell-timeout"
:
"60000"
},
...
...
graphic/windowstandard/src/main/js/default/test/List.test.js
浏览文件 @
aa56b29c
...
...
@@ -12,10 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require
(
'
./window.api.part1.js
'
)
require
(
'
./window.api.part2.js
'
)
require
(
'
./window.test.js
'
)
require
(
'
./window.parameter.js
'
)
require
(
'
./window.promise.js
'
)
require
(
'
./display.test.js
'
)
require
(
'
./screenshot.test.js
'
)
graphic/windowstandard/src/main/js/default/test/display.test.js
0 → 100644
浏览文件 @
aa56b29c
/*
* 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
app
from
'
@system.app
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
window
from
'
@ohos.window
'
import
display
from
'
@ohos.display
'
describe
(
'
display_test
'
,
function
()
{
beforeAll
(
function
()
{
})
beforeEach
(
function
()
{
})
afterEach
(
function
()
{
})
afterAll
(
function
()
{
})
/**
* @tc.number SUB_WMS_GETDEFALUTDISPLAY_JSAPI_001
* @tc.name Test getDefaultDisplay_Test_001
* @tc.desc To test the function of obtaining the default screen
*/
it
(
'
getDefaultDisplay_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
displayTest getDefaultDisplayTest1 begin
'
)
display
.
getDefaultDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
displayTest getDefaultDisplayTest1 getDefaultDisplay id :
'
+
JSON
.
stringify
(
dsp
))
expect
(
dsp
.
id
!=
null
).
assertTrue
();
expect
(
dsp
.
refreshRate
!=
null
).
assertTrue
();
expect
(
dsp
.
width
!=
null
).
assertTrue
();
expect
(
dsp
.
height
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
displayTest getDefaultDisplayTest1 getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_GETDEFALUTDISPLAY_JSAPI_001
* @tc.name Test getDefaultDisplay_Test_002.
* @tc.desc To test the function if obtaining the default screen.
*/
it
(
'
getDefaultDisplay_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
displayTest getDefaultDisplayTest2 begin
'
);
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
displayTest getDefaultDisplayTest2 getDefaultDisplay callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
displayTest getDefaultDisplayTest2 getDefaultDisplay id :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
id
!=
null
).
assertTrue
();
expect
(
data
.
refreshRate
!=
null
).
assertTrue
();
expect
(
data
.
width
!=
null
).
assertTrue
();
expect
(
data
.
height
!=
null
).
assertTrue
();
done
();
}
})
})
/**
* @tc.number SUB_WMS_GETALLDISPLAY_JSAPI_001
* @tc.name Test getAllDisplay_Test_001.
* @tc.desc To verify the function of obtaining all screens.
*/
it
(
'
getAllDisplay_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
displayTest getAllDisplayTest1 begin
'
)
display
.
getAllDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
displayTest getAllDisplayTest1 getAllDisplay id :
'
+
JSON
.
stringify
(
dsp
))
expect
(
dsp
[
0
].
id
!=
null
).
assertTrue
();
expect
(
dsp
[
0
].
refreshRate
!=
null
).
assertTrue
();
expect
(
dsp
[
0
].
width
!=
null
).
assertTrue
();
expect
(
dsp
[
0
].
height
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
displayTest getAllDisplayTest1 getAllDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_GETALLDISPLAY_JSAPI_002
* @tc.name Test getAllDisplay_Test_002
* @tc.desc To test the function if obtaining the default screen
*/
it
(
'
getAllDisplay_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
displayTest getAllDisplayTest2 begin
'
);
display
.
getAllDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
displayTest getAllDisplayTest2 getAllDisplay callback fail
'
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
displayTest getAllDisplayTest2 getDefaultDisplay id :
'
+
JSON
.
stringify
(
data
));
expect
(
data
[
0
].
refreshRate
!=
null
).
assertTrue
();
expect
(
data
[
0
].
width
!=
null
).
assertTrue
();
expect
(
data
[
0
].
height
!=
null
).
assertTrue
();
done
();
}
})
})
})
graphic/windowstandard/src/main/js/default/test/screenshot.test.js
浏览文件 @
aa56b29c
...
...
@@ -405,7 +405,7 @@ describe('screenshot_test', function () {
done
();
},
(
err
)
=>
{
console
.
log
(
'
screenshotTest screenShotSaveTest10 screenshot.save failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
expect
().
assertFail
();
done
();
})
})
...
...
graphic/windowstandard/src/main/js/default/test/window.api.part1.js
已删除
100644 → 0
浏览文件 @
7d9ad525
/*
* 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
window
from
'
@ohos.window
'
describe
(
'
window_api_test
'
,
function
()
{
var
windowTypeArr
=
[];
var
windowTypeDic
=
{
'
APP_WINDOW_BASE
'
:
1
,
'
APP_MAIN_WINDOW_BASE
'
:
1
,
'
WINDOW_TYPE_APP_MAIN_WINDOW
'
:
1
,
'
APP_MAIN_WINDOW_END
'
:
1
,
'
APP_SUB_WINDOW_BASE
'
:
1000
,
'
WINDOW_TYPE_MEDIA
'
:
1000
,
'
WINDOW_TYPE_APP_SUB_WINDOW
'
:
1001
,
'
APP_SUB_WINDOW_END
'
:
1001
,
'
APP_WINDOW_END
'
:
1001
,
'
SYSTEM_WINDOW_BASE
'
:
2000
,
'
BELOW_APP_SYSTEM_WINDOW_BASE
'
:
2000
,
'
WINDOW_TYPE_WALLPAPER
'
:
2000
,
'
WINDOW_TYPE_DESKTOP
'
:
2001
,
'
BELOW_APP_SYSTEM_WINDOW_END
'
:
2001
,
'
ABOVE_APP_SYSTEM_WINDOW_BASE
'
:
2100
,
'
WINDOW_TYPE_APP_LAUNCHING
'
:
2100
,
'
WINDOW_TYPE_DOCK_SLICE
'
:
2101
,
'
WINDOW_TYPE_INCOMING_CALL
'
:
2102
,
'
WINDOW_TYPE_SEARCHING_BAR
'
:
2103
,
'
WINDOW_TYPE_SYSTEM_ALARM_WINDOW
'
:
2104
,
'
WINDOW_TYPE_INPUT_METHOD_FLOAT
'
:
2105
,
'
WINDOW_TYPE_FLOAT
'
:
2106
,
'
WINDOW_TYPE_TOAST
'
:
2107
,
'
WINDOW_TYPE_STATUS_BAR
'
:
2108
,
'
WINDOW_TYPE_PANEL
'
:
2109
,
'
WINDOW_TYPE_KEYGUARD
'
:
2110
,
'
WINDOW_TYPE_VOLUME_OVERLAY
'
:
2111
,
'
WINDOW_TYPE_NAVIGATION_BAR
'
:
2112
,
'
WINDOW_TYPE_DRAGGING_EFFECT
'
:
2113
,
'
WINDOW_TYPE_POINTER
'
:
2114
,
'
WINDOW_TYPE_LAUNCHER_RECENT
'
:
2115
,
'
WINDOW_TYPE_LAUNCHER_DOCK
'
:
2116
,
'
ABOVE_APP_SYSTEM_WINDOW_END
'
:
2116
,
'
SYSTEM_WINDOW_END
'
:
2116
}
var
windowCount
=
2022
;
var
topWindow
=
null
;
const
DELAY_TIME
=
3000
;
const
TRUE_FLAG
=
true
;
beforeAll
(
function
(
done
)
{
windowTypeArr
=
Object
.
keys
(
windowTypeDic
);
console
.
log
(
'
jsunittest beforeAll begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest beforeAll window.getTopWindow wnd:
'
+
wnd
)
if
(
wnd
)
{
topWindow
=
wnd
;
}
else
{
console
.
log
(
'
jsunittest beforeAll window.getTopWindow empty
'
);
}
},
(
err
)
=>
{
console
.
log
(
'
jsunittest beforeAll window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
})
setTimeout
(()
=>
{
done
();
},
5000
);
})
beforeEach
(
function
(
done
)
{
if
(
topWindow
)
{
topWindow
.
show
().
then
(()
=>
{
console
.
log
(
'
jsunittest beforeEach wnd.show success
'
);
},
(
err
)
=>
{
console
.
log
(
'
jsunittest beforeEach wnd.show failed, err :
'
+
JSON
.
stringify
(
err
));
})
topWindow
.
setFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
jsunittest beforeEach wnd.setFullScreen(false) success
'
);
},
(
err
)
=>
{
console
.
log
(
'
jsunittest beforeEach wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
})
setTimeout
(()
=>
{
done
();
},
DELAY_TIME
);
}
else
{
done
();
}
})
afterEach
(
function
()
{
windowCount
++
;
})
afterAll
(
function
()
{
})
/**
* @tc.number SUB_WINDOW_HIDE_SHOW_JSAPI_001
* @tc.name Test hideOrShowTest1
* @tc.desc set window hidden
*/
it
(
'
hideOrShowTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest hideOrShowTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest hideOrShowTest1 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
hide
().
then
(()
=>
{
console
.
log
(
'
jsunittest hideOrShowTest1 wnd.hide success
'
);
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest hideOrShowTest1 wnd.hide failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest hideOrShowTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_HIDE_SHOW_JSAPI_001
* @tc.name Test hideOrShowTest1
* @tc.desc Set the window to hide and then show
*/
it
(
'
hideOrShowTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest hideOrShowTest2 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest hideOrShowTest2 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
hide
().
then
(()
=>
{
console
.
log
(
'
jsunittest hideOrShowTest2 wnd.hide success
'
);
wnd
.
show
().
then
(()
=>
{
console
.
log
(
'
jsunittest hideOrShowTest2 wnd.show success
'
);
expect
(
TRUE_FLAG
).
assertTrue
()
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest hideOrShowTest2 wnd.show failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest hideOrShowTest2 wnd.hide failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest hideOrShowTest2 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_GETPROPERTIES_JSAPI_001
* @tc.name Test getPropertiesTest1
* @tc.desc Get the current application main window properties
*/
it
(
'
getPropertiesTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest getPropertiesTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest getPropertiesTest1 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest getPropertiesTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!!
data
.
type
).
assertTrue
();
expect
(
!!
data
.
windowRect
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getPropertiesTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getPropertiesTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_001
* @tc.name Test getAvoidAreaTest1
* @tc.desc Get SystemUI type avoidance area
*/
it
(
'
getAvoidAreaTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest getAvoidAreaTest1 this.context begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
!!
wnd
).
assertTrue
();
wnd
.
getAvoidArea
(
0
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest1 wnd.getAvoidArea success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!!
data
.
topRect
).
assertTrue
();
expect
(
!!
data
.
rightRect
).
assertTrue
();
expect
(
!!
data
.
bottomRect
).
assertTrue
();
expect
(
!!
data
.
leftRect
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest1 wnd.getAvoidArea failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_002
* @tc.name Test getAvoidAreaTest2
* @tc.desc Get Notch type avoidance area
*/
it
(
'
getAvoidAreaTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest getAvoidAreaTest2 pages/index/index begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
!!
wnd
).
assertTrue
();
wnd
.
getAvoidArea
(
1
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest2 wnd.getAvoidArea success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!!
data
.
topRect
).
assertTrue
();
expect
(
!!
data
.
rightRect
).
assertTrue
();
expect
(
!!
data
.
bottomRect
).
assertTrue
();
expect
(
!!
data
.
leftRect
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest2 wnd.getAvoidArea failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest2 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_003
* @tc.name Test getAvoidAreaTest3
* @tc.desc Get system gesture type avoidance area
*/
it
(
'
getAvoidAreaTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest getAvoidAreaTest3 pages/index/ begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest3 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
getAvoidArea
(
3
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest3 wnd.getAvoidArea success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!!
data
.
topRect
).
assertTrue
();
expect
(
!!
data
.
rightRect
).
assertTrue
();
expect
(
!!
data
.
bottomRect
).
assertTrue
();
expect
(
!!
data
.
leftRect
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest3 wnd.getAvoidArea failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest getAvoidAreaTest3 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_SETFULLSCREEN_JSAPI_001
* @tc.name Test setFullScreenTest1
* @tc.desc Set the window to be non-fullscreen first and then fullscreen
*/
it
(
'
setFullScreenTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest setFullScreenTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
console
.
log
(
'
jsunittest setFullScreenTest1 setFullScreen begin
'
)
wnd
.
setFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.setFullScreen(false) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setFullScreen
(
true
).
then
(()
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.setFullScreen(true) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
data
.
isFullScreen
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.setFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
console
.
log
(
'
jsunittest setFullScreenTest1 setFullScreen end
'
)
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test setLayoutFullScreenTest1
* @tc.desc Set window and layout to full screen
*/
it
(
'
setLayoutFullScreenTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
setFullScreen
(
true
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.setFullScreen(true) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.setLayoutFullScreen(true) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.setLayoutFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 wnd.setFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_002
* @tc.name Test setLayoutFullScreenTest2
* @tc.desc Set the window to full screen, the layout is not full screen
*/
it
(
'
setLayoutFullScreenTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
setFullScreen
(
true
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.setFullScreen(true) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.setLayoutFullScreen(false) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.setLayoutFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest2 wnd.setFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_003
* @tc.name Test setLayoutFullScreenTest3
* @tc.desc Set the window to be non-full-screen and the layout to be full-screen
*/
it
(
'
setLayoutFullScreenTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
setFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.setFullScreen(false) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.setLayoutFullScreen(true) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.setLayoutFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest3 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_004
* @tc.name Test setLayoutFullScreenTest4
* @tc.desc Setting windows and layouts to be non-fullscreen
*/
it
(
'
setLayoutFullScreenTest4
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 window.getTopWindow wnd:
'
+
wnd
)
expect
(
!!
wnd
).
assertTrue
();
wnd
.
setFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.setFullScreen(false) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.setLayoutFullScreen(false) success
'
);
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.setLayoutFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
jsunittest setLayoutFullScreenTest4 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FIND_JSAPI_001
* @tc.name Test findTest1
* @tc.desc Query main window
*/
it
(
'
findTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest findTest1 begin
'
)
window
.
find
(
'
main window0
'
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest findTest1 wnd.find success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest findTest1 wnd.find failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FIND_JSAPI_002
* @tc.name Test findTest2
* @tc.desc Query for non-existing windows
*/
it
(
'
findTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest findTest2 begin
'
)
window
.
find
(
'
nonexist
'
).
then
((
window
)
=>
{
console
.
log
(
'
jsunittest findTest2 wnd.find success, window :
'
+
JSON
.
stringify
(
window
));
expect
(
!!
data
).
assertTrue
();
done
()
},
(
err
)
=>
{
console
.
log
(
'
jsunittest findTest2 wnd.find failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
).
assertTrue
();
done
();
})
})
})
graphic/windowstandard/src/main/js/default/test/window.api.part2.js
已删除
100644 → 0
浏览文件 @
7d9ad525
/*
* 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
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
window
from
'
@ohos.window
'
import
display
from
'
@ohos.display
'
import
screen
from
'
@ohos.screen
'
describe
(
'
window_api_test
'
,
function
()
{
beforeAll
(
function
()
{})
beforeEach
(
function
()
{})
afterEach
(
function
()
{})
afterAll
(
function
()
{})
/**
* @tc.number SUB_WMS_FAMODELONOFF_JSAPI_001
* @tc.name Test faModelOnOffTest1.
* @tc.desc To verify the function of enabling and disabling the monitoring function for tone change on the system bar..
*/
it
(
'
faModelOnOffTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelOnOffTest1 begin
'
);
var
listenerStatus
;
var
callback
=
(
data
)
=>
{
console
.
log
(
'
jsunittest faModelOnOffTest1 create callback
'
+
JSON
.
stringify
(
data
));
listenerStatus
=
1
;
console
.
log
(
'
jsunittest faModelOnOffTest1 listenerStatus 1:
'
+
listenerStatus
);
}
window
.
on
(
'
systemBarTintChange
'
,
callback
);
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelOnOffTest1 getTopWindow callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
expect
(
data
!=
null
).
assertTrue
();
data
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelOnOffTest1 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
setTimeout
(()
=>
{
expect
(
listenerStatus
==
1
).
assertTrue
();
window
.
off
(
'
systemBarTintChange
'
);
listenerStatus
=
0
;
data
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelOnOffTest1 listenerStatus 2:
'
+
listenerStatus
);
if
(
err
.
code
!=
0
||
listenerStatus
==
1
)
{
console
.
log
(
'
jsunittest faModelOnOffTest1 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelOnOffTest1 listenerStatus 3:
'
+
listenerStatus
);
console
.
log
(
'
jsunittest faModelOnOffTest1 off callback success
'
);
done
();
}
})
},
2000
);
}
})
})
})
/**
* @tc.number SUB_WMS_FAMODELONOFF_JSAPI_002
* @tc.name Test faModelOnOffTest2.
* @tc.desc To verify the function of enabling and disabling intercepting when the window size changes.
*/
var
listenerStatus
;
//1表示开启 其他为关闭
function
callback
(
data
)
{
console
.
log
(
'
jsunittest faModelOnOffTest2 callback
'
+
JSON
.
stringify
(
data
));
listenerStatus
=
1
;
console
.
log
(
'
jsunittest faModelOnOffTest2 listenerStatus 1:
'
+
listenerStatus
);
}
it
(
'
faModelOnOffTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelOnOffTest2 begin
'
);
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelOnOffTest2 getTopWindow callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
typeof
data
!=
undefined
).
assertTrue
();
data
.
on
(
'
windowSizeChange
'
,
callback
);
}
data
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelOnOffTest2 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
}
else
{
setTimeout
((
async
function
()
{
console
.
log
(
'
jsunittest faModelOnOffTest2 listenerStatus 111:
'
+
listenerStatus
);
expect
(
listenerStatus
).
assertEqual
(
1
);
data
.
off
(
'
windowSizeChange
'
)
listenerStatus
=
0
;
data
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelOnOffTest2 listenerStatus 2:
'
+
listenerStatus
);
if
(
err
.
code
!=
0
||
listenerStatus
==
1
)
{
console
.
log
(
'
jsunittest faModelOnOffTest2 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelOnOffTest2 listenerStatus 3:
'
+
listenerStatus
);
console
.
log
(
'
jsunittest faModelOnOffTest2 off callback success
'
);
done
();
}
})
}),
1000
)
}
})
})
})
function
callback2
(
data
)
{
console
.
log
(
'
jsunittest faModelOnOffTest3 callback
'
+
JSON
.
stringify
(
data
));
listenerStatus
=
1
;
console
.
log
(
'
jsunittest faModelOnOffTest3 listenerStatus 1:
'
+
listenerStatus
);
}
/**
* @tc.number SUB_WMS_FAMODELONOFF_JSAPI_003
* @tc.name Test faModelOnOffTest3.
* @tc.desc To verify the function of enabling and disabling lawful interception in the system and window.
*/
it
(
'
faModelOnOffTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelOnOffTest3 begin
'
)
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelOnOffTest3 getTopWindow callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
typeof
data
!=
undefined
).
assertTrue
();
data
.
on
(
'
systemAvoidAreaChange
'
,
callback2
);
}
data
.
setFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelOnOffTest3 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
setTimeout
((
async
function
()
{
console
.
log
(
'
jsunittest faModelOnOffTest3 listenerStatus 111:
'
+
listenerStatus
);
expect
(
listenerStatus
).
assertEqual
(
1
);
done
();
data
.
off
(
'
systemAvoidAreaChange
'
)
listenerStatus
=
0
;
data
.
setFullScreen
(
false
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelOnOffTest3 listenerStatus 2:
'
+
listenerStatus
);
if
(
err
.
code
!=
0
||
listenerStatus
==
1
)
{
console
.
log
(
'
jsunittest faModelOnOffTest2 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelOnOffTest3 listenerStatus 3:
'
+
listenerStatus
);
console
.
log
(
'
jsunittest faModelOnOffTest3 off callback success
'
);
done
();
}
})
}),
1000
)
}
})
})
})
/**
* @tc.number SUB_WINDOW_FAMODELHIDE_SHOW_JSAPI_001
* @tc.name Test faModelHideOrShowTest1.
* @tc.desc Set the window to hide and then show.
*/
it
(
'
faModelHideOrShowTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
hide
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.hide callback begin
'
+
err
.
code
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.hide callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
true
).
assertTrue
();
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.hide callback success
'
);
}
wnd
.
show
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.show callback begin
'
+
err
.
code
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.show callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelHideOrShowTest1 window.show callback success
'
);
expect
(
true
).
assertTrue
();
done
();
}
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest hideOrShowTest1 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELGETPROPERTIES_JSAPI_001
* @tc.name Test faModelGetPropertiesTest1.
* @tc.desc Get the current application main window properties.
*/
it
(
'
faModelGetPropertiesTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getProperties
((
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 window.getProperties callback begin
'
+
err
.
code
);
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 window.getProperties callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
type
!=
null
).
assertTrue
();
expect
(
data
.
windowRect
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 window.getProperties callback end
'
);
done
();
}
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelGetPropertiesTest1 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELGETAVOIDAREA_JSAPI_001
* @tc.name Test faModelGetAvoidAreaTest1.
* @tc.desc Get SystemUI type avoidance area.
*/
it
(
'
faModelGetAvoidAreaTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
0
,
(
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 window.getAvoidArea callback begin
'
+
err
.
code
);
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 window.getAvoidArea callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 window.getAvoidArea callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 window.getAvoidArea callback end
'
);
done
();
}
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest1 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELGETAVOIDAREA_JSAPI_002
* @tc.name Test faModelGetAvoidAreaTest2.
* @tc.desc Get Noth type avoidance area.
*/
it
(
'
faModelGetAvoidAreaTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
1
,
(
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 window.getAvoidArea callback begin
'
+
err
.
code
);
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 window.getAvoidArea callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 window.getAvoidArea callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 window.getAvoidArea callback end
'
);
done
();
}
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest2 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELGETAVOIDAREA_JSAPI_003
* @tc.name Test faModelGetAvoidAreaTest3.
* @tc.desc Get system gesture type avoidance area.
*/
it
(
'
faModelGetAvoidAreaTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest3 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
3
,
(
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest3 window.getAvoidArea callback begin
'
+
err
.
code
);
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest3 window.getAvoidArea callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelGetAvoidAreaTest3 window.getAvoidArea callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModeGetAvoidAreaTest3 window.getAvoidArea callback end
'
);
done
();
}
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModeGetAvoidAreaTest3 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELSETFULLSCREEN_JSAPI_001
* @tc.name Test faModelSetFullScreenTest1
* @tc.desc Set the window to be non-fullscreen first and then fullscreen.
*/
it
(
'
faModelSetFullScreenTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 setFullScreen callback begin
'
);
wnd
.
setFullScreen
(
false
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.setFullScreen(false) callback begin
'
+
err
.
code
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.setFullScreen(false) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 setFullScreen(false) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback begin
'
+
err
.
code
);
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
!
data
.
isFullScreen
).
assertTrue
();
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback end
'
);
wnd
.
setFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.setFullScreen(true) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 setFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback begin
'
+
err
.
code
);
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
data
.
isFullScreen
).
assertTrue
();
console
.
log
(
'
jsunittest faModelSetFullScreenTest1 window.getProperties callback end
'
);
done
();
})
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest setFullScreenTest1 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
});
/**
* @tc.number SUB_WINDOW_FAMODELSETLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test faModelSetLayoutFullScreenTest1
* @tc.desc Set window and layout to full screen.
*/
it
(
'
faModelSetLayoutFullScreenTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
true
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 wnd.setFullScreen(true) callback begin
'
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 window.setFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 wnd.setFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 window.setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 wnd.setLayoutFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 wnd.getProperties callback end
'
);
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
()
})
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest1 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELSETLAYOUTFULLSCREEN_JSAPI_002
* @tc.name Test faModelSetLayoutFullScreenTest2
* @tc.desc Set the window to full screen, the layout is not full screen.
*/
it
(
'
faModelSetLayoutFullScreenTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
true
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin
'
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 window.setFullScreen(true) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 wnd.setFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 window.setLayoutFullScreen(false) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 wnd.setLayoutFullScreen(false) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 wnd.getProperties callback end
'
);
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
})
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest2 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELSETLAYOUTFULLSCREEN_JSAPI_003
* @tc.name Test faModelSetLayoutFullScreenTest3
* @tc.desc Set the window to be non-full-screen and the layout to be full-screen.
*/
it
(
'
faModelSetLayoutFullScreenTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 wnd.setFullScreen(false) callback begin
'
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 window.setFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 wnd.setFullScreen(false) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 window.setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 wnd.setLayoutFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 wnd.getProperties callback end
'
);
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
()
})
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest3 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_FAMODELSETLAYOUTFULLSCREEN_JSAPI_004
* @tc.name Test faModelSetLayoutFullScreenTest4
* @tc.desc Setting window and layouts to be non-fullscreen.
*/
it
(
'
faModelSetLayoutFullScreenTest4
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 wnd.setFullScreen(true) callback begin
'
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 window.setFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 wnd.setFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 window.setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 wnd.setLayoutFullScreen(true) callback end
'
);
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 wnd.getProperties callback end
'
);
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
})
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetLayoutFullScreenTest4 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
});
/**
* @tc.number SUB_WINDOW_FAMODELFIND_JSAPI_001
* @tc.name Test faModelFindTest1
* @tc.desc Query main window.
*/
it
(
'
faModelFindTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelFindTest1 begin
'
);
window
.
find
(
'
main window0
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
'
jsunittest faModelFindTest1 wnd.find fail, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
}
else
{
console
.
log
(
'
jsunittest faModelFindTest1 wnd.find fail
'
);
expect
().
assertFail
();
done
();
}
})
})
/**
* @tc.number SUB_WINDOW_FAMODELFIND_JSAPI_002
* @tc.name Test faModelFindTest2
* @tc.desc Query for non-existing windows
*/
it
(
'
faModelFindTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest findTest2 begin
'
);
window
.
find
(
'
nonexist
'
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
'
jsunittest faModelFindTest2 wnd.find fail, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
}
else
{
console
.
log
(
'
jsunittest faModelFindTest2 wnd.find success
'
);
expect
().
assertFail
();
done
();
}
})
})
/**
* @tc.number SUB_WMS_FAMODELISSHOWING_JSAPI_002
* @tc.name Test faModelIsShowingTest2.
* @tc.desc To verify the function of obtaining the display status when a window is hidden and then displayed.
*/
it
(
'
faModelIsShowingTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
hide
((
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 window.hide fail err
'
+
JSON
.
stringify
(
err
));
done
();
}
wnd
.
isShowing
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 window.isShowing fail err
'
+
JSON
.
stringify
(
err
));
done
();
}
expect
(
!
data
).
assertTrue
();
wnd
.
show
((
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 window.show fail err
'
+
JSON
.
stringify
(
err
));
done
();
}
wnd
.
isShowing
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 window.isShowing fail err
'
+
JSON
.
stringify
(
err
));
done
();
}
expect
(
data
).
assertTrue
();
done
();
})
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest2 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
});
/**
* @tc.number SUB_WMS_FAMODELSETCOLORSPACE_JSAPI_003
* @tc.name Test faModelSetColorSpaceTest3.
* @tc.desc To verify the setting of the wide color gamut color space.
*/
it
(
'
faModelSetColorSpaceTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
1
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 setColorSpace callback begin
'
+
JSON
.
stringify
(
err
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 setColorSpace callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
wnd
.
getColorSpace
((
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 getColorSpace callback begin
'
+
JSON
.
stringify
(
err
)
+
'
data
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 getColorSpace callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
expect
(
data
==
1
).
assertTrue
();
wnd
.
isSupportWideGamut
((
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 getColorSpace callback begin
'
+
JSON
.
stringify
(
err
)
+
'
data
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 getColorSpace callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
expect
(
data
).
assertTrue
();
done
();
})
})
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest3 getTopWindow failed,err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
});
/**
* @tc.number SUB_WMS_FAMODELSETCOLORSPACE_JSAPI_004
* @tc.name Test faModelSetColorSpaceTest4.
* @tc.desc To verify that the color space of invalid values is set successfully.
*/
it
(
'
faModelSetColorSpaceTest4
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest4 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
-
5
,
(
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest4 setColorSpace callback begin
'
+
JSON
.
stringify
(
err
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest4 setColorSpace callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
(
err
.
code
).
assertEqual
(
130
);
done
();
}
else
{
expect
().
assertFail
();
done
();
}
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest4 getTopWindow failed,err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
});
/**
* @tc.number SUB_WMS_FAMODELGETDEFALUTDISPLAY_JSAPI_001
* @tc.name Test faModelGetDefaultDisplayTest2.
* @tc.desc To test the function if obtaining the default screen.
*/
it
(
'
faModelGetDefaultDisplayTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 begin
'
);
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay id :
'
+
JSON
.
stringify
(
data
));
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay id :
'
+
data
.
id
);
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay refreshRate :
'
+
data
.
refreshRate
);
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay width :
'
+
data
.
width
);
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay height :
'
+
data
.
height
);
expect
(
data
.
id
!=
null
).
assertTrue
();
expect
(
data
.
refreshRate
!=
null
).
assertTrue
();
expect
(
data
.
width
!=
null
).
assertTrue
();
expect
(
data
.
height
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest2 getDefaultDisplay failed,err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELGETALLDISPLAY_JSAPI_001
* @tc.name Test faModelGetAllDisplayTest2.
* @tc.desc To test the function if obtaining the default screen.
*/
it
(
'
faModelGetAllDisplayTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 begin
'
);
display
.
getAllDisplay
((
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 callback data
'
+
data
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 getAllDisplay callback fail
'
);
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 getDefaultDisplay id :
'
+
JSON
.
stringify
(
data
));
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 getDefaultDisplay id :
'
+
data
[
0
].
id
);
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 getDefaultDisplay refreshRate :
'
+
data
[
0
].
refreshRate
);
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 getDefaultDisplay width :
'
+
data
[
0
].
width
);
console
.
log
(
'
jsunittest faModelGetAllDisplayTest2 getDefaultDisplay height :
'
+
data
[
0
].
height
);
expect
(
data
[
0
].
id
!=
null
).
assertTrue
();
expect
(
data
[
0
].
refreshRate
!=
null
).
assertTrue
();
expect
(
data
[
0
].
width
!=
null
).
assertTrue
();
expect
(
data
[
0
].
height
!=
null
).
assertTrue
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELCREATE_JSAPI_001
* @tc.name Test faModelCreateTest2.
* @tc.desc To verify the function of creating an application subwindow.
*/
it
(
'
faModelCreateTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelCreateTest2 begin
'
);
window
.
create
(
'
subWindow1
'
,
0
,
(
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelCreateTest2 callback
'
+
data
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelCreateTest2 create callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
expect
(
data
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelCreateTest2 callback create success data
'
+
data
);
done
();
});
});
/**
* @tc.number SUB_WMS_FAMODELDESTROY_JSAPI_002
* @tc.name Test faModelDestroyTest2.
* @tc.desc Verify that a window is destroyed after being created.
*/
it
(
'
faModelDestroyTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelDestroyTest2 begin
'
);
window
.
create
(
'
subWindow2
'
,
0
,
(
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelDestroyTest2 create callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelDestroyTest2 create callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
expect
(
data
!=
null
).
assertTrue
();
data
.
destroy
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelDestroyTest2 destroy callback begin
'
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelDestroyTest2 create callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
window
.
find
(
'
subWindow2
'
,
(
err
,
data
)
=>
{
console
.
log
(
'
jsunittest faModelDestroyTest2 find callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelDestroyTest2 find callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
}
else
{
console
.
log
(
'
jsunittest faModelDestroyTest2 find suceess,err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
})
})
})
})
/**
* @tc.number SUB_WMS_FAMODELSETSYSTEMBARENABLE_JSAPI_002
* @tc.name Test faModelSetSystemBarEnableTest2.
* @tc.desc To verify the function of setting a scenario that is visible to the system bar.
*/
it
(
'
faModelSetSystemBarEnableTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest2 begin
'
);
var
names
=
[
"
status
"
,
"
navigation
"
];
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest2 getTopWindow fail:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
data
!=
null
).
assertTrue
();
data
.
setSystemBarEnable
(
names
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest2 getTopWindow fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest2 setSystemBarEnable success
'
);
expect
(
true
).
assertTrue
();
done
();
}
})
})
})
/**
* @tc.number SUB_WMS_FAMODELSETSYSTEMBARPROPERTIES_JSAPI_002
* @tc.name Test faModelSetSystemBarPropertiesTest2.
* @tc.desc To verify the function of setting system bar attributes.
*/
it
(
'
faModelSetSystemBarPropertiesTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest2 begin
'
);
var
SystemBarProperties
=
{
statusBarColor
:
'
#ff00ff
'
,
navigationBarColor
:
'
#00ff00
'
,
isStatusBarLightIcon
:
true
,
isNavigationBarLightIcon
:
false
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#00ffff
'
};
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest2 getTopWindow fail:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
expect
(
data
!=
null
).
assertTrue
();
data
.
setSystemBarProperties
(
SystemBarProperties
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest2 setSystemBarProperties fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest2 setSystemBarProperties success
'
);
done
();
})
})
});
/**
* @tc.number SUB_WMS_FAMODELONOFF_JSAPI_004
* @tc.name Test faModelOnOffTest4.
* @tc.desc To verify the function of enabling and disabling the listening function of the display device.
*/
it
(
'
faModelOnOffTest4
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelOnOffTest4 begin
'
);
var
listenerStatus
;
//1表示开启,其他为关闭
var
callback
=
(
data
)
=>
{
listenerStatus
=
data
;
console
.
log
(
'
jsunittest faModelOnOffTest4 create callback
'
+
JSON
.
stringify
(
data
));
}
console
.
log
(
'
jsunittest faModelOnOffTest4 listenerStatus :
'
+
listenerStatus
);
console
.
log
(
'
jsunittest faModelOnOffTest4 typeof listenerStatus
'
+
typeof
listenerStatus
);
display
.
on
(
'
add
'
,
callback
);
expect
(
typeof
(
listenerStatus
)).
assertEqual
(
'
undefined
'
);
display
.
off
(
'
add
'
);
expect
(
typeof
(
listenerStatus
)).
assertEqual
(
'
undefined
'
);
done
();
})
/**
* @tc.number SUB_WINDOW_FAMODELMOVETO_JSAPI_007
* @tc.name Test faModelmoveTest1.
* @tc.desc Verify the window movement scenario.
*/
it
(
'
faModelmoveTest1
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest faModelmoveTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelmoveTest1 getTopWindow wnd
'
+
wnd
);
wnd
.
moveTo
(
200
,
200
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
jsunittest faModelmoveTest1 moveTo callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelmoveTest1 moveTo callback success
'
);
expect
(
true
).
assertTrue
();
done
();
}
})
})
});
/**
* @tc.number SUB_WINDOW_FAMODELRESETSIZETEST_JSAPI_006
* @tc.name Test faModelResetSizeTest6.
* @tc.desc To verify the function of setting the window size.
*/
it
(
'
faModelResetSizeTest6
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest faModelResetSizeTest6 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelResetSizeTest6 getTopWindow wnd:
'
+
wnd
);
wnd
.
resetSize
(
200
,
200
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
jsunittest faModelResetSizeTest6 resetSize callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelResetSizeTest6 resetSize callback success
'
);
expect
(
true
).
assertTrue
();
done
();
}
})
})
});
/**
* @tc.number SUB_WINDOW_FAMODELSETWINDOWTYPE_JSAPI_005
* @tc.name Test faModelSetWindowTypeTest5.
* @tc.desc To verify the function of setting the window mode to application window.
*/
it
(
'
faModelSetWindowTypeTest5
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest faModelSetWindowTypeTest5 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetWindowTypeTest5 getTopWindow wnd:
'
+
wnd
);
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_APP
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
jsunittest faModelSetWindowTypeTest5 setWindowType callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelSetWindowTypeTest5 setWindowType callback success
'
);
expect
(
true
).
assertTrue
();
done
();
}
})
})
});
/**
* @tc.number SUB_WMS_FAMODELSETWINDOWLAYOUTMODE_JSAPI_004
* @tc.name Test faModelSetWindowLayoutModeTest4.
* @tc.desc To verify the function of setting different window modes.
*/
it
(
'
faModelSetWindowLayoutModeTest4
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest4 begin
'
);
await
display
.
getDefaultDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest4 getDefaultDisplay dspID :
'
+
dsp
.
id
);
window
.
setWindowLayoutMode
(
0
,
dsp
.
id
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest4 setWindowLayoutMode callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest4 setWindowLayoutMode WINDOW_LAYOUT_MODE_TILE success
'
);
done
();
}
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest4 getDefaultDisplay failed ,err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
});
})
\ No newline at end of file
graphic/windowstandard/src/main/js/default/test/window.parameter.js
已删除
100644 → 0
浏览文件 @
7d9ad525
/*
* 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
app
from
'
@system.app
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
window
from
'
@ohos.window
'
describe
(
'
window_test
'
,
function
(){
var
wnd
;
beforeAll
(
function
(){
})
beforeEach
(
function
(){
})
afterEach
(
function
(){
})
afterAll
(
function
(){
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_007
* @tc.name Test moveTestNegative.
* @tc.desc Test window.moveTo API function test7.
*/
it
(
'
moveTestNegative
'
,
0
,
function
(){
console
.
log
(
'
jsunittest moveTestNegative begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest moveTestNegative getTopWindow wnd:
'
+
wnd
)
wnd
.
moveTo
(
-
200
,
-
200
).
then
(()
=>
{
console
.
log
(
'
moveTo(-200,-200) success
'
)
})
wnd
.
moveTo
(
0
,
0
).
then
(()
=>
{
console
.
log
(
'
moveTo(0,0) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_RESETSIZE_JSAPI_006
* @tc.name Test resetSizeTestLoop.
* @tc.desc Test window.resetSize API function test6.
*/
it
(
'
resetSizeLoop
'
,
0
,
function
(){
var
width
=
100
;
var
height
=
100
;
console
.
log
(
'
jsunittest resetSizeLoop begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest resetSizeLoop getTopWindow wnd:
'
+
wnd
)
for
(
let
i
=
1
;
i
<=
5
;
i
++
){
width
=
width
*
i
;
height
=
height
*
i
;
wnd
.
resetSize
(
width
,
height
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTestLoop success
'
)
})
}
wnd
.
resetSize
(
0
,
0
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTsetLoop wnd.resetSize(0,0) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_008
* @tc.name Test setWindowTypeTestZero.
* @tc.desc Test window.setWindowType API function test8.
*/
it
(
'
setWindowTypeTestZero
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTestZero begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestZero getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_APP
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestZero wnd.setWindowType(0) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestZero wnd.moveTo(200,200) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestZero wnd.resetSize(200,200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_009
* @tc.name Test setWindowTypeTestThirty.
* @tc.desc Test window.setWindowType API function test9.
*/
it
(
'
setWindowTypeTestThirty
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTestThirty begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestThirty getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_SYSTEM_ALTER
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestThirty wnd.setWindowType(30) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestThirty wnd.moveTo(200, 200) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestThirty wnd.resetSize(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_010
* @tc.name Test setWindowTypeTestSeventy.
* @tc.desc Test window.setWindowType API function test10.
*/
it
(
'
setWindowTypeTestSeventy
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTestSeventy begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestSeventy getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_SYSTEM_VOLUME
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestSeventy wnd.setWindowType(70) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestSeventy wnd.moveTo(200, 200) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestSeventy wnd.resetSize(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_012
* @tc.name Test setWindowTypeTestNinety.
* @tc.desc Test window.setWindowType API function test12.
*/
it
(
'
setWindowTypeTestNinety
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTestNinety begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestNinety getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_SYSTEM_PANEL
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestNinety wnd.setWindowType(90) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestNinety wnd.moveTo(200, 200) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestNinety wnd.resetSize(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_011
* @tc.name Test setWindowTypeTestOrderChange.
* @tc.desc Test window.setWindowType API function test11.
*/
it
(
'
setWindowTypeTestOrderChange
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTestOrderChange begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestOrderChange getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_APP
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestOrderChange wnd.setWindowType(0) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestOrderChange wnd.resetSize(200, 200) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTestOrderChange wnd.moveTo(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_013
* @tc.name Test setWindowTypeTest15.
* @tc.desc Test window.setWindowType API function test13.
*/
it
(
'
setWindowTypeTest15
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTest15 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest15 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_SYSTEM_ALTER
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest15 wnd.setWindowType(30) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest15 wnd.resetSize(200, 200) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest15 wnd.moveTo(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_014
* @tc.name Test setWindowTypeTest16.
* @tc.desc Test window.setWindowType API function test14.
*/
it
(
'
setWindowTypeTest16
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTest16 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest16 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_SYSTEM_VOLUME
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest16 wnd.setWindowType(70) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest16 wnd.resetSize(200, 200) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest16 wnd.moveTo(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_015
* @tc.name Test setWindowTypeTest17.
* @tc.desc Test window.setWindowType API function test15.
*/
it
(
'
setWindowTypeTest17
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTest17 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest17 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_SYSTEM_PANEL
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest17 wnd.setWindowType(90) success
'
)
})
wnd
.
resetSize
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest17 wnd.resetSize(200, 200) success
'
)
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest17 wnd.moveTo(200, 200) success
'
)
})
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_006
* @tc.name Test moveTest6.
* @tc.desc Test window.moveTo API function test6.
*/
it
(
'
moveTest6
'
,
0
,
function
(){
console
.
log
(
'
jsunittest moveTest6 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest moveTest6 getTopWindow wnd:
'
+
wnd
)
wnd
.
moveTo
(
-
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest moveTest6 wnd.moveTo(-200, 300) success
'
)
})
wnd
.
moveTo
(
200
,
-
300
).
then
(()
=>
{
console
.
log
(
'
jsunittest moveTest6 wnd.moveTo(200, -300) success
'
)
})
})
})
})
\ No newline at end of file
graphic/windowstandard/src/main/js/default/test/window.promise.js
已删除
100644 → 0
浏览文件 @
7d9ad525
/*
* 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/index
'
import
window
from
'
@ohos.window
'
import
display
from
'
@ohos.display
'
import
screen
from
'
@ohos.screen
'
describe
(
'
window_test
'
,
function
()
{
var
wnd
;
const
FALSE_FLAG
=
false
;
beforeAll
(
function
()
{})
beforeEach
(
function
()
{})
afterEach
(
function
()
{})
afterAll
(
function
()
{})
/**
* @tc.number SUB_WMS_FAMODELSETCOLORSPACE_JSAPI_001
* @tc.name Test faModelSetColorSpaceTest1.
* @tc.desc To verify the setting of the wide color gamut color space.
*/
it
(
'
faModelSetColorSpaceTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
1
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 setColorSpace WIDE_GAMUT
'
);
wnd
.
getColorSpace
().
then
(
res
=>
{
expect
(
res
==
1
).
assertTrue
();
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 setColorSpace WIDE_GAMUT success
'
);
wnd
.
isSupportWideGamut
().
then
(
data
=>
{
expect
(
!!
data
).
assertTrue
();
console
.
log
(
'
ColorSpace WIDE_GAMUT SupportWideGamut
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 wnd.isSupportWideGamut failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 wnd.getColorSpace failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 wnd.setColorSpace failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETCOLORSPACE_JSAPI_002
* @tc.name Test faModelSetColorSpaceTest2.
* @tc.desc To verify that the color space of invaild values is set successfully.
*/
it
(
'
faModelSetColorSpaceTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest2 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
-
5
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest2 setColorSpace -5
'
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest2 wnd.setColorSpace failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
130
);
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetColorSpaceTest2 wnd.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETWINDOWLAYOUTMODE_JSAPI_001
* @tc.name Test faModelSetWindowLayoutModeTest1.
* @tc.desc To verify the function of setting different window modes.
*/
it
(
'
faModelSetWindowLayoutModeTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 begin
'
);
await
display
.
getDefaultDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 getDefaultDisplay dspID :
'
+
dsp
.
id
);
window
.
setWindowLayoutMode
(
0
,
dsp
.
id
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 setWindowLayoutMode WINDOW_LAYOUT_MODE_CASCADE success
'
);
window
.
setWindowLayoutMode
(
1
,
dsp
.
id
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 setWindowLayoutMode WINDOW_LAYOUT_MODE_TILE success
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 setWindowLayoutMode failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 setWindowLayoutMode failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest1 getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETWINDOWLAYOUTMODE_JSAPI_002
* @tc.name Test faModelSetWindowLayoutModeTest2.
* @tc.desc To verify the function of setting the invalied window mode.
*/
it
(
'
faModelSetWindowLayoutModeTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest2 begin
'
);
display
.
getDefaultDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest2 getDefaultDisplay dspID :
'
+
dsp
.
id
);
window
.
setWindowLayoutMode
(
-
5
,
dsp
.
id
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest2 setWindowLayoutMode -5 success
'
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest2 setWindowLayoutMode failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
130
);
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest2 getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETWINDOWLAYOUTMODE_JSAPI_003
* @tc.name Test faModelSetWindowLayoutModeTest3.
* @tc.desc To verify the scenario where the screen ID is invaild when the window mode is set.
*/
it
(
'
faModelSetWindowLayoutModeTest3
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest3 begin
'
);
window
.
setWindowLayoutMode
(
-
5
,
-
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest3 setWindowLayoutMode (-5,-100) success
'
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetWindowLayoutModeTest3 setWindowLayoutMode failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETSCREENACTIVEMODE_JSAPI_001
* @tc.name Test faModelSetScreenActiveModeTest1.
* @tc.desc To test the function of setting screen parameters.
*/
it
(
'
faModelSetScreenActiveModeTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest setScreenActiveModeTest1 begin
'
);
screen
.
getAllScreen
().
then
(
scr
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest1 getAllScreen scr
'
+
scr
);
expect
(
scr
[
0
]
!=
null
).
assertTrue
();
let
screen1
=
scr
[
0
];
screen1
.
setScreenActiveMode
(
0
).
then
(
res1
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest1 setScreenActiveMode 0 res1 :
'
+
res1
);
expect
(
res1
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest1 setScreenActiveMode 0 failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest1 getAllScreen failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETSCREENACTIVEMODE_JSAPI_002
* @tc.name Test faModelSetScreenActiveModeTest2.
* @tc.desc To set the function of setting screen parameters to abnormal values.
*/
it
(
'
faModelSetScreenActiveModeTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest2 begin
'
);
screen
.
getAllScreen
().
then
(
scr
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest2 getAllScreen scr
'
+
scr
);
expect
(
scr
[
0
]
!=
null
).
assertTrue
();
let
screen1
=
scr
[
0
];
screen1
.
setScreenActiveMode
(
-
5
).
then
(
res
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest2 setScreenActiveMode -5 res :
'
+
res
);
expect
(
!!
res
).
assertFalse
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetScreenActiveModeTest2 setScreenActiveMode -5 failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
done
();
})
})
})
/**
* @tc.number SUB_WMS_FAMODELISSHOWING_JSAPI_001
* @tc.name Test faModelIsShowingTest1.
* @tc.desc To verify the function of obtaining the display status when a window is hidden and then displayed.
*/
it
(
'
faModelIsShowingTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 getTopWindow wnd:
'
+
wnd
)
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
hide
().
then
(()
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.hide success
'
)
wnd
.
isShowing
().
then
(
data
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.isShowing data:
'
+
data
)
expect
(
!
data
).
assertTrue
();
wnd
.
show
().
then
(()
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.show success
'
)
wnd
.
isShowing
().
then
(
res
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.isShowing res:
'
+
res
)
expect
(
res
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.isShowing failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.show failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.isShowing failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 wnd.hide failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelIsShowingTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELGETDEFALUTDISPLAY_JSAPI_001
* @tc.name Test getDefaultDisplayTest1.
* @tc.desc To test the function of obtaining the default screen.
*/
it
(
'
faModelGetDefaultDisplayTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 begin
'
)
display
.
getDefaultDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 getDefaultDisplay id :
'
+
dsp
.
id
)
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 getDefaultDisplay refreshRate :
'
+
dsp
.
refreshRate
)
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 getDefaultDisplay width :
'
+
dsp
.
width
)
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 getDefaultDisplay height :
'
+
dsp
.
height
)
expect
(
dsp
.
id
!=
null
).
assertTrue
();
expect
(
dsp
.
refreshRate
!=
null
).
assertTrue
();
expect
(
dsp
.
width
!=
null
).
assertTrue
();
expect
(
dsp
.
height
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELGETALLDISPLAY_JSAPI_001
* @tc.name Test faModeGetAllDisplayTest1.
* @tc.desc To verify the function of obtaining all screens.
*/
it
(
'
faModelGetAllDisplayTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelGetAllDisplayTest1 begin
'
)
display
.
getAllDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
jsunittest faModelGetAllDisplayTest1 getDefaultDisplay id :
'
+
JSON
.
stringify
(
dsp
))
console
.
log
(
'
jsunittest faModelGetAllDisplayTest1 getDefaultDisplay id :
'
+
dsp
[
0
].
id
)
console
.
log
(
'
jsunittest faModelGetAllDisplayTest1 getDefaultDisplay refreshRate :
'
+
dsp
[
0
].
refreshRate
)
console
.
log
(
'
jsunittest faModelGetAllDisplayTest1 getDefaultDisplay width :
'
+
dsp
[
0
].
width
)
console
.
log
(
'
jsunittest faModelGetAllDisplayTest1 getDefaultDisplay height :
'
+
dsp
[
0
].
height
)
expect
(
dsp
[
0
].
id
!=
null
).
assertTrue
();
expect
(
dsp
[
0
].
refreshRate
!=
null
).
assertTrue
();
expect
(
dsp
[
0
].
width
!=
null
).
assertTrue
();
expect
(
dsp
[
0
].
height
!=
null
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelGetDefaultDisplayTest1 getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELCREATE_JSAPI_001
* @tc.name Test faModelGetAllDisplayTest1.
* @tc.desc To verify the function of creating an application subwindow.
*/
it
(
'
faModelCreateTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelCreateTest1 begin
'
)
window
.
create
(
'
subWindow
'
,
0
).
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelCreateTest1 create success wnd
'
+
wnd
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelCreateTest1 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELDESTROY_JSAPI_001
* @tc.name Test faModelDestroyTest1.
* @tc.desc Verify that a window is destroyed after being created.
*/
it
(
'
faModelDestroyTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelDestroyTest1 begin
'
)
window
.
create
(
'
subWindow2
'
,
0
).
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
console
.
log
(
'
jsunittest faModelDestroyTest1 create success wnd
'
+
wnd
);
wnd
.
destroy
().
then
(()
=>
{
console
.
log
(
'
jsunittest faModelDestroyTest1 destroy success
'
);
window
.
find
(
'
subWindow2
'
).
then
((
data
)
=>
{
console
.
log
(
'
jsunittest faModelDestroyTest1 window.find success, window :
'
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelDestroyTest1 find failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelCreateTest1 destroy failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelCreateTest1 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETSYSTEMBARENABLE_JSAPI_001
* @tc.name Test faModelSetSystemBarEnableTest1.
* @tc.desc To verify the function of setting a scenario that is visible to the system bar.
*/
it
(
'
faModelSetSystemBarEnableTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest1 begin
'
)
var
names
=
[
"
status
"
,
"
navigation
"
];
window
.
getTopWindow
().
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest1 setLayoutFullScreen(true) success
'
);
wnd
.
setSystemBarEnable
(
names
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest1 setSystemBarEnable success
'
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest1 setSystemBarEnable failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest1 setLayoutFullScreen failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarEnableTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELSETSYSTEMBARPROPERTIES_JSAPI_001
* @tc.name Test faModelSetSystemBarPropertiesTest1.
* @tc.desc To verify the function of setting system bar attributes.
*/
it
(
'
faModelSetSystemBarPropertiesTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest1 begin
'
)
var
SystemBarProperties
=
{
statusBarColor
:
'
#ff00ff
'
,
navigationBarColor
:
'
#00ff00
'
,
isStatusBarLightIcon
:
true
,
isNavigationBarLightIcon
:
false
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#00ffff
'
};
window
.
getTopWindow
().
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setSystemBarProperties
(
SystemBarProperties
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest1 setSystemBarProperties success
'
)
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest1 setSystemBarProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelSetSystemBarPropertiesTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELMINIMIZEALL_JSAPI_001
* @tc.name Test faModelMinimizeAllTest1.
* @tc.desc To verify the function of minimizing all windows on the default screen.
*/
it
(
'
faModelMinimizeAllTest1
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 begin
'
)
window
.
getTopWindow
().
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
display
.
getDefaultDisplay
().
then
(
dsp
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 getDefaultDisplay dspID :
'
+
dsp
.
id
);
window
.
minimizeAll
(
dsp
.
id
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 minimizeAll success
'
);
setTimeout
(()
=>
{
window
.
getTopWindow
().
then
((
wnd
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 getTopWindow success
'
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
120
);
wnd
.
show
().
then
(()
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 show success
'
);
expect
(
true
).
assertTrue
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 show failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
},
3000
)
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 minimizeAll failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 getDefaultDisplay failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FAMODELMINIMIZEALL_JSAPI_002
* @tc.name Test faModelMinimizeAllTest2.
* @tc.desc To verify the function of minimizing all windows on an invalid screen.
*/
it
(
'
faModelMinimizeAllTest2
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest2 begin
'
)
window
.
minimizeAll
(
-
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest2 minimizeAll success
'
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
jsunittest faModelMinimizeAllTest2 minimizeAll failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
130
);
done
();
})
})
})
\ No newline at end of file
graphic/windowstandard/src/main/js/default/test/window.test.js
浏览文件 @
aa56b29c
...
...
@@ -15,244 +15,1944 @@
import
app
from
'
@system.app
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
import
window
from
'
@ohos.window
'
import
screen
from
'
@ohos.screen
'
const
TRUE_WINDOW
=
true
;
describe
(
'
window_test
'
,
function
(){
describe
(
'
window_test
'
,
function
()
{
var
wnd
;
beforeAll
(
function
(){
var
windowTypeArr
=
[];
var
windowTypeDic
=
{
'
APP_WINDOW_BASE
'
:
1
,
'
APP_MAIN_WINDOW_BASE
'
:
1
,
'
WINDOW_TYPE_APP_MAIN_WINDOW
'
:
1
,
'
APP_MAIN_WINDOW_END
'
:
1
,
'
APP_SUB_WINDOW_BASE
'
:
1000
,
'
WINDOW_TYPE_MEDIA
'
:
1000
,
'
WINDOW_TYPE_APP_SUB_WINDOW
'
:
1001
,
'
APP_SUB_WINDOW_END
'
:
1001
,
'
APP_WINDOW_END
'
:
1001
,
'
SYSTEM_WINDOW_BASE
'
:
2000
,
'
BELOW_APP_SYSTEM_WINDOW_BASE
'
:
2000
,
'
WINDOW_TYPE_WALLPAPER
'
:
2000
,
'
WINDOW_TYPE_DESKTOP
'
:
2001
,
'
BELOW_APP_SYSTEM_WINDOW_END
'
:
2001
,
'
ABOVE_APP_SYSTEM_WINDOW_BASE
'
:
2100
,
'
WINDOW_TYPE_APP_LAUNCHING
'
:
2100
,
'
WINDOW_TYPE_DOCK_SLICE
'
:
2101
,
'
WINDOW_TYPE_INCOMING_CALL
'
:
2102
,
'
WINDOW_TYPE_SEARCHING_BAR
'
:
2103
,
'
WINDOW_TYPE_SYSTEM_ALARM_WINDOW
'
:
2104
,
'
WINDOW_TYPE_INPUT_METHOD_FLOAT
'
:
2105
,
'
WINDOW_TYPE_FLOAT
'
:
2106
,
'
WINDOW_TYPE_TOAST
'
:
2107
,
'
WINDOW_TYPE_STATUS_BAR
'
:
2108
,
'
WINDOW_TYPE_PANEL
'
:
2109
,
'
WINDOW_TYPE_KEYGUARD
'
:
2110
,
'
WINDOW_TYPE_VOLUME_OVERLAY
'
:
2111
,
'
WINDOW_TYPE_NAVIGATION_BAR
'
:
2112
,
'
WINDOW_TYPE_DRAGGING_EFFECT
'
:
2113
,
'
WINDOW_TYPE_POINTER
'
:
2114
,
'
WINDOW_TYPE_LAUNCHER_RECENT
'
:
2115
,
'
WINDOW_TYPE_LAUNCHER_DOCK
'
:
2116
,
'
ABOVE_APP_SYSTEM_WINDOW_END
'
:
2116
,
'
SYSTEM_WINDOW_END
'
:
2116
}
var
windowCount
=
2022
;
var
topWindow
=
null
;
const
DELAY_TIME
=
3000
;
var
listenerStatus
;
function
callback
(
data
)
{
listenerStatus
=
1
;
console
.
log
(
'
windowTest OnOffTest callback
'
+
JSON
.
stringify
(
data
)
+
'
listenerStatus :
'
+
listenerStatus
);
}
beforeAll
(
function
(
done
)
{
windowTypeArr
=
Object
.
keys
(
windowTypeDic
);
console
.
log
(
'
windowTest beforeAll begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest beforeAll window.getTopWindow wnd:
'
+
wnd
);
if
(
wnd
)
{
topWindow
=
wnd
;
}
else
{
console
.
log
(
'
windowTest beforeAll window.getTopWindow empty
'
);
}
},
(
err
)
=>
{
console
.
log
(
'
windowTest beforeAll window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
})
setTimeout
(()
=>
{
done
();
},
5000
);
})
beforeEach
(
function
(){
beforeEach
(
function
(
done
)
{
if
(
topWindow
)
{
topWindow
.
show
().
then
(()
=>
{
console
.
log
(
'
windowTest beforeEach wnd.show success
'
);
topWindow
.
getProperties
().
then
(
data
=>
{
if
(
data
.
isFullScreen
)
{
topWindow
.
setFullScreen
(
false
).
then
(()
=>
{
console
.
log
(
'
windowTest beforeEach wnd.setFullScreen(false) success
'
);
},
(
err
)
=>
{
console
.
log
(
'
windowTest beforeEach wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
})
}
},
(
err
)
=>
{
console
.
log
(
'
windowTest beforeEach wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest beforeEach wnd.show failed, err :
'
+
JSON
.
stringify
(
err
));
})
setTimeout
(()
=>
{
done
();
},
DELAY_TIME
);
}
else
{
done
();
}
})
afterEach
(
function
(){
afterEach
(
function
()
{
windowCount
++
;
})
afterAll
(
function
()
{
afterAll
(
function
()
{
})
/**
* @tc.number SUB_WINDOW_GETTOPWINDOW
_JSAPI_001
* @tc.name Test getTopWindowTest.
* @tc.desc Test window.getTopWindow API function test.
*/
it
(
'
get
TopWindowTest
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest getTopWindowTest begin
'
)
* @tc.number SUB_WMS_GETPROPERTIES
_JSAPI_001
* @tc.name Test getProperties_Test_001
* @tc.desc Get the current application main window properties
*/
it
(
'
get
Properties_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getPropertiesTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest getTopWindow wnd:
'
+
wnd
)
assertTrue
(
wnd
!=
null
)
console
.
log
(
'
windowTest getPropertiesTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest getPropertiesTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
type
!=
null
).
assertTrue
();
expect
(
data
.
windowRect
!=
null
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
expect
(
data
.
focusable
).
assertTrue
();
expect
(
data
.
touchable
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest getPropertiesTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest getPropertiesTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_001
* @tc.name Test movetest1.
* @tc.desc Test window.moveTo API function test1.
*/
it
(
'
moveTest1
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest movetest1 begin
'
)
* @tc.number SUB_WMS_GETPROPERTIES_JSAPI_002
* @tc.name Test getProperties_Test_002
* @tc.desc Get the current application main window properties
*/
it
(
'
getProperties_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest GetPropertiesTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest movetest1 getTopWindow wnd:
'
+
wnd
)
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest movetest1 wnd.moveTo(200, 200) success
'
)
console
.
log
(
'
windowTest GetPropertiesTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest GetPropertiesTest2 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
type
!=
null
).
assertTrue
();
expect
(
data
.
windowRect
!=
null
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
expect
(
data
.
focusable
).
assertTrue
();
expect
(
data
.
touchable
).
assertTrue
();
done
();
}
})
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_002
* @tc.name Test moveTest2.
* @tc.desc Test window.moveTo API function test2.
*/
it
(
'
moveTest2
'
,
0
,
function
(){
console
.
log
(
'
jsunittest movetest2 begin
'
)
* @tc.number SUB_WMS_GETAVOIDAREA_JSAPI_001
* @tc.name Test getAvoidArea_Test_001
* @tc.desc Get SystemUI type avoidance area
*/
it
(
'
getAvoidArea_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getAvoidAreaTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
window
.
AvoidAreaType
.
TYPE_SYSTEM
).
then
((
data
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest1 wnd.getAvoidArea success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest1 wnd.getAvoidArea failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_GETAVOIDAREA_JSAPI_002
* @tc.name Test getAvoidArea_Test_002
* @tc.desc Get Notch type avoidance area
*/
it
(
'
getAvoidArea_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getAvoidAreaTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest movetest2 getTopWindow wnd:
'
+
wnd
)
wnd
.
moveTo
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest movetest2 wnd.moveTo(100, 100) success
'
)
console
.
log
(
'
windowTest getAvoidAreaTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
window
.
AvoidAreaType
.
TYPE_CUTOUT
).
then
((
data
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest2 wnd.getAvoidArea success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest2 wnd.getAvoidArea failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
wnd
.
moveTo
(
0
,
0
).
then
(()
=>
{
console
.
log
(
'
jsunittest movetest2 wnd.moveTo(0, 0) success
'
)
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest2 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_GETAVOIDAREA_JSAPI_003
* @tc.name Test getAvoidArea_Test_003
* @tc.desc Get system gesture type avoidance area
*/
it
(
'
getAvoidArea_Test_003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getAvoidAreaTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest3 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
3
).
then
((
data
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest3 wnd.getAvoidArea success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest3 wnd.getAvoidArea failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest3 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_003
* @tc.name Test moveTest3.
* @tc.desc Test window.moveTo API function test3.
*/
it
(
'
moveTest3
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest movetest3 begin
'
)
* @tc.number SUB_WMS_GETAVOIDAREA_JSAPI_004
* @tc.name Test getAvoidArea_Test_004
* @tc.desc Get System type avoidance area
*/
it
(
'
getAvoidArea_Test_004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getAvoidAreaTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest movetest3 getTopWindow wnd:
'
+
wnd
)
wnd
.
moveTo
(
20000
,
20000
).
then
(()
=>
{
console
.
log
(
'
jsunittest movetest3 wnd.moveTo(20000, 20000) success
'
)
console
.
log
(
'
windowTest getAvoidAreaTest4 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
window
.
AvoidAreaType
.
TYPE_SYSTEM
,
(
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest getAvoidAreaTest4 wnd.getAvoidArea callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
done
();
}
})
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_004
* @tc.name Test moveTest4.
* @tc.desc Test window.moveTo API function test4.
*/
it
(
'
moveTest4
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest movetest4 begin
'
)
* @tc.number SUB_WMS_GETAVOIDAREA_JSAPI_005
* @tc.name Test getAvoidArea_Test_005
* @tc.desc Get Cutout type avoidance area
*/
it
(
'
getAvoidArea_Test_005
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getAvoidAreaTest5 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest movetest4 getTopWindow wnd:
'
+
wnd
)
wnd
.
moveTo
(
-
200
,
-
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest movetest4 wnd.moveTo(-200, -200) success
'
)
console
.
log
(
'
windowTest getAvoidAreaTest5 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
window
.
AvoidAreaType
.
TYPE_CUTOUT
,
(
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest getAvoidAreaTest5 wnd.getAvoidArea callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
console
.
log
(
'
windowTest getAvoidAreaTest5 wnd.getAvoidArea callback end
'
);
done
();
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest5 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_MOVETO_JSAPI_005
* @tc.name Test moveTest5.
* @tc.desc Test window.moveTo API function test5.
*/
it
(
'
moveTest5
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest movetest5 begin
'
)
* @tc.number SUB_WMS_GETAVOIDAREA_JSAPI_006
* @tc.name Test getAvoidArea_Test_006
* @tc.desc Get system gesture type avoidance area
*/
it
(
'
getAvoidArea_Test_006
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getAvoidAreaTest6 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest movetest5 getTopWindow wnd:
'
+
wnd
)
for
(
var
i
=
1
;
i
<=
5
;
i
++
)
{
wnd
.
moveTo
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest movetest5 wnd.movetest5(100, 100) success, count:"%d
\n
"
'
,
i
)
console
.
log
(
'
windowTest getAvoidAreaTest6 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
getAvoidArea
(
3
,
(
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest getAvoidAreaTest6 wnd.getAvoidArea callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
topRect
!=
null
).
assertTrue
();
expect
(
data
.
rightRect
!=
null
).
assertTrue
();
expect
(
data
.
bottomRect
!=
null
).
assertTrue
();
expect
(
data
.
leftRect
!=
null
).
assertTrue
();
done
();
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest getAvoidAreaTest6 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETFULLSCREEN_JSAPI_001
* @tc.name Test setFullScreen_Test_001
* @tc.desc Set the window to be non-fullscreen first and then fullscreen
*/
it
(
'
setFullScreen_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest setFullScreenTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
!=
null
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setFullScreen
(
true
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
!=
null
).
assertTrue
();
expect
(
data
.
isFullScreen
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 wnd.setFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETFULLSCREEN_JSAPI_002
* @tc.name Test setFullScreen_Test_002
* @tc.desc Set the window to be non-fullscreen first and then fullscreen.
*/
it
(
'
setFullScreen_Test_002
'
,
0
,
async
function
(
done
)
{
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetFullScreenTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetFullScreenTest2 window.setFullScreen(false) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetFullScreenTest2 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetFullScreenTest2 window.setFullScreen(true) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetFullScreenTest2 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
isFullScreen
).
assertTrue
();
console
.
log
(
'
windowTest SetFullScreenTest2 window.getProperties callback end
'
);
done
();
}
})
}
})
}
})
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setFullScreenTest1 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test setLayoutFullScreen_Test_001
* @tc.desc Set window and layout to full screen
*/
it
(
'
setLayoutFullScreen_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
true
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
!=
null
).
assertTrue
();
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 wnd.setLayoutFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 wnd.setFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest1 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test setLayoutFullScreen_Test_002
* @tc.desc Set window and layout to full screen.
*/
it
(
'
setLayoutFullScreen_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
true
,
(
err
)
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 wnd.setFullScreen(true) callback begin
'
);
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 wnd.setFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 wnd.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 wnd.setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 wnd.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 wnd.getProperties callback end
'
);
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
}
})
}
})
}
})
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest2 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_003
* @tc.name Test setLayoutFullScreen_Test_003
* @tc.desc Set the window to full screen, the layout is not full screen
*/
it
(
'
setLayoutFullScreen_Test_003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
true
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
!=
null
).
assertTrue
();
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 wnd.setLayoutFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 wnd.setFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest3 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_004
* @tc.name Test setLayoutFullScreen_Test_004
* @tc.desc Set the window to full screen, the layout is not full screen
*/
it
(
'
setLayoutFullScreen_Test_004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 wnd.setFullScreen(true) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 wnd.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 wnd.setLayoutFullScreen(false) callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 wnd.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 wnd.getProperties callback end
'
);
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
}
})
}
})
}
})
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest4 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_005
* @tc.name Test setLayoutFullScreen_Test_005
* @tc.desc Set the window to be non-full-screen and the layout to be full-screen
*/
it
(
'
setLayoutFullScreen_Test_005
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
!=
null
).
assertTrue
();
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 wnd.setLayoutFullScreen(true) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest5 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_006
* @tc.name Test setLayoutFullScreen_Test_006
* @tc.desc Set the window to be non-full-screen and the layout to be full-screen.
*/
it
(
'
setLayoutFullScreen_Test_006
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 wnd.setFullScreen fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 wnd.getProperties fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 wnd.setLayoutFullScreen fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 wnd.getProperties fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
}
})
}
})
}
})
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest6 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_007
* @tc.name Test setLayoutFullScreen_Test_007
* @tc.desc Setting windows and layouts to be non-fullscreen
*/
it
(
'
setLayoutFullScreen_Test_007
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
).
then
(()
=>
{
wnd
.
getProperties
().
then
((
data
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 wnd.getProperties success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 wnd.setLayoutFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 wnd.getProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 wnd.setFullScreen(false) failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreenTest7 window.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETLAYOUTFULLSCREEN_JSAPI_008
* @tc.name Test setLayoutFullScreen_Test_008
* @tc.desc Setting window and layouts to be non-fullscreen.
*/
it
(
'
setLayoutFullScreen_Test_008
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest8 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest8 window.getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest8 window.setFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest8 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
!
data
.
isFullScreen
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest8 window.setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getProperties
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetLayoutFullScreenTest8 window.getProperties callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
!
data
.
isLayoutFullScreen
).
assertTrue
();
done
();
}
})
}
})
}
})
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest setLayoutFullScreen_Test_008 window.getTopWindow fail :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FIND_JSAPI_001
* @tc.name Test find_Test_001
* @tc.desc Query main window
*/
it
(
'
find_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest findTest1 begin
'
);
window
.
find
(
'
window0
'
).
then
((
data
)
=>
{
console
.
log
(
'
windowTest findTest1 wnd.find success, data :
'
+
JSON
.
stringify
(
data
));
expect
(
data
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest findTest1 wnd.find failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_FIND_JSAPI_002
* @tc.name Test find_Test_002
* @tc.desc Query for non-existing windows
*/
it
(
'
find_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest findTest2 begin
'
);
window
.
find
(
'
nonexist
'
).
then
((
window
)
=>
{
console
.
log
(
'
windowTest findTest2 wnd.find success, window :
'
+
JSON
.
stringify
(
window
));
expect
().
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest findTest2 wnd.find failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
})
})
/**
* @tc.number SUB_WMS_FIND_JSAPI_004
* @tc.name Test find_Test_003
* @tc.desc Query main window.
*/
it
(
'
find_Test_003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest findTest3 begin
'
);
window
.
find
(
'
window0
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest findTest3 wnd.find fail, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest findTest3 wnd.find fail
'
);
expect
(
data
!=
null
).
assertTrue
();
done
();
}
})
})
/**
* @tc.number SUB_WINDOW_RESETSIZE_JSAPI_001
* @tc.name Test resetSizeTest1.
* @tc.desc Test window.resetSize API function test1.
*/
it
(
'
resetSizeTest1
'
,
0
,
function
(){
console
.
log
(
'
jsunittest resetSizeTest1 begin
'
)
* @tc.number SUB_WMS_FIND_JSAPI_004
* @tc.name Test find_Test_004
* @tc.desc Query for non-existing windows
*/
it
(
'
find_Test_004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest findTest4 begin
'
);
window
.
find
(
'
nonexist
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest findTest4 wnd.find fail, err :
'
+
JSON
.
stringify
(
err
));
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
else
{
console
.
log
(
'
windowTest findTest4 wnd.find success
'
);
expect
().
assertFail
();
done
();
}
})
})
/**
* @tc.number SUB_WMS_ONOFF_JSAPI_001
* @tc.name Test OnOff_Test_001.
* @tc.desc To verify the function of enabling and disabling intercepting when the window size changes.
*/
it
(
'
OnOff_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest OnOffTest1 begin
'
);
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest OnOffTest1 getTopWindow fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
data
.
on
(
'
windowSizeChange
'
,
callback
);
data
.
setLayoutFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest OnOffTest1 setLayoutFullScreen fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
setTimeout
((
async
function
()
{
expect
(
listenerStatus
).
assertEqual
(
1
);
data
.
off
(
'
windowSizeChange
'
)
listenerStatus
=
0
;
data
.
setLayoutFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
||
listenerStatus
==
1
)
{
console
.
log
(
'
windowTest OnOffTest1 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest OnOffTest1 listenerStatus 3:
'
+
listenerStatus
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
})
}),
3000
)
}
})
}
})
})
/**
* @tc.number SUB_WMS_ONOFF_JSAPI_002
* @tc.name Test OnOff_Test_002
* @tc.desc To verify the function of enabling and disabling lawful interception in the system and window
*/
it
(
'
OnOff_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest OnOffTest2 begin
'
)
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest OnOffTest2 getTopWindow callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
data
.
on
(
'
systemAvoidAreaChange
'
,
callback
);
data
.
setFullScreen
(
true
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest OnOffTest2 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
setTimeout
((
async
function
()
{
console
.
log
(
'
windowTest OnOffTest2 listenerStatus 111:
'
+
listenerStatus
);
expect
(
listenerStatus
).
assertEqual
(
1
);
data
.
off
(
'
systemAvoidAreaChange
'
)
listenerStatus
=
0
;
data
.
setFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
!=
0
||
listenerStatus
==
1
)
{
console
.
log
(
'
windowTest OnOffTest2 setLayoutFullScreen callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest OnOffTest2 off callback success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
})
}),
3000
)
}
})
}
})
})
/**
* @tc.number SUB_WMS_ISSHOWING_JSAPI_001
* @tc.name Test IsShowing_Test_001.
* @tc.desc To verify the function of obtaining the display status when a window is hidden and then displayed.
*/
it
(
'
IsShowing_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest IsShowingTest1 begin
'
);
window
.
create
(
'
isShow1
'
,
window
.
WindowType
.
TYPE_APP
).
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
isShowing
().
then
(
res
=>
{
console
.
log
(
'
windowTest IsShowingTest1 wnd.isShowing data:
'
+
res
);
expect
(
!
res
).
assertTrue
();
wnd
.
show
().
then
(()
=>
{
wnd
.
isShowing
().
then
(
res
=>
{
expect
(
res
).
assertTrue
();
wnd
.
destroy
().
then
(()
=>
{
expect
(
wnd
==
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest IsShowingTest1 wnd.destroy failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest IsShowingTest1 wnd.isShowing failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest IsShowingTest1 wnd.show failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest IsShowingTest1 wnd.isShowing failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
})
/**
* @tc.number SUB_WMS_ISSHOWING_JSAPI_002
* @tc.name Test IsShowing_Test_002.
* @tc.desc To verify the function of obtaining the display status when a window is hidden and then displayed.
*/
it
(
'
IsShowing_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest IsShowingTest2 begin
'
);
window
.
create
(
'
isShow2
'
,
window
.
WindowType
.
TYPE_APP
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest IsShowingTest2 window.create fail err
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
data
.
isShowing
((
err
,
res1
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest IsShowingTest2 data.isShowing fail err
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
!
res1
).
assertTrue
();
data
.
show
(()
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest IsShowingTest2 data.show fail err
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
data
.
isShowing
((
err
,
res2
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest IsShowingTest2 data.show fail err
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
res2
).
assertTrue
();
done
();
data
.
destroy
((
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest IsShowingTest2 data.show fail err
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
==
null
).
assertTrue
();
done
();
}
})
}
})
}
})
}
})
}
})
})
/**
* @tc.number SUB_WMS_SETCOLORSPACE_JSAPI_001
* @tc.name Test SetColorSpace_Test_001
* @tc.desc To verify the setting of the wide color gamut color space
*/
it
(
'
SetColorSpace_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetColorSpaceTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest1 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
window
.
ColorSpace
.
WIDE_GAMUT
).
then
(()
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest1 setColorSpace WIDE_GAMUT
'
);
wnd
.
getColorSpace
().
then
(
res
=>
{
expect
(
res
==
1
).
assertTrue
();
console
.
log
(
'
windowTest SetColorSpaceTest1 setColorSpace WIDE_GAMUT success
'
);
wnd
.
isSupportWideGamut
().
then
(
data
=>
{
expect
(
data
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest1 wnd.isSupportWideGamut failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest1 wnd.getColorSpace failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest1 wnd.setColorSpace failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETCOLORSPACE_JSAPI_002
* @tc.name Test SetColorSpace_Test_002
* @tc.desc To verify that the color space of invaild values is set successfully
*/
it
(
'
SetColorSpace_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetColorSpaceTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest2 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
-
5
).
then
(()
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest2 setColorSpace -5
'
);
expect
().
assertFail
();
done
();
},(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest2 wnd.setColorSpace failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
130
);
done
();
})
},(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest2 wnd.getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETCOLORSPACE_JSAPI_003
* @tc.name Test SetColorSpace_Test_003
* @tc.desc To verify the setting of the wide color gamut color space
*/
it
(
'
SetColorSpace_Test_003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetColorSpaceTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest3 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
window
.
ColorSpace
.
WIDE_GAMUT
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetColorSpaceTest3 setColorSpace fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
wnd
.
getColorSpace
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetColorSpaceTest3 getColorSpace fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
==
1
).
assertTrue
();
wnd
.
isSupportWideGamut
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetColorSpaceTest3 getColorSpace callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
).
assertTrue
();
done
();
}
})
}
})
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest3 getTopWindow failed,err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETCOLORSPACE_JSAPI_004
* @tc.name Test SetColorSpace_Test_004
* @tc.desc To verify that the color space of invalid values is set successfully
*/
it
(
'
SetColorSpace_Test_004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetColorSpaceTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest resetSizeTest1 getTopWindow wnd:
'
+
wnd
)
wnd
.
resetSize
(
200
,
600
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTes1t wnd.resetSize(200, 600) success
'
)
console
.
log
(
'
windowTest SetColorSpaceTest4 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setColorSpace
(
-
5
,
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest4 setColorSpace callback begin
'
+
JSON
.
stringify
(
err
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetColorSpaceTest4 setColorSpace callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
}
else
{
expect
().
assertFail
();
done
();
}
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetColorSpaceTest4 getTopWindow failed,err:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_CREATE_JSAPI_001
* @tc.name Test Create_Test_001.
* @tc.desc To verify the function of creating an application subwindow.
*/
it
(
'
Create_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest CreateTest1 begin
'
);
window
.
create
(
'
subWindow
'
,
window
.
WindowType
.
TYPE_APP
).
then
(
wnd
=>
{
console
.
log
(
'
windowTest CreateTest1 create success wnd
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest CreateTest1 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_RESETSIZE_JSAPI_002
* @tc.name Test resetSizeTest2.
* @tc.desc Test window.resetSize API function test2.
* @tc.number SUB_WMS_CREATE_JSAPI_001
* @tc.name Test Create_Test_002
* @tc.desc To verify the function of creating an application subwindow
*/
it
(
'
Create_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest CreateTest2 begin
'
);
window
.
create
(
'
subWindow1
'
,
window
.
WindowType
.
TYPE_APP
,
(
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest CreateTest2 create callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
console
.
log
(
'
windowTest CreateTest2 callback create success data
'
+
data
);
done
();
}
})
})
/**
* @tc.number SUB_WMS_DESTROY_JSAPI_001
* @tc.name Test Destroy_Test_001
* @tc.desc Verify that a window is destroyed after being created
*/
it
(
'
Destroy_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest DestroyTest1 begin
'
);
window
.
create
(
'
subWindow2
'
,
window
.
WindowType
.
TYPE_APP
).
then
(
wnd
=>
{
console
.
log
(
'
windowTest DestroyTest1 create success wnd
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
destroy
().
then
(()
=>
{
window
.
find
(
'
subWindow2
'
).
then
((
data
)
=>
{
console
.
log
(
'
windowTest DestroyTest1 window.find success, window :
'
+
JSON
.
stringify
(
data
));
expect
().
assertFail
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest DestroyTest1 find failed, err :
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest CreateTest1 destroy failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest CreateTest1 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_DESTROY_JSAPI_002
* @tc.name Test Destroy_Test_002
* @tc.desc Verify that a window is destroyed after being created
*/
it
(
'
Destroy_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest DestroyTest2 begin
'
);
window
.
create
(
'
subWindow2
'
,
window
.
WindowType
.
TYPE_APP
,
(
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest DestroyTest2 create callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
data
.
destroy
((
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest DestroyTest2 create callback fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
window
.
find
(
'
subWindow2
'
,
(
err
,
data
)
=>
{
console
.
log
(
'
windowTest DestroyTest2 find callback begin
'
+
JSON
.
stringify
(
data
));
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest DestroyTest2 find callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
(
err
.
code
).
assertEqual
(
120
);
done
();
}
else
{
console
.
log
(
'
windowTest DestroyTest2 find suceess,err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
})
}
})
}
})
})
/**
* @tc.number SUB_WMS_SETSYSTEMBARENABLE_JSAPI_001
* @tc.name Test SetSystemBarEnable_Test_001
* @tc.desc To verify the function of setting a scenario that is visible to the system bar
*/
it
(
'
SetSystemBarEnable_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetSystemBarEnableTest1 begin
'
);
var
names
=
[
"
status
"
,
"
navigation
"
];
window
.
getTopWindow
().
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setLayoutFullScreen
(
true
).
then
(()
=>
{
wnd
.
setSystemBarEnable
(
names
).
then
(()
=>
{
console
.
log
(
'
windowTest SetSystemBarEnableTest1 setSystemBarEnable success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetSystemBarEnableTest1 setSystemBarEnable failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetSystemBarEnableTest1 setLayoutFullScreen failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest SetSystemBarEnableTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETSYSTEMBARENABLE_JSAPI_002
* @tc.name Test SetSystemBarEnable_Test_002
* @tc.desc To verify the function of setting a scenario that is visible to the system bar
*/
it
(
'
SetSystemBarEnable_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetSystemBarEnableTest2 begin
'
);
var
names
=
[
"
status
"
,
"
navigation
"
];
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetSystemBarEnableTest2 getTopWindow fail:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
data
.
setSystemBarEnable
(
names
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetSystemBarEnableTest2 getTopWindow fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest SetSystemBarEnableTest2 setSystemBarEnable success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
})
}
})
})
/**
* @tc.number SUB_WMS_SETSYSTEMBARPROPERTIES_JSAPI_001
* @tc.name Test SetSystemBarProperties_Test_001
* @tc.desc To verify the function of setting system bar attributes
*/
it
(
'
SetSystemBarProperties_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest1 begin
'
);
var
SystemBarProperties
=
{
statusBarColor
:
'
#ff00ff
'
,
navigationBarColor
:
'
#00ff00
'
,
isStatusBarLightIcon
:
true
,
isNavigationBarLightIcon
:
false
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#00ffff
'
};
window
.
getTopWindow
().
then
(
wnd
=>
{
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
setSystemBarProperties
(
SystemBarProperties
).
then
(()
=>
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest1 setSystemBarProperties success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},(
err
)
=>
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest1 setSystemBarProperties failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},(
err
)
=>
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETSYSTEMBARPROPERTIES_JSAPI_002
* @tc.name Test SetSystemBarProperties_Test_002
* @tc.desc To verify the function of setting system bar attributes
*/
it
(
'
SetSystemBarProperties_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest2 begin
'
);
var
SystemBarProperties
=
{
statusBarColor
:
'
#ff00ff
'
,
navigationBarColor
:
'
#00ff00
'
,
isStatusBarLightIcon
:
true
,
isNavigationBarLightIcon
:
false
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#00ffff
'
};
window
.
getTopWindow
((
err
,
data
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest2 getTopWindow fail:
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
data
!=
null
).
assertTrue
();
data
.
setSystemBarProperties
(
SystemBarProperties
,
(
err
)
=>
{
if
(
err
.
code
!=
0
)
{
console
.
log
(
'
windowTest SetSystemBarPropertiesTest2 setSystemBarProperties fail
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
}
else
{
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
})
}
})
})
/**
* @tc.number SUB_WMS_MOVETO_JSAPI_007
* @tc.name Test move_Test_001
* @tc.desc Verify the scene where the window moves
*/
it
(
'
move_Test_001
'
,
0
,
function
()
{
console
.
log
(
'
windowTest moveTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest moveTest1 getTopWindow wnd
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
200
,
200
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest moveTest1 moveTo callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest moveTest1 moveTo callback success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
})
})
})
/**
* @tc.number SUB_WMS_MOVETO_JSAPI_002
* @tc.name Test move_Test_002
* @tc.desc Verify the scene where the window moves
*/
it
(
'
resetSizeTest2
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest resetSizeTest2 begin
'
)
it
(
'
move_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest resetSizeTest2 getTopWindow wnd:
'
+
wnd
)
wnd
.
resetSize
(
20000
,
20000
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTest2 wnd.resetSize(20000, 20000) success
'
)
console
.
log
(
'
windowTest moveTest2 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
windowTest moveTest2 wnd.moveTo success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest2 wnd.moveTo failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest2 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_W
INDOW_RESETSIZE
_JSAPI_003
* @tc.name Test
resetSizeTest3.
* @tc.desc
Test window.resetSize API function test3.
* @tc.number SUB_W
MS_MOVETO
_JSAPI_003
* @tc.name Test
move_Test_003
* @tc.desc
Verify the scene where the window moves
*/
it
(
'
resetSizeTest3
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest resetSizeTest3 begin
'
)
it
(
'
move_Test_003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest resetSizeTest3 getTopWindow wnd:
'
+
wnd
)
wnd
.
resetSize
(
0
,
0
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTest3 wnd.resetSize(0, 0) success
'
)
console
.
log
(
'
windowTest moveTest3 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
20000
,
20000
).
then
(()
=>
{
console
.
log
(
'
windowTest moveTest3 wnd.moveTo success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest3 wnd.moveTo failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest3 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_W
INDOW_RESETSIZE
_JSAPI_004
* @tc.name Test
resetSizeTest4.
* @tc.desc
Test window.resetSize API function test4.
* @tc.number SUB_W
MS_MOVETO
_JSAPI_004
* @tc.name Test
move_Test_004
* @tc.desc
Verify the scene where the window moves
*/
it
(
'
resetSizeTest4
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest resetSizeTest4 begin
'
)
it
(
'
move_Test_004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest resetSizeTest4 getTopWindow wnd:
'
+
wnd
)
wnd
.
resetSize
(
-
1
,
-
1
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTest4 wnd.resetSize(-1, -1) success
'
)
console
.
log
(
'
windowTest moveTest4 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
-
200
,
-
200
).
then
(()
=>
{
console
.
log
(
'
windowTest moveTest4 wnd.moveTo success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest4 wnd.moveTo failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest4 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_W
INDOW_RESETSIZE
_JSAPI_005
* @tc.name Test
resetSizeTest5.
* @tc.desc
Test window.resetSize API function test5.
* @tc.number SUB_W
MS_MOVETO
_JSAPI_005
* @tc.name Test
move_Test_005
* @tc.desc
Verify that the window is moved into the normal scene
*/
it
(
'
resetSizeTest5
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest resetSizeTest5 begin
'
)
it
(
'
move_Test_005
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTest5 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest resetSizeTest5 getTopWindow wnd:
'
+
wnd
)
console
.
log
(
'
windowTest moveTest5 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
for
(
var
i
=
1
;
i
<=
5
;
i
++
)
{
wnd
.
resetSize
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest resetSizeTest5 wnd.resetSize(100, 100) success, count:"%d
\n
"
'
,
i
)
wnd
.
moveTo
(
100
,
100
).
then
(()
=>
{
expect
(
TRUE_WINDOW
).
assertTrue
();
},(
err
)
=>
{
console
.
log
(
'
windowTest moveTest5 wnd.moveTo failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}
console
.
log
(
'
windowTest moveTest5 end
'
);
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest5 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_W
INDOW_SETWINDOWTYPE
_JSAPI_001
* @tc.name Test
setWindowTypeTest1.
* @tc.desc
Test window.setWindowType API function test1.
* @tc.number SUB_W
MS_MOVETO
_JSAPI_001
* @tc.name Test
move_Test_006
* @tc.desc
Verify that the window is moved into the normal scene
*/
it
(
'
setWindowTypeTest1
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest setWindowTypeTest1 begin
'
)
it
(
'
move_Test_006
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTest6 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest1 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_APP
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest1 wnd.setWindowType(0) success
'
)
console
.
log
(
'
windowTest moveTest6 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
windowTest moveTest6 wnd.moveTo success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest6 wnd.moveTo failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest6 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_002
* @tc.name Test setWindowTypeTest2.
* @tc.desc Test window.setWindowType API function test2.
* @tc.number SUB_WMS_MOVETO_JSAPI_007
* @tc.name Test move_Test_007
* @tc.desc Verify the scene where the window moves
*/
it
(
'
move_Test_007
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTestNegative begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest moveTestNegative getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
-
200
,
-
200
).
then
(()
=>
{
console
.
log
(
'
moveTo(-200,-200) success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTestNegative moveTo failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTestNegative getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_MOVETO_JSAPI_008
* @tc.name Test move_Test_008
* @tc.desc Verify the scene where the window moves
*/
it
(
'
move_Test_008
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest moveTest8 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest moveTest8 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
moveTo
(
-
200
,
200
).
then
(()
=>
{
wnd
.
moveTo
(
200
,
-
300
).
then
(()
=>
{
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest8 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest8 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest moveTest8 create failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_RESETSIZE_JSAPI_001
* @tc.name Test resetSize_Test_001
* @tc.desc Verify the scene where the window resets size
*/
it
(
'
setWindowTypeTest2
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest setWindowTypeTest2 begin
'
)
it
(
'
resetSize_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest resetSizeTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest2 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_APP
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest2 wnd.setWindowType(0) success
'
)
console
.
log
(
'
windowTest resetSizeTest1 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
resetSize
(
200
,
600
).
then
(()
=>
{
console
.
log
(
'
windowTest resetSizeTest1 wnd.resetSize(200, 600) success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest1 wnd.resetSize failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
wnd
.
moveTo
(
200
,
200
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest2 wnd.moveTo(200, 200) success
'
)
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_RESETSIZE_JSAPI_002
* @tc.name Test resetSize_Test_002
* @tc.desc Verify the scene where the window resets size
*/
it
(
'
resetSize_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest resetSizeTest2 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest resetSizeTest2 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
resetSize
(
20000
,
20000
).
then
(()
=>
{
console
.
log
(
'
windowTest resetSizeTest2 wnd.resetSize(20000, 20000) success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest2 wnd.resetSize failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest2 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_W
INDOW_SETWINDOWTYP
E_JSAPI_003
* @tc.name Test
setWindowTypeTest3.
* @tc.desc
Test window.setWindowType API function test3.
* @tc.number SUB_W
MS_RESETSIZ
E_JSAPI_003
* @tc.name Test
resetSize_Test_003
* @tc.desc
Verify the scene where the window resets size
*/
it
(
'
setWindowTypeTest3
'
,
0
,
function
()
{
console
.
log
(
'
jsunittest setWindowTypeTest3 begin
'
)
it
(
'
resetSize_Test_003
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest resetSizeTest3 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest3 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
window
.
WindowType
.
TYPE_APP
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest3 wnd.setWindowType(0) success
'
)
console
.
log
(
'
windowTest resetSizeTest3 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
resetSize
(
0
,
0
).
then
(()
=>
{
console
.
log
(
'
windowTest resetSizeTest3 wnd.resetSize(0, 0) success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest3 wnd.resetSize failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
wnd
.
resetSize
(
200
,
400
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest3 wnd.resetSize(200, 400) success
'
)
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest3 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_RESETSIZE_JSAPI_004
* @tc.name Test resetSize_Test_004
* @tc.desc Verify the scene where the window resets size
*/
it
(
'
resetSize_Test_004
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest resetSizeTest4 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest resetSizeTest4 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
resetSize
(
-
1
,
-
1
).
then
(()
=>
{
console
.
log
(
'
windowTest resetSizeTest4 wnd.resetSize(-1, -1) success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest4 wnd.resetSize failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest4 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_W
INDOW_SETWINDOWTYPE_JSAPI_004
* @tc.name Test
setWindowTypeTest4.
* @tc.desc
Test window.setWindowType API function test4.
* @tc.number SUB_W
MS_RESETSIZE_JSAPI_005
* @tc.name Test
resetSize_Test_005
* @tc.desc
Verify the scene where the window resets size
*/
it
(
'
setWindowTypeTest4
'
,
0
,
function
(){
console
.
log
(
'
jsunittest setWindowTypeTest4 begin
'
)
it
(
'
resetSize_Test_005
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest resetSizeTest5 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest resetSizeTest5 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
for
(
var
i
=
1
;
i
<=
5
;
i
++
)
{
wnd
.
resetSize
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
windowTest resetSizeTest5 wnd.resetSize(100, 100) success, count:"%d
\n
"
'
,
i
);
expect
(
TRUE_WINDOW
).
assertTrue
();
},(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest5 wnd.resetSize failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
})
}
console
.
log
(
'
windowTest resetSizeTest5 end
'
);
done
();
},
(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeTest5 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_RESETSIZETEST_JSAPI_006
* @tc.name Test resetSize_Test_006
* @tc.desc Verify the scene where the window resets size
*/
it
(
'
resetSize_Test_006
'
,
0
,
function
()
{
console
.
log
(
'
windowTest ResetSizeTest6 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest4 getTopWindow wnd:
'
+
wnd
)
wnd
.
setWindowType
(
1
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest4 wnd.setWindowType(1) success
'
)
console
.
log
(
'
windowTest ResetSizeTest6 getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
wnd
.
resetSize
(
200
,
200
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
log
(
'
windowTest ResetSizeTest6 resetSize callback fail
'
+
JSON
.
stringify
(
err
.
code
));
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
'
windowTest ResetSizeTest6 resetSize callback success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
done
();
}
})
wnd
.
moveTo
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest4 wnd.moveTo(100, 100) success
'
)
})
})
/**
* @tc.number SUB_WMS_RESETSIZE_JSAPI_007
* @tc.name Test resetSize_Test_007
* @tc.desc Verify the scene where the window resets size
*/
it
(
'
resetSize_Test_007
'
,
0
,
async
function
(
done
)
{
var
width
=
100
;
var
height
=
100
;
console
.
log
(
'
windowTest resetSizeLoop begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest resetSizeLoop getTopWindow wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
for
(
let
i
=
1
;
i
<=
5
;
i
++
)
{
width
=
width
*
i
;
height
=
height
*
i
;
wnd
.
resetSize
(
width
,
height
).
then
(()
=>
{
console
.
log
(
'
windowTest resetSizeTestLoop success
'
);
expect
(
TRUE_WINDOW
).
assertTrue
();
},(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeLoop resetSize failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
}
console
.
log
(
'
windowTest resetSizeLoop end
'
);
done
();
},(
err
)
=>
{
console
.
log
(
'
windowTest resetSizeLoop getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_GETTOPWINDOW_JSAPI_001
* @tc.name Test getTopWindow_Test_001
* @tc.desc Verify the scene that gets the top window
*/
it
(
'
getTopWindow_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
windowTest getTopWindowTest1 begin
'
);
window
.
getTopWindow
().
then
(
wnd
=>
{
console
.
log
(
'
windowTest getTopWindowTest1 wnd:
'
+
wnd
);
expect
(
wnd
!=
null
).
assertTrue
();
done
();
},(
err
)
=>
{
console
.
log
(
'
windowTest getTopWindowTest1 getTopWindow failed, err :
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
})
/**
* @tc.number SUB_WMS_SETSCREENACTIVEMODE_JSAPI_001
* @tc.name Test setScreenActiveMode_Test_001.
* @tc.desc To set the function of setting screen parameters
*/
it
(
'
setScreenActiveMode_Test_001
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest1 begin
'
);
screen
.
getAllScreen
().
then
(
src
=>
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest1 getAllScreen src
'
+
src
);
expect
(
src
[
0
]
!=
null
).
assertTrue
();
let
screenIndex
=
src
[
0
];
screenIndex
.
setScreenActiveMode
(
0
).
then
(
res
=>
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest1 setScreenActiveMode 0 res:
'
+
res
);
expect
(
res
).
assertTrue
();
done
();
},(
err
)
=>
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest1 setScreenActiveMode 0 failed: err
'
+
JSON
.
stringify
(
err
));
expect
().
assertFail
();
done
();
})
wnd
.
resetSize
(
100
,
100
).
then
(()
=>
{
console
.
log
(
'
jsunittest setWindowTypeTest4 wnd.resetSize(100, 100) success
'
)
},
(
err
)
=>
{
console
.
log
(
'
screenshotTest getActiveModeTest1 failed: err:
'
+
JSON
.
stringify
(
err
))
})
})
/**
* @tc.number SUB_WMS_SETSCREENACTIVEMODE_JSAPI_002
* @tc.name Test setScreenActiveMode_Test_002.
* @tc.desc To set the function of screen parameters to abnormal values.
*/
it
(
'
setScreenActiveMode_Test_002
'
,
0
,
async
function
(
done
)
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest2 begin
'
);
screen
.
getAllScreen
().
then
(
src
=>
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest2 getAllScreen src
'
+
src
);
expect
(
src
[
0
]
!=
null
).
assertTrue
();
let
screenIndex
=
src
[
0
];
screenIndex
.
setScreenActiveMode
(
-
5
).
then
(
res
=>
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest2 setScreenActiveMode -5 res:
'
+
res
);
expect
().
assertFail
();
done
();
},(
err
)
=>
{
console
.
log
(
'
screenshotTest setScreenActiveModeTest2 setScreenActiveMode -5 failed: err
'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
).
assertEqual
(
0
);
done
();
})
})
})
})
鸿蒙社区
@harmonycommunity
mentioned in commit
e375fabf
·
3月 20, 2022
mentioned in commit
e375fabf
mentioned in commit e375fabfdbd2fc06cd855d61e900293f63da3f3e
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录