Skip to content

Commit

Permalink
feat(utils): added well know step and driver helper method to long pr…
Browse files Browse the repository at this point in the history
…ess a widget
  • Loading branch information
jonsamwell committed Aug 11, 2020
1 parent 26dc2e4 commit cc1196b
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 62 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [1.1.8+7] - 11/08/2020
- Added well know steps and a driver helper method to long press a widget

```
When I long press "controlKey" button
When I long press "controlKey" icon for 1500 milliseconds
```

## [1.1.8+6] - 05/08/2020
- Upgraded to latest Gherkin library version which fixes issues with non-alpha-numeric characters in multiline strings and comments https://github.com/jonsamwell/dart_gherkin/issues/14 https://github.com/jonsamwell/dart_gherkin/issues/15 https://github.com/jonsamwell/dart_gherkin/issues/16

Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -926,16 +926,19 @@ For convenience the library defines a number of pre-defined steps so you can get
| I restart the app | Restarts the app under test | `Then I restart the app` |
| I tap the back button | Taps the page default back button widget | `Then I tap the back button` |
| I expect a {string} that contains the text {string} to also contain the text {string} | Discovers a sibling based on its parent widget type and asserts that the both text string exist within the parent. | `Then I expect a "Row" that contains the text "X" to also contain the text "Y"` |
| I swipe [down\|left\|right\|up] by {int} pixels on the {string} | Swipes in a cardinal direction on a widget discovered by its key. | `Then I swipe up by 800 pixels on the "login_screen"`, `Then I swipe left by 200 pixels on the "dismissible_list_item"` |
| I swipe [down\|left\|right\|up] by {int} pixels on the {string} | Swipes in a cardinal direction on a widget discovered by its key. | `Then I swipe up by 800 pixels on the "login_screen"` , `Then I swipe left by 200 pixels on the "dismissible_list_item"` |
| I swipe [down\|left\|right\|up] by {int} pixels on the on the [button\|element\|label\|field\|text\|widget\|dialog\|popup] that contains the text {string} | Swipes in a cardinal direction on a widget discovered by its test. | `Then I swipe left by 400 pixels on the widget that contains the text "Dismiss Me"` |
| I tap the [button\|element\|label\|field\|text\|widget] that contains the text {string} within the {string} | Taps a widget that contains the text within another widget. If the text is not visible, the ancestor will be scrolled. | `Then I tap the label that contains the text "Logout" within the "user_settings_list"` |
| I tap the [button\|element\|label\|icon\|field\|text\|widget] of type {string} | Taps a widget of type. | `Then I tap the element of type "MaterialButton"`, `Then I tap the label of type "ListTile"`, `Then I tap the field of type "TextField"` |
| I tap the [button\|element\|label\|icon\|field\|text\|widget] of type {string} | Taps a widget of type. | `Then I tap the element of type "MaterialButton"` , `Then I tap the label of type "ListTile"` , `Then I tap the field of type "TextField"` |
| I tap the [button\|element\|label\|icon\|field\|text\|widget] of type {string} within the {string} | Taps a widget of type within another widget. | `Then I tap the element of type "MaterialButton" within the "user_settings_list"` |
| I tap the [button\|element\|label\|icon\|field\|text\|widget] that contains the text {string} | Taps a widget that contains text. | `Then I tap the label that contains the text "Logout"`, `Then I tap the button that contains the text "Sign up"`, `Then I tap the widget that contains the text "My User Profile"` |
| I expect the text {string} to be [present\|absent] | Asserts the existence of text on the screen. | `Then I expect the text "Logout" to be present`, `But I expect the text "Signup" to be absent` |
| I expect the text {string} to be [present\|absent] within the {string} | Asserts the existence of text within a parent widget. | `Then I expect the text "Logout" to be present within the "user_settings_list"`, `But I expect the text "Signup" to be absent within the "login_screen"` |
| I wait until the {string} is [present\absent] | Delays until a widget is present or absent. | `Then I wait until the "login_loading_indicator" is absent`, `And I wait until the "login_screen" is present` |
| I wait until the [button\|element\|label\|icon\|field\|text\|widget] of type {string} is [present\absent] | Waits until a widget type is present or absent. | `Then I wait until the element of type "ProgressIndicator" is absent`, `And I wait until the button of type "MaterialButton" is present` |
| I tap the [button\|element\|label\|icon\|field\|text\|widget] that contains the text {string} | Taps a widget that contains text. | `Then I tap the label that contains the text "Logout"` , `Then I tap the button that contains the text "Sign up"` , `Then I tap the widget that contains the text "My User Profile"` |
| I expect the text {string} to be [present\|absent] | Asserts the existence of text on the screen. | `Then I expect the text "Logout" to be present` , `But I expect the text "Signup" to be absent` |
| I expect the text {string} to be [present\|absent] within the {string} | Asserts the existence of text within a parent widget. | `Then I expect the text "Logout" to be present within the "user_settings_list"` , `But I expect the text "Signup" to be absent within the "login_screen"` |
| I wait until the {string} is [present\absent] | Delays until a widget is present or absent. | `Then I wait until the "login_loading_indicator" is absent` , `And I wait until the "login_screen" is present` |
| I wait until the [button\|element\|label\|icon\|field\|text\|widget] of type {string} is [present\absent] | Waits until a widget type is present or absent. | `Then I wait until the element of type "ProgressIndicator" is absent` , `And I wait until the button of type "MaterialButton" is present` |
| I long press the {string} [button\|element\|label\|icon\|field\|text\|widget] | Scrolls into view and long presses the widget for 500 milliseconds. | `When I long press "controlKey" button` |
| I long press the {string} [button\|element\|label\|icon\|field\|text\|widget] without scrolling it into view | Long presses the widget for 500 milliseconds. | `When I long press "controlKey" button without scrolling it into view` |
| I long press the {string} [button\|element\|label\|icon\|field\|text\|widget] for {int} milliseconds | Scrolls into view and long presses the widget for the give number of milliseconds. | `When I long press "controlKey" button without scrolling it into view for 1500 milliseconds` |

#### Flutter Driver Utilities

Expand Down
4 changes: 4 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\Google\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
20 changes: 19 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class MyHomePage extends StatefulWidget {

class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
bool hasLongPressedText = false;

void _incrementCounter() {
setState(() {
Expand Down Expand Up @@ -91,7 +92,24 @@ class _MyHomePageState extends State<MyHomePage> {
MaterialPageRoute(builder: (context) => PageTwo()),
);
},
)
),
GestureDetector(
onLongPress: () {
setState(() {
hasLongPressedText = true;
});
},
child: Container(
color:
hasLongPressedText ? Colors.blueGrey : Colors.transparent,
child: Text(
hasLongPressedText
? 'Text has been long pressed!'
: 'Text that has not been long pressed',
key: const Key('longPressText'),
),
),
),
],
),
),
Expand Down
6 changes: 6 additions & 0 deletions example/test_driver/features/long_press_widget.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Interaction

Scenario: Widget can be long pressed
Given I expect the "longPressText" to be "Text that has not been long pressed"
When I long press the "longPressText" text
Then I expect the "longPressText" to be "Text has been long pressed!"
Loading

0 comments on commit cc1196b

Please sign in to comment.