Commit 7d6e5632 authored by Yegor's avatar Yegor Committed by GitHub

remove unused FlutterDriver methods (#9821)

parent 3d724062
......@@ -19,7 +19,6 @@ import 'find.dart';
import 'frame_sync.dart';
import 'gesture.dart';
import 'health.dart';
import 'input.dart';
import 'message.dart';
import 'render_tree.dart';
import 'timeline.dart';
......@@ -327,24 +326,6 @@ class FlutterDriver {
return null;
}
/// Sets the text value of the [TextField] widget located by [finder].
///
/// This command invokes the `onChanged` handler of the `Input` widget with
/// the provided [text].
Future<Null> setInputText(SerializableFinder finder, String text, {Duration timeout}) async {
await _sendCommand(new SetInputText(finder, text, timeout: timeout));
return null;
}
/// Submits the current text value of the [TextField] widget located by [finder].
///
/// This command invokes the `onSubmitted` handler of the [TextField] widget
/// and the returns the submitted text value.
Future<String> submitInputText(SerializableFinder finder, {Duration timeout}) async {
final Map<String, dynamic> json = await _sendCommand(new SubmitInputText(finder, timeout: timeout));
return json['text'];
}
/// Waits until [finder] locates the target.
Future<Null> waitFor(SerializableFinder finder, {Duration timeout}) async {
await _sendCommand(new WaitFor(finder, timeout: timeout));
......
......@@ -10,7 +10,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show RendererBinding;
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -19,7 +18,6 @@ import 'find.dart';
import 'frame_sync.dart';
import 'gesture.dart';
import 'health.dart';
import 'input.dart';
import 'message.dart';
import 'render_tree.dart';
......@@ -73,8 +71,6 @@ class FlutterDriverExtension {
'set_frame_sync': _setFrameSync,
'scroll': _scroll,
'scrollIntoView': _scrollIntoView,
'setInputText': _setInputText,
'submitInputText': _submitInputText,
'waitFor': _waitFor,
'waitUntilNoTransientCallbacks': _waitUntilNoTransientCallbacks,
});
......@@ -87,8 +83,6 @@ class FlutterDriverExtension {
'set_frame_sync': (Map<String, String> params) => new SetFrameSync.deserialize(params),
'scroll': (Map<String, String> params) => new Scroll.deserialize(params),
'scrollIntoView': (Map<String, String> params) => new ScrollIntoView.deserialize(params),
'setInputText': (Map<String, String> params) => new SetInputText.deserialize(params),
'submitInputText': (Map<String, String> params) => new SubmitInputText.deserialize(params),
'waitFor': (Map<String, String> params) => new WaitFor.deserialize(params),
'waitUntilNoTransientCallbacks': (Map<String, String> params) => new WaitUntilNoTransientCallbacks.deserialize(params),
});
......@@ -263,31 +257,6 @@ class FlutterDriverExtension {
return new ScrollResult();
}
Finder _findEditableText(SerializableFinder finder) {
return find.descendant(of: _createFinder(finder), matching: find.byType(EditableText));
}
EditableTextState _getEditableTextState(Finder finder) {
final StatefulElement element = finder.evaluate().single;
return element.state;
}
Future<SetInputTextResult> _setInputText(Command command) async {
final SetInputText setInputTextCommand = command;
final Finder target = await _waitForElement(_findEditableText(setInputTextCommand.finder));
final EditableTextState editable = _getEditableTextState(target);
editable.updateEditingValue(new TextEditingValue(text: setInputTextCommand.text));
return new SetInputTextResult();
}
Future<SubmitInputTextResult> _submitInputText(Command command) async {
final SubmitInputText submitInputTextCommand = command;
final Finder target = await _waitForElement(_findEditableText(submitInputTextCommand.finder));
final EditableTextState editable = _getEditableTextState(target);
editable.performAction(TextInputAction.done);
return new SubmitInputTextResult(editable.widget.controller.value.text);
}
Future<GetTextResult> _getText(Command command) async {
final GetText getTextCommand = command;
final Finder target = await _waitForElement(_createFinder(getTextCommand.finder));
......
// 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 'find.dart';
import 'message.dart';
/// Sets [text] in a text input widget.
class SetInputText extends CommandWithTarget {
@override
final String kind = 'setInputText';
/// Creates a command.
///
/// [finder] identifies the text input widget. [text] is the string that is
/// set as the value of the text input.
SetInputText(SerializableFinder finder, this.text, {Duration timeout}) : super(finder, timeout: timeout);
/// The value of the text input to set.
final String text;
/// Deserializes this command from JSON generated by [serialize].
SetInputText.deserialize(Map<String, String> json)
: this.text = json['text'],
super.deserialize(json);
@override
Map<String, String> serialize() {
final Map<String, String> json = super.serialize();
json['text'] = text;
return json;
}
}
/// The result of a [SetInputText] command.
class SetInputTextResult extends Result {
/// Deserializes this result from JSON.
static SetInputTextResult fromJson(Map<String, dynamic> json) {
return new SetInputTextResult();
}
@override
Map<String, dynamic> toJson() => <String, dynamic>{};
}
/// Submits text entered in a text input widget.
///
/// The definition of submitting input text can be found
/// [here](https://docs.flutter.io/flutter/material/Input/onSubmitted.html).
class SubmitInputText extends CommandWithTarget {
@override
final String kind = 'submitInputText';
/// Create a command that submits text on input widget identified by [finder].
SubmitInputText(SerializableFinder finder, {Duration timeout}) : super(finder, timeout: timeout);
/// Deserializes this command from JSON generated by [serialize].
SubmitInputText.deserialize(Map<String, String> json)
: super.deserialize(json);
}
/// The result of a [SubmitInputText] command.
class SubmitInputTextResult extends Result {
/// Creates a result with [text] as the submitted value.
SubmitInputTextResult(this.text);
/// The submitted value.
final String text;
/// Deserializes this result from JSON.
static SubmitInputTextResult fromJson(Map<String, dynamic> json) {
return new SubmitInputTextResult(json['text']);
}
@override
Map<String, dynamic> toJson() => <String, dynamic>{
'text': text
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment