提交 0da4c68d 编写于 作者: H hekun

add new interface testcase

Signed-off-by: Nhekun <hekun18@huawei.com>
上级 9a8f5bf2
......@@ -14,8 +14,10 @@
*/
import windowPromiseTest from './windowPromise.test'
import windowCallbackTest from './windowCallback.test'
import windowRefactorInterfaceTest from './windowRefactorInterface.test'
export default function testsuite() {
windowCallbackTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
windowPromiseTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
windowRefactorInterfaceTest(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
}
\ No newline at end of file
/*
* Copyright (c) 2022 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.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import ohosWindow from '@ohos.window';
export default function windowRefactorInterfaceTest(context, windowStage, abilityStorage) {
console.info('windowTest context: ' + JSON.stringify(context))
console.info('windowTest abilityStorage: ' + JSON.stringify(abilityStorage))
describe('windowRefactorInterface_test', function () {
console.info('describe window_api_test2 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)'];
var commonNUMBERColorArr = ['#00FF0000', '#0000FF00', '#000000FF', '#00FFFFFF', '#00000000', '#00F900E6', '#00666666', '#00FFF700'];
var commonKEYColorArr = ['red', 'green', 'blue', 'white', 'black', 'pink', 'grey', 'yellow'];
var systemWindowTypeDicArr = [];
var systemWindowTypeDic = {
'TYPE_SYSTEM_ALERT': 1,
'TYPE_INPUT_METHOD': 2,
'TYPE_STATUS_BAR': 3,
'TYPE_PANEL': 4,
'TYPE_KEYGUARD': 5,
'TYPE_VOLUME_OVERLAY': 6,
'TYPE_NAVIGATION_BAR': 7,
'TYPE_FLOAT': 8,
'TYPE_FLOAT_CAMERA':9
}
var listenerStatus = {
ready: 'ready',
pending: 'pending',
finished: 'finished'
};
var listenerData = {
on: false,
typeStr: '',
};
var newWindowObj = null;
beforeAll(function () {
console.info('jsunittest beforeall ohosWindow.WindowType=' + JSON.stringify(ohosWindow.WindowType));
systemWindowTypeDicArr = Object.keys(systemWindowTypeDic);
console.info('jsunittest beforeall systemWindowTypeDicArr=' + JSON.stringify(systemWindowTypeDicArr) + ' ,length=' + systemWindowTypeDicArr.length);
})
beforeEach(function () {
})
afterEach(async function (done) {
if (listenerData.on) {
listenerData.on = false;
console.info('jsunittest afterEach listener off, listenerData:' + JSON.stringify(listenerData));
if (listenerData.typeStr === 'systemBarTintChange') {
ohosWindow.off(listenerData.typeStr);
} else if (newWindowObj) {
newWindowObj.off(listenerData.typeStr);
}
await sleep(3000);
}
done();
})
afterAll(function () {
})
function sleep(time) {
return new Promise(resolve => {
setTimeout(() => {
resolve('sleep finished');
}, time);
})
}
/**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARPROPERTIES_JSAPI_001
* @tc.name Test setWindowSystemBarPropertiesTest1SystemBarPropertiesTest1
* @tc.desc Verify the scene where the colors of the status bar and navigation bar are set in RGB
*/
it('setWindowSystemBarPropertiesTest1', 0, async function (done) {
let cloneColorArr = JSON.parse(JSON.stringify(commonRGBColorArr));
let listenerFlag = listenerStatus.ready;
console.info('setWindowSystemBarPropertiesTest1');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest1 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) {
// 单个导航栏或者系统状态信息
let SystemBarRegionTint = systemBarData.regionTint[i];
if (SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR || SystemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
console.info('setWindowSystemBarPropertiesTest1 assert1 start!');
let backgroundIndex = cloneColorArr.indexOf(SystemBarRegionTint.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(SystemBarRegionTint.contentColor);
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
done();
}
}
}
})
console.info('setWindowSystemBarPropertiesTest1 on systemBarTintChange finished');
let mainWsync = windowStage.getMainWindowSync();
expect(mainWsync != null).assertTrue();
await mainWsync.showWindow().catch(err => {
console.info('setWindowSystemBarPropertiesTest1 mainWsync.showWindow() error : ' + JSON.stringify(err));
expect().assertFail();
done();
});
await mainWsync.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => {
console.info('setWindowSystemBarPropertiesTest1 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(1000);
listenerFlag = listenerStatus.pending;
let loopCount = commonRGBColorArr.length;
for (let i = 0; i < loopCount; i++) {
let tempColor = commonRGBColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
isStatusBarLightIcon: true,
statusBarContentColor: tempColor,
navigationBarColor: tempColor,
isNavigationBarLightIcon: false,
navigationContentColor: tempColor,
};
mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest1 success');
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
console.info('setWindowSystemBarPropertiesTest1 error : ' + JSON.stringify(err));
expect().assertFail()
done();
})
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARPROPERTIES_JSAPI_002
* @tc.name Test setWindowSystemBarPropertiesTest2
* @tc.desc Verify the scene where the status bar and navigation bar colors are set in hexadecimal form
*/
it('setWindowSystemBarPropertiesTest2', 0, async function (done) {
let cloneColorArr = {
SBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
SCC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NBC: JSON.parse(JSON.stringify(commonNUMBERColorArr)),
NCC: JSON.parse(JSON.stringify(commonNUMBERColorArr))
};
let listenerFlag = listenerStatus.ready;
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
console.info('setWindowSystemBarPropertiesTest2');
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest2 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) {
// 单个导航栏或者系统状态信息
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
let arrLength = systemBarData.regionTint.length;
for (let i = 0; i < arrLength; i++) {
let systemBarRegionTint = systemBarData.regionTint[i];
if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_STATUS_BAR) {
console.info('setWindowSystemBarPropertiesTest2 assert2 start!');
let backgroundIndex = cloneColorArr.SBC.indexOf(systemBarRegionTint.backgroundColor);
let contentColorIndex = cloneColorArr.SCC.indexOf(systemBarRegionTint.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.SBC.splice(backgroundIndex, 1);
}
if (contentColorIndex >= 0) {
cloneColorArr.SCC.splice(contentColorIndex, 1);
}
expect(backgroundIndex !== -1).assertTrue();
expect(contentColorIndex !== -1).assertTrue();
done();
} else if (systemBarRegionTint.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
let backgroundIndex = cloneColorArr.NBC.indexOf(systemBarRegionTint.backgroundColor);
let contentColorIndex = cloneColorArr.NCC.indexOf(systemBarRegionTint.contentColor);
if (backgroundIndex >= 0) {
cloneColorArr.NBC.splice(backgroundIndex, 1);
}
if (contentColorIndex >= 0) {
cloneColorArr.NCC.splice(contentColorIndex, 1);
}
expect(backgroundIndex !== -1).assertTrue();
expect(contentColorIndex !== -1).assertTrue();
done();
}
}
}
})
console.info('setWindowSystemBarPropertiesTest2 on systemBarTintChange finished');
let mainWsync = windowStage.getMainWindowSync();
expect(mainWsync != null).assertTrue();
await mainWsync.showWindow().catch((err) => {
console.info('setWindowSystemBarPropertiesTest2 mainWsync.showWindow() error : ' + JSON.stringify(err));
expect().assertFail();
done();
});
await mainWsync.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => {
console.info('setWindowSystemBarPropertiesTest2 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(1000);
listenerFlag = listenerStatus.pending;
let loopCount = commonNUMBERColorArr.length;
for (let i = 0; i < loopCount; i++) {
let tempColor = commonNUMBERColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
isStatusBarLightIcon: true,
statusBarContentColor: tempColor,
navigationBarColor: tempColor,
isNavigationBarLightIcon: true,
navigationBarContentColor: tempColor,
};
mainWsync.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest2 success');
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
console.info('setWindowSystemBarPropertiesTest2 error : ' + JSON.stringify(err));
expect().assertFail()
done();
})
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARPROPERTIES_JSAPI_003
* @tc.name Test setWindowSystemBarPropertiesTest3
* @tc.desc Verify the scene where the status bar and navigation bar colors are set as keywords
*/
it('setWindowSystemBarPropertiesTest3', 0, async function (done) {
let cloneColorArr = JSON.parse(JSON.stringify(commonKEYColorArr));
let listenerFlag = listenerStatus.ready;
console.info('setWindowSystemBarPropertiesTest3 start');
listenerData.on = true;
listenerData.typeStr = 'systemBarTintChange';
ohosWindow.on('systemBarTintChange', (systemBarData) => {
console.info('setWindowSystemBarPropertiesTest3 systemBatData : ' + JSON.stringify(systemBarData));
if (listenerFlag === listenerStatus.pending) {
expect(!!systemBarData).assertTrue();
expect(!!systemBarData.regionTint).assertTrue();
let arrLength = systemBarData.regionTint.length;
// 单个导航栏或者系统状态信息
for (let i = 0; i < arrLength; i++) {
let tempData = systemBarData.regionTint[i];
if (tempData.type === ohosWindow.WindowType.TYPE_STATUS_BAR || tempData.type === ohosWindow.WindowType.TYPE_NAVIGATION_BAR) {
let backgroundIndex = cloneColorArr.indexOf(tempData.backgroundColor);
let contentColorIndex = cloneColorArr.indexOf(tempData.contentColor);
expect(backgroundIndex === -1).assertTrue();
expect(contentColorIndex === -1).assertTrue();
done();
}
}
}
})
let tempWnd = windowStage.getMainWindowSync();
expect(tempWnd != null).assertTrue();
await tempWnd.showWindow().catch((err) => {
console.info('setWindowSystemBarPropertiesTest3 mainWsync.showWindow() error : ' + JSON.stringify(err));
expect().assertFail();
done();
});
await tempWnd.setWindowSystemBarEnable(['status', 'navigation']).catch((err) => {
console.info('setWindowSystemBarPropertiesTest3 mainWsync.setWindowSystemBarEnable error : ' + JSON.stringify(err));
expect().assertFail();
done();
});
await sleep(1000);
listenerFlag = listenerStatus.pending;
let loopCount = commonKEYColorArr.length;
for (let i = 0; i < loopCount; i++) {
let tempColor = commonKEYColorArr[i];
let systemBarProperties = {
statusBarColor: tempColor,
isStatusBarLightIcon: true,
statusBarContentColor: tempColor,
navigationBarColor: tempColor,
isNavigationBarLightIcon: false,
navigationContentColor: tempColor,
};
tempWnd.setWindowSystemBarProperties(systemBarProperties).then(() => {
console.info('setWindowSystemBarPropertiesTest3 success');
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
console.info('setWindowSystemBarPropertiesTest3 error : ' + JSON.stringify(err));
expect().assertFail()
done();
})
}
})
/**
* @tc.number SUB_WINDOW_SETWINDOWSYSTEMBARPROPERTIES_JSAPI_003
* @tc.name Test setWindowSystemBarPropertiesTestCallBack
* @tc.desc Verify the scene where the status bar and navigation bar colors are set as keywords
*/
it('setWindowSystemBarPropertiesTestCallBack', 0, async function (done) {
let SystemBarProperties = {
statusBarColor: '#ff00ff',
navigationBarColor: '#00ff00',
isStatusBarLightIcon: true,
isNavigationBarLightIcon:false,
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#00ffff'
};
let tempWnd = windowStage.getMainWindowSync();
expect(tempWnd != null).assertTrue();
try {
tempWnd.setWindowSystemBarProperties(SystemBarProperties, (err) => {
console.info('Succeeded in setting the system bar properties.' + JSON.stringify(err));
if (err.code) {
expect(err.code).assertEqual(401);
done()
} else {
console.info('Succeeded in setting the system bar properties.');
expect(TRUE_FLAG).assertTrue();
done();
}
});
} catch (exception) {
console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
})
/**
* @tc.number SUB_WMS_ISWINDOWSHOWING_JSAPI_001
* @tc.name Test iswindowShowing_Test_001.
* @tc.desc To verify the widow isshowing
*/
it('iswindowShowing_Test_001', 0, async function (done) {
console.info('windowTest isWindowShowing begin');
let config = {name: "alertWindowshow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context};
ohosWindow.createWindow(config).then(wnd => {
expect(wnd != null).assertTrue();
let isWindowShowing = wnd.isWindowShowing();
expect(!isWindowShowing).assertTrue();
wnd.showWindow().then(() => {
let isWindowShowing2 = wnd.isWindowShowing();
expect(isWindowShowing2).assertTrue();
wnd.destroyWindow();
done();
}).catch(err => {
console.error('Failed to show window1. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
})
}).catch(err => {
console.error('Failed to create the Windowshow1. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_setUIContent_JSAPI_001
* @tc.name Test setUIContentTest1
* @tc.desc Verify the scenario of loading an existing page
*/
it('setUIContentTest1', 0, async function (done) {
let config = {name: "alertWindow", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context};
try {
let promise = ohosWindow.createWindow(config);
promise.then(win => {
console.info('Succeeded in creating the window1. Data:' + JSON.stringify(win));
expect(win != null);
win.setUIContent('pages/second/second').then(() => {
console.info('setUIContent1 . Cause: success');
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
console.error('Failed to setUIContent . Cause:' + JSON.stringify(err));
expect().assertFail();
done();
});
}).catch((err) => {
console.error('Failed to create the Window1. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (exception) {
console.error('Failed to create the window. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WINDOW_setUIContentCallBack_JSAPI_001
* @tc.name Test setUIContentTestCallback1
* @tc.desc Verify the scenario of loading an existing page
*/
it('setUIContentTestCallBack1', 0, async function (done) {
let windowClass = null;
let config = {name: "alertWindowcallBack", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context};
try {
let promise = ohosWindow.createWindow(config);
promise.then(win => {
console.info('Succeededcall in creating the window2. Data:' + JSON.stringify(win));
windowClass = win;
expect(win != null).assertTrue();
// 设置setUIContent
try {
windowClass.setUIContent('pages/second/second', (err) => {
if (err.code) {
console.error('Failed to load the content callback. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('Succeeded in loading the content.');
expect(TRUE_FLAG).assertTrue();
done();
}
});
} catch (exception) {
console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception));
expect().assertFail();
done();
};
}).catch((err) => {
console.error('Failedcaa to create the inner Window2. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (exception) {
console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WINDOW_setUIContent_JSAPI_002
* @tc.name Test setUIContentTest2
* @tc.desc Verify the scene of loading the page with illegal values
*/
it('setUIContentTest2', 0, async function (done) {
let windowClass = null;
let config = {name: "alertWindow2", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context};
try {
let promise = ohosWindow.createWindow(config);
promise.then(win => {
console.info('Succeeded in creating the window2. Data:' + JSON.stringify(win));
windowClass = win;
expect(win != null).assertTrue();
// 设置setUIContent
try {
let promise = windowClass.setUIContent(null);
promise.then(()=> {
console.info('Succeeded in loading the content.');
expect().assertFail();
done();
}).catch((err)=>{
console.error('Failed to load the content. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done()
});
} catch (exception) {
console.error('Failed to load the content. exception: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
}).catch((err) => {
console.error('Failed to create the inner Window2. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (exception) {
console.error('Failed to create the window2. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WINDOW_setUIContent_JSAPI_003
* @tc.name Test setUIContentTest3
* @tc.desc Verify the scene of loading the page with illegal values
*/
it('setUIContentTest3', 0, async function (done) {
let config = {name: "alertWindow3", windowType: ohosWindow.WindowType.TYPE_SYSTEM_ALERT, ctx: context};
try {
let promise = ohosWindow.createWindow(config);
promise.then(win => {
console.info('Succeeded in creating the window3. Data:' + JSON.stringify(win));
expect(win != null).assertTrue();
// 设置setUIContent
win.setUIContent('pages/second/he').then(() => {
console.info('setUIContent3 . Cause: success');
expect(TRUE_FLAG).assertTrue();
done();
}).catch(err => {
console.error('Failed to setUIContent3 . Cause:' + JSON.stringify(err));
expect().assertFail();
done();
});
}).catch((err) => {
console.error('Failed to create the inner Window3. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
});
} catch (exception) {
console.error('Failed to create the window3. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WMS_setWindowColorSpace_JSAPI_001
* @tc.name Test setWindowColorSpace_Test_001
* @tc.desc To verify the setting of the wide color gamut color space
*/
it('setWindowColorSpace_Test_001', 0, async function (done) {
console.info('windowTest setWindowColorSpace1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowColorSpace(ohosWindow.ColorSpace.WIDE_GAMUT).then(() => {
console.info('windowTest SetWindowColorSpaceTest1 setColorSpace WIDE_GAMUT');
let windowColorSpace = wnd.getWindowColorSpace();
expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue();
console.info('windowTest SetWindowColorSpaceTest1 setColorSpace WIDE_GAMUT success');
wnd.isWindowSupportWideGamut().then(data => {
expect(data).assertTrue();
done();
}, (err) => {
console.info('windowTest SetColorSpaceTest1 wnd.isWindowSupportWideGamut failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.info('windowTest SetWindowColorSpaceTest1 wnd.setColorSpace failed, err :' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWCOLORSPACE_JSAPI_002
* @tc.name Test setWindowColorSpace_Test_002
* @tc.desc To verify that the color space of invaild values is set successfully
*/
it('setWindowColorSpace_Test_002', 0, async function (done) {
console.info('windowTest setWindowColorSpaceTest2 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
try {
let promise = wnd.setWindowColorSpace(-5);
promise.then(()=> {
console.info('Succeeded in setting window2 colorspace.');
expect().assertFail();
done();
}).catch((err)=>{
console.error('Failed to set window colorspacecatch2. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
});
} catch (exception) {
console.error('Failed to set window colorspaceexception2. Cause:' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWCOLORSPACE_JSAPI_003
* @tc.name Test setWindowColorSpace_Test_003
* @tc.desc To verify the setting of the wide color gamut color space
*/
it('setColorSpace_Test_003', 0, async function (done) {
console.info('windowTest SetWindowColorSpaceTest3 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setColorSpace(ohosWindow.ColorSpace.WIDE_GAMUT, (err) => {
if (err.code != 0) {
console.info('windowTest SetWindowColorSpaceTest3 setColorSpace fail' + JSON.stringify(err));
expect().assertFail();
done();
} else {
let windowColorSpace = wnd.getWindowColorSpace();
expect(windowColorSpace == ohosWindow.ColorSpace.WIDE_GAMUT).assertTrue();
wnd.isWindowSupportWideGamut((err, data) => {
if (err.code != 0) {
console.log('windowTest SetWindowColorSpaceTest3 getColorSpace callback fail' + JSON.stringify(err));
expect().assertFail();
done();
} else {
expect(data).assertTrue();
done();
}
})
}
})
})
/**
* @tc.number SUB_WMS_SETWINDOWBACKGROUNDCOLOR_JSAPI_001
* @tc.name Test setWindowBackgroundColor_Test_001
* @tc.desc Set the window background color to red and Default opacity
*/
it('setWindowBackgroundColor_Test_001', 0, async function (done) {
console.info('windowTest01 setWindowBackgroundColorTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let color = '#00ff33';
try {
wnd.setWindowBackgroundColor(color);
done();
try {
let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties001. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
} catch (exception) {
console.error('Failed to set the background1 color. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBACKGROUNDCOLOR_JSAPI_002
* @tc.name Test setWindowBackgroundColor_Test_002
* @tc.desc Set the window background color to red opaque
*/
it('setWindowBackgroundColor_Test_002', 0, async function (done) {
console.info('windowTest setWindowBackgroundColorTest2 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let color = '#ffffff00';
try {
wnd.setWindowBackgroundColor(color);
done();
try {
let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties002. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
} catch (exception) {
console.error('Failed to set the background2 color. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBACKGROUNDCOLOR_JSAPI_003
* @tc.name Test setWindowBackgroundColor_Test_003
* @tc.desc Set the window background color to red transparent
*/
it('setWindowBackgroundColor_Test_003', 0, async function (done) {
console.info('windowTest setWindowBackgroundColorTest3 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let color = '#00ffff00';
try {
wnd.setWindowBackgroundColor(color);
done();
try {
let properties = wnd.getWindowProperties();
expect(properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties003. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
} catch (exception) {
console.error('Failed to set the background3 color. Cause: ' + JSON.stringify(exception));
expect().assertFail();
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBACKGROUNDCOLOR_JSAPI_004
* @tc.name Test setWindowBackgroundColor_Test_004
* @tc.desc Set the background color input parameter as an outlier
*/
it('setWindowBackgroundColor_Test_004', 0, async function (done) {
console.info('windowTest setWindowBackgroundColorTest4 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let color = '#ff00';
try {
wnd.setWindowBackgroundColor(color);
done();
} catch (exception) {
console.error('Failed to set the background4 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBACKGROUNDCOLOR_JSAPI_005
* @tc.name Test setWindowBackgroundColor_Test_005
* @tc.desc Setting window background color input exception ARGB
*/
it('setWindowBackgroundColor_Test_005', 0, async function (done) {
console.info('windowTest setWindowBackgroundColorTest5 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let color = '#hhgghhgg';
try {
wnd.setWindowBackgroundColor(color);
try {
let properties = wnd.getWindowProperties();
expect(!properties.isTransparent).assertTrue();
done()
} catch (exception) {
console.error('Failed to obtain the window properties005. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
} catch (exception) {
console.error('Failed to set the background5 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBACKGROUNDCOLOR_JSAPI_006
* @tc.name Test setWindowBackgroundColor_Test_006
* @tc.desc Setting window background color input exception RGB
*/
it('setWindowBackgroundColor_Test_006', 0, async function (done) {
console.log('windowTest setWindwoBackgroundColorTest6 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let color = '#hhgghhgg';
try {
wnd.setWindowBackgroundColor(color);
done();
} catch (exception) {
console.error('Failed to set the background6 color. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESS_JSAPI_001
* @tc.name Test setWindowBrightness_Test_001
* @tc.desc Setting the brightness bar input parameter is normal
*/
it('setWindowBrightness_Test_001', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowBrightness(0).then(() => {
console.info('windowTest setWindowBrightnessTest1 setBrightness(0) success ');
let data = wnd.getWindowProperties();
expect(data.brightness).assertEqual(0);
wnd.setWindowBrightness(0.5).then(() => {
console.info('windowTest setWindowBrightnessTest1 setBrightness(0.5) success ');
let data1 = wnd.getWindowProperties();
expect(data1.brightness).assertEqual(0.5);
wnd.setWindowBrightness(1).then(() => {
console.info('windowTest setWindowBrightnessTest1 setBrightness(1) success ');
let data2 = wnd.getWindowProperties();
expect(data2.brightness).assertEqual(1);
done();
}, (err) => {
console.log('windowTest setWindwoBrightnessTest1 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setBrightnessTest1 setWindowBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.info('windowTest setWindowBrightnessTest1 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESS_JSAPI_002
* @tc.name Test setWindowBrightness_Test_002
* @tc.desc Set the brightness bar input parameter to decimal
*/
it('setWindowBrightness_Test_002', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest2 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowBrightness(0.564789).then(() => {
console.log('windowTest setBrightnessTest2 setBrightness(0.564789) success ');
expect(TRUE_FLAG).assertTrue();
done();
}, (err) => {
console.log('windowTest setWindowBrightnessTest2 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESS_JSAPI_003
* @tc.name Test setWindowBrightness_Test_003
* @tc.desc Set the brightness bar input parameter to number max
*/
it('setWindowBrightness_Test_003', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest3 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let brightness = Number.MAX_VALUE;
try {
let promise = wnd.setWindowBrightness(brightness);
promise.then(()=> {
console.info('Succeeded3 in setting the brightness.');
expect().assertFail();
done();
}).catch((err)=>{
console.error('Failed3 to set the brightness. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
});
} catch (exception) {
console.error('Failed3 to set the brightnessexception. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESS_JSAPI_004
* @tc.name Test setWindowBrightness_Test_004
* @tc.desc Set the brightness bar input parameter to number min
*/
it('setWindowBrightness_Test_004', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest4 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowBrightness(Number.MIN_VALUE).then(() => {
console.info('windowTest setWindowBrightnessTest3 setBrightness(Number.MAX_VALUE) success ');
expect(TRUE_FLAG).assertTrue();
done();
}, (err) => {
console.info('windowTest setWindowBrightnessTest4 setBrightness failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESS_JSAPI_005
* @tc.name Test setWindowBrightness_Test_005
* @tc.desc Setting brightness bar input parameter exception
*/
it('setWindowBrightness_Test_005', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest5 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let brightness = 1.1;
try {
let promise = wnd.setWindowBrightness(brightness);
promise.then(()=> {
console.info('Succeeded5 in setting the brightness.');
expect().assertFail();
done();
}).catch((err)=>{
console.error('Failed5 to set the brightness. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
});
} catch (exception) {
console.error('Failed5 to set the brightness. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
try {
let promise = wnd.setWindowBrightness(-0.5);
promise.then(()=> {
console.info('Succeeded55 in setting the brightness.');
expect().assertFail();
done();
}).catch((err)=>{
console.error('Failed55 to set the brightness. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
});
} catch (exception) {
console.error('Failed55 to set the brightness. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESSCALLBACK_JSAPI_002
* @tc.name Test setWindowBrightnessCallBack_Test_002
* @tc.desc Set the brightness bar input parameter to decimal
*/
it('setWindowBrightnessCallBack_Test_002', 0, async function (done) {
console.info('windowTest setWindowBrightnessTestCallBack2 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
try {
wnd.setWindowBrightness(1, (err) => {
if (err.code) {
console.error('Failed to set the brightnesscallback01. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
} else {
expect(TRUE_FLAG).assertTrue();
try {
let properties = wnd.getWindowProperties();
expect(properties.brightness).assertEqual(1);
done();
} catch (exception) {
console.error('Failed04 to obtain the window properties. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
}
});
} catch (exception) {
console.error('Failedca02 to set the brightness. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done()
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESSCALLBACK_JSAPI_003
* @tc.name Test setWindowBrightnessCallBack_Test_003
* @tc.desc Set the brightness bar input parameter to number max
*/
it('setWindowBrightnessCallBack_Test_003', 0, async function (done) {
console.info('windowTest setBrightnessTestCallback3 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let brightness = Number.MAX_VALUE;
try {
wnd.setWindowBrightness(brightness, (err) => {
if (err.code) {
console.error('Failed to set the brightnesscallback3. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
} else {
console.info('windowTest setBrightnessTest3CallBack setBrightness(Number.MAX_VALUE) success ');
expect().assertFail();
done();
}
});
} catch (exception) {
console.error('Failed to set the brightnesscall3CallBack. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESSCALLBACK_JSAPI_004
* @tc.name Test setWindowBrightnessCallBack_Test_004
* @tc.desc Set the brightness bar input parameter to number min
*/
it('setWindowBrightnessCallBack_Test_004', 0, async function (done) {
console.info('windowTest setBrightnessTestCallBack4 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
try {
wnd.setWindowBrightness(Number.MIN_VALUE, (err) => {
if (err.code) {
console.error('Failed to set the brightnesscallback4. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
} else {
console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.MAX_VALUE) success ');
expect(TRUE_FLAG).assertTrue();
done();
}
});
} catch (exception) {
console.error('Failed to set the brightnesscall4CallBack. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWBRIGHTNESSCALLBACK_JSAPI_005
* @tc.name Test setWindowBrightnessCALLBACK_Test_005
* @tc.desc Setting brightness bar input parameter exception
*/
it('setWindowBrightnessCallBack_Test_005', 0, async function (done) {
console.info('windowTest setWindowBrightnessTest5 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
try {
wnd.setWindowBrightness(1.1, (err) => {
if (err.code) {
console.error('Failed to set the brightnesscallback5. Cause: ' + JSON.stringify(err));
expect(err.code).assertEqual(401);
done();
} else {
console.info('windowTest setBrightnessTest5CallBack setBrightness(Number.MAX_VALUE) success ');
expect().assertFail();
done();
}
});
} catch (exception) {
console.error('Failed to set the brightnesscall5CallBack. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
})
/**
* @tc.number SUB_WMS_SETWINDOWFOCUSABLECALLBACK_JSAPI_001
* @tc.name Test setWindowFocusable_Test_001
* @tc.desc Setting window focus acquisition and defocus
*/
it('setWindowFocusableCallBack_Test_001', 0, async function (done) {
console.info('windowTest setFocusableTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowFocusable(false, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
let data = wnd.getWindowProperties();
expect(!data.focusable).assertTrue();
wnd.setWindowFocusable(true, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be setFocusable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
let data2 = wnd.getWindowProperties();
expect(data2.focusable).assertTrue();
done();
}
})
}
})
})
/**
* @tc.number SUB_WMS_SETWINDOWFOCUSABLE_JSAPI_001
* @tc.name Test setWindowFocusable_Test_001
* @tc.desc Setting window focus acquisition and defocus
*/
it('setWindowFocusable_Test_001', 0, async function (done) {
console.info('windowTest setWindowFocusableTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowFocusable(false).then(() => {
console.info('windowTest setFocusableTest1 setFocusable(false) success ');
let data2 = wnd.getWindowProperties();
expect(!data2.focusable).assertTrue();
wnd.setWindowFocusable(true).then(() => {
console.info('windowTest setFocusableTest1 setFocusable(true) success ');
expect(TRUE_FLAG).assertTrue();
done();
}, err => {
console.info('windowTest setFocusableTest1 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setWinFocusableTest1 setFocusable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWTOUCHABLE_JSAPI_001
* @tc.name Test setWindowTouchable_Test_001
* @tc.desc Set whether the window can be touched or not
*/
it('setWindowTouchable_Test_001', 0, async function (done) {
console.info('windowTest setTouchableTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let data = wnd.getWindowProperties();
expect(data.touchable).assertTrue();
wnd.setWindowTouchable(false).then(() => {
console.info('windowTest setTouchableTest1 setTouchable(false) success ');
let data2 = wnd.getWindowProperties();
expect(!data2.touchable).assertTrue();
wnd.setWindowTouchable(true).then(() => {
console.info('windowTest setTouchableTest1 setTouchable(true) success ');
let data3 = wnd.getWindowProperties();
expect(data3.touchable).assertTrue();
done();
}, (err) => {
console.info('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
}, (err) => {
console.log('windowTest setTouchableTest1 setTouchable failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWTOUCHABLECALLBACK_JSAPI_001
* @tc.name Test setWindowTouchableCallBack_Test_001
* @tc.desc Set whether the window can be touched or not
*/
it('setWindowTouchableCallBack_Test_001', 0, async function (done) {
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowTouchable(false, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
let data = wnd.getWindowProperties();
expect(!data.touchable).assertTrue();
wnd.setWindowTouchable(true, (err, data) => {
if (err.code) {
console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
let data2 = wnd.getWindowProperties();
expect(data2.touchable).assertTrue();
done();
}
})
}
})
})
/**
* @tc.number SUB_WMS_SETWINDOWKEEPSCREENON_JSAPI_002
* @tc.name Test setWindowKeepScreenOn_Test_002
* @tc.desc Set whether the window screenOn
*/
it('setWindowKeepScreenOn_Test_002', 0, async function (done) {
console.info('windowTest setWindowKeepScreenOnTest2 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let data = wnd.getWindowProperties();
expect(!data.isKeepScreenOn).assertTrue();
wnd.setWindowKeepScreenOn(true).then(() => {
console.info('windowTest setKeepScreenOnTest2 setKeepScreenOn(false) success ');
let data2 = wnd.getWindowProperties();
expect(data2.isKeepScreenOn).assertTrue();
done();
}, (err) => {
console.info('windowTest setKeepScreenOnTest2 setKeepScreenOn failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWKEEPSCREENON_JSAPI_001
* @tc.name Test setWindowKeepScreenOn_Test_001
* @tc.desc Set whether the window screenOn
*/
it('setWindowKeepScreenOn_Test_001', 0, async function (done) {
console.info('windowTest setWindowKeepScreenOnTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowKeepScreenOn(false).then(() => {
console.info('windowTest setKeepScreenOnTest1 setKeepScreenOn(false) success ');
let data2 = wnd.getWindowProperties();
expect(!data2.isKeepScreenOn).assertTrue();
done();
}, (err) => {
console.info('windowTest setKeepScreenOnTest1 setKeepScreenOn failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWKEEPSCREENONCALLBACK_JSAPI_001
* @tc.name Test setwindowKeepScreenOnCallBack_Test_001
* @tc.desc Set whether setKeepScreenOn or not
*/
it('setWindowKeepScreenOnCallBack_Test_001', 0, async function (done) {
console.info('windowTest setCallBackKeepScreenOnTest1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowKeepScreenOn(true, (err, data) => {
if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('success set the screen to be always on. Cause: ' + JSON.stringify(data));
let data2 = wnd.getWindowProperties();
expect(data2.isKeepScreenOn).assertTrue();
done();
}
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWPRIVACYMODE_JSAPI_001
* @tc.name Test setWindowPrivacyMode_Test_001
* @tc.desc Verify the window privacy mode
*/
it('setWindowPrivacyMode_Test_001', 0, async function (done) {
console.info('windowTest setWindowPrivacyMode begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let data = wnd.getWindowProperties();
expect(!data.isPrivacyMode).assertTrue();
wnd.setWindowPrivacyMode(false).then(() => {
console.info('windowTest setWindowPrivacyMode1 success ');
let data2 = wnd.getWindowProperties();
expect(!data2.isPrivacyMode).assertTrue();
done();
}, (err) => {
console.info('windowTest setWindowPrivacyMode failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WINDOW_SETWINDOWPRIVACYMODE_JSAPI_002
* @tc.name Test setWindowPrivacyMode_Test_002
* @tc.desc Verify the window privacy mode
*/
it('setWindowPrivacyMode_Test_002', 0, async function (done) {
console.info('windowTest setWindowPrivacyMode2 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
let data = wnd.getWindowProperties();
expect(!data.isPrivacyMode).assertTrue();
wnd.setWindowPrivacyMode(true).then(() => {
console.info('windowTest setWindowPrivacyMode2 success ');
let data2 = wnd.getWindowProperties();
expect(data2.isPrivacyMode).assertTrue();
done();
}, (err) => {
console.info('windowTest setWindowPrivacyMode2 failed: err' + JSON.stringify(err));
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_WMS_SETWINDOWPTIVACYCALLBACK_JSAPI_001
* @tc.name Test setwindowPrivacyModeCallBack_Test_001
* @tc.desc Set whether setWindowPrivacyMode or not
*/
it('setWindowPrivacyModeCallBack_Test_001', 0, async function (done) {
console.info('windowTest setWindowPrivacyModecallback1 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
try {
wnd.setWindowPrivacyMode(true, (err) => {
if (err.code) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err));
expect().assertFail();
done();
} else {
console.info('Succeeded in setting the window to privacy mode.');
let data2 = wnd.getWindowProperties();
expect(data2.isPrivacyMode).assertTrue();
done();
}
});
} catch (exception) {
console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(exception));
expect(exception.code).assertEqual(401);
done();
};
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册