Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.2
osx_image: xcode9
sudo: false
# Only fire off builds for specific branches.
branches:
Expand Down
5 changes: 3 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports_files(["LICENSE"])

strict_warnings_objc_library(
name = "MDFTextAccessibility",
module_name = "MDFTextAccessibility",
srcs = glob([
"src/*.m",
"src/private/*.m",
Expand All @@ -43,15 +44,15 @@ swift_library(
resources = glob(["tests/resources/*"]),
deps = [":MDFTextAccessibility"],
visibility = ["//visibility:private"],
copts = ["-swift-version", "3"],
copts = ["-swift-version", "4"],
)

ios_unit_test(
name = "UnitTests",
deps = [
":UnitTestsSwiftLib"
],
minimum_os_version = "8.2",
minimum_os_version = "9.0",
timeout = "short",
visibility = ["//visibility:private"],
)
2 changes: 1 addition & 1 deletion MDFTextAccessibility.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Pod::Spec.new do |spec|
spec.public_header_files = "src/MDFTextAccessibility.h"
spec.private_header_files = "src/private/*.h"
spec.header_dir = "MDFTextAccessibility"
spec.ios.deployment_target = '8.0'
spec.ios.deployment_target = '9.0'
spec.tvos.deployment_target = '9.0'
end
20 changes: 10 additions & 10 deletions MDFTextAccessibility.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@
};
0BDAE3DF1CECD3A6003323B9 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 1120;
};
};
};
buildConfigurationList = 0B2890D61CE27291009E605A /* Build configuration list for PBXProject "MDFTextAccessibility" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -293,7 +293,7 @@
buildSettings = {
ENABLE_TESTABILITY = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
ONLY_ACTIVE_ARCH = YES;
WARNING_CFLAGS = "-Wall";
};
Expand All @@ -304,7 +304,7 @@
baseConfigurationReference = 0B96D67A1D5CD06100491BDC /* MDFTextAccessibility.xcconfig */;
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
WARNING_CFLAGS = "-Wall";
};
name = Release;
Expand Down Expand Up @@ -349,7 +349,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = src/module.modulemap;
MTL_ENABLE_DEBUG_INFO = YES;
Expand All @@ -363,7 +363,7 @@
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "tests/unit/MDFTextAccessibility-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -400,7 +400,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = src/module.modulemap;
MTL_ENABLE_DEBUG_INFO = NO;
Expand All @@ -412,7 +412,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "tests/unit/MDFTextAccessibility-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down Expand Up @@ -469,7 +469,7 @@
SWIFT_INCLUDE_PATHS = src;
SWIFT_OBJC_BRIDGING_HEADER = "src/MDFTextAccessibility-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -517,7 +517,7 @@
SDKROOT = iphoneos;
SWIFT_INCLUDE_PATHS = src;
SWIFT_OBJC_BRIDGING_HEADER = "src/MDFTextAccessibility-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ For more advanced usage, such as selecting from a set of colors other than white
and black, see MDFTextAccessibility's
`textColorFromChoices:onBackgroundColor:options:`.

## Requirements

- Xcode 9 or higher
- Minimum iOS deployment target of 9.0 or higher
- CocoaPods 1.5 or higher

## License

MDFTextAccessiblity is licensed under the [Apache License Version 2.0](LICENSE).
24 changes: 12 additions & 12 deletions tests/unit/MDFTextAccessibilityUnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
let minAlpha = MDFTextAccessibility.minAlpha(ofTextColor: textColor,
onBackgroundColor:backgroundColor,
options:MDFTextAccessibilityOptions())
XCTAssertEqualWithAccuracy(minAlpha, 0.54, accuracy: alphaEpsilon)
XCTAssertEqual(minAlpha, 0.54, accuracy: alphaEpsilon)
}

func testLargeTextBlackOnWhiteMinAlpha() {
Expand All @@ -92,7 +92,7 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
let minAlpha = MDFTextAccessibility.minAlpha(ofTextColor: textColor,
onBackgroundColor:backgroundColor,
options:MDFTextAccessibilityOptions.largeFont)
XCTAssertEqualWithAccuracy(minAlpha, 0.42, accuracy: alphaEpsilon)
XCTAssertEqual(minAlpha, 0.42, accuracy: alphaEpsilon)
}

func testMinAlphaIgnoresColorAlpha() {
Expand All @@ -107,7 +107,7 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
onBackgroundColor:backgroundColor,
options:MDFTextAccessibilityOptions())

XCTAssertEqualWithAccuracy(minAlpha, minAlphaWithColorWithAlpha, accuracy: alphaEpsilon)
XCTAssertEqual(minAlpha, minAlphaWithColorWithAlpha, accuracy: alphaEpsilon)
}

// MARK: Accessibility standard tests
Expand Down Expand Up @@ -225,17 +225,17 @@ class MDFTextAccessibilityUnitTests: XCTestCase {
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 10)))

// Bold and thicker fonts are considered large at a lower font size than nonbold fonts.
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightBlack)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightHeavy)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightBold)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .black)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .heavy)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .bold)))
// Semibold is considered bold by iOS font-weight APIs: fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold.
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightSemibold)))
XCTAssertTrue(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .semibold)))

// Non-bold fonts are not considered large at the lower font size threshold.
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightMedium)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightRegular)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightLight)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightThin)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: UIFontWeightUltraLight)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .medium)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .regular)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .light)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .thin)))
XCTAssertFalse(MDFTextAccessibility.isLarge(forContrastRatios: UIFont.systemFont(ofSize: 15, weight: .ultraLight)))
}
}