From 03e2967162a61a736eb6bf0b4266756d48caa9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B2=B2=E8=BE=89?= Date: Fri, 30 Jun 2023 21:21:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0"=E6=BB=9A=E5=8A=A8=E7=B1=BB?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AEfling?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E7=9A=84=E5=8F=82=E6=95=B0"XTS=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李鲲辉 --- .../Grid/Grid_attribute/GridFrictionPage.ets | 61 +++++++++ .../List/List_attribute/ListFrictionPage.ets | 53 ++++++++ .../Scroll_attribute/ScrollFrictionPage.ets | 58 +++++++++ .../WaterFlowDataSource.ets | 117 ++++++++++++++++++ .../WaterFlowFrictionPage.ets | 102 +++++++++++++++ .../Grid_attribute/Grid_GridFriction.test.ets | 81 ++++++++++++ .../entry/src/main/ets/test/List.test.ets | 8 ++ .../List_attribute/List_ListFriction.test.ets | 81 ++++++++++++ .../Scroll_ScrollFriction.test.ets | 81 ++++++++++++ .../WaterFlow_WaterFlowFriction.test.ets | 81 ++++++++++++ .../resources/base/profile/main_pages.json | 6 +- 11 files changed, 728 insertions(+), 1 deletion(-) create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Grid/Grid_attribute/GridFrictionPage.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_attribute/ListFrictionPage.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Scroll/Scroll_attribute/ScrollFrictionPage.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowDataSource.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowFrictionPage.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Grid/Grid_attribute/Grid_GridFriction.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_attribute/List_ListFriction.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/Scroll/Scroll_attribute/Scroll_ScrollFriction.test.ets create mode 100644 arkui/ace_ets_layout_test/entry/src/main/ets/test/WaterFlow/WaterFlow_attribute/WaterFlow_WaterFlowFriction.test.ets diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Grid/Grid_attribute/GridFrictionPage.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Grid/Grid_attribute/GridFrictionPage.ets new file mode 100644 index 000000000..3042655e4 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Grid/Grid_attribute/GridFrictionPage.ets @@ -0,0 +1,61 @@ +import { MessageManager, Callback } from '../../../common/MessageManager'; + +@Entry +@Component +struct GridFrictionPage { + @State Number: String[] = ['0', '1', '2', '3', '4'] + scroller: Scroller = new Scroller() + @State friction:number = 1000 + + messageManager:MessageManager = new MessageManager(); + onPageShow() { + console.info('Grid_lanes page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'friction') { + this.friction = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column({ space: 5 }) { + Grid(this.scroller) { + ForEach(this.Number, (day: string) => { + ForEach(this.Number, (day: string) => { + GridItem() { + Text(day) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + }, day => day) + }, day => day) + } + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .edgeEffect(EdgeEffect.Spring) + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .onScrollBarUpdate((index: number, offset: number) => { + return {totalOffset: (index / 5) * (80 + 10) - 10 + offset, totalLength: 80 * 5 + 10 * 4} + }) + .width('90%') + .backgroundColor(0xFAEEE0) + .height(300) + .scrollBar(BarState.Off) + .onClick(() => { // 点击后滑到下一页 + this.scroller.scrollPage({ next: true }) + }) + .friction(this.friction) + .key(Grid_GridFriction) + }.width('100%').margin({ top: 5 }) + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_attribute/ListFrictionPage.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_attribute/ListFrictionPage.ets new file mode 100644 index 000000000..938f5d40f --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/List/List_attribute/ListFrictionPage.ets @@ -0,0 +1,53 @@ +import { MessageManager, Callback } from '../../../common/MessageManager'; + +@Entry +@Component +struct ListFrictionPage { + private arr: number[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + @State friction:number = 1000 + messageManager:MessageManager = new MessageManager(); + onPageShow() { + console.info('List_lanes page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'friction') { + this.friction = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Column() { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + } + }) + } + .listDirection(Axis.Vertical) // 排列方向 + .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 + .onScrollIndex((firstIndex: number, lastIndex: number) => { + console.info('first' + firstIndex) + console.info('last' + lastIndex) + }) + .width('90%') + .friction(this.friction) + .key(List_ListFriction) + } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) + .padding({ top: 5 }) + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Scroll/Scroll_attribute/ScrollFrictionPage.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Scroll/Scroll_attribute/ScrollFrictionPage.ets new file mode 100644 index 000000000..668c2a49b --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/Scroll/Scroll_attribute/ScrollFrictionPage.ets @@ -0,0 +1,58 @@ +import { MessageManager, Callback } from '../../../common/MessageManager'; + +@Entry +@Component +struct ScrollFrictionPage { + scroller: Scroller = new Scroller() + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + @State friction:number = 1000 + + messageManager:MessageManager = new MessageManager(); + onPageShow() { + console.info('Scroll_lanes page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'friction') { + this.friction = message.value; + } + } + this.messageManager.registerCallback(callback); + } + build() { + Stack({ alignContent: Alignment.TopStart }) { + Scroll(this.scroller) { + Column() { + ForEach(this.arr, (item) => { + Text(item.toString()) + .width('90%') + .height(150) + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 10 }) + }, item => item) + }.width('100%') + } + .scrollable(ScrollDirection.Vertical) // 滚动方向纵向 + .scrollBar(BarState.On) // 滚动条常驻显示 + .scrollBarColor(Color.Gray) // 滚动条颜色 + .scrollBarWidth(10) // 滚动条宽度 + .edgeEffect(EdgeEffect.None) + .onScroll((xOffset: number, yOffset: number) => { + console.info(xOffset + ' ' + yOffset) + }) + .onScrollEdge((side: Edge) => { + console.info('To the edge') + }) + .onScrollEnd(() => { + console.info('Scroll Stop') + }) + .friction(this.friction) + .key(Scroll_ScrollFriction) + }.width('100%').height('100%').backgroundColor(0xDCDCDC) + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowDataSource.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowDataSource.ets new file mode 100644 index 000000000..afc7b40e1 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowDataSource.ets @@ -0,0 +1,117 @@ +// WaterFlowDataSource.ets + +// 实现IDataSource接口的对象,用于瀑布流组件加载数据 +export class WaterFlowDataSource implements IDataSource { + + private dataArray: number[] = [] + private listeners: DataChangeListener[] = [] + + constructor() { + for (let i = 0; i < 100; i++) { + this.dataArray.push(i) + } + } + + // 获取索引对应的数据 + public getData(index: number): any { + return this.dataArray[index] + } + + // 通知控制器数据重新加载 + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded() + }) + } + + // 通知控制器数据增加 + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdded(index) + }) + } + + // 通知控制器数据变化 + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChanged(index) + }) + } + + // 通知控制器数据删除 + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDeleted(index) + }) + } + + // 通知控制器数据位置变化 + notifyDataMove(from: number, to: number): void { + this.listeners.forEach(listener => { + listener.onDataMoved(from, to) + }) + } + + // 获取数据总数 + public totalCount(): number { + return this.dataArray.length + } + + // 注册改变数据的控制器 + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + this.listeners.push(listener) + } + } + + // 注销改变数据的控制器 + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener) + if (pos >= 0) { + this.listeners.splice(pos, 1) + } + } + + // 增加数据 + public Add1stItem(): void { + this.dataArray.splice(0, 0, this.dataArray.length) + this.notifyDataAdd(0) + } + + // 在数据尾部增加一个元素 + public AddLastItem(): void { + this.dataArray.splice(this.dataArray.length, 0, this.dataArray.length) + this.notifyDataAdd(this.dataArray.length-1) + } + + // 在指定索引位置增加一个元素 + public AddItem(index: number): void { + this.dataArray.splice(index, 0, this.dataArray.length) + this.notifyDataAdd(index) + } + + // 删除第一个元素 + public Delete1stItem(): void { + this.dataArray.splice(0, 1) + this.notifyDataDelete(0) + } + + // 删除第二个元素 + public Delete2ndItem(): void { + this.dataArray.splice(1, 1) + this.notifyDataDelete(1) + } + + // 删除最后一个元素 + public DeleteLastItem(): void { + this.dataArray.splice(-1, 1) + this.notifyDataDelete(this.dataArray.length) + } + + // 重新加载数据 + public Reload(): void { + this.dataArray.splice(1, 1) + this.dataArray.splice(3, 2) + this.notifyDataReload() + } +} \ No newline at end of file diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowFrictionPage.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowFrictionPage.ets new file mode 100644 index 000000000..e9ded199e --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowFrictionPage.ets @@ -0,0 +1,102 @@ +import { MessageManager, Callback } from '../../../common/MessageManager'; +import { WaterFlowDataSource } from './WaterFlowDataSource'; + +@Entry +@Component +struct WaterFlowFrictionPage { + @State minSize: number = 50 + @State maxSize: number = 100 + @State fontSize: number = 24 + @State colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F] + scroller: Scroller = new Scroller() + datasource: WaterFlowDataSource = new WaterFlowDataSource() + private itemWidthArray: number[] = [] + private itemHeightArray: number[] = [] + + messageManager:MessageManager = new MessageManager(); + onPageShow() { + console.info('WaterFlow_lanes page show called'); + globalThis.value = { + name:'messageManager',message:this.messageManager + } + let callback:Callback = (message:any) => { + console.log('message = ' + message.name + "--" + message.value); + if (message.name == 'friction') { + this.friction = message.value; + } + } + this.messageManager.registerCallback(callback); + } + + // 计算flow item宽/高 + getSize() { + let ret = Math.floor(Math.random() * this.maxSize) + return (ret > this.minSize ? ret : this.minSize) + } + + // 保存flow item宽/高 + getItemSizeArray() { + for (let i = 0; i < 100; i++) { + this.itemWidthArray.push(this.getSize()) + this.itemHeightArray.push(this.getSize()) + } + } + + aboutToAppear() { + this.getItemSizeArray() + } + + @Builder itemFoot() { + Column() { + Text(`Footer`) + .fontSize(10) + .backgroundColor(Color.Red) + .width(50) + .height(50) + .align(Alignment.Center) + .margin({ top: 2 }) + } + } + + build() { + Column({ space: 2 }) { + WaterFlow({ footer: this.itemFoot.bind(this), scroller: this.scroller }) { + LazyForEach(this.datasource, (item: number) => { + FlowItem() { + Column() { + Text("N" + item).fontSize(12).height('16') + Image('res/waterFlowTest(' + item % 5 + ').jpg') + .objectFit(ImageFit.Fill) + .width('100%') + .layoutWeight(1) + } + } + .width('100%') + .height(this.itemHeightArray[item]) + .backgroundColor(this.colors[item % 5]) + }, item => item) + } + .columnsTemplate("1fr 1fr 1fr 1fr") + .itemConstraintSize({ + minWidth: 0, + maxWidth: '100%', + minHeight: 0, + maxHeight: '100%' + }) + .columnsGap(10) + .rowsGap(5) + .onReachStart(() => { + console.info("onReachStart") + }) + .onReachEnd(() => { + console.info("onReachEnd") + }) + .backgroundColor(0xFAEEE0) + .width('100%') + .height('80%') + .layoutDirection(FlexDirection.Column) + .friction(this.friction) + .key(WaterFlow_WaterFlowFriction) + } + } +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Grid/Grid_attribute/Grid_GridFriction.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Grid/Grid_attribute/Grid_GridFriction.test.ets new file mode 100644 index 000000000..04025ad89 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Grid/Grid_attribute/Grid_GridFriction.test.ets @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 router from '@ohos.router'; +import CommonFunc from '../../../MainAbility/common/Common'; +import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, + WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest'; +export default function Grid_GridFrictionTest() { + describe('Grid_GridFrictionTest', function () { + beforeEach(async function (done) { + console.info("Grid_GridFrictionTest beforeEach start"); + let options = { + url: 'MainAbility/pages/Grid/Grid_attribute/GridFrictionPage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get Grid_GridFrictionTest state pages:" + JSON.stringify(pages)); + if (!("Grid_GridFrictionTest" == pages.name)) { + console.info("get Grid_GridInitialIndex1 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push Grid_GridFrictionTest page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push Grid_GridFrictionTest page error:" + err); + } + console.info("Grid_GridFrictionTest beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("Grid_GridFrictionTest after each called"); + }); + /** + * @tc.number SUB_ACE_GRID_GRIDFRICTION_001 + * @tc.name testGridFriction + * @tc.desc set friction to -1 + */ + it('testGridFriction', 0, async function (done) { + console.info('[testGridFriction] START'); + globalThis.value.message.notify({name:'friction', value:-1}) + let listContainerStrJson = getInspectorByKey('Grid_GridFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('Grid'); + expect(listContainerObj.$friction).assertEqual(0.6); + console.info('[testGridFriction] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_GRID_GRIDFRICTION_002 + * @tc.name testGridFriction + * @tc.desc set friction to 100 + */ + it('testGridFriction', 0, async function (done) { + console.info('[testGridFriction] START'); + globalThis.value.message.notify({name:'friction', value:10}) + let listContainerStrJson = getInspectorByKey('Grid_GridFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('Grid'); + expect(listContainerObj.$friction).assertEqual(10); + console.info('[testGridFriction] END'); + done(); + }); + }) + + +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets index 826b6e5ef..57e66693e 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List.test.ets @@ -367,6 +367,10 @@ import Row_MarginPadding from './Row/parentComponentChanged/Row_MarginPadding.te import Row_Padding from './Row/parentComponentChanged/Row_Padding.test'; import Row_Size from './Row/parentComponentChanged/Row_Size.test'; import Row_VerticalAlign from './Row/parentComponentChanged/Row_VerticalAlign.test'; +import list_ListFrictionTest from './List/List_attribute/List_ListFriction.test'; +import grid_GridFrictionTest from './List/List_attribute/Grid_GridFriction.test'; +import waterflow_WaterFlowFrictionTest from './List/List_attribute/Waterflow_WaterFlowFriction.test'; +import scroll_ScrollFrictionTest from './List/List_attribute/Scroll_ScrollFriction.test'; import AlignContentFlex_Start from './Flex/alignContent/Start/AlignContentFlex_Start.test.ets'; import AlignContent_FlexAlign_Start_Margin from './Flex/alignContent/Start/AlignContent_FlexAlign_Start_Margin.test.ets'; @@ -759,6 +763,10 @@ RelativeContainer_AnchorPoint_Position() Row_Padding(); Row_Size(); Row_VerticalAlign(); + list_ListFrictionTest(); + grid_GridFrictionTest(); + waterflow_WaterFlowFrictionTest(); + scroll_ScrollFrictionTest(); AlignContentFlex_Start(); AlignContent_FlexAlign_Start_Margin(); AlignContent_FlexAlign_Start_Margin_padding(); diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_attribute/List_ListFriction.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_attribute/List_ListFriction.test.ets new file mode 100644 index 000000000..0f129cae8 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/List/List_attribute/List_ListFriction.test.ets @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 router from '@ohos.router'; +import CommonFunc from '../../../MainAbility/common/Common'; +import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, + WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest'; +export default function list_ListFrictionTest() { + describe('List_ListFrictionTest', function () { + beforeEach(async function (done) { + console.info("List_ListFrictionTest beforeEach start"); + let options = { + url: 'MainAbility/pages/List/List_attribute/ListFrictionPage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get List_ListFrictionTest state pages:" + JSON.stringify(pages)); + if (!("list_ListFrictionTest" == pages.name)) { + console.info("get List_ListInitialIndex1 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push List_ListFrictionTest page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push List_ListFrictionTest page error:" + err); + } + console.info("List_ListFrictionTest beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("List_ListFrictionTest after each called"); + }); + /** + * @tc.number SUB_ACE_LIST_LISTFRICTION_001 + * @tc.name testListFriction + * @tc.desc set friction to -1 + */ + it('testListFriction', 0, async function (done) { + console.info('[testListFriction] START'); + globalThis.value.message.notify({name:'friction', value:-1}) + let listContainerStrJson = getInspectorByKey('List_ListFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + expect(listContainerObj.$friction).assertEqual(0.6); + console.info('[testListFriction] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_LIST_LISTFRICTION_002 + * @tc.name testListFriction + * @tc.desc set friction to 100 + */ + it('testListFriction', 0, async function (done) { + console.info('[testListFriction] START'); + globalThis.value.message.notify({name:'friction', value:10}) + let listContainerStrJson = getInspectorByKey('List_ListFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('List'); + expect(listContainerObj.$friction).assertEqual(10); + console.info('[testListFriction] END'); + done(); + }); + }) + + +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/Scroll/Scroll_attribute/Scroll_ScrollFriction.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Scroll/Scroll_attribute/Scroll_ScrollFriction.test.ets new file mode 100644 index 000000000..439152d67 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/Scroll/Scroll_attribute/Scroll_ScrollFriction.test.ets @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 router from '@ohos.router'; +import CommonFunc from '../../../MainAbility/common/Common'; +import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, + WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest'; +export default function Scroll_ScrollFrictionTest() { + describe('Scroll_ScrollFrictionTest', function () { + beforeEach(async function (done) { + console.info("Scroll_ScrollFrictionTest beforeEach start"); + let options = { + url: 'MainAbility/pages/Scroll/Scroll_attribute/ScrollFrictionPage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get Scroll_ScrollFrictionTest state pages:" + JSON.stringify(pages)); + if (!("Scroll_ScrollFrictionTest" == pages.name)) { + console.info("get Scroll_ScrollInitialIndex1 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push Scroll_ScrollFrictionTest page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push Scroll_ScrollFrictionTest page error:" + err); + } + console.info("Scroll_ScrollFrictionTest beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("Scroll_ScrollFrictionTest after each called"); + }); + /** + * @tc.number SUB_ACE_SCROLL_SCROLLFRICTION_001 + * @tc.name testScrollFriction + * @tc.desc set friction to -1 + */ + it('testScrollFriction', 0, async function (done) { + console.info('[testScrollFriction] START'); + globalThis.value.message.notify({name:'friction', value:-1}) + let listContainerStrJson = getInspectorByKey('Scroll_ScrollFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('Scroll'); + expect(listContainerObj.$friction).assertEqual(0.6); + console.info('[testScrollFriction] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_SCROLL_SCROLLFRICTION_002 + * @tc.name testScrollFriction + * @tc.desc set friction to 100 + */ + it('testScrollFriction', 0, async function (done) { + console.info('[testScrollFriction] START'); + globalThis.value.message.notify({name:'friction', value:10}) + let listContainerStrJson = getInspectorByKey('Scroll_ScrollFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('Scroll'); + expect(listContainerObj.$friction).assertEqual(10); + console.info('[testScrollFriction] END'); + done(); + }); + }) + + +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/ets/test/WaterFlow/WaterFlow_attribute/WaterFlow_WaterFlowFriction.test.ets b/arkui/ace_ets_layout_test/entry/src/main/ets/test/WaterFlow/WaterFlow_attribute/WaterFlow_WaterFlowFriction.test.ets new file mode 100644 index 000000000..34c44c131 --- /dev/null +++ b/arkui/ace_ets_layout_test/entry/src/main/ets/test/WaterFlow/WaterFlow_attribute/WaterFlow_WaterFlowFriction.test.ets @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2023 iSoftStone Information Technology (Group) 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 router from '@ohos.router'; +import CommonFunc from '../../../MainAbility/common/Common'; +import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, + WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest'; +export default function Waterflow_WaterflowFrictionTest() { + describe('Waterflow_WaterflowFrictionTest', function () { + beforeEach(async function (done) { + console.info("Waterflow_WaterflowFrictionTest beforeEach start"); + let options = { + url: 'MainAbility/pages/Waterflow/Waterflow_attribute/WaterflowFrictionPage', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get Waterflow_WaterflowFrictionTest state pages:" + JSON.stringify(pages)); + if (!("Waterflow_WaterflowFrictionTest" == pages.name)) { + console.info("get Waterflow_WaterflowInitialIndex1 pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await CommonFunc.sleep(2000); + console.info("push Waterflow_WaterflowFrictionTest page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push Waterflow_WaterflowFrictionTest page error:" + err); + } + console.info("Waterflow_WaterflowFrictionTest beforeEach end"); + done(); + }); + afterEach(async function () { + await CommonFunc.sleep(1000); + console.info("Waterflow_WaterflowFrictionTest after each called"); + }); + /** + * @tc.number SUB_ACE_WATERFLOW_WATERFLOWFRICTION_001 + * @tc.name testWaterflowFriction + * @tc.desc set friction to -1 + */ + it('testWaterflowFriction', 0, async function (done) { + console.info('[testWaterflowFriction] START'); + globalThis.value.message.notify({name:'friction', value:-1}) + let listContainerStrJson = getInspectorByKey('Waterflow_WaterflowFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('Waterflow'); + expect(listContainerObj.$friction).assertEqual(0.6); + console.info('[testWaterflowFriction] END'); + done(); + }); + + /** + * @tc.number SUB_ACE_WATERFLOW_WATERFLOWFRICTION_002 + * @tc.name testWaterflowFriction + * @tc.desc set friction to 100 + */ + it('testWaterflowFriction', 0, async function (done) { + console.info('[testWaterflowFriction] START'); + globalThis.value.message.notify({name:'friction', value:10}) + let listContainerStrJson = getInspectorByKey('Waterflow_WaterflowFriction'); + let listContainerObj = JSON.parse(listContainerStrJson); + expect(listContainerObj.$type).assertEqual('Waterflow'); + expect(listContainerObj.$friction).assertEqual(10); + console.info('[testWaterflowFriction] END'); + done(); + }); + }) + + +} diff --git a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json index f7dfab2aa..cc17c41a0 100644 --- a/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json +++ b/arkui/ace_ets_layout_test/entry/src/main/resources/base/profile/main_pages.json @@ -249,6 +249,7 @@ "MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemRowStartEnd", "MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemVisibility", "MainAbility/pages/Grid/GridTemplatesAllSet/GridTemplateChange/Grid_RowCol_TemplateChange", + "MainAbility/pages/List/List_attribute/ListFrictionPage", "MainAbility/pages/List/List_initialIndex/List_ListInitialIndex1", "MainAbility/pages/List/List_initialIndex/List_ListInitialIndex2", "MainAbility/pages/List/List_initialIndex/List_ListInitialIndex3", @@ -397,6 +398,7 @@ "MainAbility/pages/Grid/Grid_Row/onBreakpointChange/onBreakpointChange", "MainAbility/pages/Grid/Grid_Row/Grid_Row_Direction/Grid_Row_Direction_Row", "MainAbility/pages/Grid/Grid_Row/Grid_Row_Direction/Grid_Row_Direction_RowReverse", + "MainAbility/pages/Grid/Grid_attribute/GridFrictionPage", "MainAbility/pages/Tabs/tabs_index/Tabs_index", "MainAbility/pages/Tabs/Tabs_ItemsChange/Tabs_itemPadMar", "MainAbility/pages/Tabs/Tabs_ItemsChange/Tabs_itemSize", @@ -405,6 +407,8 @@ "MainAbility/pages/Tabs/Tabs_ParmsChange/Tabs_barWidHei", "MainAbility/pages/Tabs/Tabs_ParmsChange/Tabs_PadMar", "MainAbility/pages/Tabs/Tabs_ParmsChange/Tabs_scrollable", - "MainAbility/pages/Tabs/Tabs_ParmsChange/Tabs_WidHei" + "MainAbility/pages/Tabs/Tabs_ParmsChange/Tabs_WidHei", + "MainAbility/pages/Scroll/Scroll_attribute/ScrollFrictionPage", + "MainAbility/pages/WaterFlow/WaterFlow_attribute/WaterFlowFrictionPage" ] } \ No newline at end of file -- GitLab