提交 545733a4 编写于 作者: B bayanxing

ets用例补齐 代码提交

Signed-off-by: Nbayanxing <bayanxing@kaihong.com>
上级 ef0ebff8
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="826b3f1a-35ec-44f5-a0fa-738bb4ba4c7b" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/inspector.ets" afterDir="false" />
<change afterPath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/lazyForEach.ets" afterDir="false" />
<change afterPath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/test/inspector.test.ets" afterDir="false" />
<change afterPath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/test/lazyForEach.test.ets" afterDir="false" />
<change beforePath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/test/List.test.ets" beforeDir="false" afterPath="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/test/List.test.ets" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="monthly_20220816" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="2DnUukPXey3C1GO4vnHmus2YbmX" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="Git.Branch.Popup.ShowAllRemotes" value="true" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Administrator\Desktop\xts824\xts_acts_0824\arkui\ace_ets_component_apilack\entry\src\main\ets\MainAbility\pages" />
<recent name="C:\Users\Administrator\Desktop\xts824\xts_acts_0824\arkui\ace_ets_component_apilack\entry\src\main\ets\test" />
<recent name="C:\Users\Administrator\Desktop\xts824\xts_acts_0824\arkui" />
<recent name="C:\Users\Administrator\Desktop\xts824\xts_acts_0824\arkui\ace_js_attribute_api\src\main\js\MainAbility\common\images" />
<recent name="C:\Users\Administrator\Desktop\xts824\xts_acts_0824\arkui\ace_js_attribute_api\src\main\js\MainAbility\pages" />
</key>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State>
<option name="FILTERS">
<map>
<entry key="branch">
<value>
<list>
<option value="master" />
</list>
</value>
</entry>
</map>
</option>
</State>
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
</component>
</project>
\ No newline at end of file
...@@ -75,7 +75,13 @@ ...@@ -75,7 +75,13 @@
"pages/alphabetIndexer", "pages/alphabetIndexer",
"pages/checkBoxGroup", "pages/checkBoxGroup",
"pages/circle", "pages/circle",
"pages/ellipse" "pages/ellipse",
"pages/grid",
"pages/gridItem",
"pages/inspector",
"pages/lazyForEach",
"pages/path",
"pages/polygon"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
......
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct GridMaxCount {
@State Number: String[] = ['5', '6', '7', '8', '9']
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear GridMaxCount start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear GridMaxCount end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("grid-MaxCount")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("maxCountText")
Column({ space: 5 }) {
Grid() {
ForEach(this.Number, (day: string) => {
ForEach(this.Number, (day: string) => {
GridItem() {
Text(day)
.fontSize(16)
.backgroundColor(0xF9CF93)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
}
}, day => day)
}, day => day)
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.width('90%')
.backgroundColor(0xFAEEE0)
.height(300)
.maxCount(5)
.key("maxCountTest")
}
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
import events_emitter from '@ohos.events.emitter';
@Entry
@Component
export default
struct GridItemOnSelect {
@State Number: String[] = ['5', '6', '7', '8', '9']
@State isSelect: boolean = false;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear GridItemOnSelect start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear GridItemOnSelect end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("gridItem-OnSelect")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("onSelectText")
Column({ space: 5 }) {
Grid() {
ForEach(this.Number, (day: string) => {
ForEach(this.Number, (day: string) => {
GridItem() {
Text(day)
.fontSize(16)
.backgroundColor(0xF9CF93)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
.key("onSelected")
}.onSelect((isSelect)=>{
console.info("Select:" + isSelect)
//this.showToast("onSelect() " + index)
this.isSelect = true;
try {
var backData = {
data: {
"STATUS": this.isSelect
}
}
let backEvent = {
eventId: 10200,
priority: events_emitter.EventPriority.LOW
}
console.info("onSelect start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onSelect emit action state err: " + JSON.stringify(err))
}
})
}, day => day)
}, day => day)
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.width('90%')
.backgroundColor(0xFAEEE0)
.height(300)
}
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
import events_emitter from '@ohos.events.emitter';
@Entry
@Component
export default
struct Inspector {
@State message: string = 'test'
@State setColor:string = '#F9CF93'
@State catchStatus:string = "success"
onPageShow() {
console.info('[inspector] page show called');
var stateChangeEvent = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
private stateChangCallBack = (eventData) => {
console.info("[inspector] page stateChangCallBack");
if (eventData != null) {
console.info("[inspector] page state change called:" + JSON.stringify(eventData));
if (eventData.data.setColor != null) {
this.setColor = eventData.data.setColor;
}
}
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("inspector")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
Row() {
Column() {
Text(this.message)
.key("inspectorApiOne")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
let getInspectorNodesObj = JSON.stringify(getInspectorNodes())
try {
var backData = {
data: {
"getInspectorNodes": getInspectorNodesObj,
"result":"success"
}
}
let backEvent = {
eventId: 101,
priority: events_emitter.EventPriority.LOW
}
console.info("inspector_101 onClick start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("inspector_101 onClick emit action state err: " + JSON.stringify(err.message))
}
})
Text("inspectorApiTwo")
.key("inspectorApiTwo")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
let getInspectorNodeByIdObj = JSON.stringify(getInspectorNodeById(1))
try {
var backData1 = {
data: {
"result": "success",
"getInspectorNodeById":getInspectorNodeByIdObj
}
}
let backEvent1 = {
eventId: 102,
priority: events_emitter.EventPriority.LOW
}
console.info("inspector_102 onClick start to emit action state")
events_emitter.emit(backEvent1, backData1)
} catch (err) {
console.info("inspector_102 onClick emit action state err: " + JSON.stringify(err.message))
}
})
Text("inspectorApiThree")
.key("inspectorApiThree")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
setAppBgColor('#F9CF93');
})
Text("inspectorApiFour")
.key("inspectorApiFour")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
try{
Profiler.registerVsyncCallback((info: string) => {
console.info("VsyncCallback" + info)
});
Profiler.unregisterVsyncCallback();
this.catchStatus = "callBackSuccess"
}catch(err){
console.info("inspector_103 onClick err: " + JSON.stringify(err.message))
this.catchStatus = "callBackFail"
}
try {
var backData2 = {
data: {
"catchStatus": this.catchStatus,
}
}
let backEvent2 = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
console.info("inspector_103 onClick start to emit action state")
events_emitter.emit(backEvent2, backData2)
} catch (err) {
console.info("inspector_103 onClick emit action state err: " + JSON.stringify(err.message))
}
})
}
.width('100%')
}
.height('100%')
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
var indexOne:number = 1;
var indexTwo:number = 2;
class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = []
public totalCount(): number {
return 0
}
public getData(index: number): any {
return undefined
}
registerDataChangeListener(listener: DataChangeListener): void {
if (this.listeners.indexOf(listener) < 0) {
console.info('add listener')
this.listeners.push(listener)
}
}
unregisterDataChangeListener(listener: DataChangeListener): void {
const pos = this.listeners.indexOf(listener);
if (pos >= 0) {
console.info('remove listener')
this.listeners.splice(pos, 1)
}
}
notifyDataReload(): void {
this.listeners.forEach(listener => {
listener.onDataReloaded()
})
}
notifyDataAdd(index: number): void {
this.listeners.forEach(listener => {
listener.onDataAdd(index)
})
}
notifyDataChange(index: number): void {
this.listeners.forEach(listener => {
listener.onDataChange(index)
})
}
notifyDataDelete(index: number): void {
this.listeners.forEach(listener => {
listener.onDataDelete(index)
})
}
notifyDataMove(from: number, to: number): void {
this.listeners.forEach(listener => {
listener.onDataMove(from, to)
})
}
}
class MyDataSource extends BasicDataSource {
private dataArray: string[] = ['/path/image0', '/path/image1', '/path/image2', '/path/image3']
public totalCount(): number {
return this.dataArray.length
}
public getData(index: number): any {
return this.dataArray[index]
}
public addData(index: number, data: string): void {
this.dataArray.splice(index, 0, data)
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after adding: '+ this.dataArray[i])
}
this.notifyDataAdd(index)
this.notifyDataChange(index)
}
public pushData(data: string): void {
this.dataArray.push(data)
this.notifyDataAdd(this.dataArray.length - 1)
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after adding: '+ this.dataArray[i])
}
}
public moveData(index1:number,index2:number):void{
indexOne = index1
indexTwo = index2
if(index1 < index2){
var temp = this.dataArray[index1]
for(var i = index1; i < index2 ;i++){
this.dataArray[i] = this.dataArray[i+1]
}
this.dataArray[index2] = temp
for(var j = 0 ; j < this.dataArray.length ; j++){
console.info('after moving :' + this.dataArray[j])
}
}
else if (index1 > index2){
var temp = this.dataArray[index1]
for(var i = index1 ; i > index2; i--){
this.dataArray[i] = this.dataArray[i-1]
}
this.dataArray[index2] = temp
for(var j = 0 ; j < this.dataArray.length ; j++){
console.info('after moving :' + this.dataArray[j])
}
}
this.notifyDataMove(index1,index2)
}
public popData(): void {
this.dataArray.pop()
this.notifyDataDelete(this.dataArray.length)
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after deleting: '+ this.dataArray[i])
}
}
public changeData(index: number): void {
this.dataArray[index] = 'apple'
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after changing: '+ this.dataArray[i])
}
this.notifyDataChange(index)
}
}
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct LazyForEachOnDataAdd {
private data: MyDataSource = new MyDataSource()
private scroller: Scroller = new Scroller()
@State index1:number = 1
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear LazyForEachOnDataAdd start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear LazyForEachOnDataAdd end`)
}
build() {
Column() {
Stack({ alignContent: Alignment.End }) {
Scroll(this.scroller) {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Start,
justifyContent: FlexAlign.SpaceBetween
}) {
Text("lazyForEach-OnDataAdd")
.width(300)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("onDataAddText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemOne")
.onClick(() => {
this.data.pushData('/path/image' + this.data.totalCount())
console.info("this.data.totalCount() is :" + this.data.totalCount() )
})
}, item => item)
}
Text("lazyForEach-OnDataMove")
.width(300)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("onDataMoveText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemTwo")
.onClick(() => {
this.data.moveData(3, 1)
})
}, item => item)
}
Text("lazyForEach-OnDataDelete")
.width(300)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("onDataDeleteText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemThree")
.onClick(() => {
this.data.popData()
})
}, item => item)
}
Text("lazyForEach-OnDataChange")
.width(300)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("onDataChangeText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemFour")
.onClick(() => {
this.data.changeData(2)
})
}, item => item)
}
}.width("100%").height("100%")
}
}
}
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct PathNew {
private path: any = new Path({
width: 100,
height: 100,
commands: 'M150 0 L300 300 L0 300 Z'
})
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear PathNew start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear PathNew end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("path-New")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("neText")
Path().width(100).height(100).commands('M150 0 L300 300 L0 300 Z')
.key("Path")
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct PolygonNe {
private polygon: PolygonAttribute = new Polygon({
width: 100,
height: 100
})
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear PolygonNe start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear PolygonNe end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("polygon-Ne")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("neText")
Polygon({ width: 100, height: 100 }).points([[0, 0], [50, 100], [100, 0]])
.key("Polygon")
}.width("100%").height("100%")
}
}
...@@ -17,10 +17,22 @@ import alphabetIndexerOnSelectJsunit from './alphabetIndexer.test.ets'; ...@@ -17,10 +17,22 @@ import alphabetIndexerOnSelectJsunit from './alphabetIndexer.test.ets';
import checkBoxGroupSelectAllJsunit from './checkBoxGroup.test.ets'; import checkBoxGroupSelectAllJsunit from './checkBoxGroup.test.ets';
import circleNewJsunit from './circle.test.ets'; import circleNewJsunit from './circle.test.ets';
import ellipseNeJsunit from './ellipse.test.ets'; import ellipseNeJsunit from './ellipse.test.ets';
import gridMaxCountJsunit from './grid.test.ets';
import gridItemOnSelectJsunit from './gridItem.test.ets';
import inspectorJsunit from './inspector.test.ets'
import lazyForEachOnDataAddJsunit from './lazyForEach.test.ets';
import pathNewTest from './path.test.ets';
import polygonNewJsunit from './polygon.test.ets';
export default function testsuite() { export default function testsuite() {
alphabetIndexerOnSelectJsunit() alphabetIndexerOnSelectJsunit()
checkBoxGroupSelectAllJsunit() checkBoxGroupSelectAllJsunit()
circleNewJsunit() circleNewJsunit()
ellipseNeJsunit() ellipseNeJsunit()
gridMaxCountJsunit()
gridItemOnSelectJsunit()
inspectorJsunit()
lazyForEachOnDataAddJsunit()
pathNewTest()
polygonNewJsunit()
} }
\ No newline at end of file
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 router from '@system.router';
import events_emitter from '@ohos.events.emitter';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function gridMaxCountJsunit() {
describe('gridMaxCountTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/grid',
}
try {
router.clear();
let pages = router.getState();
console.info("get grid state success " + JSON.stringify(pages));
if (!("grid" == pages.name)) {
console.info("get grid state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push grid page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push grid page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("gridMaxCount after each called");
});
it('testcheckgridMaxCount0001', 0, async function (done) {
console.info('testcheckgridMaxCount testcheckgridMaxCount0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('maxCountTest');
console.info("[testcheckgridMaxCount0001] component selectedMaxcount strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Grid');
expect(obj.$attrs.maxCount).assertEqual("5");
console.info("[testcheckgridMaxCount0001] selectedMaxCount value :" + obj.$attrs.maxCount);
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
import events_emitter from '@ohos.events.emitter';
export default function gridItemOnSelectJsunit() {
describe('gridItemOnSelectTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/gridItem',
}
try {
router.clear();
let pages = router.getState();
console.info("get gridItem state success " + JSON.stringify(pages));
if (!("gridItem" == pages.name)) {
console.info("get gridItem state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push gridItem page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push gridItem page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("gridItemOnSelect after each called");
});
it('testgridItemOnSelect0001', 0, async function (done) {
console.info('testgridItemOnSelect testgridItemOnSelect0001 START');
await Utils.sleep(2000);
let callback = (indexEvent) => {
console.info("onSelect_0001 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertEqual(true);
done();
}
let indexEvent = {
eventId: 10200,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('onSelected', 10, "")
try {
events_emitter.on(indexEvent, callback);
} catch (err) {
console.info("onSelect_0001 on events_emitter err : " + JSON.stringify(err));
}
console.info('testgridItemOnSelect0001 END');
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 router from '@system.router';
import events_emitter from '@ohos.events.emitter';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function inspectorJsunit() {
describe('inspectorTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/inspector',
}
try {
router.clear();
let pages = router.getState();
console.info("get inspector state success " + JSON.stringify(pages));
if (!("inspector" == pages.name)) {
console.info("get inspector state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push inspector page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push inspector page error: " + err);
}
done()
});
afterEach(async function () {
console.info("inspectorTest after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testlazyForEachOnDataAdd0001
* @tc.desic acelazyForEachOnDataAddEtsTest0001
*/
it('testInspectorTestAdd0001', 0, async function (done) {
console.info('Inspector testInspectorTestAdd0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('inspectorApiOne');
console.info("[testInspectorTestAdd0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.fontSize).assertEqual("50.00fp");
console.info("[testInspectorTestAdd0001] fontSize value :" + obj.$attrs.fontSize);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testInspectorTestAdd0002
* @tc.desic aceTestInspectorTestAdd0002
*/
it('testInspectorTestAdd0002', 0, async function (done) {
console.info('Inspector testInspectorTestAdd0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('inspectorApiOne');
console.info("[testInspectorTestAdd0002] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.fontWeight).assertEqual("FontWeight.Bold");
console.info("[testInspectorTestAdd0002] fontWeight value :" + obj.$attrs.fontWeight);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testInspectorTestAdd0003
* @tc.desic aceTestInspectorTestAdd0003
*/
it('testInspectorTestAdd0003', 0, async function (done) {
console.info("testInspectorTestAdd0003 start test");
var innerEvent1 = {
eventId: 101,
priority: events_emitter.EventPriority.LOW
}
var callback1 = (eventData) => {
console.info("eventData.data.getInspectorNodes result is: " + eventData.data.getInspectorNodes);
try{
console.info("callback1 success" );
console.info("inspector_101 eventData.data.result result is: " + eventData.data.result);
expect(eventData.data.result).assertEqual("success");
console.info("inspector_101 end: ");
if(eventData.data.getInspectorNodes != null){
console.info("eventData.data.result result is: " + eventData.data.result);
expect(eventData.data.result).assertEqual("success");
}
}catch(err){
console.info("inspector_101 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try {
events_emitter.on(innerEvent1, callback1);
console.info("inspector_101 click result is: " + JSON.stringify(sendEventByKey('inspectorApiOne', 10, "")));
} catch (err) {
console.info("inspector_101 on events_emitter err : " + JSON.stringify(err));
}
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testInspectorTestAdd0004
* @tc.desic aceTestInspectorTestAdd0004
*/
it('testInspectorTestAdd0004', 0, async function (done) {
var innerEvent2 = {
eventId: 102,
priority: events_emitter.EventPriority.LOW
}
var callback2 = (eventData) => {
console.info("eventData.data.getInspectorNodeById result is: " + eventData.data.getInspectorNodeById);
try{
console.info("callback2 success" );
console.info("inspector_102 eventData.data.result result is: " + eventData.data.result);
expect(eventData.data.result).assertEqual("success");
console.info("inspector_102 end");
}catch(err){
console.info("inspector_102 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("inspector_102 click result is: " + JSON.stringify(sendEventByKey('inspectorApiTwo', 10, "")));
events_emitter.on(innerEvent2, callback2);
}catch(err){
console.info("inspector_102 on events_emitter err : " + JSON.stringify(err));
}
});
it('testInspectorTestAdd0005', 0, async function (done) {
console.info('testInspectorTestAdd0005 START');
try {
var eventData = {
data: {
"setColor": 'red'
}
}
var innerEvent = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[testInspectorTestAdd0005] change component data error: " + err.message);
}
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testInspectorTestAdd0004
* @tc.desic aceTestInspectorTestAdd0004
*/
it('testInspectorTestAdd0006', 0, async function (done) {
var innerEvent3 = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
var callback3 = (eventData) => {
try{
console.info("callback2 success" );
console.info("inspector_103 eventData.data.result result is: " + eventData.data.catchStatus);
expect(eventData.data.catchStatus).assertEqual("callBackSuccess");
console.info("inspector_103 end");
}catch(err){
console.info("inspector_103 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("inspector_103 click result is: " + JSON.stringify(sendEventByKey('inspectorApiFour', 10, "")));
events_emitter.on(innerEvent3, callback3);
}catch(err){
console.info("inspector_103 on events_emitter err : " + JSON.stringify(err));
}
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function lazyForEachOnDataAddJsunit() {
describe('lazyForEachOnDataAddTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/lazyForEach',
}
try {
router.clear();
let pages = router.getState();
console.info("get lazyForEach state success " + JSON.stringify(pages));
if (!("lazyForEach" == pages.name)) {
console.info("get lazyForEach state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push lazyForEach page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push lazyForEach page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("lazyForEachOnDataAdd after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testlazyForEachOnDataAdd0001
* @tc.desic acelazyForEachOnDataAddEtsTest0001
*/
it('testlazyForEachOnDataAdd0001', 0, async function (done) {
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('onDataAddText');
console.info("[testlazyForEachOnDataAdd0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.width).assertEqual("300.00vp");
console.info("[testlazyForEachOnDataAdd0001] width value :" + obj.$attrs.width);
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function pathNewTest() {
describe('pathNewTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/path',
}
try {
router.clear();
let pages = router.getState();
console.info("get path state success " + JSON.stringify(pages));
if (!("path" == pages.name)) {
console.info("get path state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push path page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push path page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("pathNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testpathNe0001
* @tc.desic acepathNeEtsTest0001
*/
it('testpathNe0001', 0, async function (done) {
console.info('pathNe testpathNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Path');
console.info("[testpathNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("150.00px");
console.info("[testpathNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testpathNe0002
* @tc.desic acepathNeEtsTest0002
*/
it('testpathNe0002', 0, async function (done) {
console.info('pathNe testpathNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Path');
console.info("[testpathNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("150.00px");
console.info("[testpathNe0002] height value :" + obj.$attrs.height);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testpathNe0003
* @tc.desic acepathNeEtsTest0003
*/
it('testpathNe0003', 0, async function (done) {
console.info('pathNe testpathNe0003 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Path');
console.info("[testpathNe0003] component fontSize strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.commands).assertEqual("M150 0 L300 300 L0 300 Z");
console.info("[testpathNe0003] commands value :" + obj.$attrs.commands);
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function polygonNewJsunit() {
describe('polygonNewJsunit', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/polygon',
}
try {
router.clear();
let pages = router.getState();
console.info("get polygon state success " + JSON.stringify(pages));
if (!("polygon" == pages.name)) {
console.info("get polygon state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push polygon page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push polygon page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("polygonNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testpolygonNe0001
* @tc.desic acepolygonNeEtsTest0001
*/
it('testpolygonNe0001', 0, async function (done) {
console.info('polygonNe testpolygonNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Polygon');
console.info("[testpolygonNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("150.00px");
console.info("[testpolygonNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testpolygonNe0002
* @tc.desic acepolygonNeEtsTest0002
*/
it('testpolygonNe0002', 0, async function (done) {
console.info('polygonNe testpolygonNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Polygon');
console.info("[testpolygonNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("150.00px");
console.info("[testpolygonNe0002] height value :" + obj.$attrs.height);
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册