YoungSeok Yoon a10cd03b05 Flutter driver commands for controlling the Input widget (#4913)
* Driver commands for controlling the Input widget

This commit introduces two new driver commands for controlling the
material Input widget.

* setInputText(SerializableFinder finder, String text)
* submitInputText(SerializableFinder finder)

Since it is not possible to directly modify the Input widget text,
these driver commands invokes the handler functions of the Input
widget: onChanged and onSubmitted, respectively. The `submitInputText`
command returns the submitted String as a result.

* Make input command handler methods private

Addressing comments from @yjbanov.
2016-07-14 13:29:49 -07:00

63 lines
1.5 KiB
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 'message.dart';
import 'find.dart';
class SetInputText extends CommandWithTarget {
@override
final String kind = 'setInputText';
SetInputText(SerializableFinder finder, this.text) : super(finder);
final String text;
static SetInputText deserialize(Map<String, dynamic> json) {
String text = json['text'];
return new SetInputText(SerializableFinder.deserialize(json), text);
}
@override
Map<String, String> serialize() {
Map<String, String> json = super.serialize();
json['text'] = text;
return json;
}
}
class SetInputTextResult extends Result {
static SetInputTextResult fromJson(Map<String, dynamic> json) {
return new SetInputTextResult();
}
@override
Map<String, dynamic> toJson() => <String, dynamic>{};
}
class SubmitInputText extends CommandWithTarget {
@override
final String kind = 'submitInputText';
SubmitInputText(SerializableFinder finder) : super(finder);
static SubmitInputText deserialize(Map<String, dynamic> json) {
return new SubmitInputText(SerializableFinder.deserialize(json));
}
}
class SubmitInputTextResult extends Result {
SubmitInputTextResult(this.text);
final String text;
static SubmitInputTextResult fromJson(Map<String, dynamic> json) {
return new SubmitInputTextResult(json['text']);
}
@override
Map<String, dynamic> toJson() => <String, dynamic>{
'text': text
};
}