提交 b2226ed9 编写于 作者: Z zhurong

add setPrivacyMode()

Signed-off-by: Nzhurong <zhurong18@h-partners.com>
上级 a60b075e
...@@ -13,15 +13,16 @@ ...@@ -13,15 +13,16 @@
* limitations under the License. * limitations under the License.
*/ */
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import ohosWindow from '@ohos.window'; import ohosWindow from '@ohos.window';
import display from '@ohos.display'; import display from '@ohos.display';
export default function windowCallbackTest(context, windowStage, abilityStorage) { export default function windowCallbackTest(context, windowStage, abilityStorage) {
console.log('testets context 1: ' + JSON.stringify(context)) console.log('testets context: ' + JSON.stringify(context))
console.log('testets context 1 windowStage 2 : ' + JSON.stringify(windowStage)); console.log('testets context windowStage: ' + JSON.stringify(windowStage));
console.log('testets context abilityStorage: ' + JSON.stringify(abilityStorage));
describe('windowCallback_test', function () { describe('windowCallback_test', function () {
console.log('describe testets start!!') console.log('describe testets start!!')
const TRUE_FLAG = true; const TRUE_FLAG = true;
...@@ -120,21 +121,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -120,21 +121,10 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarEnableTest10 * @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 * @tc.desc Verify the scene where illegal values are entered when the navigation bar and status bar are displayed or hidden
*/ */
it('setSystemBarEnableTest10', 0, function(done) { it('setSystemBarEnableTest10', 0, function (done) {
let caseName = 'setSystemBarEnableTest10'; let caseName = 'setSystemBarEnableTest10';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let [flagStatus, flagNav] = [false, false];
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
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) {
expect(!!systembartintstate).assertTrue();
done();
}
})
let mainWnd = null; let mainWnd = null;
console.log(msgStr + 'mainWnd = null'); console.log(msgStr + 'mainWnd = null');
windowStage.getMainWindow((err, data) => { windowStage.getMainWindow((err, data) => {
...@@ -161,10 +151,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -161,10 +151,11 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
if (err && err.code) { if (err && err.code) {
unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done); unexpectedError(data, caseName, 'mainWnd.setSystemBarEnable []', done);
} }
flagStatus = true;
flagNav = true;
expect(!data).assertTrue(); expect(!data).assertTrue();
mainWnd.setSystemBarEnable([null, '123'], (err, data) => { mainWnd.setSystemBarEnable([null, '123'], (err, data) => {
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringfy(data)==' + JSON.stringify(data));
console.log(msgStr + 'mainWnd.setSystemBarEnable [null,123] JSON.stringfy(err)==' + JSON.stringify(err));
if (err && err.code) { if (err && err.code) {
expect(err.code === 130).assertTrue(); expect(err.code === 130).assertTrue();
done(); done();
...@@ -182,7 +173,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -182,7 +173,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarPropertiesTest1 * @tc.name Test setSystemBarPropertiesTest1
* @tc.desc TVerify the scene where the colors of the status bar and navigation bar are set in RGB * @tc.desc TVerify the scene where the colors of the status bar and navigation bar are set in RGB
*/ */
it('setSystemBarPropertiesTest4', 0, function(done) { it('setSystemBarPropertiesTest4', 0, done => {
let caseName = 'setSystemBarPropertiesTest4'; let caseName = 'setSystemBarPropertiesTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = JSON.parse(JSON.stringify(commonRGBColorArr)); let cloneColorArr = JSON.parse(JSON.stringify(commonRGBColorArr));
...@@ -272,7 +263,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -272,7 +263,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarPropertiesTest5 * @tc.name Test setSystemBarPropertiesTest5
* @tc.desc Verify the scene where the status bar and navigation bar colors are set in hexadecimal form * @tc.desc Verify the scene where the status bar and navigation bar colors are set in hexadecimal form
*/ */
it('setSystemBarPropertiesTest5', 0, function(done) { it('setSystemBarPropertiesTest5', 0, done => {
let caseName = 'setSystemBarPropertiesTest5'; let caseName = 'setSystemBarPropertiesTest5';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = { let cloneColorArr = {
...@@ -387,7 +378,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -387,7 +378,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setSystemBarPropertiesTest6 * @tc.name Test setSystemBarPropertiesTest6
* @tc.desc TVerify the scene where the status bar and navigation bar colors are set as keywords * @tc.desc TVerify the scene where the status bar and navigation bar colors are set as keywords
*/ */
it('setSystemBarPropertiesTest6', 0, function(done) { it('setSystemBarPropertiesTest6', 0, done => {
let caseName = 'setSystemBarPropertiesTest6'; let caseName = 'setSystemBarPropertiesTest6';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr)); let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
...@@ -477,7 +468,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -477,7 +468,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test create5 * @tc.name Test create5
* @tc.desc Verify the scenario of creating the application type window * @tc.desc Verify the scenario of creating the application type window
*/ */
it('createTest5', 0, function(done) { it('createTest5', 0, done => {
let caseName = 'createTest5'; let caseName = 'createTest5';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin context==' + JSON.stringify(context)); console.log(msgStr + 'begin context==' + JSON.stringify(context));
...@@ -507,7 +498,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -507,7 +498,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test createTest6 * @tc.name Test createTest6
* @tc.desc Verify the scenario of creating the system type window * @tc.desc Verify the scenario of creating the system type window
*/ */
it('createTest6', 0, function(done) { it('createTest6', 0, done => {
let caseName = 'createTest6'; let caseName = 'createTest6';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
...@@ -538,19 +529,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -538,19 +529,17 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
console.log(msgStr + 'tempWnd.getProperties success, !!data : ' + !!data); console.log(msgStr + 'tempWnd.getProperties success, !!data : ' + !!data);
expect(!!data).assertTrue(); expect(!!data).assertTrue();
expect(data.type == tempType).assertTrue(); expect(data.type == tempType).assertTrue();
if (i === loopCount - 1) {
done();
}
}) })
}) })
} }
done();
}) })
/** /**
* @tc.number SUB_WINDOW_CREATE_JSAPI_007 * @tc.number SUB_WINDOW_CREATE_JSAPI_007
* @tc.name Test createTest7 * @tc.name Test createTest7
* @tc.desc Verify the scenario of creating a window of a type that does not exist * @tc.desc Verify the scenario of creating a window of a type that does not exist
*/ */
it('createTest7', 0, function(done) { it('createTest7', 0, done => {
let caseName = 'createTest7'; let caseName = 'createTest7';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
...@@ -573,7 +562,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -573,7 +562,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test createTest8 * @tc.name Test createTest8
* @tc.desc Verify the scenario of creating a window with duplicate IDs * @tc.desc Verify the scenario of creating a window with duplicate IDs
*/ */
it('createTest8', 0, function(done) { it('createTest8', 0, done => {
let caseName = 'createTest8'; let caseName = 'createTest8';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
...@@ -602,7 +591,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -602,7 +591,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test listenerTest5 * @tc.name Test listenerTest5
* @tc.desc Verify whether the change of avoidance area and change monitoring can be turned on normally * @tc.desc Verify whether the change of avoidance area and change monitoring can be turned on normally
*/ */
it('listenerTest5', 0, function(done) { it('listenerTest5', 0, function (done) {
let caseName = 'listenerTest5'; let caseName = 'listenerTest5';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let listenerOnFlag = listenerStatus.ready; let listenerOnFlag = listenerStatus.ready;
...@@ -638,7 +627,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -638,7 +627,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
} }
done(); done();
}) })
tempWnd.setSystemBarEnable([], (err,data) => { tempWnd.setSystemBarEnable([], (err, data) => {
if (err && err.code) { if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([])', done);
} }
...@@ -662,7 +651,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -662,7 +651,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setWindowTypeTest3 * @tc.name Test setWindowTypeTest3
* @tc.desc Verify the scenario where the normal window type is set * @tc.desc Verify the scenario where the normal window type is set
*/ */
it('setWindowTypeTest3', 0, function(done) { it('setWindowTypeTest3', 0, function (done) {
let caseName = 'setWindowTypeTest3'; let caseName = 'setWindowTypeTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1; let baseWndType = 1;
...@@ -723,7 +712,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -723,7 +712,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test setWindowTypeTest4 * @tc.name Test setWindowTypeTest4
* @tc.desc Verify the scene of setting illegal window type * @tc.desc Verify the scene of setting illegal window type
*/ */
it('setWindowTypeTest4', 0, function(done) { it('setWindowTypeTest4', 0, function (done) {
let caseName = 'setWindowTypeTest4'; let caseName = 'setWindowTypeTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1; let baseWndType = 1;
...@@ -759,7 +748,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -759,7 +748,7 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
* @tc.name Test destroyTest2 * @tc.name Test destroyTest2
* @tc.desc Verification window destruction scenario * @tc.desc Verification window destruction scenario
*/ */
it('destroyTest2', 0, function(done) { it('destroyTest2', 0, function (done) {
let caseName = 'destroyTest2'; let caseName = 'destroyTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1; let baseWndType = 1;
...@@ -800,15 +789,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -800,15 +789,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_003 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007
* @tc.name Test loadContentTest3 * @tc.name Test loadContentTest7
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest3', 0, function(done) { it('loadContentTest7', 0, function (done) {
let caseName = 'loadContentTest3'; let caseName = 'loadContentTest7';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1; let baseWndType = 1;
let windowId = 'loadContentTest3'; let windowId = 'loadContentTest7';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let tempWnd = null let tempWnd = null
ohosWindow.create(context, windowId, baseWndType, (err, data) => { ohosWindow.create(context, windowId, baseWndType, (err, data) => {
...@@ -835,15 +824,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -835,15 +824,15 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_004 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_008
* @tc.name Test loadContentTest4 * @tc.name Test loadContentTest8
* @tc.desc Verify the scenario of loading a page that does not exist * @tc.desc Verify the scenario of loading a page that does not exist
*/ */
it('loadContentTest4', 0, function(done) { it('loadContentTest8', 0, function (done) {
let caseName = 'loadContentTest4'; let caseName = 'loadContentTest8';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
let baseWndType = 1; let baseWndType = 1;
let windowId = 'loadContentTest4'; let windowId = 'loadContentTest8';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let tempWnd = null let tempWnd = null
ohosWindow.create(context, windowId, baseWndType, (err, data) => { ohosWindow.create(context, windowId, baseWndType, (err, data) => {
...@@ -870,21 +859,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -870,21 +859,41 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
}) })
}) })
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_007 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_009
* @tc.name Test loadContentTest7 * @tc.name Test loadContentTest9
* @tc.desc Verify the scenario of loading an existing page * @tc.desc Verify the scenario of loading an existing page
*/ */
it('loadContentTest7', 0, async function (done) { it('loadContentTest9', 0, function (done) {
let caseName = 'loadContentTest7'; let caseName = 'loadContentTest9';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.loadContent('pages/index/index.ets',(err,data) => { windowStage.loadContent('pages/index/index.ets', (err, data) => {
if(err&&err.code){ if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.loadContent', done); unexpectedError(err, caseName, 'windowStage.loadContent', done);
console.log(msgStr+'windowStage.loadContent(pages/index/index.ets)'+JSON.stringify(err)); console.log(msgStr + 'windowStage.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}else{ } else {
expect(!data).assertTrue(); expect(!data).assertTrue();
console.log(msgStr + 'windowStage.loadContent end data='+JSON.stringify(data)); console.log(msgStr + 'windowStage.loadContent end data=' + JSON.stringify(data));
}
done();
});
})
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_011
* @tc.name Test loadContentTest11
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest11', 0, async function (done) {
let caseName = 'loadContentTest11';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage.loadContent('pages/index/index.ets', abilityStorage, (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(); done();
}); });
...@@ -898,13 +907,13 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -898,13 +907,13 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let caseName = 'createSubWindowTest3'; let caseName = 'createSubWindowTest3';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.createSubWindow('createSubWindowTest3',(err,data)=> { windowStage.createSubWindow('createSubWindowTest3', (err, data) => {
if(err&&err.code){ if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.createSubWindow', done); unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr+'windowStage.createSubWindow(createSubWindowTest3) err='+JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest3) err=' + JSON.stringify(err));
}else{ } else {
expect(!!data).assertTrue(); expect(!!data).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end data='+JSON.stringify(data)); console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data));
} }
done(); done();
}); });
...@@ -918,13 +927,13 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -918,13 +927,13 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let caseName = 'createSubWindowTest4'; let caseName = 'createSubWindowTest4';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.createSubWindow(null,(err,data)=> { windowStage.createSubWindow(null, (err, data) => {
if(err&&err.code){ if (err && err.code) {
expectedError(err, caseName, 'windowStage.createSubWindow', done,130); expectedError(err, caseName, 'windowStage.createSubWindow', done, 130);
console.log(msgStr+'windowStage.createSubWindow(null) err='+JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
}else{ } else {
expect(false).assertTrue(); expect(false).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end data='+JSON.stringify(data)); console.log(msgStr + 'windowStage.createSubWindow end data=' + JSON.stringify(data));
} }
done(); done();
}); });
...@@ -938,16 +947,158 @@ export default function windowCallbackTest(context, windowStage, abilityStorage) ...@@ -938,16 +947,158 @@ export default function windowCallbackTest(context, windowStage, abilityStorage)
let caseName = 'getSubWindowTest2'; let caseName = 'getSubWindowTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
windowStage.getSubWindow((err,data)=> { windowStage.getSubWindow((err, data) => {
if(err&&err.code){ if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.getSubWindow', done); unexpectedError(err, caseName, 'windowStage.getSubWindow', done);
console.log(msgStr+'windowStage.getSubWindow(null) err='+JSON.stringify(err)); console.log(msgStr + 'windowStage.getSubWindow(null) err=' + JSON.stringify(err));
}else{ } else {
expect(!!data).assertTrue(); expect(!!data).assertTrue();
console.log(msgStr + 'windowStage.getSubWindow end data='+JSON.stringify(data)); console.log(msgStr + 'windowStage.getSubWindow end data=' + JSON.stringify(data));
} }
done(); done();
}); });
}) })
/**
* @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_002
* @tc.name Test setPrivacyModeTest2
* @tc.desc Verify the scene where the application sub window is set as a security layer
*/
it('setPrivacyModeTest2', 0, async function (done) {
let caseName = 'setPrivacyModeTest2';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow));
let mainWnd = null;
ohosWindow.create(context,'setPrivacyModeTest2', ohosWindow.WindowType.TYPE_SYSTEM_ALERT, (err, data) => {
if (err&&err.code) {
console.log(msgStr + 'ohosWindow.create fail err:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
expect(data != null).assertTrue();
console.log(msgStr + 'ohosWindow.create success data' + data);
mainWnd = data;
mainWnd.getProperties((err, data) => {
if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue();
mainWnd.setPrivacyMode(true, (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err));
} else {
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => {
if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data));
expect(data.isPrivacyMode).assertTrue();
mainWnd.setPrivacyMode(false, (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err));
} else {
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => {
if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue();
}
done();
})
}
});
}
})
}
});
}
})
}
})
})
/**
* @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_003
* @tc.name Test setPrivacyModeTest3
* @tc.desc Verify that the auxiliary window is set as the security layer
*/
it('setPrivacyModeTest3', 0, async function (done) {
let caseName = 'setPrivacyModeTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin ohosWindow =' + JSON.stringify(ohosWindow));
let mainWnd = null;
windowStage.createSubWindow('setPrivacyModeTest3', (err, data) => {
if (err&&err.code) {
console.log(msgStr + 'windowStage.createSubWindow fail err:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
expect(data != null).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow success data' + data);
mainWnd = data;
mainWnd.getProperties((err, data) => {
if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=false err: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.log(msgStr + 'mainWnd.getProperties first data.isPrivacyMode=fasle data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue();
mainWnd.setPrivacyMode(true, (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err));
} else {
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.setPrivacyMode true data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => {
if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true fail err: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.log(msgStr + 'mainWnd.getProperties second isPrivacyMode=true callback data:' + JSON.stringify(data));
expect(data.isPrivacyMode).assertTrue();
mainWnd.setPrivacyMode(false, (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err));
} else {
expect(!data).assertTrue();
console.log(msgStr + 'mainWnd.setPrivacyMode(false) end data=' + JSON.stringify(data));
mainWnd.getProperties((err, data) => {
if (err.code != 0) {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback fail err: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.log(msgStr + 'mainWnd.getProperties data.isPrivacyMode=fasle callback data:' + JSON.stringify(data));
expect(!data.isPrivacyMode).assertTrue();
}
done();
})
}
});
}
})
}
});
}
})
}
})
})
}) })
} }
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
*/ */
// @ts-nocheck // @ts-nocheck
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import ohosWindow from '@ohos.window'; import ohosWindow from '@ohos.window';
export default function windowPromiseTest(context, windowStage) { export default function windowPromiseTest(context, windowStage, abilityStorage) {
console.log('windowTest context: ' + JSON.stringify(context)) console.log('windowTest context: ' + JSON.stringify(context))
console.log('windowTest abilityStorage: ' + JSON.stringify(abilityStorage))
describe('windowPromise_test', function () { describe('windowPromise_test', function () {
console.log('describe window_api_test start!!!') console.log('describe window_api_test start!!!')
const TRUE_FLAG = true; const TRUE_FLAG = true;
...@@ -64,11 +65,11 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -64,11 +65,11 @@ export default function windowPromiseTest(context, windowStage) {
const WINDOW_NAME = 'windowName'; const WINDOW_NAME = 'windowName';
beforeAll(function () { beforeAll(function () {
console.log('jsunittest beforeall ohosWindow.WindowType='+JSON.stringify(ohosWindow.WindowType)); console.log('jsunittest beforeall ohosWindow.WindowType=' + JSON.stringify(ohosWindow.WindowType));
systemWindowTypeDicArr = Object.keys(systemWindowTypeDic); systemWindowTypeDicArr = Object.keys(systemWindowTypeDic);
systemWindowValueArr = Object.keys(systemWindowTypeDic); systemWindowValueArr = Object.keys(systemWindowTypeDic);
systemWindowTypeArr = Object.keys(systemWindowTypeDic); systemWindowTypeArr = Object.keys(systemWindowTypeDic);
for(i in ohosWindow.WindowType){ for (i in ohosWindow.WindowType) {
windowTypeArr.push(ohosWindow.WindowType[i]) windowTypeArr.push(ohosWindow.WindowType[i])
} }
}) })
...@@ -91,10 +92,10 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -91,10 +92,10 @@ export default function windowPromiseTest(context, windowStage) {
afterAll(function () { afterAll(function () {
}) })
function expectedError(error, caseName, apiName, done,code) { function expectedError(error, caseName, apiName, done, code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: '; let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error)); console.log(msgStr + JSON.stringify(error));
if(error.code === code){ if (error.code === code) {
expect(TRUE_FLAG).assertTrue(); expect(TRUE_FLAG).assertTrue();
} }
done(); done();
...@@ -126,29 +127,6 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -126,29 +127,6 @@ export default function windowPromiseTest(context, windowStage) {
let statusFlag = listenerStatus.ready; let statusFlag = listenerStatus.ready;
let navigationFlag = listenerStatus.ready; let navigationFlag = listenerStatus.ready;
console.log(msgStr + 'begin'); 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 (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 === 2108 && statusFlag === listenerStatus.pending) {
statusFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue();
} else if (tempData.type === 2112 && navigationFlag === listenerStatus.pending) {
navigationFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue();
}
}
}
done();
})
console.log(msgStr + 'tempWnd.on systemBarTintChange finished'); console.log(msgStr + 'tempWnd.on systemBarTintChange finished');
let tempWnd = await windowStage.getMainWindow().catch((err) => { let tempWnd = await windowStage.getMainWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done); unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
...@@ -170,16 +148,55 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -170,16 +148,55 @@ export default function windowPromiseTest(context, windowStage) {
await sleep(1000); await sleep(1000);
statusFlag = listenerStatus.pending; statusFlag = listenerStatus.pending;
navigationFlag = listenerStatus.pending; navigationFlag = listenerStatus.pending;
if (statusFlag === listenerStatus.pending || navigationFlag === listenerStatus.pending) {
console.log(msgStr + 'start on !!!!');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.log(msgStr + 'tempWnd.on systemBarTintChange, systemBatData : ' + JSON.stringify(systemBarData));
console.log(msgStr + 'tempWnd.on , statusFlag : ' + JSON.stringify(statusFlag));
console.log(msgStr + 'tempWnd.on , listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
console.log(msgStr + 'tempWnd.on , navigationFlag : ' + JSON.stringify(navigationFlag));
console.log(msgStr + 'tempWnd.on , listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
setTimeout(() => {
console.log(msgStr + 'tempWnd.on , 3 statusFlag : ' + JSON.stringify(statusFlag));
console.log(msgStr + 'tempWnd.on , 3 listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
console.log(msgStr + 'tempWnd.on , 3 navigationFlag : ' + JSON.stringify(navigationFlag));
console.log(msgStr + 'tempWnd.on , 3 listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
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 === 2108 && statusFlag === listenerStatus.pending) {
statusFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue();
} else if (tempData.type === 2112 && navigationFlag === listenerStatus.pending) {
navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue();
}
}
ohosWindow.off('systemBarTintChange');
}
done();
}, 3000)
})
}
await tempWnd.setSystemBarEnable(['status']).catch((err) => { await tempWnd.setSystemBarEnable(['status']).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status])', done);
}); });
console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success');
setTimeout(() => { console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, statusFlag : ' + JSON.stringify(statusFlag));
if (statusFlag !== listenerStatus.finished || navigationFlag !== listenerStatus.finished) { console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
let apiStr = 'tempWnd.on systemBarTintChange time wait'; console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, navigationFlag : ' + JSON.stringify(navigationFlag));
unexpectedError(null, caseName, apiStr, done); console.log(msgStr + 'tempWnd.setSystemBarEnable([status]) success, listenerStatus.pending : ' + JSON.stringify(listenerStatus.pending));
}
}, 5000)
}) })
/** /**
...@@ -212,9 +229,6 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -212,9 +229,6 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue(); expect(tempData.isEnable).assertTrue();
} }
// if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
// done();
// }
} }
} }
done(); done();
...@@ -282,9 +296,6 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -282,9 +296,6 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(tempData.isEnable).assertTrue(); expect(tempData.isEnable).assertTrue();
} }
// if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
// done();
// }
} }
} }
done(); done();
...@@ -314,12 +325,6 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -314,12 +325,6 @@ export default function windowPromiseTest(context, windowStage) {
unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done); unexpectedError(err, caseName, 'tempWnd.setSystemBarEnable([status, navigation])', done);
}); });
console.log(msgStr + 'tempWnd.setSystemBarEnable([status, navigation]) success .'); 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)
}) })
/** /**
...@@ -352,9 +357,6 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -352,9 +357,6 @@ export default function windowPromiseTest(context, windowStage) {
navigationFlag = listenerStatus.finished; navigationFlag = listenerStatus.finished;
expect(!tempData.isEnable).assertTrue(); expect(!tempData.isEnable).assertTrue();
} }
// if (statusFlag === listenerStatus.finished && navigationFlag === listenerStatus.finished) {
// done();
// }
} }
} }
done(); done();
...@@ -412,7 +414,7 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -412,7 +414,7 @@ export default function windowPromiseTest(context, windowStage) {
console.log(msgStr + 'tempWnd.show success'); console.log(msgStr + 'tempWnd.show success');
await tempWnd.setFullScreen(true).catch((err) => { await tempWnd.setFullScreen(true).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done); unexpectedError(err, caseName, 'tempWnd.setFullScreen(true)', done);
console.log(msgStr + 'tempWnd.setFullScreen(true) err'+JSON.stringify(err)); console.log(msgStr + 'tempWnd.setFullScreen(true) err' + JSON.stringify(err));
}); });
console.log(msgStr + 'tempWnd.setFullScreen(true) success'); console.log(msgStr + 'tempWnd.setFullScreen(true) success');
await tempWnd.setSystemBarEnable([]).catch((err) => { await tempWnd.setSystemBarEnable([]).catch((err) => {
...@@ -420,7 +422,7 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -420,7 +422,7 @@ export default function windowPromiseTest(context, windowStage) {
}); });
console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success'); console.log(msgStr + 'tempWnd.setSystemBarEnable([]) success');
await tempWnd.setSystemBarEnable([null, '123']).catch((err) => { await tempWnd.setSystemBarEnable([null, '123']).catch((err) => {
console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) err='+JSON.stringify(err)); console.log(msgStr + 'tempWnd.setSystemBarEnable([null, 123]) err=' + JSON.stringify(err));
expect(err.code === 130).assertTrue(); expect(err.code === 130).assertTrue();
done(); done();
}); });
...@@ -497,7 +499,6 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -497,7 +499,6 @@ export default function windowPromiseTest(context, windowStage) {
}, (err) => { }, (err) => {
console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err)); console.log(msgStr + 'tempWnd.setSystemBarProperties failed, err : ' + JSON.stringify(err));
expect(TRUE_FLAG).assertFail(); expect(TRUE_FLAG).assertFail();
done();
}) })
} }
setTimeout(() => { setTimeout(() => {
...@@ -637,7 +638,7 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -637,7 +638,7 @@ export default function windowPromiseTest(context, windowStage) {
let arrLength = systemBarData.regionTint.length; let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) { for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i]; let tempData = systemBarData.regionTint[i];
console.log(msgStr +'i='+i+ ' , ohosWindow.on for='+JSON.stringify(tempData)); console.log(msgStr + 'i=' + i + ' , ohosWindow.on for=' + JSON.stringify(tempData));
if (tempData.type === 2108 || tempData.type === 2112) { if (tempData.type === 2108 || tempData.type === 2112) {
console.log(msgStr + 'systemBarTintChange compare start!'); console.log(msgStr + 'systemBarTintChange compare start!');
compareCount++; compareCount++;
...@@ -712,8 +713,8 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -712,8 +713,8 @@ export default function windowPromiseTest(context, windowStage) {
let windId = 'createTest1' + i; let windId = 'createTest1' + i;
console.log(msgStr + 'ohosWindow.create ' + tempType + ' start'); console.log(msgStr + 'ohosWindow.create ' + tempType + ' start');
let tempWnd = await ohosWindow.create(context, windId, tempType).catch((err) => { let tempWnd = await ohosWindow.create(context, windId, tempType).catch((err) => {
console.log(msgStr + 'ohosWindow.create ' + tempType + 'catched, err: ' + JSON.stringify(err)); console.log(msgStr + 'ohosWindow.create ' + tempType + 'catched, err: ' + JSON.stringify(err));
unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done); unexpectedError(err, caseName, 'ohosWindow.create ' + tempType, done);
}); });
console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.create ' + tempType + 'finished, wnd: ' + tempWnd);
expect(!tempWnd).assertTrue(); expect(!tempWnd).assertTrue();
...@@ -756,11 +757,11 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -756,11 +757,11 @@ export default function windowPromiseTest(context, windowStage) {
console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' , wnd: ' + tempWnd); console.log(msgStr + 'ohosWindow.create ' + baseWndType + ' , wnd: ' + tempWnd);
expect(!!tempWnd).assertTrue(); expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start'); console.log(msgStr + 'tempWnd.loadContent start');
let load = await tempWnd.loadContent('pages/second/second').catch((err) => { let load = await tempWnd.loadContent('pages/second/second').catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done); 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) err=' + JSON.stringify(err));
}); });
console.log(msgStr+'tempWnd.loadContent(pages/second/second) load='+JSON.stringify(load)); console.log(msgStr + 'tempWnd.loadContent(pages/second/second) load=' + JSON.stringify(load));
expect(!load).assertTrue(); expect(!load).assertTrue();
done(); done();
}) })
...@@ -786,7 +787,7 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -786,7 +787,7 @@ export default function windowPromiseTest(context, windowStage) {
await tempWnd.loadContent(null).catch((err) => { await tempWnd.loadContent(null).catch((err) => {
errFlag = true; errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 130); expectedError(err, caseName, 'tempWnd.loadContent', done, 130);
console.log(msgStr+'tempWnd.loadContent(null)'+JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err));
}); });
console.log(msgStr + 'tempWnd.loadContent end'); console.log(msgStr + 'tempWnd.loadContent end');
if (!errFlag) { if (!errFlag) {
...@@ -796,6 +797,23 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -796,6 +797,23 @@ export default function windowPromiseTest(context, windowStage) {
} }
}) })
/**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_003
* @tc.name Test loadContentTest3
* @tc.desc Verify the scenario of loading an existing page
*/
it('loadContentTest3', 0, async function (done) {
let caseName = 'loadContentTest3';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let load3 = 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(!load3).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load=' + JSON.stringify(load3));
done();
})
/** /**
* @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_005 * @tc.number SUB_WINDOW_LOADCONTENT_JSAPI_005
* @tc.name Test loadContentTest5 * @tc.name Test loadContentTest5
...@@ -805,12 +823,12 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -805,12 +823,12 @@ export default function windowPromiseTest(context, windowStage) {
let caseName = 'loadContentTest5'; let caseName = 'loadContentTest5';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let load5 = await windowStage.loadContent('pages/index/index.ets').catch((err) => { let load5 = await windowStage.loadContent('pages/index/index.ets', abilityStorage).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done); unexpectedError(err, caseName, 'tempWnd.loadContent', done);
console.log(msgStr+'tempWnd.loadContent(pages/index/index.ets)'+JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}); });
expect(!load5).assertTrue(); expect(!load5).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load='+JSON.stringify(load5)); console.log(msgStr + 'tempWnd.loadContent end load=' + JSON.stringify(load5));
done(); done();
}) })
/** /**
...@@ -822,11 +840,12 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -822,11 +840,12 @@ export default function windowPromiseTest(context, windowStage) {
let caseName = 'loadContentTest6'; let caseName = 'loadContentTest6';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let load6 = await windowStage.loadContent(null).catch((err) => { let load6 = await windowStage.loadContent('pages/index/index.ets', null).catch((err) => {
expectedError(err, caseName, 'tempWnd.loadContent', done, 130); unexpectedError(err, caseName, 'tempWnd.loadContent', done);
console.log(msgStr+'tempWnd.loadContent(null)'+JSON.stringify(err)); console.log(msgStr + 'tempWnd.loadContent(pages/index/index.ets)' + JSON.stringify(err));
}); });
console.log(msgStr + 'tempWnd.loadContent end load='+JSON.stringify(load6)); expect(!load6).assertTrue();
console.log(msgStr + 'tempWnd.loadContent end load=' + JSON.stringify(load6));
done(); done();
}) })
/** /**
...@@ -838,12 +857,12 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -838,12 +857,12 @@ export default function windowPromiseTest(context, windowStage) {
let caseName = 'createSubWindowTest1'; let caseName = 'createSubWindowTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow('createSubWindowTest1').catch((err) => { let subWindow = await windowStage.createSubWindow('createSubWindowTest1').catch((err) => {
unexpectedError(err, caseName, 'windowStage.createSubWindow', done); unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr+'windowStage.createSubWindow(createSubWindowTest1)='+JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest1)=' + JSON.stringify(err));
}); });
expect(!!subWindow).assertTrue(); expect(!!subWindow).assertTrue();
console.log(msgStr + 'windowStage.createSubWindow end subWindow='+JSON.stringify(subWindow)); console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
done(); done();
}) })
/** /**
...@@ -855,11 +874,11 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -855,11 +874,11 @@ export default function windowPromiseTest(context, windowStage) {
let caseName = 'createSubWindowTest2'; let caseName = 'createSubWindowTest2';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let subWindow = await windowStage.createSubWindow(null).catch((err) => { let subWindow = await windowStage.createSubWindow(null).catch((err) => {
expectedError(err, caseName, 'windowStage.createSubWindow', done,130); expectedError(err, caseName, 'windowStage.createSubWindow', done, 130);
console.log(msgStr+'windowStage.createSubWindow(null) err='+JSON.stringify(err)); console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
}); });
console.log(msgStr + 'windowStage.createSubWindow end subWindow='+JSON.stringify(subWindow)); console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
done(); done();
}) })
/** /**
...@@ -871,12 +890,61 @@ export default function windowPromiseTest(context, windowStage) { ...@@ -871,12 +890,61 @@ export default function windowPromiseTest(context, windowStage) {
let caseName = 'getSubWindowTest1'; let caseName = 'getSubWindowTest1';
let msgStr = 'jsunittest ' + caseName + ' '; let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin'); console.log(msgStr + 'begin');
let subWindow = await windowStage.getSubWindow().catch((err) => { let subWindow = await windowStage.getSubWindow().catch((err) => {
unexpectedError(err, caseName, 'windowStage.getSubWindow', done); unexpectedError(err, caseName, 'windowStage.getSubWindow', done);
console.log(msgStr+'windowStage.getSubWindow(null) err='+JSON.stringify(err)); console.log(msgStr + 'windowStage.getSubWindow(null) err=' + JSON.stringify(err));
}); });
expect(!!subWindow).assertTrue(); expect(!!subWindow).assertTrue();
console.log(msgStr + 'windowStage.getSubWindow end subWindow='+JSON.stringify(subWindow)); console.log(msgStr + 'windowStage.getSubWindow end subWindow=' + JSON.stringify(subWindow));
done();
})
/**
* @tc.number SUB_WINDOW_SETPRIVACYMODE_JSAPI_001
* @tc.name Test setPrivacyModeTest1
* @tc.desc Verify the scene where the application sub window is set as a security layer
*/
it('setPrivacyModeTest1', 0, async function (done) {
let caseName = 'setPrivacyModeTest1';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin ');
let mainWnd = null;
let windowData = await ohosWindow.create(context,'setPrivacyModeTest1', ohosWindow.WindowType.TYPE_SYSTEM_ALERT).catch((err) => {
unexpectedError(err, caseName, 'ohosWindow.create', done);
done();
})
expect(!!windowData).assertTrue();
console.log(msgStr + 'window.create success windowData' + windowData);
mainWnd = windowData;
let firstPro = await mainWnd.getProperties().catch((err, data) => {
unexpectedError(err, caseName, 'mainWnd.getProperties', done);
done();
})
expect(!firstPro.isPrivacyMode).assertTrue();
console.log(msgStr + 'mainWnd.getProperties firstPro=' + JSON.stringify(firstPro));
let firstPrivacyMode = await mainWnd.setPrivacyMode(true).catch((err, data) => {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(true) err=' + JSON.stringify(err));
})
expect(!firstPrivacyMode).assertTrue();
console.log(msgStr + 'mainWnd.setPrivacyMode true firstPrivacyMode=' + JSON.stringify(firstPrivacyMode));
let secondPro = await mainWnd.getProperties().catch((err, data) => {
unexpectedError(err, caseName, 'mainWnd.getProperties', done);
done();
})
console.log(msgStr + 'mainWnd.getProperties secondPro:' + JSON.stringify(secondPro.isPrivacyMode));
expect(secondPro.isPrivacyMode).assertTrue();
let secondPrivacyMode = await mainWnd.setPrivacyMode(false).catch((err, data) => {
unexpectedError(err, caseName, 'mainWnd.setPrivacyMode', done);
console.log(msgStr + 'mainWnd.setPrivacyMode(false) err=' + JSON.stringify(err));
})
expect(!secondPrivacyMode).assertTrue();
console.log(msgStr + 'mainWnd.setPrivacyMode(false) secondPrivacyMode=' + JSON.stringify(secondPrivacyMode));
let lastPro = await mainWnd.getProperties().catch((err, data) => {
unexpectedError(err, caseName, 'mainWnd.getProperties', done);
done();
})
console.log(msgStr + 'mainWnd.getProperties lastPro:' + JSON.stringify(lastPro.isPrivacyMode));
expect(!lastPro.isPrivacyMode).assertTrue();
done(); done();
}) })
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册