Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
fa93fa47
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看板
提交
fa93fa47
编写于
8月 17, 2022
作者:
华
华华小仙女
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add xts snapshotTest、dialogTargetTouchTest、animationForShownTest
Signed-off-by:
N
华华小仙女
<
zhurong18@h-partners.com
>
上级
2d0193e1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
312 addition
and
1 deletion
+312
-1
graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets
...ndowStage/entry/src/main/ets/test/windowCallback.test.ets
+233
-1
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
...indowStage/entry/src/main/ets/test/windowPromise.test.ets
+79
-0
未找到文件。
graphic/windowStage/entry/src/main/ets/test/windowCallback.test.ets
浏览文件 @
fa93fa47
...
...
@@ -520,7 +520,134 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
})
})
})
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARPROPERTIES_JSAPI_005
* @tc.name Test setSystemBarPropertiesTest5
* @tc.desc Verify the scene where the status bar and navigation bar colors are set in hexadecimal form
*/
it('setSystemBarPropertiesTest5', 0, done => {
let caseName = 'setSystemBarPropertiesTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = {
SBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
SCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr))
};
let compareCount = 0;
let endNum = 0;
let listenerFlag = listenerStatus.ready;
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 === 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! 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));
}
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));
} 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 + 'compareCount: ' + compareCount + ' ,true flag:' + flag);
expect(true).assertTrue();
done();
} 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
}
}
}
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
windowStage.getMainWindow((err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
}
let tempWnd = data
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
tempWnd.show((err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.show', done);
}
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.show success');
tempWnd.setFullScreen(true, (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
}
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.setFullScreen(true) success');
tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
}
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
listenerFlag = listenerStatus.pending;
let loopCount = commonNUMBERColorArr.length
for (let i = 0; i < loopCount; i++) {
let tempColor = commonNUMBERColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
isStatusBarLightIcon: true,
statusBarContentColor: tempColor,
navigationBarColor: tempColor,
isNavigationBarLightIcon: true,
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) {
expect(TRUE_FLAG).assertFail();
done();
}
})
}
})
})
})
})
})
/**
* @tc.number SUB_WINDOW_SETSYSTEMBARPROPERTIES_JSAPI_006
* @tc.name Test setSystemBarPropertiesTest6
...
...
@@ -1348,5 +1475,110 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'done ');
done();
})
/**
* @tc.number SUB_WINDOW_SNAPSHOT_JSAPI_002
* @tc.name Test snapshotTest2
* @tc.desc Scenario of screenshot of verification window
*/
it('snapshotTest2', 0, async function (done) {
let caseName = 'snapshotTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let mainWin = await windowStage.getMainWindow().catch(err => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
});
console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin));
expect(!!mainWin).assertTrue();
await mainWin.snapshot((err, data) => {
if (err && err.code) {
console.log(msgStr + 'snapshot err.code:' + JSON.stringify(err.code));
return;
}
console.log(msgStr + 'snapshot success data:' + JSON.stringify(data));
mainWin.on('snapshot', (err, data) => {
if (err && err.code) {
console.log(msgStr + 'mainWin.on(snapshot) err.code:' + JSON.stringify(err.code));
return;
}
mainWin.off('snapshot', (err, data) => {
if (err && err.code) {
console.log(msgStr + 'mainWin.off(snapshot) err.code:' + JSON.stringify(err.code));
return;
}
})
})
})
done();
})
/**
* @tc.number SUB_WINDOW_DIALOGTARGETTOUCH_JSAPI_002
* @tc.name Test dialogTargetTouchTest2
* @tc.desc Verify the scenario of opening modal window
*/
it('dialogTargetTouchTest2', 0, done => {
let caseName = 'dialogTargetTouchTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let tempType = ohosWindow.WindowType.TYPE_DIALOG
ohosWindow.create(context, 'dialogTargetTouchTest2', tempType, (err, data) => {
console.log(msgStr + 'ohosWindow.create err' + JSON.stringify(err));
console.log(msgStr + 'ohosWindow.create data' + JSON.stringify(data));
if (err && err.code) {
unexpectedError(err, caseName, 'ohosWindow.create', done);
} else {
let dialogTargetTouchTest2Win = data
expect(!!dialogTargetTouchTest2Win).assertTrue();
dialogTargetTouchTest2Win.destroy();
done();
}
})
})
/**
* @tc.number SUB_WINDOW_ANIMATIONFORSHOWN_JSAPI_002
* @tc.name Test animationForShownTest2
* @tc.desc Verify window custom animation configuration of the scene
*/
it('animationForShownTest2', 0, async function (done) {
let caseName = 'animationForShownTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
console.log(msgStr + 'begin ohosWindow==' + JSON.stringify(ohosWindow));
let wndId = 'animationForShownTest2';
let baseType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let tempWnd = null;
ohosWindow.create(context, wndId, baseType, (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
} else {
tempWnd = data
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
let controller = tempWnd.getTransitionController();
controller.animationForShown = (context: ohosWindow.TransitionContext) => {
let toWindow = context.toWindow
animateTo({
duration: 1000, // 动画时长
tempo: 0.5, // 播放速率
curve: Curve.EaseInOut, // 动画曲线
delay: 0, // 动画延迟
iterations: 1, // 播放次数
playMode: PlayMode.Normal, // 动画模式
}, () => {
var obj: ohosWindow.TranslateOptions;
obj.x = 100.0;
obj.y = 0.0;
obj.z = 0.0;
toWindow.translate(obj);
console.info(msgStr + 'toWindow translate end');
}
)
context.completeTransition(true)
console.info(msgStr + 'complete transition end');
}
done();
}
});
})
})
}
graphic/windowStage/entry/src/main/ets/test/windowPromise.test.ets
浏览文件 @
fa93fa47
...
...
@@ -1404,5 +1404,84 @@ export default function windowPromiseTest(context, windowStage, abilityStorage)
console.log(msgStr + 'done ');
done();
})
/**
* @tc.number SUB_WINDOW_SNAPSHOT_JSAPI_001
* @tc.name Test snapshotTest1
* @tc.desc Scenario of screenshot of verification window
*/
it('snapshotTest1', 0, async function (done) {
let caseName = 'snapshotTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let mainWin = await windowStage.getMainWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
});
console.log(msgStr + 'windowStage.getMainWindow' + JSON.stringify(mainWin));
expect(!!mainWin).assertTrue();
let snapshotData = await mainWin.snapshot().catch((err) => {
unexpectedError(err, caseName, 'mainWin.snapshot', done);
console.log(msgStr + 'snapshot err.code:' + JSON.stringify(err.code));
})
expect(!!snapshotData).assertTrue();
done();
})
/**
* @tc.number SUB_WINDOW_DIALOGTARGETTOUCH_JSAPI_001
* @tc.name Test dialogTargetTouchTest1
* @tc.desc Verify the scenario of opening modal window
*/
it('dialogTargetTouchTest1', 0, async function (done) {
let caseName = 'dialogTargetTouchTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
let tempType = ohosWindow.WindowType.TYPE_DIALOG
let dialogTargetTouchTest1Win = await ohosWindow.create(context, 'dialogTargetTouchTest1', tempType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
})
expect(!!dialogTargetTouchTest1Win).assertTrue();
dialogTargetTouchTest1Win.destroy();
done();
})
/**
* @tc.number SUB_WINDOW_ANIMATIONFORSHOWN_JSAPI_001
* @tc.name Test animationForShownTest1
* @tc.desc Verify window custom animation configuration of the scene
*/
it('animationForShownTest1', 0, async function (done) {
let caseName = 'animationForShownTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
console.log(msgStr + 'begin ohosWindow==' + JSON.stringify(ohosWindow));
let wndId = 'animationForShownTest1';
let baseType = ohosWindow.WindowType.TYPE_SYSTEM_ALERT;
let tempWnd = await ohosWindow.create(context,wndId, baseType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create ' + baseType, done);
});
console.log(msgStr + 'ohosWindow.create ' + baseType + ', tempWnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
let controller = tempWnd.getTransitionController();
controller.animationForShown = (context: ohosWindow.TransitionContext) => {
let toWindow = context.toWindow
animateTo({
duration: 1000, // 动画时长
tempo: 0.5, // 播放速率
curve: Curve.EaseInOut, // 动画曲线
delay: 0, // 动画延迟
iterations: 1, // 播放次数
playMode: PlayMode.Normal, // 动画模式
}, () => {
var obj: ohosWindow.TranslateOptions;
obj.x = 100.0;
obj.y = 0.0;
obj.z = 0.0;
toWindow.translate(obj);
console.info(msgStr + 'toWindow translate end');
}
)
context.completeTransition(true)
console.info(msgStr + 'complete transition end');
}
done();
})
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录