blob: d9b6598a30c7cebc570342d5f25fe83c019c0c8e [file] [log] [blame]
Ian Hickson9adb4a72017-06-23 14:58:29 -07001// 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
Ian Hickson8f56f6f2017-07-21 16:39:04 -07007/// A Flutter Driver command that sends a string to the application and expects a
8/// string response.
Ian Hickson9adb4a72017-06-23 14:58:29 -07009class RequestData extends Command {
Ian Hickson9adb4a72017-06-23 14:58:29 -070010 /// Create a command that sends a message.
11 RequestData(this.message, { Duration timeout }) : super(timeout: timeout);
12
Ian Hickson9adb4a72017-06-23 14:58:29 -070013 /// Deserializes this command from the value generated by [serialize].
14 RequestData.deserialize(Map<String, String> params)
Alexandre Ardhuin5de96bb2018-10-02 17:14:59 +020015 : message = params['message'],
Ian Hickson9adb4a72017-06-23 14:58:29 -070016 super.deserialize(params);
17
Ian Hickson8f56f6f2017-07-21 16:39:04 -070018 /// The message being sent from the test to the application.
19 final String message;
20
21 @override
22 final String kind = 'request_data';
23
Ian Hickson9adb4a72017-06-23 14:58:29 -070024 @override
25 Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
26 'message': message,
27 });
28}
29
30/// The result of the [RequestData] command.
31class RequestDataResult extends Result {
32 /// Creates a result with the given [message].
33 RequestDataResult(this.message);
34
35 /// The text extracted by the [RequestData] command.
36 final String message;
37
38 /// Deserializes the result from JSON.
39 static RequestDataResult fromJson(Map<String, dynamic> json) {
Alexandre Ardhuind927c932018-09-12 08:29:29 +020040 return RequestDataResult(json['message']);
Ian Hickson9adb4a72017-06-23 14:58:29 -070041 }
42
43 @override
44 Map<String, dynamic> toJson() => <String, String>{
45 'message': message,
46 };
47}