/*
* Copyright (c) 2025 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 { beforeAll, describe, expect, it, Level, TestType, Size } from '@ohos/hypium';
import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit';
import { UIAbility, Want } from '@kit.AbilityKit';
import router from '@ohos.router';
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
let driver: Driver;
let want: Want;
export default function StackLayout() {
describe('StackLayout', () => {
beforeAll(async () => {
want = {
bundleName: bundleName,
abilityName: 'EntryAbility'
};
await delegator.startAbility(want);
driver = Driver.create();
await driver.delayMs(1000);
const ability: UIAbility = await delegator.getCurrentTopAbility();
console.info('get top ability');
expect(ability.context.abilityInfo.name).assertEqual('EntryAbility');
});
/*
* @tc.number : StackLayoutExample_001
* @tc.name : testStackLayoutExample
* @tc.desc : 测试StackLayout布局
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testStackLayoutExample', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1,
async (done: Function) => {
let driver = Driver.create();
await driver.delayMs(1000);
await router.pushUrl({ url: 'pages/stacklayout/StackLayoutExample' })
await driver.delayMs(2000);
await driver.pressBack();
await driver.delayMs(1000);
done();
});
/*
* @tc.number : StackLayoutAlignContent_002
* @tc.name : testStackLayoutAlignContent
* @tc.desc : 测试StackLayout布局,对齐方式
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testStackLayoutAlignContent', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1,
async (done: Function) => {
let driver = Driver.create();
await driver.delayMs(1000);
await router.pushUrl({ url: 'pages/stacklayout/StackLayoutAlignContent' })
await driver.delayMs(2000);
await driver.pressBack();
await driver.delayMs(1000);
done();
});
/*
* @tc.number : StackLayoutNozIndex_003
* @tc.name : testStackLayoutNozIndex
* @tc.desc : 测试StackLayout布局,Z序控制
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testStackLayoutNozIndex', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1,
async (done: Function) => {
let driver = Driver.create();
await driver.delayMs(1000);
await router.pushUrl({ url: 'pages/stacklayout/StackLayoutNozIndex' })
await driver.delayMs(2000);
await driver.pressBack();
await driver.delayMs(1000);
done();
});
/*
* @tc.number : StackLayoutzIndex_004
* @tc.name : testStackLayoutzIndex
* @tc.desc : 测试StackLayout布局,Z序控制
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testStackLayoutzIndex', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1,
async (done: Function) => {
let driver = Driver.create();
await driver.delayMs(1000);
await router.pushUrl({ url: 'pages/stacklayout/StackLayoutzIndex' })
await driver.delayMs(2000);
await driver.pressBack();
await driver.delayMs(1000);
done();
});
/*
* @tc.number : StackLayoutSceneExample_005
* @tc.name : testStackLayoutSceneExample
* @tc.desc : 测试StackLayout布局
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 1
*/
it('testStackLayoutSceneExample', TestType.FUNCTION | Size.MEDIUMTEST | Level.LEVEL1,
async (done: Function) => {
let driver = Driver.create();
await driver.delayMs(1000);
await router.pushUrl({ url: 'pages/stacklayout/StackLayoutSceneExample' })
await driver.delayMs(2000);
await driver.pressBack();
await driver.delayMs(1000);
done();
});
});
}