Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e92e27af
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看板
提交
e92e27af
编写于
8月 28, 2023
作者:
Y
yaocui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
Signed-off-by:
N
yaocui
<
yaocui2@h-partners.com
>
上级
e24536ba
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
2095 addition
and
561 deletion
+2095
-561
graphic/windowStage/entry/src/main/ets/test/List.test.ets
graphic/windowStage/entry/src/main/ets/test/List.test.ets
+2
-0
graphic/windowStage/entry/src/main/ets/test/parameterVerificationIsOptional.test.ets
...rc/main/ets/test/parameterVerificationIsOptional.test.ets
+46
-16
graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets
...ndowStage/entry/src/main/ets/test/windowCallback.test.ets
+4
-200
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
...indowStage/entry/src/main/ets/test/windowPromise.test.ets
+21
-220
graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets
.../entry/src/main/ets/test/windowRefactorInterface.test.ets
+0
-125
graphic/windowStage/entry/src/main/ets/test/windowRichScene.test.ets
...dowStage/entry/src/main/ets/test/windowRichScene.test.ets
+2022
-0
未找到文件。
graphic/windowStage/entry/src/main/ets/test/List.test.ets
浏览文件 @
e92e27af
...
...
@@ -17,6 +17,7 @@ import windowCallbackTest from './windowCallback.test'
import windowRefactorInterfaceTest from './windowRefactorInterface.test'
import displayAndWindowRefactorInterfaceTest from './displayAndWindowRefactorInterface.test'
import parameterVerificationIsOptional from './parameterVerificationIsOptional.test'
import windowRichScene from './windowRichScene.test'
export default function testsuite() {
windowCallbackTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
...
...
@@ -24,4 +25,5 @@ export default function testsuite() {
windowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
displayAndWindowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
parameterVerificationIsOptional(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
windowRichScene(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
}
\ No newline at end of file
graphic/windowStage/entry/src/main/ets/test/parameterVerificationIsOptional.test.ets
浏览文件 @
e92e27af
...
...
@@ -117,6 +117,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'window_off_windowSizeChange_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
baseWndType
=
1
;
...
...
@@ -132,10 +133,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expect
(
!!
tempWnd
)
.
assertTrue
();
tempWnd
.
on
(
'windowSizeChange'
,
()
=>
{
console
.
info
(
msgStr
+
"first listener trigger"
);
num
++
firstListenFlag
=
true
});
tempWnd
.
on
(
'windowSizeChange'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"second listener trigger"
);
num
++
secondListenFlag
=
true
});
await
tempWnd
.
show
()
.
catch
((
err
)
=>
{
...
...
@@ -161,8 +164,9 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
await
tempWnd
.
destroyWindow
();
done
();
})
console
.
error
(
msgStr
+
'num : '
+
num
);
await
sleep
(
500
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
await
tempWnd
.
destroyWindow
();
done
();
}
...
...
@@ -245,6 +249,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'window_off_avoidAreaChange_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
tempWnd
=
null
...
...
@@ -257,15 +262,20 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
tempWnd
.
on
(
'avoidAreaChange'
,
()
=>
{
console
.
info
(
msgStr
+
"first listener trigger"
);
num
++
firstListenFlag
=
true
});
tempWnd
.
on
(
'avoidAreaChange'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
'second listener trigger'
);
num
++
secondListenFlag
=
true
});
await
tempWnd
.
setFullScreen
(
true
)
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setFullScreen(true)'
,
done
);
});
await
tempWnd
.
setSystemBarEnable
([
'status'
])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status])'
,
done
);
});
await
sleep
(
1000
);
tempWnd
.
off
(
'avoidAreaChange'
);
firstListenFlag
=
false
...
...
@@ -277,7 +287,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
await
tempWnd
.
setSystemBarEnable
([
'status'
,
'navigation'
])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status])'
,
done
);
});
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
done
();
}
})
...
...
@@ -346,6 +356,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'window_off_screenshot_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
windowId
=
'window_off_screenshot_Test_001'
;
...
...
@@ -368,10 +379,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
tempWnd
.
on
(
'screenshot'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"first listener trigger"
);
num
++
firstListenFlag
=
true
});
tempWnd
.
on
(
'screenshot'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"second listener trigger"
);
num
++
secondListenFlag
=
true
});
// 截屏代码
...
...
@@ -397,7 +410,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done
();
});
await
sleep
(
1000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
await
tempWnd
.
destroyWindow
();
done
();
}
else
{
...
...
@@ -490,6 +503,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'window_off_dialogTargetTouch_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
windowId
=
'window_off_dialogTargetTouch_Test_001'
;
...
...
@@ -512,10 +526,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
tempWnd
.
on
(
'dialogTargetTouch'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"first listener trigger"
);
num
++
firstListenFlag
=
true
});
tempWnd
.
on
(
'dialogTargetTouch'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"second listener trigger"
);
num
++
secondListenFlag
=
true
});
// 点击模态窗口
...
...
@@ -536,7 +552,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done
();
})
await
sleep
(
1000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
await
tempWnd
.
destroyWindow
();
done
();
}
...
...
@@ -618,6 +634,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'window_off_keyboardHeightChange_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
windowId
=
'window_off_keyboardHeightChange_Test_001'
;
...
...
@@ -643,10 +660,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
tempWnd
.
on
(
'keyboardHeightChange'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"first listener trigger"
);
num
++
firstListenFlag
=
true
});
tempWnd
.
on
(
'keyboardHeightChange'
,
(
data
)
=>
{
console
.
info
(
msgStr
+
"second listener trigger"
);
num
++
secondListenFlag
=
true
});
await
inputClick
(
'pageTwoinput'
,
msgStr
)
.
catch
(
async
err
=>
{
...
...
@@ -666,7 +685,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
done
();
})
await
sleep
(
2000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
await
tempWnd
.
destroyWindow
();
done
();
}
...
...
@@ -754,16 +773,18 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'windowStage_off_windowStageEvent_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
function
firstCall
()
{
console
.
log
(
msgStr
+
"first listener trigger"
)
num
++
firstListenFlag
=
true
}
function
secondCall
()
{
console
.
log
(
msgStr
+
"second listener trigger"
)
num
++
secondListenFlag
=
true
}
...
...
@@ -783,7 +804,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.show'
,
done
);
});
await
sleep
(
1000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
done
();
}
})
...
...
@@ -828,7 +849,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
windowStage
.
off
(
"windowStageEvent"
);
if
(
!
firstListenFlag
&&
secondListenFlag
)
{
done
();
}
else
{
}
else
{
expect
(
TRUE_FLAG
)
.
assertFail
();
done
();
}
...
...
@@ -843,6 +864,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'display_off_add_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
screenClass
=
null
;
...
...
@@ -850,11 +872,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
function
firstCall
()
{
console
.
log
(
msgStr
+
"first listener trigger"
)
num
++
firstListenFlag
=
true
}
function
secondCall
()
{
console
.
log
(
msgStr
+
"second listener trigger"
)
num
++
secondListenFlag
=
true
}
...
...
@@ -900,7 +924,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'screen.makeExpand'
,
done
);
});
await
sleep
(
1000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
await
screen
.
destroyVirtualScreen
(
screenClass_two
.
id
)
done
();
}
...
...
@@ -975,7 +999,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
display
.
off
(
"add"
)
if
(
!
firstListenFlag
&&
secondListenFlag
)
{
done
();
}
else
{
}
else
{
expect
(
TRUE_FLAG
)
.
assertFail
();
done
();
}
...
...
@@ -989,6 +1013,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'display_off_remove_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
screenClass
=
null
;
...
...
@@ -996,11 +1021,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
function
firstCall
()
{
console
.
log
(
msgStr
+
"first listener trigger"
)
num
++
firstListenFlag
=
true
}
function
secondCall
()
{
console
.
log
(
msgStr
+
"second listener trigger"
)
num
++
secondListenFlag
=
true
}
...
...
@@ -1047,7 +1074,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
await
screen
.
destroyVirtualScreen
(
screenClass_two
.
id
)
await
sleep
(
1000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
done
();
}
})
...
...
@@ -1121,7 +1148,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
display
.
off
(
'remove'
)
if
(
!
firstListenFlag
&&
secondListenFlag
)
{
done
();
}
else
{
}
else
{
expect
(
TRUE_FLAG
)
.
assertFail
();
done
();
}
...
...
@@ -1135,17 +1162,20 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
caseName
=
'display_off_change_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
num
=
0
let
firstListenFlag
=
false
let
secondListenFlag
=
false
let
screenClass
=
null
;
function
firstCall
()
{
console
.
log
(
msgStr
+
"first listener trigger"
)
num
++
firstListenFlag
=
true
}
function
secondCall
()
{
console
.
log
(
msgStr
+
"second listener trigger"
)
num
++
secondListenFlag
=
true
}
...
...
@@ -1179,7 +1209,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'screenClass.setOrientation'
,
done
);
});
await
sleep
(
1000
);
if
(
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
if
(
num
>=
2
&&
firstListenFlag
===
false
&&
secondListenFlag
===
false
)
{
await
screen
.
destroyVirtualScreen
(
screenClass
.
id
)
done
();
}
...
...
@@ -1241,7 +1271,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
display
.
off
(
'change'
)
if
(
!
firstListenFlag
&&
secondListenFlag
)
{
done
();
}
else
{
}
else
{
expect
(
TRUE_FLAG
)
.
assertFail
();
done
();
}
...
...
@@ -1254,7 +1284,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
it
(
'getUIContext_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getUIContext_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
uiContext
=
null
;
let
uiContext
=
null
;
console
.
log
(
msgStr
+
'begin'
);
let
mainWindow
=
null
mainWindow
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
...
...
@@ -1264,7 +1294,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
// 获取UIContext实例。
uiContext
=
mainWindow
.
getUIContext
();
expect
(
!!
uiContext
)
.
assertTrue
();
console
.
log
(
msgStr
+
'after uiContext: '
+
JSON
.
stringify
(
uiContext
));
console
.
log
(
msgStr
+
'after uiContext: '
+
JSON
.
stringify
(
uiContext
));
done
();
})
...
...
graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets
浏览文件 @
e92e27af
...
...
@@ -131,28 +131,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest6'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest6'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
[
flagStatus
,
flagNav
]
=
[
false
,
false
];
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
systembartintstate
=>
{
console
.
log
(
msgStr
+
'ohosWindow.on systembartintstate.regionTint : '
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
console
.
log
(
msgStr
+
'ohosWindow.on flagNav : '
+
JSON
.
stringify
(
flagNav
));
console
.
log
(
msgStr
+
'ohosWindow.on flagStatus : '
+
JSON
.
stringify
(
flagStatus
));
console
.
log
(
msgStr
+
'ohosWindow.on flagStatus && flagNav : '
+
(
flagStatus
&&
flagNav
));
if
(
flagStatus
||
flagNav
)
{
try
{
expect
(
!!
systembartintstate
)
.
assertTrue
();
expect
(
!!
systembartintstate
.
regionTint
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on ${JSON.stringify(error)}`
)
}
console
.
log
(
msgStr
+
'flagStatus || flagNav'
+
msgStr
+
'ohosWindow.on systemBarTintChange regionTint:'
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
ohosWindow
.
off
(
'systemBarTintChange'
)
done
();
}
})
function
getMainWindow
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
...
...
@@ -191,7 +170,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
reject
(
null
)
}
else
{
console
.
log
(
msgStr
+
'mainWnd.setFullScreen success'
);
flagNav
=
true
;
resolve
(
true
)
}
})
...
...
@@ -207,7 +185,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
reject
(
null
)
}
else
{
console
.
log
(
msgStr
+
'mainWnd.setSystemBarEnable success'
);
flagStatus
=
true
;
resolve
(
true
)
}
})
...
...
@@ -257,6 +234,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done
();
});
console
.
log
(
msgStr
+
'finished!!'
);
done
();
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_007
...
...
@@ -266,24 +244,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest7'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest7'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
[
flagStatus
,
flagNav
]
=
[
false
,
false
];
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
on
(
'systemBarTintChange'
,
systembartintstate
=>
{
console
.
log
(
msgStr
+
'ohosWindow.on systembartintstate :'
+
JSON
.
stringify
(
systembartintstate
));
console
.
log
(
msgStr
+
'ohosWindow.on systembartintstate.regionTint : '
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
if
(
flagStatus
||
flagNav
)
{
console
.
log
(
msgStr
+
'ohosWindow.on flagStatus || flagNav:'
);
try
{
expect
(
!!
systembartintstate
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch err: ${JSON.stringify(error)}`
)
}
ohosWindow
.
off
(
'systemBarTintChange'
)
done
();
}
})
function
getMainWindow
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
...
...
@@ -333,7 +294,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if
(
err
&&
err
.
code
)
{
reject
(
null
)
}
else
{
flagStatus
=
true
;
resolve
(
true
)
}
})
...
...
@@ -347,7 +307,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if
(
err
&&
err
.
code
)
{
reject
(
null
)
}
else
{
flagNav
=
true
;
resolve
(
true
)
}
})
...
...
@@ -381,6 +340,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect
()
.
assertFail
();
done
();
});
done
();
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_008
...
...
@@ -390,30 +350,8 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest8'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest8'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
[
flagStatus
,
flagNav
]
=
[
false
,
false
];
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
on
(
'systemBarTintChange'
,
systembartintstate
=>
{
if
(
flagStatus
&&
flagNav
)
{
console
.
log
(
msgStr
+
'ohosWindow.on systembartintstate.regionTint : '
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
let
enable
=
systembartintstate
.
regionTint
[
0
]
.
isEnable
let
numType
=
systembartintstate
.
regionTint
[
0
]
.
type
console
.
log
(
msgStr
+
'ohosWindow.on isEnable : '
+
JSON
.
stringify
(
enable
));
console
.
log
(
msgStr
+
'ohosWindow.on numType : '
+
JSON
.
stringify
(
numType
));
try
{
expect
(
numType
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
numType
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
&&
enable
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch err: ${JSON.stringify(error)}`
)
}
ohosWindow
.
off
(
'systemBarTintChange'
)
done
();
}
else
{
console
.
log
(
msgStr
+
'flagStatus :'
+
flagStatus
+
' ,regionTint:'
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
console
.
log
(
msgStr
+
'flagNav :'
+
flagNav
+
' ,regionTint:'
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
}
})
function
getMainWindow
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
...
...
@@ -460,8 +398,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if
(
err
&&
err
.
code
)
{
reject
(
null
)
}
else
{
flagStatus
=
true
;
flagNav
=
true
;
resolve
(
true
)
console
.
log
(
msgStr
+
'mainWnd.setSystemBarEnable [status, navigation] data=='
+
JSON
.
stringify
(
data
));
}
...
...
@@ -492,6 +428,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect
()
.
assertFail
();
done
();
});
done
();
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_009
...
...
@@ -501,22 +438,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest9'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest9'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
[
flagStatus
,
flagNav
]
=
[
false
,
false
];
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
on
(
'systemBarTintChange'
,
(
systembartintstate
)
=>
{
console
.
log
(
msgStr
+
'ohosWindow.on systemBarTintChange :'
+
JSON
.
stringify
(
systembartintstate
));
console
.
log
(
msgStr
+
'ohosWindow.on systemBarTintChange systembartintstate.regionTint : '
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
if
(
flagStatus
||
flagNav
)
{
try
{
expect
(
!!
systembartintstate
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch err: ${JSON.stringify(error)}`
)
}
ohosWindow
.
off
(
'systemBarTintChange'
)
done
();
}
})
function
getMainWindow
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
...
...
@@ -576,8 +498,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if
(
err
&&
err
.
code
)
{
reject
(
null
)
}
else
{
flagStatus
=
true
;
flagNav
=
true
;
resolve
(
true
)
}
})
...
...
@@ -612,6 +532,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect
()
.
assertFail
();
done
();
});
done
();
});
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_010
...
...
@@ -786,88 +707,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let
endNum
=
0
;
let
listenerFlag
=
false
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
)
{
try
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
console
.
log
(
msgStr
+
'for arrLenght compareCount: '
+
compareCount
+
' ,i:'
+
i
+
' ,arrLength:'
+
arrLength
);
let
tempData
=
systemBarData
.
regionTint
[
i
];
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start! arrLength= '
+
arrLength
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
SBC
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
SCC
.
indexOf
(
tempData
.
contentColor
);
if
(
backgroundIndex
>=
0
)
{
cloneColorArr
.
SBC
.
splice
(
backgroundIndex
,
1
);
}
else
{
console
.
log
(
msgStr
+
'SBC tempData.backgroundColor:'
+
JSON
.
stringify
(
tempData
.
backgroundColor
));
}
if
(
contentColorIndex
>=
0
)
{
cloneColorArr
.
SCC
.
splice
(
contentColorIndex
,
1
);
}
else
{
console
.
log
(
msgStr
+
'SCC tempData.contentColor:'
+
JSON
.
stringify
(
tempData
.
contentColor
));
}
let
ca
=
cloneColorArr
;
let
flag
=
ca
.
NCC
.
length
||
ca
.
NBC
.
length
||
ca
.
SBC
.
length
||
ca
.
SCC
.
length
if
(
compareCount
===
18
&&
!
flag
)
{
console
.
log
(
msgStr
+
'if compareCount: '
+
compareCount
+
' ,true flag:'
+
flag
);
try
{
expect
(
true
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
}
else
{
console
.
log
(
msgStr
+
'compareCount: '
+
compareCount
+
' ,flag:'
+
flag
);
}
console
.
log
(
msgStr
+
'compareCount: '
+
compareCount
+
' ,length: '
+
JSON
.
stringify
(
cloneColorArr
.
SCC
.
length
)
+
' ,cloneColorArr.SBC:'
+
JSON
.
stringify
(
cloneColorArr
.
SBC
));
console
.
log
(
msgStr
+
'compareCount: '
+
compareCount
+
' ,length: '
+
JSON
.
stringify
(
cloneColorArr
.
SCC
.
length
)
+
' ,cloneColorArr.SCC'
+
JSON
.
stringify
(
cloneColorArr
.
SCC
));
done
();
}
else
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
NBC
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
NCC
.
indexOf
(
tempData
.
contentColor
);
if
(
backgroundIndex
>=
0
)
{
cloneColorArr
.
NBC
.
splice
(
backgroundIndex
,
1
);
}
else
{
console
.
log
(
msgStr
+
'NBC tempData.backgroundColor:'
+
JSON
.
stringify
(
tempData
.
backgroundColor
));
}
if
(
contentColorIndex
>=
0
)
{
cloneColorArr
.
NCC
.
splice
(
contentColorIndex
,
1
);
}
else
{
console
.
log
(
msgStr
+
'NCC tempData.contentColor:'
+
JSON
.
stringify
(
tempData
.
contentColor
));
}
let
ca
=
cloneColorArr
;
let
flag
=
ca
.
NCC
.
length
||
ca
.
NBC
.
length
||
ca
.
SBC
.
length
||
ca
.
SCC
.
length
if
(
compareCount
===
18
&&
!
flag
)
{
console
.
log
(
msgStr
+
'else compareCount: '
+
compareCount
+
' ,true flag:'
+
flag
);
try
{
expect
(
true
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
}
else
{
console
.
log
(
msgStr
+
'compareCount: '
+
compareCount
+
' ,flag:'
+
flag
);
}
console
.
log
(
msgStr
+
'compareCount: '
+
endNum
+
' ,compareCount: '
+
compareCount
+
' ,length: '
+
JSON
.
stringify
(
cloneColorArr
.
NBC
.
length
)
+
' ,cloneColorArr.SBC:'
+
JSON
.
stringify
(
cloneColorArr
.
NBC
));
console
.
log
(
msgStr
+
'compareCount: '
+
endNum
+
' ,compareCount: '
+
compareCount
+
' ,length: '
+
JSON
.
stringify
(
cloneColorArr
.
NCC
.
length
)
+
' ,cloneColorArr.SCC'
+
JSON
.
stringify
(
cloneColorArr
.
NCC
));
endNum
=
compareCount
done
();
}
}
}
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
})
let
tempWnd
;
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
err
));
...
...
@@ -891,7 +730,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done
();
});
await
sleep
(
1000
);
listenerFlag
=
true
let
loopCount
=
commonNUMBERColorArr
.
length
for
(
let
i
=
0
;
i
<
loopCount
;
i
++
)
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable i:'
+
i
);
...
...
@@ -906,7 +744,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
};
tempWnd
.
setSystemBarProperties
(
systemBarProperties
,
(
err
,
data
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties err'
+
JSON
.
stringify
(
err
));
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties data'
+
JSON
.
stringify
(
data
));
if
(
err
&&
err
.
code
)
{
try
{
expect
(
TRUE_FLAG
)
.
assertFail
();
...
...
@@ -933,38 +770,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
cloneColorArr
=
JSON
.
parse
(
JSON
.
stringify
(
commonKEYColorArr
));
let
compareCount
=
0
;
let
listenerFlag
=
false
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
)
{
try
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
indexOf
(
tempData
.
contentColor
);
try
{
expect
(
backgroundIndex
===
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
===
-
1
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
}
}
}
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
})
let
tempWnd
;
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
err
));
...
...
@@ -988,7 +794,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
done
();
});
await
sleep
(
1000
);
listenerFlag
=
true
let
loopCount
=
commonRGBColorArr
.
length
for
(
let
i
=
0
;
i
<
loopCount
;
i
++
)
{
let
tempColor
=
commonKEYColorArr
[
i
];
...
...
@@ -1001,7 +806,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
navigationBarContentColor
:
tempColor
,
};
tempWnd
.
setSystemBarProperties
(
systemBarProperties
,
(
err
,
data
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties err'
+
JSON
.
stringify
(
err
));
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties data'
+
JSON
.
stringify
(
data
));
if
(
err
&&
err
.
code
)
{
try
{
...
...
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
浏览文件 @
e92e27af
...
...
@@ -240,7 +240,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
listenerData
.
typeStr
=
'systemAvoidAreaChange'
;
tempWnd
.
on
(
'systemAvoidAreaChange'
,
(
avoidAreaData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, systemBatData : '
+
JSON
.
stringify
(
avoidAreaData
));
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, systemBatData 1100 : '
+
JSON
.
stringify
(
avoidAreaData
)
);
tempWnd
.
off
(
'systemAvoidAreaChange'
);
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange finished'
);
...
...
@@ -256,14 +256,13 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([]) success'
);
await
sleep
(
1000
);
tempWnd
.
off
(
'systemAvoidAreaChange'
);
await
sleep
(
500
);
console
.
log
(
msgStr
+
'tempWnd.off systemAvoidAreaChange finished'
);
await
sleep
(
10010
);
listenerOffFlag
=
listenerStatus
.
pending
;
await
tempWnd
.
setSystemBarEnable
([
'status'
,
'navigation'
])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status, navigation])'
,
done
);
});
await
sleep
(
500
);
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
})
/**
...
...
@@ -434,33 +433,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest1'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest1'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
statusFlag
=
listenerStatus
.
ready
;
let
navigationFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
statusFlag
===
listenerStatus
.
pending
||
navigationFlag
===
listenerStatus
.
pending
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
console
.
log
(
msgStr
+
'compare, type: '
+
tempData
.
type
+
';isEnable: '
+
tempData
.
isEnable
);
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
&&
statusFlag
===
listenerStatus
.
pending
)
{
statusFlag
=
listenerStatus
.
finished
;
expect
(
tempData
.
isEnable
)
.
assertTrue
();
}
else
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
&&
navigationFlag
===
listenerStatus
.
pending
)
{
navigationFlag
=
listenerStatus
.
finished
;
expect
(
!
tempData
.
isEnable
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -479,13 +452,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status]) success'
);
await
sleep
(
1000
);
statusFlag
=
listenerStatus
.
pending
;
navigationFlag
=
listenerStatus
.
pending
;
await
sleep
(
500
);
await
tempWnd
.
setSystemBarEnable
([
'status'
])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([navigation]) success'
);
done
();
})
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_JSAPI_002
...
...
@@ -495,33 +467,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest2'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest2'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
statusFlag
=
listenerStatus
.
ready
;
let
navigationFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
statusFlag
===
listenerStatus
.
pending
||
navigationFlag
===
listenerStatus
.
pending
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
console
.
log
(
msgStr
+
'compare, type: '
+
tempData
.
type
+
';isEnable: '
+
tempData
.
isEnable
);
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
&&
statusFlag
===
listenerStatus
.
pending
)
{
statusFlag
=
listenerStatus
.
finished
;
expect
(
!
tempData
.
isEnable
)
.
assertTrue
();
}
else
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
&&
navigationFlag
===
listenerStatus
.
pending
)
{
navigationFlag
=
listenerStatus
.
finished
;
expect
(
tempData
.
isEnable
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -540,12 +486,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status]) success'
);
await
sleep
(
1000
);
statusFlag
=
listenerStatus
.
pending
;
navigationFlag
=
listenerStatus
.
pending
;
await
tempWnd
.
setSystemBarEnable
([
'navigation'
])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([navigation]) success'
);
done
();
})
/**
...
...
@@ -556,33 +501,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest3'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest3'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
statusFlag
=
listenerStatus
.
ready
;
let
navigationFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
statusFlag
===
listenerStatus
.
pending
||
navigationFlag
===
listenerStatus
.
pending
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
console
.
log
(
msgStr
+
'compare, type: '
+
tempData
.
type
+
';isEnable: '
+
tempData
.
isEnable
);
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
&&
statusFlag
===
listenerStatus
.
pending
)
{
statusFlag
=
listenerStatus
.
finished
;
expect
(
tempData
.
isEnable
)
.
assertTrue
();
}
else
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
&&
navigationFlag
===
listenerStatus
.
pending
)
{
navigationFlag
=
listenerStatus
.
finished
;
expect
(
tempData
.
isEnable
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -600,13 +519,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([]) success'
);
await
sleep
(
1000
);
statusFlag
=
listenerStatus
.
pending
;
navigationFlag
=
listenerStatus
.
pending
;
await
sleep
(
500
);
await
tempWnd
.
setSystemBarEnable
([
'status'
,
'navigation'
])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status, navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success .'
);
done
();
})
/**
...
...
@@ -617,33 +535,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
it
(
'setSystemBarEnableTest4'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnableTest4'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
statusFlag
=
listenerStatus
.
ready
;
let
navigationFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
statusFlag
===
listenerStatus
.
pending
||
navigationFlag
===
listenerStatus
.
pending
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
console
.
log
(
msgStr
+
'compare, type: '
+
tempData
.
type
+
';isEnable: '
+
tempData
.
isEnable
);
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
&&
statusFlag
===
listenerStatus
.
pending
)
{
statusFlag
=
listenerStatus
.
finished
;
expect
(
!
tempData
.
isEnable
)
.
assertTrue
();
}
else
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
&&
navigationFlag
===
listenerStatus
.
pending
)
{
navigationFlag
=
listenerStatus
.
finished
;
expect
(
!
tempData
.
isEnable
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -661,13 +553,12 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status, navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
await
sleep
(
1000
);
statusFlag
=
listenerStatus
.
pending
;
navigationFlag
=
listenerStatus
.
pending
;
await
sleep
(
500
);
await
tempWnd
.
setSystemBarEnable
([])
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([]) success'
);
done
();
})
/**
...
...
@@ -715,31 +606,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
cloneColorArr
=
JSON
.
parse
(
JSON
.
stringify
(
commonRGBColorArr
));
let
compareCount
=
0
;
let
listenerFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
===
listenerStatus
.
pending
)
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
indexOf
(
tempData
.
contentColor
);
expect
(
backgroundIndex
===
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
===
-
1
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -757,8 +624,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status, navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
await
sleep
(
1000
);
listenerFlag
=
listenerStatus
.
pending
;
await
sleep
(
500
);
let
loopCount
=
commonRGBColorArr
.
length
;
for
(
let
i
=
0
;
i
<
loopCount
;
i
++
)
{
let
tempColor
=
commonRGBColorArr
[
i
];
...
...
@@ -772,9 +638,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
};
await
tempWnd
.
setSystemBarProperties
(
systemBarProperties
)
.
then
(()
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties '
+
tempColor
+
' success'
);
done
();
},
(
err
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties failed, err : '
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
)
.
assertFail
();
expect
()
.
assertFail
();
done
();
})
}
})
...
...
@@ -794,50 +662,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
NCC
:
JSON
.
parse
(
JSON
.
stringify
(
commonNUMBERColorArr
))
};
let
compareCount
=
0
;
let
listenerFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
===
listenerStatus
.
pending
)
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
SBC
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
SCC
.
indexOf
(
tempData
.
contentColor
);
if
(
backgroundIndex
>=
0
)
{
cloneColorArr
.
SBC
.
splice
(
backgroundIndex
,
1
);
}
if
(
contentColorIndex
>=
0
)
{
cloneColorArr
.
SCC
.
splice
(
contentColorIndex
,
1
);
}
expect
(
backgroundIndex
!==
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
!==
-
1
)
.
assertTrue
();
}
else
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
NBC
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
NCC
.
indexOf
(
tempData
.
contentColor
);
if
(
backgroundIndex
>=
0
)
{
cloneColorArr
.
NBC
.
splice
(
backgroundIndex
,
1
);
}
if
(
contentColorIndex
>=
0
)
{
cloneColorArr
.
NCC
.
splice
(
contentColorIndex
,
1
);
}
expect
(
backgroundIndex
!==
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
!==
-
1
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -855,8 +680,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status, navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
await
sleep
(
1000
);
listenerFlag
=
listenerStatus
.
pending
;
await
sleep
(
500
);
let
loopCount
=
commonNUMBERColorArr
.
length
;
for
(
let
i
=
0
;
i
<
loopCount
;
i
++
)
{
let
tempColor
=
commonNUMBERColorArr
[
i
];
...
...
@@ -870,9 +694,11 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
};
await
tempWnd
.
setSystemBarProperties
(
systemBarProperties
)
.
then
(()
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties '
+
tempColor
+
' success'
);
done
();
},
(
err
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties failed, err : '
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
)
.
assertFail
();
expect
()
.
assertFail
();
done
();
})
}
})
...
...
@@ -887,32 +713,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
let
cloneColorArr
=
JSON
.
parse
(
JSON
.
stringify
(
commonKEYColorArr
));
let
compareCount
=
0
;
let
listenerFlag
=
listenerStatus
.
ready
;
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
async
(
systemBarData
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange, systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
===
listenerStatus
.
pending
)
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
console
.
log
(
msgStr
+
'i='
+
i
+
' , ohosWindow.on for='
+
JSON
.
stringify
(
tempData
));
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
console
.
log
(
msgStr
+
'systemBarTintChange compare start!'
);
compareCount
++
;
let
backgroundIndex
=
cloneColorArr
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
indexOf
(
tempData
.
contentColor
);
expect
(
backgroundIndex
===
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
===
-
1
)
.
assertTrue
();
}
}
}
done
();
})
console
.
log
(
msgStr
+
'tempWnd.on systemBarTintChange finished'
);
let
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
unexpectedError
(
err
,
caseName
,
'windowStage.getMainWindow'
,
done
);
});
...
...
@@ -930,8 +731,7 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
unexpectedError
(
err
,
caseName
,
'tempWnd.setSystemBarEnable([status, navigation])'
,
done
);
});
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
await
sleep
(
1000
);
listenerFlag
=
listenerStatus
.
pending
;
await
sleep
(
500
);
let
loopCount
=
commonKEYColorArr
.
length
;
for
(
let
i
=
0
;
i
<
loopCount
;
i
++
)
{
let
tempColor
=
commonKEYColorArr
[
i
];
...
...
@@ -945,9 +745,10 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
};
await
tempWnd
.
setSystemBarProperties
(
systemBarProperties
)
.
then
(()
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties '
+
tempColor
+
' success'
);
done
();
},
(
err
)
=>
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarProperties failed, err : '
+
JSON
.
stringify
(
err
));
expect
(
TRUE_FLAG
)
.
assertFail
();
expect
()
.
assertFail
();
done
();
})
}
...
...
graphic/windowStage/entry/src/main/ets/test/windowRefactorInterface.test.ets
浏览文件 @
e92e27af
...
...
@@ -92,42 +92,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
let
listenerFlag
=
listenerStatus
.
ready
;
let
caseName
=
'setWindowSystemBarPropertiesTest1'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
info
(
'setWindowSystemBarPropertiesTest1'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
(
systemBarData
)
=>
{
console
.
info
(
'setWindowSystemBarPropertiesTest1 systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
===
listenerStatus
.
pending
)
{
try
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
let
arrLength
=
systemBarData
.
regionTint
.
length
;
console
.
log
(
'setWindowSystemBarPropertiesTest1 arrLength is: '
+
systemBarData
.
regionTint
.
length
)
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
){
console
.
info
(
'setWindowSystemBarPropertiesTest1 start step:'
+
i
);
// 单个导航栏或者系统状态信息
let
SystemBarRegionTint
=
systemBarData
.
regionTint
[
i
];
if
(
SystemBarRegionTint
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
SystemBarRegionTint
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
console
.
info
(
'setWindowSystemBarPropertiesTest1 assert1 start!'
);
let
backgroundIndex
=
cloneColorArr
.
indexOf
(
SystemBarRegionTint
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
indexOf
(
SystemBarRegionTint
.
contentColor
);
try
{
expect
(
backgroundIndex
===
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
===
-
1
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
if
(
i
==
arrLength
-
1
){
console
.
info
(
'setWindowSystemBarPropertiesTest1 finished step:'
+
i
);
}
}
}
}
})
console
.
info
(
'setWindowSystemBarPropertiesTest1 on systemBarTintChange finished'
);
let
mainWsync
=
windowStage
.
getMainWindowSync
();
expect
(
mainWsync
!=
null
)
.
assertTrue
();
await
mainWsync
.
showWindow
()
.
catch
(
err
=>
{
...
...
@@ -141,7 +105,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
done
();
});
await
sleep
(
1000
);
listenerFlag
=
listenerStatus
.
pending
;
for
(
let
i
=
0
;
i
<
commonRGBColorArr
.
length
;
i
++
){
console
.
info
(
'setWindowSystemBarPropertiesTest1 begin step:'
+
i
);
let
tempColor
=
commonRGBColorArr
[
i
];
...
...
@@ -184,63 +147,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
NBC
:
JSON
.
parse
(
JSON
.
stringify
(
commonNUMBERColorArr
)),
NCC
:
JSON
.
parse
(
JSON
.
stringify
(
commonNUMBERColorArr
))
};
let
listenerFlag
=
listenerStatus
.
ready
;
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
let
caseName
=
'setWindowSystemBarPropertiesTest2'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
info
(
'setWindowSystemBarPropertiesTest2'
);
ohosWindow
.
on
(
'systemBarTintChange'
,
(
systemBarData
)
=>
{
console
.
info
(
'setWindowSystemBarPropertiesTest2 systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
===
listenerStatus
.
pending
)
{
// 单个导航栏或者系统状态信息
try
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
let
arrLength
=
systemBarData
.
regionTint
.
length
;
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
systemBarRegionTint
=
systemBarData
.
regionTint
[
i
];
if
(
systemBarRegionTint
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
)
{
console
.
info
(
'setWindowSystemBarPropertiesTest2 assert2 start!'
);
let
backgroundIndex
=
cloneColorArr
.
SBC
.
indexOf
(
systemBarRegionTint
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
SCC
.
indexOf
(
systemBarRegionTint
.
contentColor
);
if
(
backgroundIndex
>=
0
)
{
cloneColorArr
.
SBC
.
splice
(
backgroundIndex
,
1
);
}
if
(
contentColorIndex
>=
0
)
{
cloneColorArr
.
SCC
.
splice
(
contentColorIndex
,
1
);
}
try
{
expect
(
backgroundIndex
!==
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
!==
-
1
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
done
();
}
else
if
(
systemBarRegionTint
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
let
backgroundIndex
=
cloneColorArr
.
NBC
.
indexOf
(
systemBarRegionTint
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
NCC
.
indexOf
(
systemBarRegionTint
.
contentColor
);
if
(
backgroundIndex
>=
0
)
{
cloneColorArr
.
NBC
.
splice
(
backgroundIndex
,
1
);
}
if
(
contentColorIndex
>=
0
)
{
cloneColorArr
.
NCC
.
splice
(
contentColorIndex
,
1
);
}
try
{
expect
(
backgroundIndex
!==
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
!==
-
1
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
done
();
}
}
}
})
console
.
info
(
'setWindowSystemBarPropertiesTest2 on systemBarTintChange finished'
);
let
mainWsync
=
windowStage
.
getMainWindowSync
();
expect
(
mainWsync
!=
null
)
.
assertTrue
();
await
mainWsync
.
showWindow
()
.
catch
((
err
)
=>
{
...
...
@@ -255,7 +163,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
done
();
});
await
sleep
(
1000
);
listenerFlag
=
listenerStatus
.
pending
;
for
(
let
i
=
0
;
i
<
commonNUMBERColorArr
.
length
;
i
++
){
console
.
info
(
'setWindowSystemBarPropertiesTest2 begin step:'
+
i
);
let
tempColor
=
commonNUMBERColorArr
[
i
];
...
...
@@ -293,39 +200,8 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
*/
it
(
'setWindowSystemBarPropertiesTest3'
,
0
,
async
function
(
done
)
{
let
cloneColorArr
=
JSON
.
parse
(
JSON
.
stringify
(
commonKEYColorArr
));
let
listenerFlag
=
listenerStatus
.
ready
;
let
caseName
=
'setWindowSystemBarPropertiesTest3'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
info
(
'setWindowSystemBarPropertiesTest3 start'
);
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemBarTintChange'
;
ohosWindow
.
on
(
'systemBarTintChange'
,
(
systemBarData
)
=>
{
console
.
info
(
'setWindowSystemBarPropertiesTest3 systemBatData : '
+
JSON
.
stringify
(
systemBarData
));
if
(
listenerFlag
===
listenerStatus
.
pending
)
{
try
{
expect
(
!!
systemBarData
)
.
assertTrue
();
expect
(
!!
systemBarData
.
regionTint
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
let
arrLength
=
systemBarData
.
regionTint
.
length
;
// 单个导航栏或者系统状态信息
for
(
let
i
=
0
;
i
<
arrLength
;
i
++
)
{
let
tempData
=
systemBarData
.
regionTint
[
i
];
if
(
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
tempData
.
type
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
)
{
let
backgroundIndex
=
cloneColorArr
.
indexOf
(
tempData
.
backgroundColor
);
let
contentColorIndex
=
cloneColorArr
.
indexOf
(
tempData
.
contentColor
);
try
{
expect
(
backgroundIndex
===
-
1
)
.
assertTrue
();
expect
(
contentColorIndex
===
-
1
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch error: ${JSON.stringify(error)}`
)
}
done
();
}
}
}
})
let
tempWnd
=
windowStage
.
getMainWindowSync
();
expect
(
tempWnd
!=
null
)
.
assertTrue
();
await
tempWnd
.
showWindow
()
.
catch
((
err
)
=>
{
...
...
@@ -339,7 +215,6 @@ export default function windowRefactorInterfaceTest(context, windowStage, abilit
done
();
});
await
sleep
(
1000
);
listenerFlag
=
listenerStatus
.
pending
;
for
(
let
i
=
0
;
i
<
commonKEYColorArr
.
length
;
i
++
){
console
.
info
(
'setWindowSystemBarPropertiesTest3 begin step:'
+
i
);
let
tempColor
=
commonKEYColorArr
[
i
];
...
...
graphic/windowStage/entry/src/main/ets/test/windowRichScene.test.ets
0 → 100644
浏览文件 @
e92e27af
/*
* 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
"@ohos/hypium"
import
ohosWindow
from
'@ohos.window'
;
import
screen
from
'@ohos.screen'
;
import
display
from
'@ohos.display'
;
import
screenshot
from
'@ohos.screenshot'
;
import
{
UiDriver
,
BY
,
ON
,
PointerMatrix
}
from
'@ohos.UiTest'
export
default
function
windowPromiseTest
(
context
,
windowStage
,
abilityStorage
)
{
console
.
log
(
'windowTest context: '
+
JSON
.
stringify
(
context
))
console
.
log
(
'windowTest abilityStorage: '
+
JSON
.
stringify
(
abilityStorage
))
describe
(
'window_richScene_test'
,
function
()
{
console
.
log
(
'describe window_api_test start!!!'
)
const
TRUE_FLAG
=
true
;
async
function
sleep
(
time
)
{
let
timeoutId
=
null
;
let
promise
=
new
Promise
(
resolve
=>
{
timeoutId
=
setTimeout
(()
=>
{
resolve
(
'sleep finished'
);
},
time
);
})
let
result
=
await
promise
;
clearTimeout
(
timeoutId
)
}
/**
* @tc.number SUB_WINDOW_CREATEWINDOWTEST_JSAPI_001
* @tc.name Test createWindow_Test_001
* @tc.desc Verify The optional parameter is error
*/
it
(
'createWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'createWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
'createWindow_Test_001'
let
windowConfig
=
{
name
:
windowId
,
windowType
:
18
,
ctx
:
context
};
let
win
;
try
{
win
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
then
((
data
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow data: '
+
JSON
.
stringify
(
data
));
done
();
})
}
catch
(
err
)
{
console
.
log
(
msgStr
+
'Window createWindow catch err: '
+
JSON
.
stringify
(
err
))
expect
(
err
.
code
)
.
assertEqual
(
401
)
done
()
}
})
/**
* @tc.number SUB_WINDOW_CREATEWINDOWTEST_JSAPI_002
* @tc.name Test createWindow_Test_002
* @tc.desc Verify The optional parameter is error
*/
it
(
'createWindow_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'createWindow_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
'createWindow_Test_002'
let
windowConfig
=
{
name
:
windowId
,
windowType
:
18
,
ctx
:
context
};
let
win
;
try
{
win
=
await
ohosWindow
.
createWindow
(
windowConfig
,
(
err
,
data
)
=>
{
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
});
}
catch
(
err
)
{
console
.
log
(
msgStr
+
'Window createWindow catch err: '
+
JSON
.
stringify
(
err
))
expect
(
err
.
code
)
.
assertEqual
(
401
)
done
()
}
})
/**
* @tc.number SUB_WINDOW_FINEDWINDOW_JSAPI_001
* @tc.name Test findWindow_Test_001
* @tc.desc Find the window corresponding to name
*/
it
(
'findWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'findWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
'findWindow_Test_001'
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
win
;
win
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
win
)
.
assertTrue
();
try
{
let
windowClass
=
ohosWindow
.
findWindow
(
'findWindow_Test_001'
);
console
.
log
(
msgStr
+
'findWindow windowClass: '
+
JSON
.
stringify
(
windowClass
))
expect
(
!!
windowClass
)
.
assertTrue
();
await
win
.
destroyWindow
()
done
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to find the Window. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_FINEDWINDOW_JSAPI_002
* @tc.name Test findWindow_Test_002
* @tc.desc Verify The optional parameter is error
*/
it
(
'findWindow_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'findWindow_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
try
{
let
windowClass
;
windowClass
=
ohosWindow
.
findWindow
(
'findWindow_Test_002'
);
expect
(
!
windowClass
)
.
assertTrue
();
done
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to find the Window. Cause: '
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
1300002
);
done
();
}
})
/**
* @tc.number SUB_WINDOW_CREATE_JSAPI_001
* @tc.name Test create_Test_001
* @tc.desc Verify The optional parameter is error
*/
it
(
'create_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'create_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
create
(
context
,
'create_Test_001'
,
20
)
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to create the subWindow. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1003
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_CREATE_JSAPI_002
* @tc.name Test create_Test_002
* @tc.desc Verify The optional parameter is error
*/
it
(
'create_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'create_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
create
(
context
,
'create_Test_002'
,
20
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to create the subWindow. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
(
err
.
code
)
.
assertEqual
(
1003
);
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in creating the subWindow. Data: '
+
JSON
.
stringify
(
data
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
});
})
/**
* @tc.number SUB_WINDOW_FINED_JSAPI_001
* @tc.name Test find_Test_001
* @tc.desc Find the window corresponding to name
*/
it
(
'find_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'find_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
'find_Test_001'
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
win
;
win
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
win
)
.
assertTrue
();
try
{
let
windowClass
;
windowClass
=
await
ohosWindow
.
find
(
'find_Test_001'
)
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to find the Window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
let
windowClass2
;
windowClass2
=
await
ohosWindow
.
find
(
'find_Test_001'
)
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to find the Window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass2
)
.
assertTrue
();
await
win
.
destroyWindow
()
done
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to find the Window. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_FINED_JSAPI_002
* @tc.name Test find_Test_002
* @tc.desc Verify The optional parameter is error
*/
it
(
'find_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'find_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
=
null
;
ohosWindow
.
find
(
'find_Test_002'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to find the Window. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
(
err
.
code
)
.
assertEqual
(
1001
);
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
windowClass
=
data
;
console
.
info
(
msgStr
+
'Succeeded in finding the window. Data: '
+
JSON
.
stringify
(
data
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETTOPWINDOW_JSAPI_001
* @tc.name Test getTopWindow_Test_001
* @tc.desc Gets the last window displayed in the current app
*/
it
(
'getTopWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getTopWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
getTopWindow
(
context
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to obtain the top window. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in obtaining the top window. Data: '
+
JSON
.
stringify
(
data
));
ohosWindow
.
getTopWindow
(
context
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to obtain the top window. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in obtaining the top window. Data: '
+
JSON
.
stringify
(
data
));
done
();
});
});
})
/**
* @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_001
* @tc.name Test showWindow_Test_001
* @tc.desc Verify The optional parameter is error
*/
it
(
'showWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'showWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
=
null
;
windowClass
=
await
ohosWindow
.
getLastWindow
(
context
)
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the top window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
windowClass
.
showWindow
((
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to show the window. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in showing the window.'
);
windowClass
.
showWindow
()
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in showing the window.'
);
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to show the window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
});
})
/**
* @tc.number SUB_WINDOW_SHOWWINDOW_JSAPI_002
* @tc.name Test showWindow_Test_002
* @tc.desc Verify The optional parameter is error
*/
it
(
'showWindow_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'showWindow_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"showWindow_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
windowClass
.
showWindow
()
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in showing the window.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to show the window. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_DESTROYWINOW_JSAPI_001
* @tc.name Test destroyWindow_Test_001
* @tc.desc Verify The optional parameter is error
*/
it
(
'destroyWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'destroyWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"destroyWindow_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
windowClass
.
destroyWindow
((
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to destroy the window. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in destroying the window.'
);
expect
()
.
assertFail
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETWINDOWPROPERTIES_JSAPI_001
* @tc.name Test getWindowProperties_Test_001
* @tc.desc Gets the properties of the current window Continuous call interface
*/
it
(
'getWindowProperties_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getWindowProperties_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getWindowProperties_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
let
properties
=
windowClass
.
getWindowProperties
();
expect
(
!!
properties
)
.
assertTrue
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the window properties. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
let
properties2
=
windowClass
.
getWindowProperties
();
expect
(
!!
properties2
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
done
()
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the window properties. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_001
* @tc.name Test getWindowAvoidArea_Test_001
* @tc.desc Verify The optional parameter is error
*/
it
(
'getWindowAvoidArea_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getWindowAvoidArea_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getWindowAvoidArea_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
let
type
=
ohosWindow
.
AvoidAreaType
.
TYPE_SYSTEM
;
try
{
let
avoidArea
=
windowClass
.
getWindowAvoidArea
(
type
);
expect
(
!!
avoidArea
)
.
assertTrue
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
let
type2
=
ohosWindow
.
AvoidAreaType
.
TYPE_CUTOUT
;
try
{
let
avoidArea
=
windowClass
.
getWindowAvoidArea
(
type2
);
expect
(
!!
avoidArea
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
done
()
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_GETWINDOWAVOIDAREA_JSAPI_002
* @tc.name Test getWindowAvoidArea_Test_002
* @tc.desc Verify The optional parameter is error
*/
it
(
'getWindowAvoidArea_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getWindowAvoidArea_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getWindowAvoidArea_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
let
avoidArea
=
windowClass
.
getWindowAvoidArea
(
4
);
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
401
);
await
windowClass
.
destroyWindow
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test setWindowLayoutFullScreen_Test_001
* @tc.desc Sets whether the layout of the window is immersive
*/
it
(
'setWindowLayoutFullScreen_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowLayoutFullScreen_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowLayoutFullScreen_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
let
isLayoutFullScreen
=
true
;
try
{
await
windowClass
.
setWindowLayoutFullScreen
(
isLayoutFullScreen
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window layout to full-screen mode.'
);
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
windowClass
.
setWindowLayoutFullScreen
(
false
,
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the window layout to full-screen mode.'
);
await
windowClass
.
destroyWindow
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWLAYOUTFULLSCREEN_JSAPI_002
* @tc.name Test setWindowLayoutFullScreen_Test_002
* @tc.desc Sets whether the layout of the window is immersive
*/
it
(
'setWindowLayoutFullScreen_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowLayoutFullScreen_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowLayoutFullScreen_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
let
isLayoutFullScreen
=
true
;
try
{
await
windowClass
.
setWindowLayoutFullScreen
(
isLayoutFullScreen
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window layout to full-screen mode.'
);
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
await
windowClass
.
destroyWindow
();
try
{
windowClass
.
setWindowLayoutFullScreen
(
false
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the window layout to full-screen mode.'
);
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window layout to full-screen mode. catch Cause:'
+
JSON
.
stringify
(
exception
));
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWCOLORAPACE_JSAPI_001
* @tc.name Test setWindowColorSpace_Test_001
* @tc.desc Set the current window to wide gamut mode or default gamut mode
*/
it
(
'setWindowColorSpace_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowColorSpace_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
windowClass
.
setWindowColorSpace
(
2
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting window colorspace.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set window colorspace. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
401
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set window colorspace.catch Cause:'
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
401
);
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWCOLORAPACE_JSAPI_002
* @tc.name Test setWindowColorSpace_Test_002
* @tc.desc Set the current window to wide gamut mode or default gamut mode
*/
it
(
'setWindowColorSpace_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowColorSpace_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
windowClass
.
setWindowColorSpace
(
ohosWindow
.
ColorSpace
.
WIDE_GAMUT
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set window colorspace. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting window colorspace.'
);
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set window colorspace. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
let
promise
=
windowClass
.
setWindowColorSpace
(
ohosWindow
.
ColorSpace
.
DEFAULT
);
promise
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting window colorspace.'
);
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set window colorspace. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set window colorspace. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_GETWINDOWCOLORAPACE_JSAPI_001
* @tc.name Test getWindowColorSpace_Test_001
* @tc.desc Gets the current window gamut mode
*/
it
(
'getWindowColorSpace_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getWindowColorSpace_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
let
colorSpace
=
windowClass
.
getWindowColorSpace
();
let
res1
=
colorSpace
==
0
||
colorSpace
==
1
expect
(
res1
)
.
assertEqual
(
true
);
let
colorSpace2
=
windowClass
.
getWindowColorSpace
();
let
res2
=
colorSpace2
==
0
||
colorSpace
==
1
expect
(
res2
)
.
assertEqual
(
true
);
done
();
})
/**
* @tc.number SUB_WINDOW_SETWINDOWBACKGROUNDCOLOR_JSAPI_001
* @tc.name Test setWindowBackgroundColor_Test_001
* @tc.desc Set the background color of the window
*/
it
(
'setWindowBackgroundColor_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowBackgroundColor_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
let
color
=
'#00ff33'
;
try
{
windowClass
.
setWindowBackgroundColor
(
color
);
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the background color. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
let
color2
=
'#FFFFFF'
;
try
{
windowClass
.
setWindowBackgroundColor
(
color2
);
done
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the background color. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWBACKGROUNDCOLOR_JSAPI_002
* @tc.name Test setWindowBackgroundColor_Test_002
* @tc.desc Set the background color of the window
*/
it
(
'setWindowBackgroundColor_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowBackgroundColor_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
let
color
=
'#00f'
;
try
{
windowClass
.
setWindowBackgroundColor
(
color
);
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the background color. Cause: '
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
401
);
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWBRIGHTNESS_JSAPI_001
* @tc.name Test setWindowBrightness_Test_001
* @tc.desc Set the screen brightness value
*/
it
(
'setWindowBrightness_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowBrightness_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
let
brightness
=
2
;
try
{
windowClass
.
setWindowBrightness
(
brightness
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the brightness.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the brightness. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
401
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the brightness. catch Cause: '
+
JSON
.
stringify
(
exception
));
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWBRIGHTNESS_JSAPI_002
* @tc.name Test setWindowBrightness_Test_002
* @tc.desc Set the screen brightness value
*/
it
(
'setWindowBrightness_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowBrightness_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
let
brightness
=
1
;
try
{
windowClass
.
setWindowBrightness
(
brightness
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the brightness.'
);
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the brightness. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the brightness. catch Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
let
brightness2
=
0.5
;
try
{
windowClass
.
setWindowBrightness
(
brightness2
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the brightness. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the brightness.'
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the brightness. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWFOCUSABLE_JSAPI_001
* @tc.name Test setWindowFocusable_Test_001
* @tc.desc Set whether to switch focus window when clicking
*/
it
(
'setWindowFocusable_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowFocusable_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
let
promise
=
windowClass
.
setWindowFocusable
(
false
);
promise
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window to be focusable.'
);
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the window to be focusable. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be focusable. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
windowClass
.
setWindowFocusable
(
true
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be focusable. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the window to be focusable.'
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be focusable. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWKEEPSCREENON_JSAPI_001
* @tc.name Test setWindowKeepScreenOn_Test_001
* @tc.desc Set whether the screen is steady on
*/
it
(
'setWindowKeepScreenOn_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowKeepScreenOn_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowKeepScreenOn_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
try
{
windowClass
.
setWindowKeepScreenOn
(
true
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the screen to be always on.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'Failed to set the screen to be always on. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the screen to be always on. catch Cause: '
+
JSON
.
stringify
(
exception
));
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWKEEPSCREENON_JSAPI_002
* @tc.name Test setWindowKeepScreenOn_Test_002
* @tc.desc Set whether the screen is steady on
*/
it
(
'setWindowKeepScreenOn_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowKeepScreenOn_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowKeepScreenOn_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
await
windowClass
.
setWindowKeepScreenOn
(
false
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the screen to be always on.'
);
})
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'Failed to set the screen to be always on. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the screen to be always on. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
windowClass
.
setWindowKeepScreenOn
(
true
,
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the screen to be always on. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
await
windowClass
.
destroyWindow
();
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the screen to be always on.'
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the screen to be always on. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWPRIVACYMODE_TEST_JSAPI_001
* @tc.name Test setWindowPrivacyMode_Test_001
* @tc.desc Sets whether the window is in private mode
*/
it
(
'setWindowPrivacyMode_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowPrivacyMode_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowPrivacyMode_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
try
{
windowClass
.
setWindowPrivacyMode
(
true
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window to privacy mode.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'Failed to set the window to privacy mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to privacy mode. catch Cause: '
+
JSON
.
stringify
(
exception
));
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWPRIVACYMODE_TEST_JSAPI_002
* @tc.name Test setWindowPrivacyMode_Test_002
* @tc.desc Sets whether the window is in private mode
*/
it
(
'setWindowPrivacyMode_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowPrivacyMode_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowPrivacyMode_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
await
windowClass
.
setWindowPrivacyMode
(
true
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window to privacy mode.'
);
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the window to privacy mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to privacy mode. Cause:'
+
JSON
.
stringify
(
exception
));
}
try
{
windowClass
.
setWindowPrivacyMode
(
false
,
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the window to privacy mode. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
await
windowClass
.
destroyWindow
();
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the window to privacy mode.'
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to privacy mode. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTOUCHABLE_JSAPI_001
* @tc.name Test setWindowTouchable_Test_001
* @tc.desc Sets whether the window is touchable
*/
it
(
'setWindowTouchable_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowTouchable_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowTouchable_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
await
windowClass
.
setWindowTouchable
(
false
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window to be touchable.'
);
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the window to be touchable. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be touchable. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
windowClass
.
setWindowTouchable
(
true
,
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be touchable. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
await
windowClass
.
destroyWindow
();
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in setting the window to be touchable.'
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be touchable. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTOUCHABLE_JSAPI_002
* @tc.name Test setWindowTouchable_Test_002
* @tc.desc Sets whether the window is touchable
*/
it
(
'setWindowTouchable_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowTouchable_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowTouchable_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
try
{
await
windowClass
.
setWindowTouchable
(
true
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting the window to be touchable.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the window to be touchable. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the window to be touchable. Cause:'
+
JSON
.
stringify
(
exception
));
}
})
/**
* @tc.number SUB_WINDOW_SETASPECTRATIO_TEST_JSAPI_001
* @tc.name Test setAspectRatio_Test_001
* @tc.desc Set the proportion of the window content layout
*/
it
(
'setAspectRatio_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setAspectRatio_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setAspectRatio_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
let
ratio
=
1.0
;
await
windowClass
.
setAspectRatio
(
ratio
)
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in setting aspect ratio of window.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to set the aspect ratio of window. Cause:'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to set the aspect ratio of window. Cause: '
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
1300004
);
await
windowClass
.
destroyWindow
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_RESETASPECTRATIO_JSAPI_001
* @tc.name Test resetAspectRatio_Test_001
* @tc.desc Unset the proportion of the window content layout
*/
it
(
'resetAspectRatio_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'resetAspectRatio_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"resetAspectRatio_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
await
windowClass
.
resetAspectRatio
()
.
then
(()
=>
{
console
.
info
(
msgStr
+
'Succeeded in resetting aspect ratio of window.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to reset the aspect ratio of window. Cause:'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to reset the aspect ratio of window. catch Cause: '
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
1300004
);
await
windowClass
.
destroyWindow
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_GETPROPERTIES_JSAPI_001
* @tc.name Test getProperties_Test_001
* @tc.desc Gets the properties of the current window Continuous call interface
*/
it
(
'getProperties_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getProperties_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getProperties_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
getProperties
()
.
then
((
data
)
=>
{
console
.
info
(
msgStr
+
'Succeeded in obtaining the window properties. Data: '
+
JSON
.
stringify
(
data
));
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the window properties. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowClass
.
getProperties
(
async
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to obtain the window properties. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
msgStr
+
'Succeeded in obtaining the window properties. Data: '
+
JSON
.
stringify
(
data
));
await
windowClass
.
destroyWindow
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETPROPERTIES_JSAPI_002
* @tc.name Test getProperties_Test_002
* @tc.desc Gets the properties of the current window Continuous call interface
*/
it
(
'getProperties_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getProperties_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getProperties_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
await
windowClass
.
getProperties
()
.
then
((
data
)
=>
{
console
.
info
(
msgStr
+
'Succeeded in obtaining the window properties. Data: '
+
JSON
.
stringify
(
data
));
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the window properties. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1001
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_001
* @tc.name Test getAvoidArea_Test_001
* @tc.desc Gets the area where the window content is avoided
*/
it
(
'getAvoidArea_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getAvoidArea_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getAvoidArea_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
getAvoidArea
(
ohosWindow
.
AvoidAreaType
.
TYPE_SYSTEM
)
.
then
((
data
)
=>
{
console
.
info
(
'Succeeded in obtaining the area. Data:'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
)
.
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowClass
.
getAvoidArea
(
ohosWindow
.
AvoidAreaType
.
TYPE_CUTOUT
,
async
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
'Succeeded in obtaining the area. Data:'
+
JSON
.
stringify
(
data
));
expect
(
!!
data
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_002
* @tc.name Test getAvoidArea_Test_002
* @tc.desc Gets the area where the window content is avoided
*/
it
(
'getAvoidArea_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getAvoidArea_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getAvoidArea_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
getAvoidArea
(
6
)
.
then
(
async
(
data
)
=>
{
console
.
info
(
'Succeeded in obtaining the area. Data:'
+
JSON
.
stringify
(
data
));
expect
()
.
assertFail
();
done
();
})
.
catch
(
async
(
err
)
=>
{
console
.
error
(
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1003
);
await
windowClass
.
destroyWindow
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETAVOIDAREA_JSAPI_003
* @tc.name Test getAvoidArea_Test_003
* @tc.desc Gets the area where the window content is avoided
*/
it
(
'getAvoidArea_Test_003'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getAvoidArea_Test_003'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"getAvoidArea_Test_003"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
await
windowClass
.
getAvoidArea
(
ohosWindow
.
AvoidAreaType
.
TYPE_CUTOUT
)
.
then
((
data
)
=>
{
console
.
info
(
'Succeeded in obtaining the area. Data:'
+
JSON
.
stringify
(
data
));
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to obtain the area. Cause:'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1001
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_SETFULLSCREEN_JSAPI_001
* @tc.name Test setFullScreen_Test_001
* @tc.desc Sets whether the window layout is full-screen
*/
it
(
'setFullScreen_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setFullScreen_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setFullScreen_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
setFullScreen
(
true
)
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowClass
.
setFullScreen
(
false
,
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
'Succeeded in enabling the full-screen mode.'
);
await
windowClass
.
destroyWindow
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_SETFULLSCREEN_JSAPI_002
* @tc.name Test setFullScreen_Test_002
* @tc.desc Sets whether the window layout is full-screen
*/
it
(
'setFullScreen_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setFullScreen_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setFullScreen_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
await
windowClass
.
setFullScreen
(
true
)
.
then
(()
=>
{
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1001
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_001
* @tc.name Test setLayoutFullScreen_Test_001
* @tc.desc Sets whether the window layout is full-screen
*/
it
(
'setLayoutFullScreen_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setLayoutFullScreen_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setLayoutFullScreen_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
setLayoutFullScreen
(
true
)
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowClass
.
setLayoutFullScreen
(
false
,
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'Failed to set the window layout to full-screen mode. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
'Succeeded in setting the window layout to full-screen mode.'
);
await
windowClass
.
destroyWindow
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_SETLAYOUTFULLSCREEN_JSAPI_002
* @tc.name Test setLayoutFullScreen_Test_002
* @tc.desc Sets whether the window layout is full-screen
*/
it
(
'setLayoutFullScreen_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setLayoutFullScreen_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setLayoutFullScreen_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
await
windowClass
.
setLayoutFullScreen
(
true
)
.
then
(()
=>
{
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1001
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_TEST_JSAPI_001
* @tc.name Test setSystemBarEnable_Test_001
* @tc.desc Set the visibility mode of the navigation bar and status bar when the window is in full-screen mode
*/
it
(
'setSystemBarEnable_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnable_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setSystemBarEnable_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
setSystemBarEnable
([])
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to set the system bar to be invisible. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowClass
.
setSystemBarEnable
([
'status'
,
'navigation'
],
async
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'Failed to set the system bar to be invisible. Cause:'
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
console
.
info
(
'Succeeded in setting the system bar to be invisible.'
);
await
windowClass
.
destroyWindow
();
done
();
});
})
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARENABLE_TEST_JSAPI_002
* @tc.name Test setSystemBarEnable_Test_002
* @tc.desc Set the visibility mode of the navigation bar and status bar when the window is in full-screen mode
*/
it
(
'setSystemBarEnable_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setSystemBarEnable_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setSystemBarEnable_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
windowClass
.
setSystemBarEnable
([])
.
then
(()
=>
{
console
.
info
(
'Succeeded in setting the system bar to be invisible.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to set the system bar to be invisible. Cause:'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1001
);
done
();
});
})
/**
* @tc.number SUB_WINDOW_GETMAINWINDOW_JSAPI_001
* @tc.name Test getMainWindow_Test_001
* @tc.desc Gets the main window under the WindowStage instance
*/
it
(
'getMainWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getMainWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
=
null
;
let
windowClass2
=
null
;
await
windowStage
.
getMainWindow
()
.
then
((
data
)
=>
{
console
.
info
(
msgStr
+
'Succeeded in obtaining the main window. Data: '
+
JSON
.
stringify
(
data
));
windowClass
=
data
;
expect
(
!!
windowClass
)
.
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowStage
.
getMainWindow
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
windowClass2
=
data
;
expect
(
!!
windowClass2
)
.
assertTrue
();
done
();
console
.
info
(
msgStr
+
'Succeeded in obtaining the main window. Data: '
+
JSON
.
stringify
(
data
));
});
})
/**
* @tc.number SUB_WINDOW_GETMAINWINDOWSYNC_JSAPI_001
* @tc.name Test getMainWindowSync_Test_001
* @tc.desc Gets the main window under the WindowStage instance
*/
it
(
'getMainWindowSync_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getMainWindowSync_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
=
null
;
let
windowClass2
=
null
;
try
{
windowClass
=
windowStage
.
getMainWindowSync
();
expect
(
!!
windowClass
)
.
assertTrue
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
;
try
{
windowClass2
=
windowStage
.
getMainWindowSync
();
expect
(
!!
windowClass2
)
.
assertTrue
();
done
();
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
;
})
/**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_001
* @tc.name Test createSubWindow_Test_001
* @tc.desc Create a child window under the WindowStage instance
*/
it
(
'createSubWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'createSubWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
=
null
;
let
windowClass2
=
null
;
try
{
await
windowStage
.
createSubWindow
(
'createSubWindow_Test_001_mySubWindow1'
)
.
then
((
data
)
=>
{
console
.
info
(
msgStr
+
'Succeeded in creating the subwindow. Data: '
+
JSON
.
stringify
(
data
));
windowClass
=
data
;
expect
(
!!
windowClass
)
.
assertTrue
();
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to create the subwindow. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to create the subwindow. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
;
try
{
windowStage
.
createSubWindow
(
'createSubWindow_Test_001_mySubWindow2'
,
async
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to create the subwindow. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
windowClass2
=
data
;
expect
(
!!
windowClass2
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
await
windowClass2
.
destroyWindow
();
done
();
console
.
info
(
msgStr
+
'Succeeded in creating the subwindow. Data: '
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
console
.
error
(
msgStr
+
'Failed to create the subwindow. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
;
})
/**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_001
* @tc.name Test getSubWindow_Test_001
* @tc.desc Gets all the child Windows under the WindowStage instance
*/
it
(
'getSubWindow_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'getSubWindow_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
=
null
;
let
windowClass2
=
null
;
windowClass
=
await
windowStage
.
getSubWindow
()
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the subwindow. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
windowStage
.
getSubWindow
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
msgStr
+
'Failed to obtain the subwindow. Cause: '
+
JSON
.
stringify
(
err
));
try
{
expect
()
.
assertFail
();
}
catch
(
error
)
{
console
.
log
(
msgStr
+
'expect catch err: '
+
JSON
.
stringify
(
error
))
}
done
();
return
;
}
windowClass2
=
data
;
expect
(
!!
windowClass2
)
.
assertTrue
();
done
();
console
.
info
(
'Succeeded in obtaining the subwindow. Data: '
+
JSON
.
stringify
(
data
));
});
})
/**
* @tc.number SUB_WINDOW_ISWINDOWSUPPORTWIDEGAMUT_JSAPI_001
* @tc.name Test isWindowSupportWideGamut_Test_001
* @tc.desc Check whether the current window supports the wide color gamut mode
*/
it
(
'isWindowSupportWideGamut_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'isWindowSupportWideGamut_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
windowStage
.
getMainWindow
()
.
catch
(
err
=>
{
expect
()
.
assertFail
();
done
();
});
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
isWindowSupportWideGamut
()
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to check whether the window support WideGamut. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
windowClass
.
isWindowSupportWideGamut
(
async
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'Failed to check whether the window support WideGamut. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
return
;
}
console
.
info
(
'Succeeded in checking whether the window support WideGamut Data: '
+
JSON
.
stringify
(
data
));
done
();
});
})
/**
* @tc.number SUB_WINDOW_ISWINDOWSHOWING_JSAPI_001
* @tc.name Test isWindowShowing_Test_001
* @tc.desc Check whether the current window is displayed
*/
it
(
'isWindowShowing_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'isWindowShowing_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"isWindowShowing_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
try
{
let
data
=
windowClass
.
isWindowShowing
();
expect
(
!
data
)
.
assertTrue
();
console
.
info
(
'Succeeded in checking whether the window is showing. Data: '
+
JSON
.
stringify
(
data
));
}
catch
(
exception
)
{
console
.
error
(
'Failed to check whether the window is showing. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
try
{
let
data2
=
windowClass
.
isWindowShowing
();
expect
(
!
data2
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
done
();
console
.
info
(
'Succeeded in checking whether the window is showing. Data: '
+
JSON
.
stringify
(
data2
));
}
catch
(
exception
)
{
console
.
error
(
'Failed to check whether the window is showing. Cause: '
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETUICONTENT_TEST_JSAPI_001
* @tc.name Test setUIContent_Test_001
* @tc.desc Set the display direction property of the window
*/
it
(
'setUIContent_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setUIContent_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setUIContent_Test_001"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
destroyWindow
();
try
{
windowClass
.
setUIContent
(
'MainAbility/pages/second/pageTwo'
,
(
err
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'Failed to load the content. Cause:'
+
JSON
.
stringify
(
err
));
expect
(
err
.
code
)
.
assertEqual
(
1300002
);
done
();
return
;
}
console
.
info
(
'Succeeded in loading the content.'
);
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
'Failed to load the content. Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETUICONTENT_JSAPI_002
* @tc.name Test setUIContent_Test_002
* @tc.desc Set the display direction property of the window
*/
it
(
'setUIContent_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setUIContent_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setUIContent_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
await
windowClass
.
setUIContent
(
'MainAbility/pages/second/pageTwo'
)
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to load the content. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
await
windowClass
.
setUIContent
(
'MainAbility/pages/second/pageOne'
)
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to load the content. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
await
windowClass
.
destroyWindow
();
done
();
})
/**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_001
* @tc.name Test setWindowSystemBarEnable_Test_001
* @tc.desc Set the visibility mode of the navigation bar and status bar when the window is in full-screen mode
*/
it
(
'setWindowSystemBarEnable_Test_001'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowSystemBarEnable_Test_001'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowClass
;
windowClass
=
await
ohosWindow
.
getLastWindow
(
context
)
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to obtain the top window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
return
;
})
expect
(
!!
windowClass
)
.
assertTrue
();
// 后端采用遍历方式,获取有效值,所以用例成功
let
names
=
[
'parmes'
,
'status'
,
'navigation'
];
try
{
windowClass
.
setWindowSystemBarEnable
(
names
)
.
then
(
async
()
=>
{
console
.
info
(
'Succeeded in setting the system bar to be invisible.'
);
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to set the system bar to be invisible. Cause:'
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
}
catch
(
exception
)
{
console
.
error
(
'Failed to set the system bar to be invisible. catch Cause:'
+
JSON
.
stringify
(
exception
));
expect
()
.
assertFail
();
done
();
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARENABLE_JSAPI_002
* @tc.name Test setWindowSystemBarEnable_Test_002
* @tc.desc Set the visibility mode of the navigation bar and status bar when the window is in full-screen mode
*/
it
(
'setWindowSystemBarEnable_Test_002'
,
0
,
async
function
(
done
)
{
let
caseName
=
'setWindowSystemBarEnable_Test_002'
;
let
msgStr
=
'jsunittest '
+
caseName
+
' '
;
console
.
log
(
msgStr
+
'begin'
);
let
windowId
=
"setWindowSystemBarEnable_Test_002"
let
windowConfig
=
{
name
:
windowId
,
windowType
:
1
,
ctx
:
context
};
let
windowClass
;
windowClass
=
await
ohosWindow
.
createWindow
(
windowConfig
)
.
catch
((
err
)
=>
{
console
.
log
(
msgStr
+
'Window createWindow err: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
})
expect
(
!!
windowClass
)
.
assertTrue
();
let
names
=
[
'status'
,
'navigation'
];
await
windowClass
.
destroyWindow
();
try
{
windowClass
.
setWindowSystemBarEnable
(
names
)
.
then
(()
=>
{
console
.
info
(
'Succeeded in setting the system bar to be invisible.'
);
expect
()
.
assertFail
();
done
();
})
.
catch
((
err
)
=>
{
console
.
error
(
'Failed to set the system bar to be invisible. Cause:'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'Failed to set the system bar to be invisible. catch Cause:'
+
JSON
.
stringify
(
exception
));
expect
(
exception
.
code
)
.
assertEqual
(
1300002
);
done
();
}
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录