未验证 提交 702f73d8 编写于 作者: O openharmony_ci 提交者: Gitee

!3185 新增窗口子系统stage模式xts用例

Merge pull request !3185 from 华华小仙女/master
......@@ -9,17 +9,15 @@
# 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.
# limitations under the License.
# "webGL:webGL_hap_test",
# "windowstandard:window_hap_test",
import("//build/ohos_var.gni")
group("graphic") {
testonly = true
if (is_standard_system) {
deps = [
"webGL:webGL_hap_test",
"windowStage:window_stage_hap_test",
"windowstandard:window_hap_test",
]
deps = [ "windowStage:ActsWindowStageTest" ]
} else {
deps = [
"appaccount:appaccount_hap",
......
......@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("window_stage_hap_test") {
ohos_js_hap_suite("ActsWindowStageTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
......@@ -22,7 +22,7 @@ ohos_js_hap_suite("window_stage_hap_test") {
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "window_stage_hap_test"
hap_name = "ActsWindowStageTest"
}
ohos_app_scope("windowStage_app_profile") {
......
......@@ -6,13 +6,11 @@
"package": "com.example.myapplication",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"window_stage_hap_test.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
"kits": [{
"test-file-name": [
"ActsWindowStageTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}]
}
\ No newline at end of file
......@@ -13,9 +13,9 @@
* limitations under the License.
*/
import windowPromiseTest from './windowPromise.test.ets'
import windoCallbackTest from './windowCallback.test.ets'
import windowCallbackTest from './windowCallback.test.ets'
export default function testsuite(context, windowStage, abilityStorage) {
windoCallbackTest(context, windowStage, abilityStorage)
windowCallbackTest(context, windowStage, abilityStorage)
windowPromiseTest(context, windowStage, abilityStorage)
}
\ No newline at end of file
......@@ -18,11 +18,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import ohosWindow from '@ohos.window';
import display from '@ohos.display';
export default function windoCallbackTest(context, windowStage, abilityStorage) {
export default function windowCallbackTest(context, windowStage, abilityStorage) {
console.log('testets context 1: ' + JSON.stringify(context))
console.log('testets context 1 windowStage 2 : ' + JSON.stringify(windowStage));
describe('windowApiCallback_test', function () {
describe('windowCallback_test', function () {
console.log('describe testets start!!')
const TRUE_FLAG = true;
console.log('describe window_api_test start!!!');
......@@ -120,7 +120,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarEnableTest10
* @tc.desc Verify the scene where illegal values are entered when the navigation bar and status bar are displayed or hidden
*/
it('setSystemBarEnableTest10', 0, done => {
it('setSystemBarEnableTest10', 0, function(done) {
let caseName = 'setSystemBarEnableTest10';
let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
......@@ -182,7 +182,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarPropertiesTest1
* @tc.desc TVerify the scene where the colors of the status bar and navigation bar are set in RGB
*/
it('setSystemBarPropertiesTest4', 0, done => {
it('setSystemBarPropertiesTest4', 0, function(done) {
let caseName = 'setSystemBarPropertiesTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = JSON.parse(JSON.stringify(commonRGBColorArr));
......@@ -272,7 +272,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @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 => {
it('setSystemBarPropertiesTest5', 0, function(done) {
let caseName = 'setSystemBarPropertiesTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = {
......@@ -387,7 +387,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarPropertiesTest6
* @tc.desc TVerify the scene where the status bar and navigation bar colors are set as keywords
*/
it('setSystemBarPropertiesTest6', 0, done => {
it('setSystemBarPropertiesTest6', 0, function(done) {
let caseName = 'setSystemBarPropertiesTest6';
let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
......@@ -477,7 +477,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test create5
* @tc.desc Verify the scenario of creating the application type window
*/
it('createTest5', 0, done => {
it('createTest5', 0, function(done) {
let caseName = 'createTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context));
......@@ -507,7 +507,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test createTest6
* @tc.desc Verify the scenario of creating the system type window
*/
it('createTest6', 0, done => {
it('createTest6', 0, function(done) {
let caseName = 'createTest6';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
......@@ -550,7 +550,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test createTest7
* @tc.desc Verify the scenario of creating a window of a type that does not exist
*/
it('createTest7', 0, done => {
it('createTest7', 0, function(done) {
let caseName = 'createTest7';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
......@@ -573,7 +573,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test createTest8
* @tc.desc Verify the scenario of creating a window with duplicate IDs
*/
it('createTest8', 0, done => {
it('createTest8', 0, function(done) {
let caseName = 'createTest8';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
......@@ -602,7 +602,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test listenerTest5
* @tc.desc Verify whether the change of avoidance area and change monitoring can be turned on normally
*/
it('listenerTest5', 0, done => {
it('listenerTest5', 0, function(done) {
let caseName = 'listenerTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
let listenerOnFlag = listenerStatus.ready;
......@@ -629,6 +629,15 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
}
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.setFullScreen(true) success');
tempWnd.on('systemAvoidAreaChange', avoidAreaData => {
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData));
if (listenerOnFlag === listenerStatus.pending) {
listenerOnFlag = listenerStatus.finished;
expect(!!avoidAreaData).assertTrue();
}
done();
})
tempWnd.setSystemBarEnable([], (err,data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done);
......@@ -636,32 +645,24 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
listenerOnFlag = listenerStatus.pending;
tempWnd.on('systemAvoidAreaChange', avoidAreaData => {
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange, avoidAreaData : ' + JSON.stringify(avoidAreaData));
if (listenerOnFlag === listenerStatus.pending) {
listenerOnFlag = listenerStatus.finished;
expect(!!avoidAreaData).assertTrue();
done();
tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
}
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
})
}
})
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished');
})
tempWnd.setSystemBarEnable(['status', 'navigation'], (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
}
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
})
console.log(msgStr + 'tempWnd.on systemAvoidAreaChange finished');
})
})
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_003
* @tc.name Test setWindowTypeTest3
* @tc.desc Verify the scenario where the normal window type is set
*/
it('setWindowTypeTest3', 0, done => {
* @tc.number SUB_WINDOW_SETWINDOWTYPE_JSAPI_003
* @tc.name Test setWindowTypeTest3
* @tc.desc Verify the scenario where the normal window type is set
*/
it('setWindowTypeTest3', 0, function(done) {
let caseName = 'setWindowTypeTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
......@@ -722,7 +723,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setWindowTypeTest4
* @tc.desc Verify the scene of setting illegal window type
*/
it('setWindowTypeTest4', 0, done => {
it('setWindowTypeTest4', 0, function(done) {
let caseName = 'setWindowTypeTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
......@@ -758,7 +759,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test destroyTest2
* @tc.desc Verification window destruction scenario
*/
it('destroyTest2', 0, done => {
it('destroyTest2', 0, function(done) {
let caseName = 'destroyTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
......@@ -803,7 +804,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test loadContentTest3
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest3', 0, done => {
it('loadContentTest3', 0, function(done) {
let caseName = 'loadContentTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
......@@ -838,7 +839,7 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test loadContentTest4
* @tc.desc Verify the scenario of loading a page that does not exist
*/
it('loadContentTest4', 0, done => {
it('loadContentTest4', 0, function(done) {
let caseName = 'loadContentTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
......@@ -868,5 +869,85 @@ export default function windoCallbackTest(context, windowStage, abilityStorage)
}
})
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007
* @tc.name Test loadContentTest7
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest7', 0, async function (done) {
let caseName = 'loadContentTest7';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.loadContent('pages/index/index.ets',(err,data) => {
if(err&&err.code){
unexpectedError(err, caseName, 'windowStage.loadContent', done);
console.log(msgStr+'windowStage.loadContent(pages/index/index.ets)'+JSON.stringify(err));
}else{
expect(!data).assertTrue();
console.log(msgStr + 'windowStage.loadContent end data='+JSON.stringify(data));
}
done();
});
})
/**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_003
* @tc.name Test createSubWindowTest3
* @tc.desc Verify the scenario of creating an auxiliary window
*/
it('createSubWindowTest3', 0, function (done) {
let caseName = 'createSubWindowTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.createSubWindow('createSubWindowTest3',(err,data)=> {
if(err&&err.code){
unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr+'windowStage.createSubWindow(createSubWindowTest3) err='+JSON.stringify(err));
}else{
expect(!!data).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end data='+JSON.stringify(data));
}
done();
});
})
/**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_004
* @tc.name Test createSubWindowTest4
* @tc.desc Verify the scene of entering illegal values to create an auxiliary window
*/
it('createSubWindowTest4', 0, function (done) {
let caseName = 'createSubWindowTest4';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.createSubWindow(null,(err,data)=> {
if(err&&err.code){
expectedError(err, caseName, 'windowStage.createSubWindow', done,130);
console.log(msgStr+'windowStage.createSubWindow(null) err='+JSON.stringify(err));
}else{
expect(false).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end data='+JSON.stringify(data));
}
done();
});
})
/**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_002
* @tc.name Test getSubWindowTest2
* @tc.desc Verify the scene of obtaining all auxiliary sub windows
*/
it('getSubWindowTest2', 0, async function (done) {
let caseName = 'getSubWindowTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.getSubWindow((err,data)=> {
if(err&&err.code){
unexpectedError(err, caseName, 'windowStage.getSubWindow', done);
console.log(msgStr+'windowStage.getSubWindow(null) err='+JSON.stringify(err));
}else{
expect(!!data).assertTrue();
console.log(msgStr + 'windowStage.getSubWindow end data='+JSON.stringify(data));
}
done();
});
})
})
}
......@@ -19,7 +19,7 @@ import ohosWindow from '@ohos.window';
export default function windowPromiseTest(context, windowStage) {
console.log('windowTest context: ' + JSON.stringify(context))
describe('window_api_test', function () {
describe('windowPromise_test', function () {
console.log('describe window_api_test start!!!')
const TRUE_FLAG = true;
var commonRGBColorArr = ['rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(0,0,255)', 'rgb(255,255,255)', 'rgb(0,0,0)', 'rgb(249,0,230)', 'rgb(102,102,102)', 'rgb(255,247,0)'];
......@@ -34,6 +34,7 @@ export default function windowPromiseTest(context, windowStage) {
};
var systemWindowValueArr = [];
var systemWindowTypeArr = [];
var systemWindowTypeDicArr = [];
var systemWindowTypeDic = {
'TYPE_SYSTEM_ALERT': 1,
'TYPE_INPUT_METHOD': 2,
......@@ -64,7 +65,7 @@ export default function windowPromiseTest(context, windowStage) {
beforeAll(function () {
console.log('jsunittest beforeall ohosWindow.WindowType='+JSON.stringify(ohosWindow.WindowType));
appWindowTypeArr = Object.keys(appWindowTypeDic);
systemWindowTypeDicArr = Object.keys(systemWindowTypeDic);
systemWindowValueArr = Object.keys(systemWindowTypeDic);
systemWindowTypeArr = Object.keys(systemWindowTypeDic);
for(i in ohosWindow.WindowType){
......@@ -90,10 +91,12 @@ export default function windowPromiseTest(context, windowStage) {
afterAll(function () {
})
function expectedError(error, caseName, apiName, done) {
function expectedError(error, caseName, apiName, done,code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
expect(TRUE_FLAG).assertTrue();
if(error.code === code){
expect(TRUE_FLAG).assertTrue();
}
done();
}
......@@ -142,11 +145,9 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue();
}
if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
done();
}
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -211,11 +212,12 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue();
}
if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
done();
}
// if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
// done();
// }
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -280,11 +282,12 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue();
}
if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
done();
}
// if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
// done();
// }
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -310,13 +313,13 @@ export default function windowPromiseTest(context, windowStage) {
await tempWnd.setSystemBarEnable(['status', 'navigation']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
});
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success');
setTimeout(() => {
if (statusFlag !== listenerStatus.finished || navigationFlag !== listenerStatus.finished) {
let apiStr = 'tempWnd.on systemBarTintChange time wait';
unexpectedError(null, caseName, apiStr, done);
}
}, 5000)
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success .');
// setTimeout(() => {
// if (statusFlag !== listenerStatus.finished || navigationFlag !== listenerStatus.finished) {
// let apiStr = 'tempWnd.on systemBarTintChange time wait';
// unexpectedError(null, caseName, apiStr, done);
// }
// }, 5000)
})
/**
......@@ -349,11 +352,12 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue();
}
if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
done();
}
// if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
// done();
// }
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -400,7 +404,7 @@ export default function windowPromiseTest(context, windowStage) {
let tempWnd = await windowStage.getMainWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
});
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + tempWnd);
console.log(msgStr + 'windowStage.getMainWindow, tempWnd: ' + JSON.stringify(tempWnd));
expect(!!tempWnd).assertTrue();
await tempWnd.show().catch((err) => {
unexpectedError(err, caseName, 'tempWnd.show', done);
......@@ -408,6 +412,7 @@ export default function windowPromiseTest(context, windowStage) {
console.log(msgStr + 'tempWnd.show success');
await tempWnd.setFullScreen(true).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
console.log(msgStr + 'tempWnd.setFullScreen(true) err'+JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.setFullScreen(true) success');
await tempWnd.setSystemBarEnable([]).catch((err) => {
......@@ -415,7 +420,9 @@ export default function windowPromiseTest(context, windowStage) {
});
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
await tempWnd.setSystemBarEnable([null, '123']).catch((err) => {
expectedError(err, caseName, 'tempWnd.setSystemBarEnable([null, 123])', done);
console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) err='+JSON.stringify(err));
expect(err.code === 130).assertTrue();
done();
});
console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) finished');
})
......@@ -452,6 +459,7 @@ export default function windowPromiseTest(context, windowStage) {
}
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -555,6 +563,7 @@ export default function windowPromiseTest(context, windowStage) {
}
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -592,7 +601,6 @@ export default function windowPromiseTest(context, windowStage) {
}, (err) => {
console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail();
done();
})
}
setTimeout(() => {
......@@ -629,6 +637,7 @@ export default function windowPromiseTest(context, windowStage) {
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 === 2108 || tempData.type === 2112) {
console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++;
......@@ -639,6 +648,7 @@ export default function windowPromiseTest(context, windowStage) {
}
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => {
......@@ -698,17 +708,15 @@ export default function windowPromiseTest(context, windowStage) {
let loopCount = appWindowTypeArr.length;
console.log('jsunittest loopCount: ' + loopCount);
for (let i = 0; i < loopCount; i++) {
let tempType = appWindowTypeDic[appWindowTypeArr[i]];
let tempType = systemWindowTypeDic[systemWindowTypeDicArr[i]];
let windId = 'createTest1' + i;
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
let tempWnd = await ohosWindow.create(context, windId, tempType).catch((err) => {
console.log(msgStr + 'ohosWindow.create ' + tempType + 'catched, err: ' + JSON.stringify(err));
expectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
});
console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd);
expect(!tempWnd).assertTrue();
if (i === loopCount - 1) {
}
}
console.log(msgStr + 'done ');
done();
......@@ -731,5 +739,145 @@ export default function windowPromiseTest(context, windowStage) {
done();
});
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_001
* @tc.name Test loadContentTest1
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest1', 0, async function (done) {
let caseName = 'loadContentTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
let windowId = 'loadContentTest1';
console.log(msgStr + 'begin');
let tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
});
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' , wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let load = await tempWnd.loadContent('pages/second/second').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();
done();
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_002
* @tc.name Test loadContentTest2
* @tc.desc Verify the scene of loading the page with illegal values
*/
it('loadContentTest2', 0, async function (done) {
let caseName = 'loadContentTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1;
let windowId = 'loadContentTest2';
console.log(msgStr + 'begin');
let tempWnd = await ohosWindow.create(context, windowId, baseWndType).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
});
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let errFlag = false;
await tempWnd.loadContent(null).catch((err) => {
errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 130);
console.log(msgStr+'tempWnd.loadContent(null)'+JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end');
if (!errFlag) {
console.log(msgStr + 'should report err');
expect(TRUE_FLAG).assertFail();
done();
}
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_005
* @tc.name Test loadContentTest5
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest5', 0, async function (done) {
let caseName = 'loadContentTest5';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load5 = await windowStage.loadContent('pages/index/index.ets').catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
console.log(msgStr+'tempWnd.loadContent(pages/index/index.ets)'+JSON.stringify(err));
});
expect(!load5).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load='+JSON.stringify(load5));
done();
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_006
* @tc.name Test loadContentTest6
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest6', 0, async function (done) {
let caseName = 'loadContentTest6';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load6 = await windowStage.loadContent(null).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done, 130);
console.log(msgStr+'tempWnd.loadContent(null)'+JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent end load='+JSON.stringify(load6));
done();
})
/**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_001
* @tc.name Test createSubWindowTest1
* @tc.desc Verify the scenario of creating an auxiliary window
*/
it('createSubWindowTest1', 0, async function (done) {
let caseName = 'createSubWindowTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow('createSubWindowTest1').catch((err) => {
unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr+'windowStage.createSubWindow(createSubWindowTest1)='+JSON.stringify(err));
});
expect(!!subWindow).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end subWindow='+JSON.stringify(subWindow));
done();
})
/**
* @tc.number SUB_WINDOW_CREATESUBWINDOW_JSAPI_002
* @tc.name Test createSubWindowTest2
* @tc.desc Verify the scene of entering illegal values to create an auxiliary window
*/
it('createSubWindowTest2', 0, async function (done) {
let caseName = 'createSubWindowTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow(null).catch((err) => {
expectedError(err, caseName, 'windowStage.createSubWindow', done,130);
console.log(msgStr+'windowStage.createSubWindow(null) err='+JSON.stringify(err));
});
console.log(msgStr + 'windowStage.createSubWindow end subWindow='+JSON.stringify(subWindow));
done();
})
/**
* @tc.number SUB_WINDOW_GETSUBWINDOW_JSAPI_001
* @tc.name Test getSubWindowTest1
* @tc.desc Verify the scene of obtaining all auxiliary sub windows
*/
it('getSubWindowTest1', 0, async function (done) {
let caseName = 'getSubWindowTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let subWindow = await windowStage.getSubWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getSubWindow', done);
console.log(msgStr+'windowStage.getSubWindow(null) err='+JSON.stringify(err));
});
expect(!!subWindow).assertTrue();
console.log(msgStr + 'windowStage.getSubWindow end subWindow='+JSON.stringify(subWindow));
done();
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册