// 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:typed_data';import'package:flutter/scheduler.dart';import'package:flutter/services.dart';import'package:flutter_test/flutter_test.dart';import'package:flutter/widgets.dart';voidmain(){test('Can only schedule frames after widget binding attaches the root widget',()async{finalWidgetsBindingbinding=WidgetsFlutterBinding.ensureInitialized();expect(SchedulerBinding.instance.framesEnabled,isFalse);expect(SchedulerBinding.instance.hasScheduledFrame,isFalse);// Sends a message to notify that the engine is ready to accept frames.finalByteDatamessage=constStringCodec().encodeMessage('AppLifecycleState.resumed');awaitServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle',message,(_){});// Enables the semantics should not schedule any frames if the root widget// has not been attached.binding.setSemanticsEnabled(true);expect(SchedulerBinding.instance.framesEnabled,isFalse);expect(SchedulerBinding.instance.hasScheduledFrame,isFalse);// The widget binding should be ready to produce frames after it attaches// the root widget.binding.attachRootWidget(constPlaceholder());expect(SchedulerBinding.instance.framesEnabled,isTrue);expect(SchedulerBinding.instance.hasScheduledFrame,isTrue);});}