Skip to content

Commit

Permalink
consider scroll max iteration and ScrollDelta from capabilities (#26)
Browse files Browse the repository at this point in the history
* Modified the element_helper file to set defaultScrollMaxIteration dynamically | Rahul|Purnima|Dharsana

* Modified element helper util to set ScrollDelta dyanamically from capabilities

* Removed the unused Commmented code

* Implemented the review comments

* Upgraded the serverVersion to 0.0.25

* Updated the import path as per review comments|Rahul
  • Loading branch information
rahul-kumar-sdet authored Jul 30, 2024
1 parent 7ce1a27 commit c1569fb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:package_info_plus/package_info_plus.dart';
const MAX_TEST_DURATION_SECS = 24 * 60 * 60;
// Need a better way to fetch this for automated release, this needs to be updated along with version bump
// Can stay for now as it is not a breaking change
const serverVersion = '0.0.24';
const serverVersion = '0.0.25';

void initializeTest({Widget? app, Function? callback}) async {
IntegrationTestWidgetsFlutterBinding binding =
Expand Down
12 changes: 4 additions & 8 deletions server/lib/src/utils/element_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ enum NATIVE_ELEMENT_ATTRIBUTES { enabled, displayed, clickable }

typedef WaitPredicate = Future<bool> Function();

/// Default amount to drag by when scrolling.
const defaultScrollDelta = 64.0;

/// Default maximum number of drags during scrolling.
const defaultScrollMaxIteration = 15;

class ElementHelper {
static Future<Finder> findElement(Finder by, {String? contextId}) async {
List<Finder> elementList =
Expand Down Expand Up @@ -492,8 +486,10 @@ class ElementHelper {
Duration? settleBetweenScrollsTimeout,
Duration? dragDuration,
}) async {
delta ??= defaultScrollDelta;
maxScrolls ??= defaultScrollMaxIteration;
delta ??= FlutterDriver.instance.settings
.getSetting(FlutterSettings.flutterScrollDelta);
maxScrolls ??= FlutterDriver.instance.settings
.getSetting(FlutterSettings.flutterScrollMaxIteration);
WidgetTester tester = _getTester();
Finder scrollViewElement = scrollView != null
? await locateElement(scrollView)
Expand Down
4 changes: 3 additions & 1 deletion server/lib/src/utils/flutter_settings.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
class FlutterSettings {
Map<String, dynamic> _settings = {};
static const String flutterElementWaitTimeout = "flutterElementWaitTimeout";
static const String flutterScrollMaxIteration = "flutterScrollMaxIteration";
static const String flutterScrollDelta = "flutterScrollDelta";

FlutterSettings() {
_setDefaultSetting();
}

_setDefaultSetting() {
_settings = {flutterElementWaitTimeout: 5000};
_settings = {flutterElementWaitTimeout: 5000,flutterScrollMaxIteration: 15,flutterScrollDelta:64};
}

updateSetting(Map<String, dynamic> capabilities) {
Expand Down
2 changes: 1 addition & 1 deletion server/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: appium_flutter_server
description: "Appium Flutter server using Integration Test package for testing Flutter apps with Appium"
version: 0.0.24
version: 0.0.25
homepage: "https://github.com/AppiumTestDistribution/appium-flutter-server"

environment:
Expand Down

0 comments on commit c1569fb

Please sign in to comment.