Skip to content

Commit

Permalink
test: 更新 rust 测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanzebin committed Jun 16, 2024
1 parent 0b3736d commit 9742737
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ export default struct TARO_TEMPLATES_f0t0 {
.onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
(this.node0.childNodes[0] as TaroElement)._nodeInfo.areaInfo = res[1]
}))
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement)) }
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement) } )
Column() {}
.attributeModifier(columnModify.setNode(this.node0.childNodes[1] as TaroElement))
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[1] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[1] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
.onAreaChange(getComponentEventCallback(this.node0.childNodes[1] as TaroElement, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
(this.node0.childNodes[1] as TaroElement)._nodeInfo.areaInfo = res[1]
}))
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[1] as TaroElement)) }
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[1] as TaroElement) } )
Column() {}
.attributeModifier(columnModify.setNode(this.node1 as TaroElement))
.onVisibleAreaChange(getNodeThresholds(this.node1 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node1 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
.onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
(this.node1 as TaroElement)._nodeInfo.areaInfo = res[1]
}))
.onClick(e => { eventHandler(e, 'click', this.node1 as TaroElement)) }
.onClick(e => { eventHandler(e, 'click', this.node1 as TaroElement) } )
Column() {}
.attributeModifier(columnModify.setNode(this.node2 as TaroElement))
.onVisibleAreaChange(getNodeThresholds(this.node2 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node2 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
Expand All @@ -104,15 +104,15 @@ export default struct TARO_TEMPLATES_f0t0 {
bottomLeft: (this.node0.childNodes[4] as TaroElement)._st.hmStyle.borderBottomLeftRadius,
bottomRight: (this.node0.childNodes[4] as TaroElement)._st.hmStyle.borderBottomRightRadius
})
.onComplete(e => { eventHandler(e, 'complete', this.node0.childNodes[4] as TaroElement)) }
.onComplete(e => { eventHandler(e, 'complete', this.node0.childNodes[4] as TaroElement) } )
Column() {}
.attributeModifier(columnModify.setNode(this.node0.childNodes[5] as TaroElement))
.onVisibleAreaChange(getNodeThresholds(this.node0.childNodes[5] as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0.childNodes[5] as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
.onAreaChange(getComponentEventCallback(this.node0.childNodes[5] as TaroElement, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
(this.node0.childNodes[5] as TaroElement)._nodeInfo.areaInfo = res[1]
}))
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[5] as TaroElement)) }
.onTouch(e => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node0.childNodes[5] as TaroElement)) }
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[5] as TaroElement) } )
.onTouch(e => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node0.childNodes[5] as TaroElement) } )
}
.attributeModifier(columnModify.setNode(this.node0 as TaroElement))
.onVisibleAreaChange(getNodeThresholds(this.node0 as TaroElement) || [0.0, 1.0], getComponentEventCallback(this.node0 as TaroElement, VISIBLE_CHANGE_EVENT_NAME))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default struct TARO_TEMPLATES_f0t0 {
.onAreaChange(getComponentEventCallback(this.node1 as TaroElement, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
(this.node1 as TaroElement)._nodeInfo.areaInfo = res[1]
}))
.onClick(e => { eventHandler(e, 'click', this.node1 as TaroElement)) }
.onClick(e => { eventHandler(e, 'click', this.node1 as TaroElement) } )
}
}
.attributeModifier(columnModify.setNode(this.node0 as TaroElement))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function createText (node: TaroTextElement) {
if (node.childNodes.length > 1 || ((node.childNodes[0] && node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
ForEach(node.childNodes, (item: TaroElement) => {
createTextChildNode(item)
}, (item: TaroElement) => item._nid)
}, (item: TaroElement) => item._nid.toString())
}
}
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', node) }, node, ['click']))
Expand All @@ -198,42 +198,23 @@ function createText (node: TaroTextElement) {
}
}
function getImageSpanAlignment (align: TaroAny): TaroAny {
if (align === Alignment.Top) {
return ImageSpanAlignment.TOP
} else if (align === Alignment.Bottom) {
return ImageSpanAlignment.BOTTOM
} else if (align === Alignment.Center) {
return ImageSpanAlignment.CENTER
}
}
@Builder
function createTextChildNode (item: TaroElement) {
if (item.tagName === 'IMAGE') {
ImageSpan(item.getAttribute('src'))
// .attributeModifier(commonStyleModify.setNode(item))
.attributeModifier(commonStyleModify.setNode(item))
.objectFit(getImageMode(item.getAttribute('mode')))
// .verticalAlign(align)
.width(item._st.hmStyle.width)
.height(item._st.hmStyle.height)
.margin({
top: item._st.hmStyle.marginTop,
left: item._st.hmStyle.marginLeft,
right: item._st.hmStyle.marginRight,
bottom: item._st.hmStyle.marginBottom,
})
.padding({
top: item._st.hmStyle.paddingTop,
left: item._st.hmStyle.paddingLeft,
right: item._st.hmStyle.paddingRight,
bottom: item._st.hmStyle.paddingBottom,
})
.textBackgroundStyle({
color: item._st.hmStyle.backgroundColor,
radius: {
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius,
}
})
.borderRadius({
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius
})
.verticalAlign(getImageSpanAlignment(item?.hmStyle?.verticalAlign))
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
} else if (item.nodeType === NodeType.TEXT_NODE) {
Span(item.textContent)
Expand Down Expand Up @@ -284,7 +265,7 @@ function getButtonFontSize (node: TaroButtonElement): string | number {
function getTextInViewWidth (node: TaroElement | null): TaroAny {
if (node) {
const hmStyle = node.hmStyle || {}
const hmStyle: TaroAny = node.hmStyle || {}
const isFlexView = hmStyle.display === 'flex'
const width: TaroAny = getStyleAttr(node, 'width')
const isPercentWidth = isString(width) && width.includes('%')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function createText (node: TaroTextElement) {
if (node.childNodes.length > 1 || ((node.childNodes[0] && node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
ForEach(node.childNodes, (item: TaroElement) => {
createTextChildNode(item)
}, (item: TaroElement) => item._nid)
}, (item: TaroElement) => item._nid.toString())
}
}
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', node) }, node, ['click']))
Expand All @@ -141,42 +141,23 @@ function createText (node: TaroTextElement) {
}
}
function getImageSpanAlignment (align: TaroAny): TaroAny {
if (align === Alignment.Top) {
return ImageSpanAlignment.TOP
} else if (align === Alignment.Bottom) {
return ImageSpanAlignment.BOTTOM
} else if (align === Alignment.Center) {
return ImageSpanAlignment.CENTER
}
}
@Builder
function createTextChildNode (item: TaroElement) {
if (item.tagName === 'IMAGE') {
ImageSpan(item.getAttribute('src'))
// .attributeModifier(commonStyleModify.setNode(item))
.attributeModifier(commonStyleModify.setNode(item))
.objectFit(getImageMode(item.getAttribute('mode')))
// .verticalAlign(align)
.width(item._st.hmStyle.width)
.height(item._st.hmStyle.height)
.margin({
top: item._st.hmStyle.marginTop,
left: item._st.hmStyle.marginLeft,
right: item._st.hmStyle.marginRight,
bottom: item._st.hmStyle.marginBottom,
})
.padding({
top: item._st.hmStyle.paddingTop,
left: item._st.hmStyle.paddingLeft,
right: item._st.hmStyle.paddingRight,
bottom: item._st.hmStyle.paddingBottom,
})
.textBackgroundStyle({
color: item._st.hmStyle.backgroundColor,
radius: {
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius,
}
})
.borderRadius({
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius
})
.verticalAlign(getImageSpanAlignment(item?.hmStyle?.verticalAlign))
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
} else if (item.nodeType === NodeType.TEXT_NODE) {
Span(item.textContent)
Expand Down Expand Up @@ -227,7 +208,7 @@ function getButtonFontSize (node: TaroButtonElement): string | number {
function getTextInViewWidth (node: TaroElement | null): TaroAny {
if (node) {
const hmStyle = node.hmStyle || {}
const hmStyle: TaroAny = node.hmStyle || {}
const isFlexView = hmStyle.display === 'flex'
const width: TaroAny = getStyleAttr(node, 'width')
const isPercentWidth = isString(width) && width.includes('%')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function createText (node: TaroTextElement) {
if (node.childNodes.length > 1 || ((node.childNodes[0] && node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
ForEach(node.childNodes, (item: TaroElement) => {
createTextChildNode(item)
}, (item: TaroElement) => item._nid)
}, (item: TaroElement) => item._nid.toString())
}
}
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', node) }, node, ['click']))
Expand All @@ -149,42 +149,23 @@ function createText (node: TaroTextElement) {
}
}
function getImageSpanAlignment (align: TaroAny): TaroAny {
if (align === Alignment.Top) {
return ImageSpanAlignment.TOP
} else if (align === Alignment.Bottom) {
return ImageSpanAlignment.BOTTOM
} else if (align === Alignment.Center) {
return ImageSpanAlignment.CENTER
}
}
@Builder
function createTextChildNode (item: TaroElement) {
if (item.tagName === 'IMAGE') {
ImageSpan(item.getAttribute('src'))
// .attributeModifier(commonStyleModify.setNode(item))
.attributeModifier(commonStyleModify.setNode(item))
.objectFit(getImageMode(item.getAttribute('mode')))
// .verticalAlign(align)
.width(item._st.hmStyle.width)
.height(item._st.hmStyle.height)
.margin({
top: item._st.hmStyle.marginTop,
left: item._st.hmStyle.marginLeft,
right: item._st.hmStyle.marginRight,
bottom: item._st.hmStyle.marginBottom,
})
.padding({
top: item._st.hmStyle.paddingTop,
left: item._st.hmStyle.paddingLeft,
right: item._st.hmStyle.paddingRight,
bottom: item._st.hmStyle.paddingBottom,
})
.textBackgroundStyle({
color: item._st.hmStyle.backgroundColor,
radius: {
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius,
}
})
.borderRadius({
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius
})
.verticalAlign(getImageSpanAlignment(item?.hmStyle?.verticalAlign))
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
} else if (item.nodeType === NodeType.TEXT_NODE) {
Span(item.textContent)
Expand Down Expand Up @@ -235,7 +216,7 @@ function getButtonFontSize (node: TaroButtonElement): string | number {
function getTextInViewWidth (node: TaroElement | null): TaroAny {
if (node) {
const hmStyle = node.hmStyle || {}
const hmStyle: TaroAny = node.hmStyle || {}
const isFlexView = hmStyle.display === 'flex'
const width: TaroAny = getStyleAttr(node, 'width')
const isPercentWidth = isString(width) && width.includes('%')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default struct TARO_TEMPLATES_f0t0 {
.onAreaChange(getComponentEventCallback(this.node0.childNodes[0] as TaroElement, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
(this.node0.childNodes[0] as TaroElement)._nodeInfo.areaInfo = res[1]
}))
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement)) }
.onClick(e => { eventHandler(e, 'click', this.node0.childNodes[0] as TaroElement) } )
}
Column() {
createText(this.node1.childNodes[0] as TaroTextElement)
Expand Down Expand Up @@ -176,7 +176,7 @@ function createText (node: TaroTextElement) {
if (node.childNodes.length > 1 || ((node.childNodes[0] && node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
ForEach(node.childNodes, (item: TaroElement) => {
createTextChildNode(item)
}, (item: TaroElement) => item._nid)
}, (item: TaroElement) => item._nid.toString())
}
}
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', node) }, node, ['click']))
Expand All @@ -188,42 +188,23 @@ function createText (node: TaroTextElement) {
}
}
function getImageSpanAlignment (align: TaroAny): TaroAny {
if (align === Alignment.Top) {
return ImageSpanAlignment.TOP
} else if (align === Alignment.Bottom) {
return ImageSpanAlignment.BOTTOM
} else if (align === Alignment.Center) {
return ImageSpanAlignment.CENTER
}
}
@Builder
function createTextChildNode (item: TaroElement) {
if (item.tagName === 'IMAGE') {
ImageSpan(item.getAttribute('src'))
// .attributeModifier(commonStyleModify.setNode(item))
.attributeModifier(commonStyleModify.setNode(item))
.objectFit(getImageMode(item.getAttribute('mode')))
// .verticalAlign(align)
.width(item._st.hmStyle.width)
.height(item._st.hmStyle.height)
.margin({
top: item._st.hmStyle.marginTop,
left: item._st.hmStyle.marginLeft,
right: item._st.hmStyle.marginRight,
bottom: item._st.hmStyle.marginBottom,
})
.padding({
top: item._st.hmStyle.paddingTop,
left: item._st.hmStyle.paddingLeft,
right: item._st.hmStyle.paddingRight,
bottom: item._st.hmStyle.paddingBottom,
})
.textBackgroundStyle({
color: item._st.hmStyle.backgroundColor,
radius: {
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius,
}
})
.borderRadius({
topLeft: item._st.hmStyle.borderTopLeftRadius,
topRight: item._st.hmStyle.borderTopRightRadius,
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
bottomRight: item._st.hmStyle.borderBottomRightRadius
})
.verticalAlign(getImageSpanAlignment(item?.hmStyle?.verticalAlign))
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
} else if (item.nodeType === NodeType.TEXT_NODE) {
Span(item.textContent)
Expand Down Expand Up @@ -274,7 +255,7 @@ function getButtonFontSize (node: TaroButtonElement): string | number {
function getTextInViewWidth (node: TaroElement | null): TaroAny {
if (node) {
const hmStyle = node.hmStyle || {}
const hmStyle: TaroAny = node.hmStyle || {}
const isFlexView = hmStyle.display === 'flex'
const width: TaroAny = getStyleAttr(node, 'width')
const isPercentWidth = isString(width) && width.includes('%')
Expand Down
Loading

0 comments on commit 9742737

Please sign in to comment.