mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(ios): FormattedString and Span a11y font scale (#10281)
This commit is contained in:
committed by
GitHub
parent
b8a548f009
commit
a14becdc6a
@@ -227,6 +227,9 @@ allTests['LISTVIEW'] = listViewTests;
|
||||
import * as activityIndicatorTests from './ui/activity-indicator/activity-indicator-tests';
|
||||
allTests['ACTIVITY-INDICATOR'] = activityIndicatorTests;
|
||||
|
||||
import * as textBaseTests from './ui/text-base/text-base-tests';
|
||||
allTests['TEXT-BASE'] = textBaseTests;
|
||||
|
||||
import * as textFieldTests from './ui/text-field/text-field-tests';
|
||||
allTests['TEXT-FIELD'] = textFieldTests;
|
||||
|
||||
|
||||
@@ -580,26 +580,6 @@ export function test_setting_font_properties_sets_native_font() {
|
||||
test_native_font('italic', 'bold');
|
||||
}
|
||||
|
||||
export function test_native_font_size_with_a11y_font_scale() {
|
||||
if (isIOS) {
|
||||
const deviceFontScaleMock = 4.0;
|
||||
|
||||
const page = helper.getCurrentPage();
|
||||
const testView = new Label();
|
||||
const layout = new StackLayout();
|
||||
layout.addChild(testView);
|
||||
|
||||
page.content = layout;
|
||||
|
||||
layout.style.iosAccessibilityAdjustsFontSize = true;
|
||||
layout.style.fontScaleInternal = deviceFontScaleMock;
|
||||
|
||||
const nativeFontSize = testView.nativeTextViewProtected.font.pointSize;
|
||||
const expectedNativeFontSize = testView.style.fontInternal.fontSize * deviceFontScaleMock;
|
||||
TKUnit.assertEqual(nativeFontSize, expectedNativeFontSize, 'View font size does not respect a11y font scaling');
|
||||
}
|
||||
}
|
||||
|
||||
function test_native_font(style: 'normal' | 'italic', weight: '100' | '200' | '300' | 'normal' | '400' | '500' | '600' | 'bold' | '700' | '800' | '900') {
|
||||
const testView = new Button();
|
||||
|
||||
|
||||
23
apps/automated/src/ui/text-base/text-base-tests.ts
Normal file
23
apps/automated/src/ui/text-base/text-base-tests.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as TKUnit from '../../tk-unit';
|
||||
import * as helper from '../../ui-helper';
|
||||
import { FormattedString, isIOS, Label, Span, StackLayout } from '@nativescript/core';
|
||||
|
||||
export function test_native_font_size_with_a11y_font_scale() {
|
||||
if (isIOS) {
|
||||
const deviceFontScaleMock = 4.0;
|
||||
|
||||
const page = helper.getCurrentPage();
|
||||
const testView = new Label();
|
||||
const layout = new StackLayout();
|
||||
layout.addChild(testView);
|
||||
|
||||
page.content = layout;
|
||||
|
||||
layout.style.iosAccessibilityAdjustsFontSize = true;
|
||||
layout.style.fontScaleInternal = deviceFontScaleMock;
|
||||
|
||||
const nativeFontSize = testView.nativeTextViewProtected.font.pointSize;
|
||||
const expectedNativeFontSize = testView.style.fontInternal.fontSize * deviceFontScaleMock;
|
||||
TKUnit.assertEqual(nativeFontSize, expectedNativeFontSize, 'View font size does not respect a11y font scaling');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user