-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utilities for highlighting hit test regions
- Loading branch information
Showing
21 changed files
with
729 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" | ||
Note: Edits made to this file will be overriden the next time pods are installed. | ||
This file is auto-generated using the cocoapods-bazel plugin and it's contents are based on the .podspec. | ||
It is currently listed in the .gitignore and as such you must use 'bundle exec pod install' to update the file when needed. | ||
""" | ||
|
||
load("//Tools/Rules:framework.bzl", "cash_framework") | ||
|
||
cash_framework( | ||
name = "AccessibilitySnapshot-Core", | ||
srcs = glob([ | ||
"Sources/AccessibilitySnapshot/Core/Swift/Classes/**/*.swift", | ||
"Sources/AccessibilitySnapshot/Core/ObjC/**/*.h", | ||
"Sources/AccessibilitySnapshot/Core/ObjC/**/*.m", | ||
]), | ||
module_name = "AccessibilitySnapshot", | ||
platforms = {"ios": "13.0"}, | ||
public_headers = glob([ | ||
"Sources/AccessibilitySnapshot/Core/ObjC/include/*.h", | ||
]), | ||
resource_bundles = {"AccessibilitySnapshot": glob( | ||
[ | ||
"Sources/AccessibilitySnapshot/Core/Swift/Assets/**/*.strings", | ||
"Sources/AccessibilitySnapshot/Core/Swift/Assets/**/*.xcassets/**/*", | ||
], | ||
exclude_directories = 0, | ||
)}, | ||
swift_version = "5.0.1", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cash_framework( | ||
name = "AccessibilitySnapshot", | ||
testonly = True, | ||
srcs = glob([ | ||
"Sources/AccessibilitySnapshot/Core/Swift/Classes/**/*.swift", | ||
"Sources/AccessibilitySnapshot/Core/ObjC/**/*.h", | ||
"Sources/AccessibilitySnapshot/Core/ObjC/**/*.m", | ||
"Sources/AccessibilitySnapshot/SnapshotTesting/**/*.swift", | ||
]), | ||
platforms = {"ios": "13.0"}, | ||
public_headers = glob([ | ||
"Sources/AccessibilitySnapshot/Core/ObjC/include/*.h", | ||
]), | ||
resource_bundles = {"AccessibilitySnapshot": glob( | ||
[ | ||
"Sources/AccessibilitySnapshot/Core/Swift/Assets/**/*.strings", | ||
"Sources/AccessibilitySnapshot/Core/Swift/Assets/**/*.xcassets/**/*", | ||
], | ||
exclude_directories = 0, | ||
)}, | ||
sdk_frameworks = ["XCTest"], | ||
swift_version = "5.0.1", | ||
visibility = ["//visibility:public"], | ||
weak_sdk_frameworks = ["XCTest"], | ||
deps = ["//Pods/SnapshotTesting"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...cbaselines/607FACE41AFB9204008FA782.xcbaseline/EDA548A6-E453-4CBA-9366-15D413356833.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>classNames</key> | ||
<dict> | ||
<key>HitTargetTests</key> | ||
<dict> | ||
<key>testPerformance()</key> | ||
<dict> | ||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key> | ||
<dict> | ||
<key>baselineAverage</key> | ||
<real>48.792810</real> | ||
<key>baselineIntegrationDisplayName</key> | ||
<string>Local Baseline</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
40 changes: 40 additions & 0 deletions
40
...napshot.xcodeproj/xcshareddata/xcbaselines/607FACE41AFB9204008FA782.xcbaseline/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>runDestinationsByUUID</key> | ||
<dict> | ||
<key>EDA548A6-E453-4CBA-9366-15D413356833</key> | ||
<dict> | ||
<key>localComputer</key> | ||
<dict> | ||
<key>busSpeedInMHz</key> | ||
<integer>0</integer> | ||
<key>cpuCount</key> | ||
<integer>1</integer> | ||
<key>cpuKind</key> | ||
<string>Apple M1 Max</string> | ||
<key>cpuSpeedInMHz</key> | ||
<integer>0</integer> | ||
<key>logicalCPUCoresPerPackage</key> | ||
<integer>10</integer> | ||
<key>modelCode</key> | ||
<string>MacBookPro18,2</string> | ||
<key>physicalCPUCoresPerPackage</key> | ||
<integer>10</integer> | ||
<key>platformIdentifier</key> | ||
<string>com.apple.platform.macosx</string> | ||
</dict> | ||
<key>targetArchitecture</key> | ||
<string>arm64</string> | ||
<key>targetDevice</key> | ||
<dict> | ||
<key>modelCode</key> | ||
<string>iPhone13,3</string> | ||
<key>platformIdentifier</key> | ||
<string>com.apple.platform.iphonesimulator</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// Copyright 2023 Block Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import AccessibilitySnapshot | ||
import FBSnapshotTestCase | ||
import Paralayout | ||
|
||
@testable import AccessibilitySnapshotDemo | ||
|
||
final class HitTargetTests: SnapshotTestCase { | ||
|
||
func testButtonHitTarget() { | ||
let buttonTraitsViewController = ButtonAccessibilityTraitsViewController() | ||
buttonTraitsViewController.view.frame = UIScreen.main.bounds | ||
SnapshotVerifyWithHitTargets(buttonTraitsViewController.view) | ||
} | ||
|
||
@available(iOS 14, *) | ||
func testTableHitTarget() { | ||
let viewController = TableViewController() | ||
viewController.view.frame = UIScreen.main.bounds | ||
SnapshotVerifyWithHitTargets(viewController.view) | ||
} | ||
|
||
func testPerformance() throws { | ||
let buttonTraitsViewController = ButtonAccessibilityTraitsViewController() | ||
buttonTraitsViewController.view.frame = UIScreen.main.bounds | ||
|
||
measure { | ||
do { | ||
_ = try HitTargetSnapshotUtility.generateSnapshotImage( | ||
for: buttonTraitsViewController.view, | ||
useMonochromeSnapshot: true, | ||
viewRenderingMode: .drawHierarchyInRect | ||
) | ||
} catch { | ||
XCTFail("Utility should not fail to generate snapshot image") | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
// MARK: - | ||
|
||
@available(iOS 14, *) | ||
private final class TableViewController: UITableViewController { | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 3 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = UITableViewCell() | ||
|
||
var config = cell.defaultContentConfiguration() | ||
config.text = "Hello World" | ||
cell.contentConfiguration = config | ||
|
||
cell.accessoryView = UISwitch() | ||
|
||
return cell | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.