test: a11y scale (#10251)

This commit is contained in:
Dimitris-Rafail Katsampas
2023-03-28 01:12:38 +03:00
committed by GitHub
parent 09832ad7ab
commit 671603ab4b
2 changed files with 16 additions and 17 deletions

View File

@ -1,17 +0,0 @@
import * as TKUnit from '../../tk-unit';
import * as helper from '../../ui-helper';
import { Label } from '@nativescript/core';
export function test_native_font_size_with_a11y_font_scale() {
const page = helper.getCurrentPage();
const testView = new Label();
const deviceFontScaleMock = 4.0;
page.content = testView;
testView.style._fontScale = 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');
}

View File

@ -580,6 +580,22 @@ 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 page = helper.getCurrentPage();
const testView = new Label();
const deviceFontScaleMock = 4.0;
page.content = testView;
testView.style._fontScale = 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();