diff --git a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/gridScrollBar.ets b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/gridScrollBar.ets new file mode 100644 index 0000000000000000000000000000000000000000..3bbdcea14417a9900f002e5618909cf01349611a --- /dev/null +++ b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/TestAbility/pages/gridScrollBar.ets @@ -0,0 +1,57 @@ +/* + * 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 gridScrollBar { + @State Number: String[] = ['0', '1', '2', '3', '4'] + + + build() { + Column({ space: 5 }) { + + Grid() { + 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) + } + .key('Grid_scrollbarUpdate_0800') + .columnsTemplate('1fr 1fr 1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .onScrollIndex((first: number) => { + console.info(first.toString()) + }) + .onScrollBarUpdate((index:number,offset:number)=> { + return ({totalOffset:10, totalLength:200}) + }) + .width('90%') + .backgroundColor(0xFAEEE0) + .height(300) + + }.width('100%').margin({ top: 5 }) + + } + } \ No newline at end of file diff --git a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/List.test.ets b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/List.test.ets index 9e542546eaa461e7314ae9c53ab53d0e800ddf2a..492b87a2a4ab990cc9574dccafe70430bbaa51c7 100644 --- a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/List.test.ets +++ b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/List.test.ets @@ -31,6 +31,7 @@ import imageObscuredTest from './imageObscuredTest.test'; import stageAnimatorTest from './stageAnimator.test'; import navigationTypeTest from './navigationType.test'; import textSpanFontTest from './textSpanFont.test'; +import gridScrollbarUpdateTest from './gridScrollbarUpdate.test'; export default function testsuite() { stageFontTest() @@ -51,4 +52,5 @@ export default function testsuite() { stageAnimatorTest() navigationTypeTest() textSpanFontTest() + gridScrollbarUpdateTest() } \ No newline at end of file diff --git a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/gridScrollbarUpdate.test.ets b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/gridScrollbarUpdate.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..93ea3c526c8ecf3b12fda94a486833d52263bc28 --- /dev/null +++ b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/ets/test/gridScrollbarUpdate.test.ets @@ -0,0 +1,97 @@ +/* + * 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. + */ +import hilog from '@ohos.hilog'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' +import router from '@system.router'; + +export default function gridScrollbarUpdateTest() { + describe('gridScrollbarUpdateTest', function () { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(async function (done) { + console.info("flex beforeEach start"); + let options = { + uri: 'TestAbility/pages/gridScrollBar', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get gridScrollBar state success " + JSON.stringify(pages)); + if (!("gridScrollBar" == pages.name)) { + console.info("get gridScrollBar state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + console.info("push gridScrollBar page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push gridScrollBar page error: " + err); + } + done() + }); + afterEach(function () { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + + it('Grid_scrollbarUpdate_0801', 0, async function (done) { + console.info('Grid_scrollbarUpdate_0801 START'); + setTimeout(()=>{ + try{ + let strJson = getInspectorByKey('Grid_scrollbarUpdate_0800'); + console.info('Grid_scrollbarUpdate_0801 START :'+ JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info("Grid_scrollbarUpdate_0801 obj is: " + JSON.stringify(obj)); + let width = obj.$attrs.width + let height = obj.$attrs.height + expect(width).assertEqual("90.00%"); + expect(height).assertEqual("300.00vp"); + console.info('Grid_scrollbarUpdate_0801 END '); + } catch(err) { + expect().assertFail() + console.info('Grid_scrollbarUpdate_0801 ERR '+ JSON.stringify(err)); + } + done(); + },500) + }) + + it('Grid_scrollbarUpdate_0802', 0, async function (done) { + console.info('Grid_scrollbarUpdate_0802 START'); + setTimeout(()=>{ + try{ + let strJson = getInspectorByKey('Grid_scrollbarUpdate_0800'); + console.info('Grid_scrollbarUpdate_0802 START :'+ JSON.stringify(strJson)); + let obj = JSON.parse(strJson); + console.info("Grid_scrollbarUpdate_0802 obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual("Grid"); + console.info('Grid_scrollbarUpdate_0802 END '); + + } catch(err) { + expect().assertFail() + console.info('Grid_scrollbarUpdate_0802 ERR '+ JSON.stringify(err)); + } + done(); + },500) + }) + + + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/resources/base/profile/test_pages.json b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/resources/base/profile/test_pages.json index 118f911461cf99bb5d0a7ea8d2433de689f81947..83e0abd91a40c45251699ec82c124c468e54c354 100644 --- a/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/resources/base/profile/test_pages.json +++ b/arkui/ace_ets_component_completion/ace_ets_component_wholeCompletion/src/main/resources/base/profile/test_pages.json @@ -19,6 +19,7 @@ "TestAbility/pages/imageObscuredTest", "TestAbility/pages/stageAnimator", "TestAbility/pages/navigationType", - "TestAbility/pages/textSpanFont" + "TestAbility/pages/textSpanFont", + "TestAbility/pages/gridScrollBar" ] } \ No newline at end of file