From 7d6e5632d752da4ddd7015c5b1deb37ac6e2811c Mon Sep 17 00:00:00 2001 From: Yegor Date: Thu, 4 May 2017 18:11:05 -0700 Subject: [PATCH] remove unused FlutterDriver methods (#9821) --- packages/flutter_driver/lib/src/driver.dart | 19 ----- .../flutter_driver/lib/src/extension.dart | 31 -------- packages/flutter_driver/lib/src/input.dart | 79 ------------------- 3 files changed, 129 deletions(-) delete mode 100644 packages/flutter_driver/lib/src/input.dart diff --git a/packages/flutter_driver/lib/src/driver.dart b/packages/flutter_driver/lib/src/driver.dart index 0f15222fbe..ab35369d3a 100644 --- a/packages/flutter_driver/lib/src/driver.dart +++ b/packages/flutter_driver/lib/src/driver.dart @@ -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 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 submitInputText(SerializableFinder finder, {Duration timeout}) async { - final Map json = await _sendCommand(new SubmitInputText(finder, timeout: timeout)); - return json['text']; - } - /// Waits until [finder] locates the target. Future waitFor(SerializableFinder finder, {Duration timeout}) async { await _sendCommand(new WaitFor(finder, timeout: timeout)); diff --git a/packages/flutter_driver/lib/src/extension.dart b/packages/flutter_driver/lib/src/extension.dart index 18fbfd72e2..1af359d89e 100644 --- a/packages/flutter_driver/lib/src/extension.dart +++ b/packages/flutter_driver/lib/src/extension.dart @@ -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 params) => new SetFrameSync.deserialize(params), 'scroll': (Map params) => new Scroll.deserialize(params), 'scrollIntoView': (Map params) => new ScrollIntoView.deserialize(params), - 'setInputText': (Map params) => new SetInputText.deserialize(params), - 'submitInputText': (Map params) => new SubmitInputText.deserialize(params), 'waitFor': (Map params) => new WaitFor.deserialize(params), 'waitUntilNoTransientCallbacks': (Map 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 _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 _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 _getText(Command command) async { final GetText getTextCommand = command; final Finder target = await _waitForElement(_createFinder(getTextCommand.finder)); diff --git a/packages/flutter_driver/lib/src/input.dart b/packages/flutter_driver/lib/src/input.dart deleted file mode 100644 index 679451da21..0000000000 --- a/packages/flutter_driver/lib/src/input.dart +++ /dev/null @@ -1,79 +0,0 @@ -// 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 json) - : this.text = json['text'], - super.deserialize(json); - - @override - Map serialize() { - final Map 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 json) { - return new SetInputTextResult(); - } - - @override - Map toJson() => {}; -} - -/// 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 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 json) { - return new SubmitInputTextResult(json['text']); - } - - @override - Map toJson() => { - 'text': text - }; -}