Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
28afd11b
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
28afd11b
编写于
7月 14, 2023
作者:
H
hu0475
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复gn格式问题和按接口人要求完善代码
Signed-off-by:
N
hu0475
<
huyanqiang5@huawei.com
>
上级
842c5fe2
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
187 addition
and
185 deletion
+187
-185
graphic/BUILD.gn
graphic/BUILD.gn
+1
-1
graphic/crossplatform/window/AppScope/app.json
graphic/crossplatform/window/AppScope/app.json
+3
-3
graphic/crossplatform/window/BUILD.gn
graphic/crossplatform/window/BUILD.gn
+3
-3
graphic/crossplatform/window/Test.json
graphic/crossplatform/window/Test.json
+2
-2
graphic/crossplatform/window/src/main/ets/TestAbility/pages/Index1.ets
...platform/window/src/main/ets/TestAbility/pages/Index1.ets
+28
-0
graphic/crossplatform/window/src/main/ets/test/Window.test.ets
...ic/crossplatform/window/src/main/ets/test/Window.test.ets
+71
-57
graphic/crossplatform/window/src/main/ets/test/WindowStage.test.ets
...ossplatform/window/src/main/ets/test/WindowStage.test.ets
+77
-118
graphic/crossplatform/window/src/main/resources/base/profile/test_pages.json
...rm/window/src/main/resources/base/profile/test_pages.json
+2
-1
未找到文件。
graphic/BUILD.gn
浏览文件 @
28afd11b
...
...
@@ -16,7 +16,7 @@ group("graphic") {
testonly = true
if (is_standard_system) {
deps = [
"crossplatform/window:
window_ets_normal_t
est",
"crossplatform/window:
ActsCrossplatformWindowT
est",
"effectKit:EffectKitTest",
"graphicColorSpace:ActsColorSpaceManagerTest",
"graphicnapidrawingtest:ActsGraphicNapiDrawingTest",
...
...
graphic/crossplatform/window/AppScope/app.json
浏览文件 @
28afd11b
...
...
@@ -6,10 +6,10 @@
"versionName"
:
"1.0.0"
,
"icon"
:
"$media:app_icon"
,
"label"
:
"$string:app_name"
,
"minAPIVersion"
:
9
,
"targetAPIVersion"
:
9
,
"minAPIVersion"
:
10
,
"targetAPIVersion"
:
10
,
"car"
:
{
"apiCompatibleVersion"
:
9
,
"apiCompatibleVersion"
:
10
,
"singleUser"
:
false
}
}
...
...
graphic/crossplatform/window/BUILD.gn
浏览文件 @
28afd11b
...
...
@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("
window_ets_normal_t
est") {
ohos_js_hap_suite("
ActsCrossplatformWindowT
est") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
...
...
@@ -21,7 +21,7 @@ ohos_js_hap_suite("window_ets_normal_test") {
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsWindowTest"
hap_name = "Acts
Crossplatform
WindowTest"
subsystem_name = "window"
part_name = "window_manager"
}
...
...
@@ -36,4 +36,4 @@ ohos_resources("windowStage_resources") {
sources = [ "src/main/resources" ]
deps = [ ":windowStage_app_profile" ]
hap_profile = "src/main/module.json"
}
\ No newline at end of file
}
graphic/crossplatform/window/Test.json
浏览文件 @
28afd11b
...
...
@@ -6,12 +6,12 @@
"shell-timeout"
:
"300000"
,
"bundle-name"
:
"ohos.acts.graphic.crossplatform.window"
,
"module-name"
:
"window"
,
"testcase-timeout"
:
5
000
"testcase-timeout"
:
10
000
},
"kits"
:
[
{
"test-file-name"
:
[
"ActsWindowTest.hap"
"Acts
Crossplatform
WindowTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
...
...
graphic/crossplatform/window/src/main/ets/TestAbility/pages/Index1.ets
0 → 100644
浏览文件 @
28afd11b
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index1 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World \n pages/Index1!!!')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
graphic/crossplatform/window/src/main/ets/test/Window.test.ets
浏览文件 @
28afd11b
...
...
@@ -23,6 +23,10 @@ export default function Window() {
let storage;
const TRUE_FLAG = true;
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
beforeAll(async function () {
console.info("beforeAll case");
context = globalThis.abilityContext;
...
...
@@ -172,7 +176,11 @@ export default function Window() {
return;
}
console.info(msgStr + 'Succeeded in obtaining the top window. Data: ' + JSON.stringify(data));
expect(data != null).assertTrue();
try {
expect(data != null).assertTrue();
} catch (err) {
console.info(msgStr + "err " + err);
}
await windowData.destroyWindow();
done();
})
...
...
@@ -197,8 +205,9 @@ export default function Window() {
try {
tempWnd = await windowStage.createSubWindow('testShowWindowPromise001');
expect(!!tempWnd).assertTrue();
await tempWnd.showWindow().then(async (data) => {
console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data));
await tempWnd.showWindow().then(async () => {
expect(TRUE_FLAG).assertTrue();
console.info(msgStr + 'Succeeded in showing the window. ');
await tempWnd.destroyWindow();
done();
}).catch((err) => {
...
...
@@ -227,7 +236,7 @@ export default function Window() {
let winData;
winData = await windowStage.createSubWindow('testShowWindowCb001');
expect(!!winData).assertTrue();
winData.showWindow(async (err
, data
) => {
winData.showWindow(async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to show the window. Cause: ' + JSON.stringify(err));
try {
...
...
@@ -238,7 +247,8 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in showing the window. Data: ' + JSON.stringify(data));
console.info(msgStr + 'Succeeded in showing the window.');
expect(TRUE_FLAG).assertTrue();
await winData.destroyWindow();
done();
})
...
...
@@ -314,7 +324,11 @@ export default function Window() {
expect(!findWnd).assertTrue();
} catch (exception) {
console.error(msgStr + 'try catch Failed to find the Window. Cause: ' + JSON.stringify(exception));
expect(exception.code).assertEqual(1300002);
try {
expect(exception.code).assertEqual(1300002);
} catch (err) {
console.error(msgStr + 'fail ' + JSON.stringify(err));
}
}
}
done();
...
...
@@ -520,7 +534,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(300, 300, async (err
, data
) => {
winData.moveWindowTo(300, 300, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
...
...
@@ -532,7 +546,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window.
Data: ' + JSON.stringify(data)
);
console.info(msgStr + 'Succeeded in moving the window.
'
);
await winData.destroyWindow();
done();
})
...
...
@@ -559,7 +573,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(100, 50, async (err
, data
) => {
winData.moveWindowTo(100, 50, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
...
...
@@ -571,7 +585,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window.
Data: ' + JSON.stringify(data)
);
console.info(msgStr + 'Succeeded in moving the window.
'
);
await winData.destroyWindow();
done();
})
...
...
@@ -598,7 +612,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(20000, 20000, async (err
, data
) => {
winData.moveWindowTo(20000, 20000, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
...
...
@@ -610,7 +624,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window.
Data: ' + JSON.stringify(data)
);
console.info(msgStr + 'Succeeded in moving the window.
'
);
await winData.destroyWindow();
done();
})
...
...
@@ -637,7 +651,7 @@ export default function Window() {
expect(!!winData).assertTrue();
try {
await winData.showWindow();
winData.moveWindowTo(-200, -200, async (err
, data
) => {
winData.moveWindowTo(-200, -200, async (err) => {
if (err.code) {
console.error(msgStr + 'Failed to move the window. Cause:' + JSON.stringify(err));
try {
...
...
@@ -649,7 +663,7 @@ export default function Window() {
done();
return;
}
console.info(msgStr + 'Succeeded in moving the window.
Data: ' + JSON.stringify(data)
);
console.info(msgStr + 'Succeeded in moving the window.
'
);
await winData.destroyWindow();
done();
})
...
...
@@ -1239,7 +1253,7 @@ export default function Window() {
expect(!!mainWin).assertTrue();
let num = 0
let orientationItem = ['UNSPECIFIED', 'PORTRAIT', 'LANDSCAPE', 'PORTRAIT_INVERTED',
'LANDSCAPE_INVERTED'];
'LANDSCAPE_INVERTED'
, 'UNSPECIFIED'
];
for (let i = 0; i < orientationItem.length; i++) {
let orientation = window.Orientation[orientationItem[i]]
console.log(msgStr + 'i : ' + i + ' ,orientation : ' + orientation);
...
...
@@ -1249,8 +1263,9 @@ export default function Window() {
num++
if (num == orientationItem.length) done();
}).catch(err => {
console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation);
console.log(msgStr + 'window.setPreferredOrientation failed set error:' + orientation
+ err
);
});
await sleep(500);
}
})
/**
...
...
@@ -1294,7 +1309,11 @@ export default function Window() {
let orientation = window.Orientation[orientationItem[i]]
await setPreferredOrientationFun(mainWin, orientation).catch((err) => {
console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
expect().assertFail();
try {
expect().assertFail();
} catch (err) {
console.error(msgStr + 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
}
done();
});
console.info(msgStr + 'Succeeded in setting window orientation. orientation: ' + orientation + "step: " + i);
...
...
@@ -1322,14 +1341,14 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
let load = await tempWnd.loadContent('pages/second/second', storage).catch((err) => {
await tempWnd.loadContent('TestAbility/pages/index1', storage).then(async () => {
console.log(msgStr + 'tempWnd.loadContent() success');
expect(TRUE_FLAG).assertTrue();
await tempWnd.destroyWindow();
done();
}).catch((err) => {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
console.log(msgStr + 'tempWnd.loadContent(pages/second/second) err=' + JSON.stringify(err));
});
console.log(msgStr + 'tempWnd.loadContent(pages/second/second) load=' + JSON.stringify(load));
expect(!load).assertTrue();
await tempWnd.destroyWindow();
done();
})
/**
* @tc.number : TEST_LOADCONTENT_PROMISE_002
...
...
@@ -1348,15 +1367,13 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
console.log(msgStr + 'tempWnd.loadContent start');
await tempWnd.destroyWindow();
let errFlag = false;
try {
await tempWnd.loadContent(null, storage);
expect().assertFail();
done();
} catch (err) {
errFlag = true;
expectedError(err, caseName, 'tempWnd.loadContent', done, 401);
await tempWnd.destroyWindow();
console.log(msgStr + 'tempWnd.loadContent(null)' + JSON.stringify(err));
}
})
...
...
@@ -1378,17 +1395,19 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
tempWnd.loadContent('
pages/index', storage, async (err, data
) => {
tempWnd.loadContent('
TestAbility/pages/index1', storage, async (err
) => {
if (err && err.code) {
unexpectedError(err, caseName, 'tempWnd.loadContent', done);
} else {
try {
expect(!data).assertTrue();
console.log(msgStr + 'tempWnd.loadContent() success');
expect(TRUE_FLAG).assertTrue();
done();
} catch (error) {
console.info(`tempWnd.loadContent catch error: ${JSON.stringify(error)}`)
done()
}
await tempWnd.destroyWindow();
done()
}
})
})
...
...
@@ -1409,7 +1428,7 @@ export default function Window() {
tempWnd = await windowStage.createSubWindow(windowId);
expect(!!tempWnd).assertTrue();
try {
tempWnd.loadContent(null, storage, async (err
, data
) => {
tempWnd.loadContent(null, storage, async (err) => {
if (err && err.code) {
try {
expect(err.code === 401).assertTrue();
...
...
@@ -1434,7 +1453,7 @@ export default function Window() {
}
})
/**
* @tc.number :
testGetUIContext
001
* @tc.number :
TEST_GETUICONTEXT_
001
* @tc.name : testGetUIContext001
* @tc.desc : test getUIContext
* @tc.size : MediumTest
...
...
@@ -1442,20 +1461,12 @@ export default function Window() {
* @tc.level : Level 2
*/
it('testGetUIContext001', 0, async function (done) {
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error('testGetUIContext001 Failed to obtain the main window. Cause: ' + JSON.stringify(err));
expect(false).assertTrue();
done()
} else {
console.info('testGetUIContext001 Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
expect(data != undefined).assertTrue();
let UIContext = data.getUIContext();
expect(UIContext != undefined).assertTrue();
console.info('testGetUIContext001 Succeeded');
done();
}
})
let tempWnd = await windowStage.getMainWindow();
expect(!!tempWnd).assertTrue();
let UIContext = tempWnd.getUIContext();
expect(UIContext != undefined).assertTrue();
console.info('testGetUIContext001 Succeeded');
done();
})
/**
* @tc.number : TEST_SETUICONTENT_PROMISE_001
...
...
@@ -1470,7 +1481,7 @@ export default function Window() {
try {
win = await windowStage.createSubWindow('testSetUIContentPromise001');
expect(win != null);
await win.setUIContent('
pages/second/second
').then(async () => {
await win.setUIContent('
TestAbility/pages/index1
').then(async () => {
console.info('setUIContent1 . Cause: success');
expect(TRUE_FLAG).assertTrue();
await win.destroyWindow();
...
...
@@ -1537,7 +1548,7 @@ export default function Window() {
try {
win = await windowStage.createSubWindow('testSetUIContentPromise003');
expect(win != null).assertTrue();
await win.setUIContent('
pages/second/he
').then(async () => {
await win.setUIContent('
wrong pages
').then(async () => {
console.info('setUIContent3 . Cause: success');
expect(TRUE_FLAG).assertTrue();
await win.destroyWindow();
...
...
@@ -1567,12 +1578,11 @@ export default function Window() {
winData = await windowStage.createSubWindow('testSetUIContentCb001');
expect(!!winData).assertTrue();
try {
winData.setUIContent('
pages/second/second
', async (err) => {
winData.setUIContent('
TestAbility/pages/index1
', async (err) => {
try {
if (err.code) {
console.error('Failed to load the content callback. Cause:' + JSON.stringify(err));
expect().assertFail();
} else {
console.info('Succeeded in loading the content.');
expect(TRUE_FLAG).assertTrue();
...
...
@@ -1585,7 +1595,11 @@ export default function Window() {
});
} catch (exception) {
console.error('Failed callback to load the content. Cause:' + JSON.stringify(exception));
expect().assertFail();
try {
expect().assertFail();
} catch (err) {
console.error('Failed callback to load the content. Cause:' + JSON.stringify(err));
}
await winData.destroyWindow();
done();
}
...
...
@@ -1867,7 +1881,7 @@ export default function Window() {
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
await wnd.setWindowBrightness(Number.MIN_VALUE).then(() => {
console.info('windowTest setWindowBrightnessTest
3 setBrightness(Number.MAX
_VALUE) success ');
console.info('windowTest setWindowBrightnessTest
4 setBrightness(Number.MIN
_VALUE) success ');
expect(TRUE_FLAG).assertTrue();
done();
}, (err) => {
...
...
@@ -2075,7 +2089,7 @@ export default function Window() {
}
done();
} else {
console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.M
AX
_VALUE) success ');
console.info('windowTest setBrightnessTest4CallBack setBrightness(Number.M
IN
_VALUE) success ');
try {
expect(TRUE_FLAG).assertTrue();
} catch (error) {
...
...
@@ -2113,7 +2127,7 @@ export default function Window() {
}
done();
} else {
console.info('windowTest setBrightnessTest5CallBack setBrightness(
Number.MAX_VALUE
) success ');
console.info('windowTest setBrightnessTest5CallBack setBrightness(
1.1
) success ');
try {
expect().assertFail();
} catch (error) {
...
...
@@ -2187,7 +2201,7 @@ export default function Window() {
console.info('windowTest testSetWindowKeepScreenOnCb001 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowKeepScreenOn(true, (err
, data
) => {
wnd.setWindowKeepScreenOn(true, (err) => {
if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
try {
...
...
@@ -2197,7 +2211,7 @@ export default function Window() {
}
done();
} else {
console.info('success set the screen to be always on.
Cause: ' + JSON.stringify(data)
);
console.info('success set the screen to be always on.
'
);
let data2 = wnd.getWindowProperties();
try {
expect(data2.isKeepScreenOn).assertTrue();
...
...
@@ -2220,7 +2234,7 @@ export default function Window() {
console.info('windowTest testSetWindowKeepScreenOnCb002 begin');
let wnd = windowStage.getMainWindowSync();
expect(wnd != null).assertTrue();
wnd.setWindowKeepScreenOn(false, (err
, data
) => {
wnd.setWindowKeepScreenOn(false, (err) => {
if (err.code) {
console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err));
try {
...
...
@@ -2230,7 +2244,7 @@ export default function Window() {
}
done();
} else {
console.info('success set the screen to be always on.
Cause: ' + JSON.stringify(data)
);
console.info('success set the screen to be always on.
'
);
let data2 = wnd.getWindowProperties();
try {
expect(!data2.isKeepScreenOn).assertTrue();
...
...
graphic/crossplatform/window/src/main/ets/test/WindowStage.test.ets
浏览文件 @
28afd11b
...
...
@@ -13,19 +13,23 @@
* limitations under the License.
*/
import
window
from
'@ohos.window'
;
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function WindowStage() {
describe("WindowStage", function () {
let windowStage;
let
abilityS
torage
;
let
s
torage;
const TRUE_FLAG = true;
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
beforeAll(async function () {
console.info("beforeAll case");
windowStage = globalThis.windowStage;
abilityStorage
=
globalThis
.
abilityStorage
;
storage = new LocalStorage();
storage.setOrCreate('storageSimpleProp', 121);
});
beforeEach(async function () {
...
...
@@ -40,16 +44,6 @@ export default function WindowStage() {
console.info("afterAll case");
});
async
function
sleep
(
time
)
{
let
timeoutId
=
null
;
let
promise
=
new
Promise
(
resolve
=>
{
timeoutId
=
setTimeout
(()
=>
{
resolve
(
'sleep finished'
);
},
time
);
})
clearTimeout
(
timeoutId
)
}
function expectedError(error, caseName, apiName, done, code) {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
...
...
@@ -66,15 +60,13 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ' + apiName + ' failed, err: ';
console.log(msgStr + JSON.stringify(error));
try {
expect
(
TRUE_FLAG
)
.
assertFail
();
expect().assertFail();
} catch (error) {
console.info(`unexpectedError catch error: ${JSON.stringify(error)}`)
}
done();
}
/**
* @tc.number : TEST_GETMAINWINDOW_PROMISE_001
* @tc.name : testGetMainWindowPromise001
...
...
@@ -109,12 +101,15 @@ export default function WindowStage() {
windowStage.getMainWindow((err, data) => {
if (err.code) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
expect
(
false
)
.
assertTrue
();
return;
}
try {
expect(!!data).assertTrue();
console.log(msgStr + 'getMainWindow success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
}
expect
(
!!
data
)
.
assertTrue
();
console
.
log
(
msgStr
+
'getMainWindow success'
);
done
();
})
})
/**
...
...
@@ -152,14 +147,14 @@ export default function WindowStage() {
let caseName = 'testCreateSubWindowPromise001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let
subWindow
=
await
windowStage
.
createSubWindow
(
'
createSubWindow
'
)
.
catch
((
err
)
=>
{
let subWindow = await windowStage.createSubWindow('
testCreateSubWindowPromise001
').catch((err) => {
unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
console.log(msgStr + 'windowStage.createSubWindow(createSubWindowTest1)=' + JSON.stringify(err));
});
expect(!!subWindow).assertTrue();
await
subWindow
.
destroy
();
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
console.log(msgStr + 'windowStage.createSubWindow end !!subWindow=' + !!subWindow);
await subWindow.destroyWindow();
done();
})
/**
...
...
@@ -180,8 +175,7 @@ export default function WindowStage() {
console.log(msgStr + 'windowStage.createSubWindow(null) err=' + JSON.stringify(err));
});
console.log(msgStr + 'windowStage.createSubWindow end subWindow=' + JSON.stringify(subWindow));
}
catch
(
err
)
{
} catch (err) {
expectedError(err, caseName, 'windowStage.createSubWindow', done, 401);
console.log(msgStr + 'windowStage.createSubWindow catch err=' + JSON.stringify(err));
}
...
...
@@ -199,70 +193,19 @@ export default function WindowStage() {
let caseName = 'testCreateSubWindowCb001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let
subWnd
=
null
function
createSubWindow
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
windowStage
.
createSubWindow
(
'createSubWindow'
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
reject
(
null
)
console
.
log
(
msgStr
+
'windowStage.createSubWindow(createSubWindowTest3) err='
+
JSON
.
stringify
(
err
));
}
else
{
resolve
(
data
)
}
})
})
}
function
findWin
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
window
.
find
(
'createSubWindow'
,
(
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
reject
(
false
)
}
else
{
resolve
(
data
)
}
})
})
}
function
destroyWin
(
win
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
win
.
destroy
((
err
,
data
)
=>
{
if
(
err
&&
err
.
code
)
{
reject
(
null
)
}
else
{
resolve
(
true
)
}
})
})
}
subWnd
=
await
createSubWindow
()
.
catch
(
err
=>
{
console
.
info
(
`window.create failed error: ${JSON.stringify(err)}`
)
expect
()
.
assertFail
();
done
();
})
expect
(
!!
subWnd
)
.
assertTrue
();
let
subWindow
;
subWindow
=
await
findWin
()
.
catch
(
err
=>
{
console
.
info
(
`window.find failed error: ${JSON.stringify(err)}`
)
expect
()
.
assertFail
();
done
();
})
await
destroyWin
(
subWindow
)
.
catch
(
err
=>
{
console
.
info
(
`window.destroy failed error: ${JSON.stringify(err)}`
)
expect
()
.
assertFail
();
done
();
})
let
subWindowLast
;
subWindowLast
=
await
findWin
()
.
catch
(
err
=>
{
console
.
info
(
`window.find failed error: ${JSON.stringify(err)}`
)
expect
(
!
err
)
.
assertTrue
();
done
()
windowStage.createSubWindow('testCreateSubWindowCb001', async (err, data) => {
if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.createSubWindow', done);
} else {
try {
expect(!!data).assertTrue();
console.log(msgStr + ' success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.getMainWindow', done);
}
}
})
})
/**
...
...
@@ -359,12 +302,17 @@ export default function WindowStage() {
let caseName = 'testLoadContentPromise001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let
load3
=
await
windowStage
.
loadContent
(
'MainAbility/pages/second/second'
)
.
catch
((
err
)
=>
{
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index1').then(async () => {
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
}).catch((err) => {
unexpectedError(err, caseName, 'windowStage loadContent', done);
console
.
log
(
msgStr
+
'windowStage loadContent MainAbility/pages/second/second'
+
JSON
.
stringify
(
err
));
});
expect
(
!
load3
)
.
assertTrue
();
console
.
log
(
msgStr
+
'tempWnd.loadContent end load='
+
JSON
.
stringify
(
load3
));
done();
})
/**
...
...
@@ -380,11 +328,11 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
try {
let
load
4
=
await
windowStage
.
loadContent
(
null
)
.
catch
((
err
)
=>
{
let load = await windowStage.loadContent(null).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'windowStage loadContent null' + JSON.stringify(err));
});
console
.
log
(
msgStr
+
'windowStage loadContent end load
5='
+
JSON
.
stringify
(
load4
));
console.log(msgStr + 'windowStage loadContent end load
=' + JSON.stringify(load
));
}
catch (err) {
console.log(msgStr + 'windowStage loadContent catch err=' + JSON.stringify(err));
...
...
@@ -395,7 +343,7 @@ export default function WindowStage() {
/**
* @tc.number : TEST_LOADCONTENT_PROMISE_003
* @tc.name : testLoadContentPromise003
* @tc.desc : Verify the scenario of loading an null page with
abilityS
torage
* @tc.desc : Verify the scenario of loading an null page with
s
torage
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -405,11 +353,11 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
try {
let
load
5
=
await
windowStage
.
loadContent
(
null
,
abilityS
torage
)
.
catch
((
err
)
=>
{
let load
= await windowStage.loadContent(null, s
torage).catch((err) => {
expect(false).assertTrue();
console.log(msgStr + 'windowStage loadContent null' + JSON.stringify(err));
});
console
.
log
(
msgStr
+
'windowStage loadContent end load
5='
+
JSON
.
stringify
(
load5
));
console.log(msgStr + 'windowStage loadContent end load
=' + JSON.stringify(load
));
}
catch (err) {
console.log(msgStr + 'windowStage loadContent catch err=' + JSON.stringify(err));
...
...
@@ -420,7 +368,7 @@ export default function WindowStage() {
/**
* @tc.number : TEST_LOADCONTENT_PROMISE_004
* @tc.name : testLoadContentPromise004
* @tc.desc : Verify the scenario of loading an page and
abilityS
torage of null
* @tc.desc : Verify the scenario of loading an page and
s
torage of null
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -429,11 +377,17 @@ export default function WindowStage() {
let caseName = 'testLoadContentPromise004';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
let
load6
=
await
windowStage
.
loadContent
(
'MainAbility/pages/second/second'
,
null
)
.
catch
((
err
)
=>
{
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index1', null).then(async () => {
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
}).catch((err) => {
unexpectedError(err, caseName, 'windowStage loadContent', done);
console
.
log
(
msgStr
+
'windowStage loadContent MainAbility/pages/second/second'
+
JSON
.
stringify
(
err
));
});
expect
(
!
load6
)
.
assertTrue
();
done();
})
...
...
@@ -449,18 +403,21 @@ export default function WindowStage() {
let caseName = 'testLoadContentCb001';
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage
.
loadContent
(
'MainAbility/pages/second/second'
,
(
err
,
data
)
=>
{
await sleep(500);
windowStage.loadContent('TestAbility/pages/Index1', async (err) => {
if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
console
.
log
(
msgStr
+
'windowStage loadContent MainAbility/pages/second/second'
+
JSON
.
stringify
(
err
));
} else {
try {
expect
(
!
data
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`windowStage.loadContent catch error: ${JSON.stringify(error)}`
)
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
}
console
.
log
(
msgStr
+
'windowStage.loadContent end data='
+
JSON
.
stringify
(
data
));
done
();
}
})
})
...
...
@@ -478,7 +435,7 @@ export default function WindowStage() {
console.log(msgStr + 'begin');
try {
windowStage
.
loadContent
(
null
,
(
err
,
data
)
=>
{
windowStage.loadContent(null, (err) => {
console.log(msgStr + 'windowStage loadContent null' + JSON.stringify(err));
try {
expect(false).assertTrue();
...
...
@@ -502,7 +459,7 @@ export default function WindowStage() {
/**
* @tc.number : TEST_LOADCONTENT_STORAGE_CB_001
* @tc.name : testLoadContentStorageCb001
* @tc.desc : Verify the scenario of loading an page and
abilityS
torage
* @tc.desc : Verify the scenario of loading an page and
s
torage
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -512,25 +469,27 @@ export default function WindowStage() {
let msgStr = 'jsunittest ' + caseName + ' ';
console.log(msgStr + 'begin');
windowStage
.
loadContent
(
'
MainAbility/pages/second/second'
,
abilityStorage
,
(
err
,
data
)
=>
{
windowStage.loadContent('
TestAbility/pages/Index1', storage, async (err
) => {
if (err && err.code) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
console
.
log
(
msgStr
+
'windowStage loadContent MainAbility/pages/second/second'
+
JSON
.
stringify
(
err
));
} else {
try {
expect
(
!
data
)
.
assertTrue
();
}
catch
(
error
)
{
console
.
info
(
`windowStage.loadContent catch error: ${JSON.stringify(error)}`
)
expect(true).assertTrue();
await sleep(500);
await windowStage.loadContent('TestAbility/pages/Index')
await sleep(500);
console.log(msgStr + 'tempWnd.loadContent success');
done();
} catch (err) {
unexpectedError(err, caseName, 'windowStage.loadContent', done);
}
done
();
console
.
log
(
msgStr
+
'windowStage.loadContent end data='
+
JSON
.
stringify
(
data
));
}
})
})
/**
* @tc.number : TEST_LOADCONTENT_STORAGE_CB_002
* @tc.name : testLoadContentStorageCb002
* @tc.desc : Verify the scenario of loading an null page with
abilityS
torage
* @tc.desc : Verify the scenario of loading an null page with
s
torage
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 2
...
...
@@ -541,7 +500,7 @@ export default function WindowStage() {
console.log(msgStr + 'begin');
try {
windowStage
.
loadContent
(
null
,
abilityStorage
,
(
err
,
data
)
=>
{
windowStage.loadContent(null,
storage, (err
) => {
console.log(msgStr + 'windowStage loadContent null ' + JSON.stringify(err));
try {
expect(false).assertTrue();
...
...
graphic/crossplatform/window/src/main/resources/base/profile/test_pages.json
浏览文件 @
28afd11b
{
"src"
:
[
"TestAbility/pages/Index"
"TestAbility/pages/Index"
,
"TestAbility/pages/Index1"
]
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录