提交 28afd11b 编写于 作者: H hu0475

修复gn格式问题和按接口人要求完善代码

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 842c5fe2
......@@ -16,7 +16,7 @@ group("graphic") {
testonly = true
if (is_standard_system) {
deps = [
"crossplatform/window:window_ets_normal_test",
"crossplatform/window:ActsCrossplatformWindowTest",
"effectKit:EffectKitTest",
"graphicColorSpace:ActsColorSpaceManagerTest",
"graphicnapidrawingtest:ActsGraphicNapiDrawingTest",
......
......@@ -6,10 +6,10 @@
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 9,
"targetAPIVersion": 9,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 9,
"apiCompatibleVersion": 10,
"singleUser": false
}
}
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("window_ets_normal_test") {
ohos_js_hap_suite("ActsCrossplatformWindowTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
......@@ -21,7 +21,7 @@ ohos_js_hap_suite("window_ets_normal_test") {
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsWindowTest"
hap_name = "ActsCrossplatformWindowTest"
subsystem_name = "window"
part_name = "window_manager"
}
......
......@@ -6,12 +6,12 @@
"shell-timeout": "300000",
"bundle-name": "ohos.acts.graphic.crossplatform.window",
"module-name": "window",
"testcase-timeout": 5000
"testcase-timeout": 10000
},
"kits": [
{
"test-file-name": [
"ActsWindowTest.hap"
"ActsCrossplatformWindowTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
/*
* Copyright (c) 2023 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.
*/
@Entry
@Component
struct Index1 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World \n pages/Index1!!!')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
......@@ -23,6 +23,10 @@ export default function Window() {
let storage;
const TRUE_FLAG = true;
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
beforeAll(async function () {
console.info("beforeAll case");
context = globalThis.abilityContext;
......@@ -172,7 +176,11 @@ export default function Window() {
return;
}
console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
try {
expect(data != null).assertTrue();
} catch (err) {
console.info(msgStr + "err " + err);
}
await windowData.destroyWindow();
done();
})
......@@ -197,8 +205,9 @@ export default function Window() {
try {
tempWnd = await windowStage.createSubWindow('testShowWindowPromise001');
expect(!!tempWnd).assertTrue();
await tempWnd.showWindow().then(async (data) => {
console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data));
await tempWnd.showWindow().then(async () => {
expect(TRUE_FLAG).assertTrue();
console.info(msgStr + 'Succeeded in showing the window. ');
await tempWnd.destroyWindow();
done();
}).catch((err) => {
......@@ -227,7 +236,7 @@ export default function Window() {
let winData;
winData = await windowStage.createSubWindow('testShowWindowCb001');
expect(!!winData).assertTrue();
winData.showWindow(async (err, data) => {
winData.showWindow(async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err));
try {
......@@ -238,7 +247,8 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data));
console.info(msgStr + 'Succeeded in showing the window.');
expect(TRUE_FLAG).assertTrue();
await winData.destroyWindow();
done();
})
......@@ -314,7 +324,11 @@ export default function Window() {
expect(!findWnd).assertTrue();
} catch (exception) {
console.error(msgStr + 'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception));
try {
expect(exception.code).assertEqual(1300002);
} catch (err) {
console.error(msgStr + 'fail ' + JSON.stringify(err));
}
}
}
done();
......@@ -520,7 +534,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(300, 300, async (err, data) => {
winData.moveWindowTo(300, 300, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
......@@ -532,7 +546,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
console.info(msgStr + 'Succeeded in moving the window. ');
await winData.destroyWindow();
done();
})
......@@ -559,7 +573,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(100, 50, async (err, data) => {
winData.moveWindowTo(100, 50, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
......@@ -571,7 +585,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
console.info(msgStr + 'Succeeded in moving the window. ');
await winData.destroyWindow();
done();
})
......@@ -598,7 +612,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(20000, 20000, async (err, data) => {
winData.moveWindowTo(20000, 20000, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
......@@ -610,7 +624,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
console.info(msgStr + 'Succeeded in moving the window. ');
await winData.destroyWindow();
done();
})
......@@ -637,7 +651,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(-200, -200, async (err, data) => {
winData.moveWindowTo(-200, -200, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
......@@ -649,7 +663,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window. Data: ' + JSON.stringify(data));
console.info(msgStr + 'Succeeded in moving the window.');
await winData.destroyWindow();
done();
})
......@@ -1239,7 +1253,7 @@ export default function Window() {
expect(!!mainWin).assertTrue();
let num = 0
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED',
'LANDSCAPE_INVERTED'];
'LANDSCAPE_INVERTED', 'UNSPECIFIED'];
for (let i = 0; i < orientationItem.length; i++) {
let orientation = window.Orientation[orientationItem[i]]
console.log(msgStr + 'i : ' + i + ' ,orientation : ' + orientation);
......@@ -1249,8 +1263,9 @@ export default function Window() {
num++
if (num == orientationItem.length) done();
}).catch(err => {
console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation);
console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation + err);
});
await sleep(500);
}
})
/**
......@@ -1294,7 +1309,11 @@ export default function Window() {
let orientation = window.Orientation[orientationItem[i]]
await setPreferredOrientationFun(mainWin, orientation).catch((err) => {
console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
try {
expect().assertFail();
} catch (err) {
console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
}
done();
});
console.info(msgStr + 'Succeeded in setting window orientation. orientation: ' + orientation + "step: " + i);
......@@ -1322,14 +1341,14 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let load = await tempWnd.loadContent('pages/second/second', storage).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
console.log(msgStr + 'tempWnd.loadContent(pages/second/second) err=' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent(pages/second/second) load=' + JSON.stringify(load));
expect(!load).assertTrue();
await tempWnd.loadContent('TestAbility/pages/index1', storage).then(async () => {
console.log(msgStr + 'tempWnd.loadContent() success');
expect(TRUE_FLAG).assertTrue();
await tempWnd.destroyWindow();
done();
}).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
});
})
/**
* @tc.number : TEST_LOADCONTENT_PROMISE_002
......@@ -1348,15 +1367,13 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
await tempWnd.destroyWindow();
let errFlag = false;
try {
await tempWnd.loadContent(null, storage);
expect().assertFail();
done();
} catch (err) {
errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 401);
await tempWnd.destroyWindow();
console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err));
}
})
......@@ -1378,17 +1395,19 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
tempWnd.loadContent('pages/index', storage, async (err, data) => {
tempWnd.loadContent('TestAbility/pages/index1', storage, async (err) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
} else {
try {
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.loadContent() success');
expect(TRUE_FLAG).assertTrue();
done();
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
done()
}
await tempWnd.destroyWindow();
done()
}
})
})
......@@ -1409,7 +1428,7 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
try {
tempWnd.loadContent(null, storage, async (err, data) => {
tempWnd.loadContent(null, storage, async (err) => {
if (err && err.code) {
try {
expect(err.code === 401).assertTrue();
......@@ -1434,7 +1453,7 @@ export default function Window() {
}
})
/**
* @tc.number : testGetUIContext001
* @tc.number : TEST_GETUICONTEXT_001
* @tc.name : testGetUIContext001
* @tc.desc : test getUIContext
* @tc.size : MediumTest
......@@ -1442,20 +1461,12 @@ export default function Window() {
* @tc.level : Level 2
*/
it('testGetUIContext001', 0, async function (done) {
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error('testGetUIContext001 Failed to obtain the main window. Cause: ' + JSON.stringify(err));
expect(false).assertTrue();
done()
} else {
console.info('testGetUIContext001 Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
expect(data != undefined).assertTrue();
let UIContext = data.getUIContext();
let tempWnd = await windowStage.getMainWindow();
expect(!!tempWnd).assertTrue();
let UIContext = tempWnd.getUIContext();
expect(UIContext != undefined).assertTrue();
console.info('testGetUIContext001 Succeeded');
done();
}
})
})
/**
* @tc.number : TEST_SETUICONTENT_PROMISE_001
......@@ -1470,7 +1481,7 @@ export default function Window() {
try {
win = await windowStage.createSubWindow('testSetUIContentPromise001');
expect(win != null);
await win.setUIContent('pages/second/second').then(async () => {
await win.setUIContent('TestAbility/pages/index1').then(async () => {
console.info('setUIContent1 . Cause: success');
expect(TRUE_FLAG).assertTrue();
await win.destroyWindow();
......@@ -1537,7 +1548,7 @@ export default function Window() {
try {
win = await windowStage.createSubWindow('testSetUIContentPromise003');
expect(win != null).assertTrue();
await win.setUIContent('pages/second/he').then(async () => {
await win.setUIContent('wrong pages').then(async () => {
console.info('setUIContent3 . Cause: success');
expect(TRUE_FLAG).assertTrue();
await win.destroyWindow();
......@@ -1567,12 +1578,11 @@ export default function Window() {
winData = await windowStage.createSubWindow('testSetUIContentCb001');
expect(!!winData).assertTrue();
try {
winData.setUIContent('pages/second/second', async (err) => {
winData.setUIContent('TestAbility/pages/index1', async (err) => {
try {
if (err.code) {
console.error('Failed to load the content callback. Cause:' + JSON.stringify(err));
expect().assertFail();
} else {
console.info('Succeeded in loading the content.');
expect(TRUE_FLAG).assertTrue();
......@@ -1585,7 +1595,11 @@ export default function Window() {
});
} catch (exception) {
console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception));
try {
expect().assertFail();
} catch (err) {
console.error('Failed callback to load the content. Cause:' + JSON.stringify(err));
}
await winData.destroyWindow();
done();
}
......@@ -1867,7 +1881,7 @@ export default function Window() {
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
await wnd.setWindowBrightness(Number.MIN_VALUE).then(() => {
console.info('windowTest setWindowBrightnessTest3 setBrightness(Number.MAX_VALUE) success ');
console.info('windowTest setWindowBrightnessTest4 setBrightness(Number.MIN_VALUE) success ');
expect(TRUE_FLAG).assertTrue();
done();
}, (err) => {
......@@ -2075,7 +2089,7 @@ export default function Window() {
}
done();
} else {
console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.MAX_VALUE) success ');
console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.MIN_VALUE) success ');
try {
expect(TRUE_FLAG).assertTrue();
} catch (error) {
......@@ -2113,7 +2127,7 @@ export default function Window() {
}
done();
} else {
console.info('windowTest setBrightnessTest5CallBack setBrightness(Number.MAX_VALUE) success ');
console.info('windowTest setBrightnessTest5CallBack setBrightness(1.1) success ');
try {
expect().assertFail();
} catch (error) {
......@@ -2187,7 +2201,7 @@ export default function Window() {
console.info('windowTest testSetWindowKeepScreenOnCb001 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowKeepScreenOn(true, (err, data) => {
wnd.setWindowKeepScreenOn(true, (err) => {
if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
try {
......@@ -2197,7 +2211,7 @@ export default function Window() {
}
done();
} else {
console.info('success set the screen to be always on. Cause: ' + JSON.stringify(data));
console.info('success set the screen to be always on.');
let data2 = wnd.getWindowProperties();
try {
expect(data2.isKeepScreenOn).assertTrue();
......@@ -2220,7 +2234,7 @@ export default function Window() {
console.info('windowTest testSetWindowKeepScreenOnCb002 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowKeepScreenOn(false, (err, data) => {
wnd.setWindowKeepScreenOn(false, (err) => {
if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
try {
......@@ -2230,7 +2244,7 @@ export default function Window() {
}
done();
} else {
console.info('success set the screen to be always on. Cause: ' + JSON.stringify(data));
console.info('success set the screen to be always on. ');
let data2 = wnd.getWindowProperties();
try {
expect(!data2.isKeepScreenOn).assertTrue();
......
......@@ -13,19 +13,23 @@
* limitations under the License.
*/
import window from '@ohos.window';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function WindowStage() {
describe("WindowStage", function () {
let windowStage;
let abilityStorage;
let storage;
const TRUE_FLAG = true;
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
beforeAll(async function () {
console.info("beforeAll case");
windowStage = globalThis.windowStage;
abilityStorage = globalThis.abilityStorage;
storage = new LocalStorage();
storage.setOrCreate('storageSimpleProp', 121);
});
beforeEach(async function () {
......@@ -40,16 +44,6 @@ export default function WindowStage() {
console.info("afterAll case");
});
async function sleep(time) {
let timeoutId = null;
let promise = new Promise(resolve => {
timeoutId = setTimeout(() => {
resolve('sleep finished');
}, time);
})
clearTimeout(timeoutId)
}
function expectedError(error, caseName, apiName, done, code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
......@@ -66,15 +60,13 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
try {
expect(TRUE_FLAG).assertFail();
expect().assertFail();
} catch (error) {
console.info(`unexpectedError catch error: ${JSON.stringify(error)}`)
}
done();
}
/**
* @tc.number : TEST_GETMAINWINDOW_PROMISE_001
* @tc.name : testGetMainWindowPromise001
......@@ -109,12 +101,15 @@ export default function WindowStage() {
windowStage.getMainWindow((err, data) => {
if (err.code) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
expect(false).assertTrue();
done();
return;
}
try {
expect(!!data).assertTrue();
console.log(msgStr + 'getMainWindow success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
}
})
})
/**
......@@ -152,14 +147,14 @@ export default function WindowStage() {
let caseName = 'testCreateSubWindowPromise001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow('createSubWindow').catch((err) => {
let subWindow = await windowStage.createSubWindow('testCreateSubWindowPromise001').catch((err) => {
unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest1)=' + JSON.stringify(err));
});
expect(!!subWindow).assertTrue();
await subWindow.destroy();
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
console.log(msgStr + 'windowStage.createSubWindow end !!subWindow=' + !!subWindow);
await subWindow.destroyWindow();
done();
})
/**
......@@ -180,8 +175,7 @@ export default function WindowStage() {
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
});
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
}
catch (err) {
} catch (err) {
expectedError(err, caseName, 'windowStage.createSubWindow', done, 401);
console.log(msgStr + 'windowStage.createSubWindow catch err=' + JSON.stringify(err));
}
......@@ -199,70 +193,19 @@ export default function WindowStage() {
let caseName = 'testCreateSubWindowCb001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let subWnd = null
function createSubWindow() {
return new Promise(function (resolve, reject) {
windowStage.createSubWindow('createSubWindow', (err, data) => {
windowStage.createSubWindow('testCreateSubWindowCb001', async (err, data) => {
if (err && err.code) {
reject(null)
console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest3) err=' + JSON.stringify(err));
} else {
resolve(data)
}
})
})
}
function findWin() {
return new Promise(function (resolve, reject) {
window.find('createSubWindow', (err, data) => {
if (err && err.code) {
reject(false)
} else {
resolve(data)
}
})
})
}
function destroyWin(win) {
return new Promise(function (resolve, reject) {
win.destroy((err, data) => {
if (err && err.code) {
reject(null)
unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
} else {
resolve(true)
try {
expect(!!data).assertTrue();
console.log(msgStr + ' success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
}
})
})
}
subWnd = await createSubWindow().catch(err => {
console.info(`window.create failed error: ${JSON.stringify(err)}`)
expect().assertFail();
done();
})
expect(!!subWnd).assertTrue();
let subWindow;
subWindow = await findWin().catch(err => {
console.info(`window.find failed error: ${JSON.stringify(err)}`)
expect().assertFail();
done();
})
await destroyWin(subWindow).catch(err => {
console.info(`window.destroy failed error: ${JSON.stringify(err)}`)
expect().assertFail();
done();
})
let subWindowLast;
subWindowLast = await findWin().catch(err => {
console.info(`window.find failed error: ${JSON.stringify(err)}`)
expect(!err).assertTrue();
done()
})
})
/**
......@@ -359,12 +302,17 @@ export default function WindowStage() {
let caseName = 'testLoadContentPromise001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load3 = await windowStage.loadContent('MainAbility/pages/second/second').catch((err) => {
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index1').then(async () => {
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
}).catch((err) => {
unexpectedError(err, caseName, 'windowStage loadContent', done);
console.log(msgStr + 'windowStage loadContent MainAbility/pages/second/second' + JSON.stringify(err));
});
expect(!load3).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load=' + JSON.stringify(load3));
done();
})
/**
......@@ -380,11 +328,11 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
try {
let load4 = await windowStage.loadContent(null).catch((err) => {
let load = await windowStage.loadContent(null).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'windowStage loadContent null' + JSON.stringify(err));
});
console.log(msgStr + 'windowStage loadContent end load5=' + JSON.stringify(load4));
console.log(msgStr + 'windowStage loadContent end load=' + JSON.stringify(load));
}
catch (err) {
console.log(msgStr + 'windowStage loadContent catch err=' + JSON.stringify(err));
......@@ -395,7 +343,7 @@ export default function WindowStage() {
/**
* @tc.number : TEST_LOADCONTENT_PROMISE_003
* @tc.name : testLoadContentPromise003
* @tc.desc : Verify the scenario of loading an null page with abilityStorage
* @tc.desc : Verify the scenario of loading an null page with storage
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
......@@ -405,11 +353,11 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
try {
let load5 = await windowStage.loadContent(null, abilityStorage).catch((err) => {
let load = await windowStage.loadContent(null, storage).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'windowStage loadContent null' + JSON.stringify(err));
});
console.log(msgStr + 'windowStage loadContent end load5=' + JSON.stringify(load5));
console.log(msgStr + 'windowStage loadContent end load=' + JSON.stringify(load));
}
catch (err) {
console.log(msgStr + 'windowStage loadContent catch err=' + JSON.stringify(err));
......@@ -420,7 +368,7 @@ export default function WindowStage() {
/**
* @tc.number : TEST_LOADCONTENT_PROMISE_004
* @tc.name : testLoadContentPromise004
* @tc.desc : Verify the scenario of loading an page and abilityStorage of null
* @tc.desc : Verify the scenario of loading an page and storage of null
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
......@@ -429,11 +377,17 @@ export default function WindowStage() {
let caseName = 'testLoadContentPromise004';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load6 = await windowStage.loadContent('MainAbility/pages/second/second', null).catch((err) => {
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index1', null).then(async () => {
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
}).catch((err) => {
unexpectedError(err, caseName, 'windowStage loadContent', done);
console.log(msgStr + 'windowStage loadContent MainAbility/pages/second/second' + JSON.stringify(err));
});
expect(!load6).assertTrue();
done();
})
......@@ -449,18 +403,21 @@ export default function WindowStage() {
let caseName = 'testLoadContentCb001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.loadContent('MainAbility/pages/second/second', (err, data) => {
await sleep(500);
windowStage.loadContent('TestAbility/pages/Index1', async (err) => {
if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
console.log(msgStr + 'windowStage loadContent MainAbility/pages/second/second' + JSON.stringify(err));
} else {
try {
expect(!data).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data));
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
}
}
})
})
......@@ -478,7 +435,7 @@ export default function WindowStage() {
console.log(msgStr + 'begin');
try {
windowStage.loadContent(null, (err, data) => {
windowStage.loadContent(null, (err) => {
console.log(msgStr + 'windowStage loadContent null' + JSON.stringify(err));
try {
expect(false).assertTrue();
......@@ -502,7 +459,7 @@ export default function WindowStage() {
/**
* @tc.number : TEST_LOADCONTENT_STORAGE_CB_001
* @tc.name : testLoadContentStorageCb001
* @tc.desc : Verify the scenario of loading an page and abilityStorage
* @tc.desc : Verify the scenario of loading an page and storage
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
......@@ -512,25 +469,27 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.loadContent('MainAbility/pages/second/second', abilityStorage, (err, data) => {
windowStage.loadContent('TestAbility/pages/Index1', storage, async (err) => {
if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
console.log(msgStr + 'windowStage loadContent MainAbility/pages/second/second' + JSON.stringify(err));
} else {
try {
expect(!data).assertTrue();
} catch (error) {
console.info(`windowStage.loadContent catch error: ${JSON.stringify(error)}`)
}
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data));
} catch (err) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
}
}
})
})
/**
* @tc.number : TEST_LOADCONTENT_STORAGE_CB_002
* @tc.name : testLoadContentStorageCb002
* @tc.desc : Verify the scenario of loading an null page with abilityStorage
* @tc.desc : Verify the scenario of loading an null page with storage
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
......@@ -541,7 +500,7 @@ export default function WindowStage() {
console.log(msgStr + 'begin');
try {
windowStage.loadContent(null, abilityStorage, (err, data) => {
windowStage.loadContent(null, storage, (err) => {
console.log(msgStr + 'windowStage loadContent null ' + JSON.stringify(err));
try {
expect(false).assertTrue();
......
{
"src": [
"TestAbility/pages/Index"
"TestAbility/pages/Index",
"TestAbility/pages/Index1"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册