From 415202ec7cd04d0b01cf8bbf3b103fadb84de3ea Mon Sep 17 00:00:00 2001 From: denlvovich Date: Fri, 22 Nov 2024 10:22:37 +0300 Subject: [PATCH] iOS XCUI tests commit_hash:5aeac8bafb97ad362d28ead2e85b4a64de0452f7 --- .mapping.json | 5 +- client/ios/DivKit.xcodeproj/project.pbxproj | 226 +++++++++++++++++- .../xcschemes/DivKitPlayground.xcscheme | 11 + client/ios/DivKit/Views/DivView.swift | 11 +- .../UI/DivView/DivViewController.swift | 8 + .../ios/DivKitUITests/AppLaunchUITests.swift | 22 ++ .../ios/DivKitUITests/TooltipsUITests.swift | 103 ++++++++ test_data/regression_test_data/index.json | 24 +- .../tooltips/tooltip-positions.json | 219 +++++++++++++++++ .../{ => tooltips}/tooltips.json | 0 10 files changed, 621 insertions(+), 8 deletions(-) create mode 100644 client/ios/DivKitUITests/AppLaunchUITests.swift create mode 100644 client/ios/DivKitUITests/TooltipsUITests.swift create mode 100644 test_data/regression_test_data/tooltips/tooltip-positions.json rename test_data/regression_test_data/{ => tooltips}/tooltips.json (100%) diff --git a/.mapping.json b/.mapping.json index 312b3472a..e4af0b396 100644 --- a/.mapping.json +++ b/.mapping.json @@ -12309,6 +12309,8 @@ "client/ios/DivKitTests/Variables/DivVariableTrackerTests.swift":"divkit/public/client/ios/DivKitTests/Variables/DivVariableTrackerTests.swift", "client/ios/DivKitTests/Variables/DivVariablesStorageTests.swift":"divkit/public/client/ios/DivKitTests/Variables/DivVariablesStorageTests.swift", "client/ios/DivKitTests/ViewSizeTests.swift":"divkit/public/client/ios/DivKitTests/ViewSizeTests.swift", + "client/ios/DivKitUITests/AppLaunchUITests.swift":"divkit/public/client/ios/DivKitUITests/AppLaunchUITests.swift", + "client/ios/DivKitUITests/TooltipsUITests.swift":"divkit/public/client/ios/DivKitUITests/TooltipsUITests.swift", "client/ios/LayoutKit/Interface/ActionsAttribute.swift":"divkit/public/client/ios/LayoutKit/Interface/ActionsAttribute.swift", "client/ios/LayoutKit/Interface/CommonHandler.swift":"divkit/public/client/ios/LayoutKit/Interface/CommonHandler.swift", "client/ios/LayoutKit/Interface/Menu.swift":"divkit/public/client/ios/LayoutKit/Interface/Menu.swift", @@ -18249,7 +18251,8 @@ "test_data/regression_test_data/timers/countdown-timer.json":"divkit/public/test_data/regression_test_data/timers/countdown-timer.json", "test_data/regression_test_data/timers/endless-timer.json":"divkit/public/test_data/regression_test_data/timers/endless-timer.json", "test_data/regression_test_data/timers/typed-common-timer.json":"divkit/public/test_data/regression_test_data/timers/typed-common-timer.json", - "test_data/regression_test_data/tooltips.json":"divkit/public/test_data/regression_test_data/tooltips.json", + "test_data/regression_test_data/tooltips/tooltip-positions.json":"divkit/public/test_data/regression_test_data/tooltips/tooltip-positions.json", + "test_data/regression_test_data/tooltips/tooltips.json":"divkit/public/test_data/regression_test_data/tooltips/tooltips.json", "test_data/regression_test_data/typed-tooltips.json":"divkit/public/test_data/regression_test_data/typed-tooltips.json", "test_data/regression_test_data/typed_stored_value.json":"divkit/public/test_data/regression_test_data/typed_stored_value.json", "test_data/regression_test_data/variables/div_gallery.json":"divkit/public/test_data/regression_test_data/variables/div_gallery.json", diff --git a/client/ios/DivKit.xcodeproj/project.pbxproj b/client/ios/DivKit.xcodeproj/project.pbxproj index 081d94bed..7e563cae9 100644 --- a/client/ios/DivKit.xcodeproj/project.pbxproj +++ b/client/ios/DivKit.xcodeproj/project.pbxproj @@ -274,6 +274,8 @@ 8CF8BBEA2B32682700569777 /* DivBuilders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CF8BBE92B32682700569777 /* DivBuilders.swift */; }; 8CFD4C9E2B2C5B780092814C /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CFD4C9D2B2C5B780092814C /* Theme.swift */; }; 982A7F142C9C08F30081DE74 /* PagerViewLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982A7F132C9C08F30081DE74 /* PagerViewLayoutTests.swift */; }; + 986F579A2CD68E8400990A2A /* TooltipsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F57992CD68E8400990A2A /* TooltipsUITests.swift */; }; + 986F579C2CD68E8400990A2A /* AppLaunchUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F579B2CD68E8400990A2A /* AppLaunchUITests.swift */; }; 98AF8DD62CC97CF600DE1B58 /* BlockTooltipTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 98AF8DD52CC97CF600DE1B58 /* BlockTooltipTests.swift */; }; 98C920F42C8F46EE00B2FFD8 /* LookinServer in Frameworks */ = {isa = PBXBuildFile; productRef = 98C920F32C8F46EE00B2FFD8 /* LookinServer */; }; 9D09984F2CA30D010098098C /* AccessoryViewProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D09984E2CA30D010098098C /* AccessoryViewProvider.swift */; }; @@ -301,6 +303,13 @@ remoteGlobalIDString = 8C9284F6288ADEEA00BEA1FA; remoteInfo = SnapshotTestsHostApp; }; + 986F579D2CD68E8400990A2A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 8C9844F32864C2CC001ED5F3 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 8C4409EC2864C4D200EF4175; + remoteInfo = DivKitPlayground; + }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -568,6 +577,9 @@ 8CF8BBE92B32682700569777 /* DivBuilders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DivBuilders.swift; sourceTree = ""; }; 8CFD4C9D2B2C5B780092814C /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; 982A7F132C9C08F30081DE74 /* PagerViewLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PagerViewLayoutTests.swift; sourceTree = ""; }; + 986F57972CD68E8400990A2A /* DivKitUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DivKitUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 986F57992CD68E8400990A2A /* TooltipsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipsUITests.swift; sourceTree = ""; }; + 986F579B2CD68E8400990A2A /* AppLaunchUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLaunchUITests.swift; sourceTree = ""; }; 98AF8DD52CC97CF600DE1B58 /* BlockTooltipTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockTooltipTests.swift; sourceTree = ""; }; 9D09984E2CA30D010098098C /* AccessoryViewProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessoryViewProvider.swift; sourceTree = ""; }; 9D5BFB082CA1DA20005F8EB1 /* CustomFunctionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomFunctionTests.swift; sourceTree = ""; }; @@ -657,6 +669,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 986F57942CD68E8400990A2A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -864,6 +883,7 @@ 8C6E40B128AAA47B0038E107 /* LayoutKitSnapshotTests.xctest */, 52DED04729F7346900D64519 /* DivKitExtensionsTests.xctest */, 7E2DFA8F2C7C7ED40095775C /* LayoutKitPlayground.framework */, + 986F57972CD68E8400990A2A /* DivKitUITests.xctest */, ); name = Products; sourceTree = ""; @@ -1184,6 +1204,7 @@ 8C6E40B228AAA47B0038E107 /* LayoutKitSnapshotTests */, 8CF329252875D534003F799A /* LayoutKitTests */, 8C9284F8288ADEEA00BEA1FA /* SnapshotTestsHostApp */, + 986F57982CD68E8400990A2A /* DivKitUITests */, 8C7B1B112865BF4C0036EF4C /* Frameworks */, 8C6DEA3D2866120A009956A1 /* Packages */, 8C4409D22864C3A900EF4175 /* Products */, @@ -1300,6 +1321,15 @@ path = Utils; sourceTree = ""; }; + 986F57982CD68E8400990A2A /* DivKitUITests */ = { + isa = PBXGroup; + children = ( + 986F57992CD68E8400990A2A /* TooltipsUITests.swift */, + 986F579B2CD68E8400990A2A /* AppLaunchUITests.swift */, + ); + path = DivKitUITests; + sourceTree = ""; + }; E986A85A293DE77000D19572 /* Timers */ = { isa = PBXGroup; children = ( @@ -1505,6 +1535,24 @@ productReference = 8CF329242875D534003F799A /* LayoutKitTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 986F57962CD68E8400990A2A /* DivKitUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 986F57A12CD68E8400990A2A /* Build configuration list for PBXNativeTarget "DivKitUITests" */; + buildPhases = ( + 986F57932CD68E8400990A2A /* Sources */, + 986F57942CD68E8400990A2A /* Frameworks */, + 986F57952CD68E8400990A2A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 986F579E2CD68E8400990A2A /* PBXTargetDependency */, + ); + name = DivKitUITests; + productName = "DivKit PlaygroundUITests"; + productReference = 986F57972CD68E8400990A2A /* DivKitUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -1512,7 +1560,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1410; + LastSwiftUpdateCheck = 1540; LastUpgradeCheck = 1400; TargetAttributes = { 52DED04629F7346900D64519 = { @@ -1545,6 +1593,10 @@ 8CF329232875D534003F799A = { CreatedOnToolsVersion = 13.2.1; }; + 986F57962CD68E8400990A2A = { + CreatedOnToolsVersion = 15.4; + TestTargetID = 8C4409EC2864C4D200EF4175; + }; }; }; buildConfigurationList = 8C9844F62864C2CC001ED5F3 /* Build configuration list for PBXProject "DivKit" */; @@ -1575,6 +1627,7 @@ 8CF329232875D534003F799A /* LayoutKitTests */, 8C9284F6288ADEEA00BEA1FA /* SnapshotTestsHostApp */, 7E2DFA8E2C7C7ED40095775C /* LayoutKitPlayground */, + 986F57962CD68E8400990A2A /* DivKitUITests */, ); }; /* End PBXProject section */ @@ -1658,6 +1711,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 986F57952CD68E8400990A2A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -1974,6 +2034,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 986F57932CD68E8400990A2A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 986F579C2CD68E8400990A2A /* AppLaunchUITests.swift in Sources */, + 986F579A2CD68E8400990A2A /* TooltipsUITests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -2047,6 +2116,11 @@ isa = PBXTargetDependency; productRef = 8CF3296D2875D645003F799A /* LayoutKit */; }; + 986F579E2CD68E8400990A2A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 8C4409EC2864C4D200EF4175 /* DivKitPlayground */; + targetProxy = 986F579D2CD68E8400990A2A /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -2507,6 +2581,147 @@ }; name = Release; }; + 986F579F2CD68E8400990A2A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = Y6G74A59K6; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "ru.ya.lottie-test.DivKit-PlaygroundUITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = DivKitPlayground; + }; + name = Debug; + }; + 986F57A02CD68E8400990A2A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = Y6G74A59K6; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 17.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MARKETING_VERSION = 1.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = "ru.ya.lottie-test.DivKit-PlaygroundUITests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_TARGET_NAME = DivKitPlayground; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -2591,6 +2806,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 986F57A12CD68E8400990A2A /* Build configuration list for PBXNativeTarget "DivKitUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 986F579F2CD68E8400990A2A /* Debug */, + 986F57A02CD68E8400990A2A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ diff --git a/client/ios/DivKit.xcodeproj/xcshareddata/xcschemes/DivKitPlayground.xcscheme b/client/ios/DivKit.xcodeproj/xcshareddata/xcschemes/DivKitPlayground.xcscheme index 91254b13b..13779a99f 100644 --- a/client/ios/DivKit.xcodeproj/xcshareddata/xcschemes/DivKitPlayground.xcscheme +++ b/client/ios/DivKit.xcodeproj/xcshareddata/xcschemes/DivKitPlayground.xcscheme @@ -28,6 +28,17 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + () + private let identifier: String = "baseDivView" + init( jsonPublisher: JsonPublisher, divKitComponents: DivKitComponents, @@ -52,6 +54,8 @@ open class DivViewController: UIViewController { $0.id != pinchToZoomExtensionHandler.id } divKitComponents.extensionHandlers.append(pinchToZoomExtensionHandler) + + setTestIdentifier() } public override func viewDidDisappear(_ animated: Bool) { @@ -73,6 +77,10 @@ open class DivViewController: UIViewController { ) } } + + private func setTestIdentifier() { + divView.accessibilityIdentifier = identifier + } } private let cardId: DivCardID = "DivViewCard" diff --git a/client/ios/DivKitUITests/AppLaunchUITests.swift b/client/ios/DivKitUITests/AppLaunchUITests.swift new file mode 100644 index 000000000..c57b6ace4 --- /dev/null +++ b/client/ios/DivKitUITests/AppLaunchUITests.swift @@ -0,0 +1,22 @@ + +import XCTest + +final class AppLaunchUITests: XCTestCase { + override class var runsForEachTargetApplicationUIConfiguration: Bool { + true + } + + override func setUpWithError() throws { + continueAfterFailure = false + } + + func testLaunch() throws { + let app = XCUIApplication() + app.launch() + + let attachment = XCTAttachment(screenshot: app.screenshot()) + attachment.name = "Launch Screen" + attachment.lifetime = .keepAlways + add(attachment) + } +} diff --git a/client/ios/DivKitUITests/TooltipsUITests.swift b/client/ios/DivKitUITests/TooltipsUITests.swift new file mode 100644 index 000000000..4e836f70a --- /dev/null +++ b/client/ios/DivKitUITests/TooltipsUITests.swift @@ -0,0 +1,103 @@ +import XCTest + +final class TooltipsUITests: XCTestCase { + private let app = XCUIApplication() + private var elementsQuery: XCUIElementTypeQueryProvider { + app.scrollViews.otherElements + } + + private lazy var baseDivView: XCUIElement = { + let mainWindow = app.windows.element(boundBy: 0) + return mainWindow.descendants(matching: .any).matching(identifier: "baseDivView").element + }() + + private lazy var tooltip: XCUIElement = { + app.staticTexts["Title tooltip"] + }() + + private lazy var toggleTooltipButton: XCUIElement = { + elementsQuery.staticTexts["tooltip with close button"] + }() + + override func setUpWithError() throws { + try super.setUpWithError() + + continueAfterFailure = false + + app.launchArguments.append("UITestsMode") + app.launch() + } + + override func tearDownWithError() throws { + try super.tearDownWithError() + } + + func testTooltipPosition() throws { + goTo(test: .tooltipPosition) + + for position in Position.allCases { + checkTooltip(for: position) + } + } + + func testTooltipCloseOnSwitchOrientation() throws { + let device = XCUIDevice.shared + device.orientation = .portrait + + goTo(test: .closeOnSwitchOrientation) + + setPosition(.bottom) + toggleTooltipButton.tap() + XCTAssertTrue(tooltip.exists) + + device.orientation = .landscapeRight + XCTAssertTrue(!tooltip.exists) // tooltip closed + + toggleTooltipButton.tap() + device.orientation = .portrait + XCTAssertTrue(!tooltip.exists) // tooltip closed again + } +} + +extension TooltipsUITests { + private func checkTooltip(for position: Position) { + setPosition(position) + + toggleTooltipButton.tap() // Open tooltip + XCTAssertTrue(tooltip.exists) + XCTAssertTrue(baseDivView.frame.contains(tooltip.frame), "Wrong result on \(position) position") + + toggleTooltipButton.tap() // Close tooltip + XCTAssertTrue(!tooltip.exists) + } + + private func setPosition(_ position: Position) { + switch position { + case .bottom: + let setTooltipBottomPos = elementsQuery.staticTexts["Restore bottom position"] + setTooltipBottomPos.tap() + case .top: + let setTooltipTopPos = elementsQuery.staticTexts["Set top position"] + setTooltipTopPos.tap() + case .right: + let setTooltipRightPos = elementsQuery.staticTexts["Set right position"] + setTooltipRightPos.tap() + } + } + + private func goTo(test: TooltipTest) { + switch test { + case .tooltipPosition, .closeOnSwitchOrientation: + app.buttons["testing"].tap() + app.scrollViews.otherElements.staticTexts["Tooltip on different positions"].tap() + } + } + + private enum TooltipTest { + case tooltipPosition, closeOnSwitchOrientation + } + + private enum Position: CaseIterable { + case bottom, top, right + } +} diff --git a/test_data/regression_test_data/index.json b/test_data/regression_test_data/index.json index be4a27a46..d9abb671d 100644 --- a/test_data/regression_test_data/index.json +++ b/test_data/regression_test_data/index.json @@ -2470,7 +2470,29 @@ "Tooltips are hidden when tapping into an empty area", "The tooltip is closed by tapping on the cross button and disappears when the Disappear Action is called" ], - "file": "tooltips.json" + "file": "tooltips/tooltips.json" + }, + { + "title": "Tooltip on different positions", + "platforms": [ + "ios" + ], + "automated": [ + "ios" + ], + "tags": [ + "Tooltips" + ], + "steps": [ + "Click on buttons to set different positions of the tooltip", + "After that, click the \"tooltip with close button\" button to display the tooltip" + ], + "expected_results": [ + "The tooltip is always fully visible on the screen", + "Tooltips are hidden when tapping into an empty area", + "The tooltip is closed by tapping on the cross button and disappears when the Disappear Action is called" + ], + "file": "tooltips/tooltip-positions.json" }, { "title": "Persistent values storage", diff --git a/test_data/regression_test_data/tooltips/tooltip-positions.json b/test_data/regression_test_data/tooltips/tooltip-positions.json new file mode 100644 index 000000000..0dad36c33 --- /dev/null +++ b/test_data/regression_test_data/tooltips/tooltip-positions.json @@ -0,0 +1,219 @@ +{ + "templates": { + "button": { + "type": "text", + "width": { + "type": "match_parent" + }, + "height": { + "type": "wrap_content" + }, + "paddings": { + "left": 16, + "top": 16, + "right": 16, + "bottom": 16 + }, + "margins": { + "top": 16, + "left": 12, + "right": 12 + }, + "border": { + "corner_radius": 8 + }, + "background": [ + { + "type": "solid", + "color": "#0E000000" + } + ], + "font_size": 16, + "font_weight": "medium", + "text_alignment_vertical": "center", + "text_alignment_horizontal": "center", + "text_color": "#000000", + "alpha": 1, + "alignment_horizontal": "center", + "alignment_vertical": "center" + } + }, + "card": { + "log_id": "visibility", + "variables": [ + { + "type": "string", + "name": "position", + "value": "bottom" + } + ], + "states": [ + { + "state_id": 0, + "div": { + "type": "container", + "height": { + "type": "wrap_content" + }, + "items": [ + { + "type": "button", + "text": "tooltip with close button", + "margins": { + "top": 60 + }, + "tooltips": [ + { + "id": "tooltip", + "position": "@{position}", + "duration": 0, + "offset": { + "x": { + "value": 0 + }, + "y": { + "value": 4 + } + }, + "div": { + "type": "container", + "orientation": "overlap", + "items": [ + { + "type": "container", + "paddings": { + "left": 16, + "top": 16, + "right": 16, + "bottom": 16 + }, + "items": [ + { + "type": "text", + "width": { + "type": "wrap_content" + }, + "paddings": { + "left": 16, + "top": 16, + "right": 16, + "bottom": 16 + }, + "background": [ + { + "type": "solid", + "color": "#799eb7" + } + ], + "border": { + "corner_radius": 6 + }, + "text_color": "#2C3E50", + "text": "Title tooltip" + } + ] + }, + { + "type": "image", + "width": { + "type": "fixed", + "value": 20 + }, + "height": { + "type": "fixed", + "value": 20 + }, + "margins": { + "left": 8, + "top": 8 + }, + "action": { + "log_id": "hide_tooltip", + "url": "div-action://hide_tooltip?id=tooltip" + }, + "image_url": "https://yastatic.net/s3/home/div/div_fullscreens/cross2.3.png", + "tint_color": "#000000", + "alignment_horizontal": "left", + "alignment_vertical": "top" + } + ] + } + } + ], + "actions": [ + { + "log_id": "show_tooltip", + "url": "div-action://show_tooltip?id=tooltip&multiple=true" + } + ] + }, + { + "type": "text", + "text": "Tooltip position: @{position}" + }, + { + "type": "button", + "text": "Set top position", + "margins": { + "top": 150, + "right": 15, + "left": 15 + }, + "actions": [ + { + "log_id": "set_top_pos", + "url": "div-action://set_variable?name=position&value=top" + } + ] + }, + { + "type": "button", + "text": "Set right position", + "margins": { + "top": 15, + "right": 15, + "left": 15 + }, + "actions": [ + { + "log_id": "set_right_pos", + "url": "div-action://set_variable?name=position&value=right" + } + ] + }, + { + "type": "button", + "text": "Set center position", + "margins": { + "top": 15, + "right": 15, + "left": 15 + }, + "actions": [ + { + "log_id": "set_center_pos", + "url": "div-action://set_variable?name=position&value=center" + } + ] + }, + { + "type": "button", + "text": "Restore bottom position", + "margins": { + "top": 15, + "right": 15, + "left": 15 + }, + "actions": [ + { + "log_id": "restore_bottom_pos", + "url": "div-action://set_variable?name=position&value=bottom" + } + ] + } + ] + } + } + ] + } +} diff --git a/test_data/regression_test_data/tooltips.json b/test_data/regression_test_data/tooltips/tooltips.json similarity index 100% rename from test_data/regression_test_data/tooltips.json rename to test_data/regression_test_data/tooltips/tooltips.json