updated tests

This commit is contained in:
pkurchatov
2022-09-28 09:22:37 +03:00
parent bc9544436f
commit d72fa48d49
8 changed files with 71 additions and 132 deletions
@@ -7,9 +7,15 @@ extension Array where Element == Div {
mappedBy modificator: (Div, Block) throws -> T
) throws -> [T] {
try iterativeFlatMap { div, index in
let divContext = modified(context) { $0.parentPath += index }
let block = try? div.value.makeBlock(context: divContext)
return try block.map { try modificator(div, $0) }
let itemContext = modified(context) { $0.parentPath += index }
let block: Block
do {
block = try div.value.makeBlock(context: itemContext)
} catch {
DivKitLogger.error("Failed to create block: \(error)")
return nil
}
return try modificator(div, block)
}
}
@@ -1,5 +1,6 @@
import Foundation
import BaseUI
import DivKit
import LayoutKit
@@ -8,19 +9,10 @@ struct DemoDivCustomBlockFactory: DivCustomBlockFactory {
data: DivCustomData,
context _: DivBlockModelingContext
) -> Block {
let name = data.name
switch name {
case "generic":
let view = TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "Generic")
).makeBlockView()
return GenericViewBlock(view: view, height: 100)
default:
return TextBlock(
widthTrait: .resizable,
text: NSAttributedString(string: "DivCustom(custom_id = \(name))")
)
}
TextBlock(
widthTrait: .intrinsic,
text: NSAttributedString(string: "DivCustom(custom_type = \(data.name))")
.with(typo: Typo(size: 16, weight: .regular))
)
}
}
@@ -277,61 +277,6 @@
"text": "Title",
"width": {
"type": "wrap_content"
},
"tooltips": [
{
"id": "tooltip",
"position": "bottom",
"duration": 0,
"offset": {
"x": {
"value": 0
},
"y": {
"value": 4
}
},
"div": {
"type": "text",
"width": {
"type": "wrap_content"
},
"paddings": {
"left": 16,
"top": 16,
"right": 16,
"bottom": 16
},
"background": [
{
"type": "solid",
"color": "#3498DB"
}
],
"border": {
"corner_radius": 6
},
"text_color": "#2C3E50",
"text": "Title tooltip",
"action": {
"log_id": "hide_tooltip",
"url": "div-action://hide_tooltip?id=tooltip"
},
"visibility_actions": [
{
"log_id": "item_log_id",
"url": "div-action://hide_tooltip?id=tooltip",
"log_limit": 0,
"visibility_duration": 5000,
"visibility_percentage": 100
}
]
}
}
],
"action": {
"log_id": "show_tooltip",
"url": "div-action://show_tooltip?id=tooltip"
}
},
{
@@ -187,7 +187,7 @@
{
"log_id": "show_unmute_notification",
"url": "div-action://set_state?state_id=0/mute/unmute_notification",
"visibility_duration": 4000,
"visibility_duration": 2000,
"visibility_percentage": 1
}
]
@@ -240,7 +240,7 @@
"log_id": "hide_unmute_notification",
"url": "div-action://set_state?state_id=0/mute/muted",
"log_limit": 0,
"visibility_duration": 4000,
"visibility_duration": 2000,
"visibility_percentage": 1
}
],
@@ -6,12 +6,6 @@
"state_id": 0,
"div": {
"type": "container",
"width": {
"type": "match_parent"
},
"height": {
"type": "wrap_content"
},
"margins": {
"left": 16,
"top": 16,
@@ -22,45 +16,21 @@
{
"type": "custom",
"id": "old_custom_card_1",
"width": {
"type": "wrap_content"
},
"height": {
"type": "wrap_content"
},
"custom_type": "old_custom_card_1"
},
{
"type": "custom",
"id": "old_custom_card_2",
"width": {
"type": "wrap_content"
},
"height": {
"type": "wrap_content"
},
"custom_type": "old_custom_card_2"
},
{
"type": "custom",
"id": "new_custom_card_1",
"width": {
"type": "wrap_content"
},
"height": {
"type": "wrap_content"
},
"custom_type": "new_custom_card_1"
},
{
"type": "custom",
"id": "new_custom_card_2",
"width": {
"type": "wrap_content"
},
"height": {
"type": "wrap_content"
},
"custom_type": "new_custom_card_2"
}
]
@@ -20,12 +20,6 @@
"state_id": 0,
"div": {
"type": "container",
"width": {
"type": "match_parent"
},
"height": {
"type": "wrap_content"
},
"margins": {
"left": 16,
"top": 16,
@@ -36,12 +30,6 @@
{
"type": "custom",
"id": "new_custom_container_1",
"width": {
"type": "wrap_content"
},
"height": {
"type": "wrap_content"
},
"items": [
{
"type": "news_item_template",
+51 -16
View File
@@ -296,6 +296,9 @@
},
{
"title": "Focus",
"platforms": [
"android"
],
"steps": [
"Switch focus"
],
@@ -306,6 +309,9 @@
},
{
"title": "Focus events",
"platforms": [
"android"
],
"steps": [
"Switch focus to handler",
"Switch focus to idle"
@@ -448,6 +454,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Fade full",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -462,6 +471,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Fade part",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -476,6 +488,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Scale full",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -490,6 +505,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Scale part",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -504,6 +522,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Slide full",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -518,6 +539,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Slide part",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -532,6 +556,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Set",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -546,6 +573,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Diff ids",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -560,6 +590,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Diff sizes",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -574,6 +607,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Diff types",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -588,6 +624,9 @@
},
{
"title": "Synchronizing multiple change bounds animations. Change bounds same ids",
"platforms": [
"android"
],
"tags": [
"Animations"
],
@@ -643,19 +682,6 @@
],
"file": "animations/blink.json"
},
{
"title": "Example of tooltip animation",
"tags": [
"Animations"
],
"steps": [
"A few seconds after the card is shown, a tooltip should appear"
],
"expected_results": [
"Toolip hides a few seconds later"
],
"file": "animations/mute_notification.json"
},
{
"title": "Scale transition ignore pivot_x/pivot_y",
"tags": [
@@ -675,9 +701,10 @@
"Animations"
],
"steps": [
"Click on notificattion"
"Click on tooltip"
],
"expected_results": [
"A few seconds after the card is shown, a tooltip should appear",
"The text should disappear first, and the background after a short delay"
],
"file": "animations/mute_notification.json"
@@ -883,11 +910,10 @@
"Visibility_actions"
],
"steps": [
"Click on items",
"Click EXPAND",
"Check logs"
],
"expected_results": [
"Card article.json is opened",
"Elements are expanded",
"Visibility actions logged, example logViewShown(cardId = ..., id = separator) logViewShown(cardId = ..., id = text) logViewShown(cardId = ..., id = text2) logViewShown(cardId = ..., id = comment_state) logViewShown(cardId = ..., id = comment_01) logViewShown(cardId = ..., id = comment_02) logViewShown(cardId = ..., id = comment_03) logViewShown(cardId = ..., id = comment_04)"
],
@@ -1026,6 +1052,9 @@
},
{
"title": "Animations of switching tabs headers",
"platforms": [
"android"
],
"tags": [
"DivTabs",
"Animations"
@@ -1106,6 +1135,9 @@
},
{
"title": "Manage VideoCustom",
"platforms": [
"android"
],
"tags": [
"VideoCustom"
],
@@ -1135,6 +1167,9 @@
},
{
"title": "Data transition trigger",
"platforms": [
"android"
],
"steps": [
"Press 'Change data'"
],
@@ -16,6 +16,9 @@
{
"type": "image",
"image_url": "https://yastatic.net/s3/home/yandex-app/div_demo/containers.png",
"aspect": {
"ratio": 1
},
"extensions": [
{
"id": "pinch-to-zoom"