#102 FIX by TikhomirovSergey · Pull Request #772 · appium/java-client

@TikhomirovSergey

Change list

  • MissingParameterException was removed
  • some code improvements in MultiTouchAction. Now it will throw IllegalArgumentException when no action is defined.

#102

Types of changes

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@TikhomirovSergey

@mykola-mokhnach

  • 💯 for picking up issues that have been waiting for three years in the backlog 👍

mykola-mokhnach

} else if (size == 1) {
} else {
//android doesn't like having multi-touch actions with only a single TouchAction...
performsTouchActions.performTouchAction(actions.build().get(0));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps touchActions.get(0) ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. Will improve soon

@TikhomirovSergey

mykola-mokhnach

checkArgument(touchActions.size() > 0,
"MultiTouch action must have at least one TouchAction added before it can be performed");
if (touchActions.size() > 1) {
performsTouchActions.performMultiTouchAction(this);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can returns this immediately here, so then else block is not needed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mykola-mokhnach
I can't understand how to do it

performsTouchActions.performMultiTouchAction(this);

is void

performsTouchActions.performTouchAction(touchActions.get(0));

returns TouchAction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        if (touchActions.size() > 1) {
            performsTouchActions.performMultiTouchAction(this);
            return this;
        }
        //android doesn't like having multi-touch actions with only a single TouchAction...
        performsTouchActions.performTouchAction(touchActions.get(0));
        return this;

mykola-mokhnach

touchActions.forEach(action -> {
listOfActionChains.add(action.getParameters().get("actions"));
});
touchActions.forEach(action ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to replace it with something like ImmutableList.Builder<Object> listOfActionChains = ImmutableList.copyOf(touchActions.stream().map(x -> x.getParameters().get("actions"))); ?

@TikhomirovSergey

@TikhomirovSergey

@mykola-mokhnach There is one more change.
Yes. There is some legacy (from Java 7 times) code which still can be here. Sometimes it is difficult to see it because of force of habit :)
@SrinivasanTarget your rewiev is is also valuable.

SrinivasanTarget

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mykola-mokhnach

@TikhomirovSergey