• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2017 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 enables or disables semantics.
8class SetSemantics extends Command {
9  /// Creates a command that enables or disables semantics.
10  const SetSemantics(this.enabled, { Duration timeout }) : super(timeout: timeout);
11
12  /// Deserializes this command from the value generated by [serialize].
13  SetSemantics.deserialize(Map<String, String> params)
14    : enabled = params['enabled'].toLowerCase() == 'true',
15      super.deserialize(params);
16
17  /// Whether semantics should be enabled (true) or disabled (false).
18  final bool enabled;
19
20  @override
21  String get kind => 'set_semantics';
22
23  @override
24  Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
25    'enabled': '$enabled',
26  });
27}
28
29/// The result of a [SetSemantics] command.
30class SetSemanticsResult extends Result {
31  /// Create a result with the given [changedState].
32  const SetSemanticsResult(this.changedState);
33
34  /// Whether the [SetSemantics] command actually changed the state that the
35  /// application was in.
36  final bool changedState;
37
38  /// Deserializes this result from JSON.
39  static SetSemanticsResult fromJson(Map<String, dynamic> json) {
40    return SetSemanticsResult(json['changedState']);
41  }
42
43  @override
44  Map<String, dynamic> toJson() => <String, dynamic>{
45    'changedState': changedState,
46  };
47}
48