2017-02-27 23:38:47 +00:00
|
|
|
// Copyright 2017 The Chromium 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_tools/src/base/process.dart';
|
|
|
|
|
2018-08-15 03:33:58 +00:00
|
|
|
import '../src/common.dart';
|
2018-03-07 19:39:59 +00:00
|
|
|
import '../src/context.dart';
|
|
|
|
|
2017-02-27 23:38:47 +00:00
|
|
|
void main() {
|
|
|
|
group('shutdownHooks', () {
|
2018-03-07 19:39:59 +00:00
|
|
|
testUsingContext('runInExpectedOrder', () async {
|
2017-02-27 23:38:47 +00:00
|
|
|
int i = 1;
|
|
|
|
int serializeRecording1;
|
|
|
|
int serializeRecording2;
|
|
|
|
int postProcessRecording;
|
|
|
|
int cleanup;
|
|
|
|
|
|
|
|
addShutdownHook(() async {
|
|
|
|
serializeRecording1 = i++;
|
|
|
|
}, ShutdownStage.SERIALIZE_RECORDING);
|
|
|
|
|
|
|
|
addShutdownHook(() async {
|
|
|
|
cleanup = i++;
|
|
|
|
}, ShutdownStage.CLEANUP);
|
|
|
|
|
|
|
|
addShutdownHook(() async {
|
|
|
|
postProcessRecording = i++;
|
|
|
|
}, ShutdownStage.POST_PROCESS_RECORDING);
|
|
|
|
|
|
|
|
addShutdownHook(() async {
|
|
|
|
serializeRecording2 = i++;
|
|
|
|
}, ShutdownStage.SERIALIZE_RECORDING);
|
|
|
|
|
|
|
|
await runShutdownHooks();
|
|
|
|
|
|
|
|
expect(serializeRecording1, lessThanOrEqualTo(2));
|
|
|
|
expect(serializeRecording2, lessThanOrEqualTo(2));
|
|
|
|
expect(postProcessRecording, 3);
|
|
|
|
expect(cleanup, 4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|