Giter Site home page Giter Site logo

kalaimathi03 / ios-accessibility-text-snapshot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from minddistrict/ios-accessibility-text-snapshot

0.0 0.0 0.0 7 KB

Textual snapshot tests for your app's VoiceOver support

License: MIT License

Ruby 8.52% Swift 91.48%

ios-accessibility-text-snapshot's Introduction

AccessibilityTextSnapshot

A snapshot strategy for testing your VoiceOvers support in UIKit, using the SnapshotTesting library by PointFree.

This strategy uses a textual representation of the view hierarchy, focusing on just the information that is relevant for VoiceOver. (Related work: AccessibilitySnapshot is a visual snapshot-test tool for a similar use case.)

Usage

import SnapshotTesting
import AccessibilityTextSnapshot

assertSnapshot(                     // SnapshotTesting gives you this...
    matching: someView,
    as: .recursiveA11yDescription)  // ... but AccessibilityTextSnapshot gives you this

This generates a recursive (textual) description of all voiceover-relevant information, suitable for snapshot testing.

The string shows

  • all UIView subclasses with isAccessibilityElement true, together with their ancestor UIViews (if any) to show hierarchy
  • their voiceover-relevant properties (accessibilityValue, accessibilityLabel, etc)
  • any a11y-relevant subviews they might have, prefixed by | to emphasise that they are not involved in VoiceOver

It does not show UIImageViews, which we maybe should reconsider at some point.

Example:

* UIView                                       // non-a11y view but has a11y-relevant descendant
   * UIScrollView                              // (same)
     * UIView                                  // (same)
       * UIStackView                           // ...
         * MDViewLayer.ElementView
           * UIStackView
             * MDViewModels.Label              // | hanging from this view means it has a11y-relevant stuff
             | -label: Relaxation exercises    // a11y property
             | -traits: .staticText            // a11y property
             * UIStackView
               * MDViewLayer.MultilineButton
               | -label: Yes
               | -hint: Unselected option
               | -traits: .button
               * MDViewLayer.MultilineButton
               | -label: No
               | -hint: Unselected option
               | -traits: .button
         * MDViewLayer.ConversationListItemView // hanging | means a11y-relevant view
         | -label: Only you. No messages yet    // a11y property
         | -hint: Open conversation             // a11y property
         | * UIStackView                        // subviews that would be a11y-relevant
         |   * UIStackView                      // BUT are not read by VoiceOver because
         |     * UIStackView                    // the parent view overrides, note leading |
         |       * MDViewModels.Label
         |       | -label: Only you
         |     * UIStackView
         |       * MDViewModels.Label
         |       | -label: No messages yet.
         |   * MDViewLayer.Button
         |     * UIView
         |       * MDViewModels.Label
         |       | -label: Ongoing video call
         o MDViewLayer.StepValidationView        // o means isHidden=true (on self or a parent)
         o -label: Please correct the errors above. Actions available
         o -action: Go to first error            // We still show it because we want to
         o * MDViewLayer.MultilineButton         // be reminded that there *could* be something!
         o | -label: Please correct the errors above

Installing with CocoaPods

target 'MyAppTests' do
  pod 'AccessibilityTextSnapshot'
end

ios-accessibility-text-snapshot's People

Contributors

mroro avatar sherlouk avatar tikitu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.