• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'message.dart';
6
7/// A Flutter Driver command that sends a string to the application and expects a
8/// string response.
9class RequestData extends Command {
10  /// Create a command that sends a message.
11  const RequestData(this.message, { Duration timeout }) : super(timeout: timeout);
12
13  /// Deserializes this command from the value generated by [serialize].
14  RequestData.deserialize(Map<String, String> params)
15    : message = params['message'],
16      super.deserialize(params);
17
18  /// The message being sent from the test to the application.
19  final String message;
20
21  @override
22  String get kind => 'request_data';
23
24  @override
25  bool get requiresRootWidgetAttached => false;
26
27  @override
28  Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
29    'message': message,
30  });
31}
32
33/// The result of the [RequestData] command.
34class RequestDataResult extends Result {
35  /// Creates a result with the given [message].
36  const RequestDataResult(this.message);
37
38  /// The text extracted by the [RequestData] command.
39  final String message;
40
41  /// Deserializes the result from JSON.
42  static RequestDataResult fromJson(Map<String, dynamic> json) {
43    return RequestDataResult(json['message']);
44  }
45
46  @override
47  Map<String, dynamic> toJson() => <String, String>{
48    'message': message,
49  };
50}
51