text_theme_test.dart 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('CupertinoTextTheme matches Apple Design resources', () {
    // Check the default cupertino text theme against the style values
    // Values derived from https://developer.apple.com/design/resources/.

    const CupertinoTextThemeData theme = CupertinoTextThemeData();
    const FontWeight normal = FontWeight.normal;
    const FontWeight regular = FontWeight.w400;
    const FontWeight medium = FontWeight.w500;
    const FontWeight semiBold = FontWeight.w600;
    const FontWeight bold = FontWeight.w700;

    // TextStyle 17 -0.41
    expect(theme.textStyle.fontSize, 17);
22
    expect(theme.textStyle.fontFamily, 'CupertinoSystemText');
23 24 25 26 27
    expect(theme.textStyle.letterSpacing, -0.41);
    expect(theme.textStyle.fontWeight, null);

    // ActionTextStyle 17 -0.41
    expect(theme.actionTextStyle.fontSize, 17);
28
    expect(theme.actionTextStyle.fontFamily, 'CupertinoSystemText');
29 30 31 32 33
    expect(theme.actionTextStyle.letterSpacing, -0.41);
    expect(theme.actionTextStyle.fontWeight, null);

    // TextStyle 17 -0.41
    expect(theme.tabLabelTextStyle.fontSize, 10);
34
    expect(theme.tabLabelTextStyle.fontFamily, 'CupertinoSystemText');
35 36 37 38 39
    expect(theme.tabLabelTextStyle.letterSpacing, -0.24);
    expect(theme.tabLabelTextStyle.fontWeight, medium);

    // NavTitle SemiBold 17 -0.41
    expect(theme.navTitleTextStyle.fontSize, 17);
40
    expect(theme.navTitleTextStyle.fontFamily, 'CupertinoSystemText');
41 42 43 44 45
    expect(theme.navTitleTextStyle.letterSpacing, -0.41);
    expect(theme.navTitleTextStyle.fontWeight, semiBold);

    // NavLargeTitle Bold 34 0.41
    expect(theme.navLargeTitleTextStyle.fontSize, 34);
46 47
    expect(theme.navLargeTitleTextStyle.fontFamily, 'CupertinoSystemDisplay');
    expect(theme.navLargeTitleTextStyle.letterSpacing, 0.38);
48 49 50 51
    expect(theme.navLargeTitleTextStyle.fontWeight, bold);

    // Picker Regular 21 -0.6
    expect(theme.pickerTextStyle.fontSize, 21);
52
    expect(theme.pickerTextStyle.fontFamily, 'CupertinoSystemDisplay');
53 54 55 56 57
    expect(theme.pickerTextStyle.letterSpacing, -0.6);
    expect(theme.pickerTextStyle.fontWeight, regular);

    // DateTimePicker Normal 21
    expect(theme.dateTimePickerTextStyle.fontSize, 21);
58 59
    expect(theme.dateTimePickerTextStyle.fontFamily, 'CupertinoSystemDisplay');
    expect(theme.dateTimePickerTextStyle.letterSpacing, 0.4);
60 61 62
    expect(theme.dateTimePickerTextStyle.fontWeight, normal);
  });
}