Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e7b58781
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看板
提交
e7b58781
编写于
2月 20, 2023
作者:
华
华华小仙女
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.优化setSystemBarEnableTest8用例 2.优化listenerTest5 3.补充WindowEventType、Orientation属性枚举值
Signed-off-by:
N
华华小仙女
<
zhurong18@h-partners.com
>
上级
c4fc77be
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
95 addition
and
45 deletion
+95
-45
graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets
...ndowStage/entry/src/main/ets/test/windowCallback.test.ets
+51
-45
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
...indowStage/entry/src/main/ets/test/windowPromise.test.ets
+44
-0
未找到文件。
graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets
浏览文件 @
e7b58781
...
@@ -401,22 +401,24 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -401,22 +401,24 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console
.
log
(
msgStr
+
'begin'
);
console
.
log
(
msgStr
+
'begin'
);
ohosWindow
.
on
(
'systemBarTintChange'
,
systembartintstate
=>
{
ohosWindow
.
on
(
'systemBarTintChange'
,
systembartintstate
=>
{
console
.
log
(
msgStr
+
'ohosWindow.on systemBarTintChange :'
+
JSON
.
stringify
(
systembartintstate
));
if
(
flagStatus
&&
flagNav
)
{
console
.
log
(
msgStr
+
'ohosWindow.on systembartintstate.regionTint : '
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
console
.
log
(
msgStr
+
'ohosWindow.on systembartintstate.regionTint : '
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
if
(
flagStatus
||
flagNav
)
{
let
enable
=
systembartintstate
.
regionTint
[
0
]
.
isEnable
let
enable
=
systembartintstate
.
regionTint
[
0
]
.
isEnable
let
numType
=
systembartintstate
.
regionTint
[
0
]
.
type
let
numType
=
systembartintstate
.
regionTint
[
0
]
.
type
console
.
log
(
msgStr
+
'ohosWindow.on isEnable : '
+
JSON
.
stringify
(
enable
));
console
.
log
(
msgStr
+
'ohosWindow.on isEnable : '
+
JSON
.
stringify
(
enable
));
console
.
log
(
msgStr
+
'ohosWindow.on numType : '
+
JSON
.
stringify
(
numType
));
console
.
log
(
msgStr
+
'ohosWindow.on numType : '
+
JSON
.
stringify
(
numType
));
try
{
try
{
expect
(
numType
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
||
enable
)
.
assertTrue
();
expect
(
numType
===
ohosWindow
.
WindowType
.
TYPE_STATUS_BAR
||
numType
===
ohosWindow
.
WindowType
.
TYPE_NAVIGATION_BAR
&&
enable
)
.
assertTrue
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
`ohosWindow.on catch err: ${JSON.stringify(error)}`
)
console
.
info
(
`ohosWindow.on catch err: ${JSON.stringify(error)}`
)
}
}
ohosWindow
.
off
(
'systemBarTintChange'
)
ohosWindow
.
off
(
'systemBarTintChange'
)
done
();
done
();
}
else
{
console
.
log
(
msgStr
+
'flagStatus :'
+
flagStatus
+
' ,regionTint:'
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
console
.
log
(
msgStr
+
'flagNav :'
+
flagNav
+
' ,regionTint:'
+
JSON
.
stringify
(
systembartintstate
.
regionTint
));
}
}
})
})
function
getMainWindow
()
{
function
getMainWindow
()
{
...
@@ -459,19 +461,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -459,19 +461,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
})
})
}
}
function
setSystemBarEnable
(
mainWnd
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
mainWnd
.
setSystemBarEnable
([],
(
err
)
=>
{
console
.
log
(
msgStr
+
'mainWnd.setSystemBarEnable [] JSON.stringify(data)=='
+
JSON
.
stringify
(
err
));
if
(
err
&&
err
.
code
)
{
reject
(
null
)
}
else
{
resolve
(
true
)
}
})
})
}
function
setSystemBarEnableT
(
mainWnd
)
{
function
setSystemBarEnableT
(
mainWnd
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
mainWnd
.
setSystemBarEnable
([
'status'
,
'navigation'
],
(
err
,
data
)
=>
{
mainWnd
.
setSystemBarEnable
([
'status'
,
'navigation'
],
(
err
,
data
)
=>
{
...
@@ -481,7 +470,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -481,7 +470,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
flagStatus
=
true
;
flagStatus
=
true
;
flagNav
=
true
;
flagNav
=
true
;
resolve
(
true
)
resolve
(
true
)
console
.
log
(
msgStr
+
'mainWnd.setSystemBarEnable [status, navigation]
JSON.stringify(data)
=='
+
JSON
.
stringify
(
data
));
console
.
log
(
msgStr
+
'mainWnd.setSystemBarEnable [status, navigation]
data
=='
+
JSON
.
stringify
(
data
));
}
}
})
})
})
})
...
@@ -504,11 +493,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -504,11 +493,6 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
expect
()
.
assertFail
()
expect
()
.
assertFail
()
done
();
done
();
});
});
await
setSystemBarEnable
(
mainWnd
)
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
await
setSystemBarEnableT
(
mainWnd
)
.
catch
((
err
)
=>
{
await
setSystemBarEnableT
(
mainWnd
)
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
expect
()
.
assertFail
();
...
@@ -1233,6 +1217,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -1233,6 +1217,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console
.
log
(
msgStr
+
'begin'
);
console
.
log
(
msgStr
+
'begin'
);
listenerData
.
on
=
true
;
listenerData
.
on
=
true
;
listenerData
.
typeStr
=
'systemAvoidAreaChange'
;
listenerData
.
typeStr
=
'systemAvoidAreaChange'
;
let
setSystemBarEnableType
=
null
;
function
setSystemBarEnable
(
tempWnd
)
{
function
setSystemBarEnable
(
tempWnd
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
...
@@ -1242,6 +1227,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -1242,6 +1227,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}
else
{
}
else
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([]) success'
);
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([]) success'
);
listenerOnFlag
=
true
;
listenerOnFlag
=
true
;
setSystemBarEnableType
=
0
;
resolve
(
true
)
resolve
(
true
)
}
}
})
})
...
@@ -1255,7 +1241,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -1255,7 +1241,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
reject
(
false
)
reject
(
false
)
}
else
{
}
else
{
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
console
.
log
(
msgStr
+
'tempWnd.setSystemBarEnable([status, navigation]) success'
);
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange finished'
)
;
setSystemBarEnableType
=
2
;
resolve
(
true
)
resolve
(
true
)
}
}
})
})
...
@@ -1266,46 +1252,66 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
...
@@ -1266,46 +1252,66 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
tempWnd
=
await
windowStage
.
getMainWindow
()
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
err
));
console
.
error
(
msgStr
+
'Failed to obtain the main window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
()
expect
()
.
assertFail
()
done
();
});
});
expect
(
!!
tempWnd
)
.
assertTrue
();
expect
(
!!
tempWnd
)
.
assertTrue
();
await
tempWnd
.
show
()
.
then
((
data
)
=>
{
console
.
info
(
msgStr
+
'Success to show the window. data: '
+
JSON
.
stringify
(
data
));
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to show the window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
()
});
await
tempWnd
.
setFullScreen
(
true
)
.
then
((
data
)
=>
{
console
.
info
(
msgStr
+
'Success to enable the full-screen mode. data: '
+
JSON
.
stringify
(
data
));
})
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
()
});
tempWnd
.
on
(
'systemAvoidAreaChange'
,
avoidAreaData
=>
{
tempWnd
.
on
(
'systemAvoidAreaChange'
,
avoidAreaData
=>
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, avoidAreaData : '
+
JSON
.
stringify
(
avoidAreaData
));
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, avoidAreaData : '
+
JSON
.
stringify
(
avoidAreaData
));
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, setSystemBarEnableType : '
+
setSystemBarEnableType
);
if
(
listenerOnFlag
===
true
)
{
if
(
listenerOnFlag
===
true
)
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, listenerOnFlag : '
+
listenerOnFlag
);
try
{
try
{
expect
(
!!
avoidAreaData
)
.
assertTrue
();
expect
(
!!
avoidAreaData
)
.
assertTrue
();
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
info
(
`tempWnd.on catch error: ${JSON.stringify(error)}`
)
console
.
info
(
msgStr
+
`tempWnd.on catch error: ${JSON.stringify(error)}`
)
}
}
tempWnd
.
off
(
'systemAvoidAreaChange'
)
tempWnd
.
off
(
'systemAvoidAreaChange'
)
done
()
done
();
}
else
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, listenerOnFlag : '
+
listenerOnFlag
);
if
(
setSystemBarEnableType
===
0
)
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, setSystemBarEnableType === 0'
);
try
{
expect
()
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
msgStr
+
`tempWnd.on catch error: ${JSON.stringify(error)}`
)
}
tempWnd
.
off
(
'systemAvoidAreaChange'
)
done
();
}
else
if
(
setSystemBarEnableType
===
2
)
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, setSystemBarEnableType === 2'
);
try
{
expect
()
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
msgStr
+
`tempWnd.on catch error: ${JSON.stringify(error)}`
)
}
tempWnd
.
off
(
'systemAvoidAreaChange'
)
done
();
}
else
{
console
.
log
(
msgStr
+
'tempWnd.on systemAvoidAreaChange, setSystemBarEnableType null:'
+
setSystemBarEnableType
);
}
}
}
})
})
await
tempWnd
.
show
()
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to show the window. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
()
done
();
});
await
tempWnd
.
setFullScreen
(
true
)
.
catch
((
err
)
=>
{
console
.
error
(
msgStr
+
'Failed to enable the full-screen mode. Cause: '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
()
done
();
});
await
tempWnd
.
setSystemBarEnable
([
'status'
,
'navigation'
])
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
done
();
});
await
setSystemBarEnable
(
tempWnd
)
.
catch
((
err
)
=>
{
await
setSystemBarEnable
(
tempWnd
)
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
expect
()
.
assertFail
();
done
();
});
});
await
setSystemBarEnableT
(
tempWnd
)
.
catch
((
err
)
=>
{
await
setSystemBarEnableT
(
tempWnd
)
.
catch
((
err
)
=>
{
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
console
.
info
(
msgStr
+
'setWindowSystemBarEnable error : '
+
JSON
.
stringify
(
err
));
expect
()
.
assertFail
();
expect
()
.
assertFail
();
done
();
});
});
})
})
/**
/**
...
...
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
浏览文件 @
e7b58781
...
@@ -1727,5 +1727,49 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
...
@@ -1727,5 +1727,49 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
expectedError(exception, caseName, 'mainWnd.setAspectRatio', done, 401);
expectedError(exception, caseName, 'mainWnd.setAspectRatio', done, 401);
}
}
})
})
/**
* @tc.number WINDOWEVENTTYPE_JSAPI_001
* @tc.name Test windowEventType_Test_001.
* @tc.desc Test the enumeration value of WindowEventType
*/
it('windowEventType_Test_001', 0, async function (done) {
let caseName = 'windowEventType_Test_001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
console.log(msgStr + 'ohosWindow.WindowEventType:' +JSON.stringify(ohosWindow.WindowEventType));
try {
expect(1).assertEqual(ohosWindow.WindowEventType.WINDOW_SHOWN);
expect(2).assertEqual(ohosWindow.WindowEventType.WINDOW_ACTIVE);
expect(3).assertEqual(ohosWindow.WindowEventType.WINDOW_INACTIVE);
expect(4).assertEqual(ohosWindow.WindowEventType.WINDOW_HIDDEN);
done();
} catch (err) {
console.info(msgStr + 'windowEventType error :' + JSON.stringify(err));
expect().assertFail();
done();
}
})
/**
* @tc.number ORIENTATION_JSAPI_001
* @tc.name Test orientation_Test_001.
* @tc.desc Test the enumeration value of Orientation
*/
it('orientation_Test_001', 0, async function (done) {
let caseName = 'orientation_Test_001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
console.log(msgStr + 'display.orientation:' +JSON.stringify(display.Orientation));
try {
expect(0).assertEqual(display.Orientation.PORTRAIT);
expect(1).assertEqual(display.Orientation.LANDSCAPE);
expect(2).assertEqual(display.Orientation.PORTRAIT_INVERTED);
expect(3).assertEqual(display.Orientation.LANDSCAPE_INVERTED);
done();
} catch (err) {
console.info(msgStr + 'Orientation error :' + JSON.stringify(err));
expect().assertFail();
done();
}
})
})
})
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录