flutter/packages/flutter/test/services/platform_messages_test.dart
Mikkel Nygaard Ravn dce4bf8599 Remove old platform messaging API (#8837)
Breaking change: removed deprecated methods of PlatformMessages, leaving only binary messaging there. All other use of platform communication now goes through PlatformMessageChannel and PlatformMethodChannels. Retained use of String and JSON codecs for now.

Companion engine PR: flutter/engine#3482
2017-03-17 11:56:50 +01:00

28 lines
852 B
Dart

// Copyright 2016 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 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:test/test.dart';
void main() {
test('Mock binary message handler control test', () async {
final List<ByteData> log = <ByteData>[];
PlatformMessages.setMockBinaryMessageHandler('test1', (ByteData message) async {
log.add(message);
});
final ByteData message = new ByteData(2)..setUint16(0, 0xABCD);
await PlatformMessages.sendBinary('test1', message);
expect(log, equals(<ByteData>[message]));
log.clear();
PlatformMessages.setMockBinaryMessageHandler('test1', null);
await PlatformMessages.sendBinary('test1', message);
expect(log, isEmpty);
});
}