binding_first_frame_developer_test.dart 1.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 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 'dart:developer' as developer;
import 'dart:ui';

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

void main() {
  test('first frame callback sets the default UserTag', () {
      final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized();

15 16 17 18 19
      // TODO(iskakaushik): https://github.com/flutter/flutter/issues/86947
      final String userTag = developer.getCurrentTag().label;
      final bool isValid = <String>{'Default', 'AppStartUp'}.contains(userTag);
      expect(isValid, equals(true));

20 21 22 23 24
      developer.UserTag('test tag').makeCurrent();
      expect(developer.getCurrentTag().label, equals('test tag'));

      binding.drawFrame();
      // Simulates the engine again.
25
      binding.platformDispatcher.onReportTimings!(<FrameTiming>[]);
26 27 28 29

      expect(developer.getCurrentTag().label, equals('Default'));
  });
}