semantics.dart 1.49 KB
Newer Older
1 2 3 4 5 6
// 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 'message.dart';

7
/// A Flutter Driver command that enables or disables semantics.
8
class SetSemantics extends Command {
9
  /// Creates a command that enables or disables semantics.
10 11
  SetSemantics(this.enabled, { Duration timeout }) : super(timeout: timeout);

12 13 14 15 16
  /// Deserializes this command from the value generated by [serialize].
  SetSemantics.deserialize(Map<String, String> params)
      : this.enabled = params['enabled'].toLowerCase() == 'true',
        super.deserialize(params);

17 18 19 20 21 22
  /// Whether semantics should be enabled (true) or disabled (false).
  final bool enabled;

  @override
  final String kind = 'set_semantics';

23 24 25 26 27 28 29 30
  @override
  Map<String, String> serialize() => super.serialize()..addAll(<String, String>{
    'enabled': '$enabled',
  });
}

/// The result of a [SetSemantics] command.
class SetSemanticsResult extends Result {
31
  /// Create a result with the given [changedState].
32 33
  SetSemanticsResult(this.changedState);

34 35
  /// Whether the [SetSemantics] command actually changed the state that the
  /// application was in.
36 37 38 39 40 41 42 43 44 45 46 47
  final bool changedState;

  /// Deserializes this result from JSON.
  static SetSemanticsResult fromJson(Map<String, dynamic> json) {
    return new SetSemanticsResult(json['changedState']);
  }

  @override
  Map<String, dynamic> toJson() => <String, dynamic>{
    'changedState': changedState,
  };
}