From d72fa48d494fdeaae6cd031f815fcfdf75d1fc6d Mon Sep 17 00:00:00 2001 From: pkurchatov Date: Wed, 28 Sep 2022 09:22:37 +0300 Subject: [PATCH] updated tests --- .../DivKit/Extensions/ArrayExtensions.swift | 12 +++- .../DivKit/DemoDivCustomBlockFactory.swift | 20 ++---- .../action_visibility/article.json | 55 --------------- .../animations/mute_notification.json | 4 +- .../regression_test_data/custom-card.json | 30 --------- .../custom-container.json | 12 ---- test_data/regression_test_data/index.json | 67 ++++++++++++++----- .../pinch-to-zoom-longtap-actions.json | 3 + 8 files changed, 71 insertions(+), 132 deletions(-) diff --git a/client/ios/DivKit/Extensions/ArrayExtensions.swift b/client/ios/DivKit/Extensions/ArrayExtensions.swift index caa5fa7f2..6f3d9466c 100644 --- a/client/ios/DivKit/Extensions/ArrayExtensions.swift +++ b/client/ios/DivKit/Extensions/ArrayExtensions.swift @@ -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) } } diff --git a/client/ios/DivKitPlayground/DivKit/DemoDivCustomBlockFactory.swift b/client/ios/DivKitPlayground/DivKit/DemoDivCustomBlockFactory.swift index c348ff596..9e214ff4e 100644 --- a/client/ios/DivKitPlayground/DivKit/DemoDivCustomBlockFactory.swift +++ b/client/ios/DivKitPlayground/DivKit/DemoDivCustomBlockFactory.swift @@ -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)) + ) } } diff --git a/test_data/regression_test_data/action_visibility/article.json b/test_data/regression_test_data/action_visibility/article.json index 9bda301fe..4eb205d39 100644 --- a/test_data/regression_test_data/action_visibility/article.json +++ b/test_data/regression_test_data/action_visibility/article.json @@ -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" } }, { diff --git a/test_data/regression_test_data/animations/mute_notification.json b/test_data/regression_test_data/animations/mute_notification.json index c0996b3e3..7863c1d25 100644 --- a/test_data/regression_test_data/animations/mute_notification.json +++ b/test_data/regression_test_data/animations/mute_notification.json @@ -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 } ], diff --git a/test_data/regression_test_data/custom-card.json b/test_data/regression_test_data/custom-card.json index 8bff5bcec..e6341eafa 100644 --- a/test_data/regression_test_data/custom-card.json +++ b/test_data/regression_test_data/custom-card.json @@ -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" } ] diff --git a/test_data/regression_test_data/custom-container.json b/test_data/regression_test_data/custom-container.json index 6b41eebb3..6ff43abb9 100644 --- a/test_data/regression_test_data/custom-container.json +++ b/test_data/regression_test_data/custom-container.json @@ -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", diff --git a/test_data/regression_test_data/index.json b/test_data/regression_test_data/index.json index 2ed95be42..766b8656a 100644 --- a/test_data/regression_test_data/index.json +++ b/test_data/regression_test_data/index.json @@ -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'" ], diff --git a/test_data/regression_test_data/pinch-to-zoom-longtap-actions.json b/test_data/regression_test_data/pinch-to-zoom-longtap-actions.json index 6c35f2478..d486547e3 100644 --- a/test_data/regression_test_data/pinch-to-zoom-longtap-actions.json +++ b/test_data/regression_test_data/pinch-to-zoom-longtap-actions.json @@ -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"