Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update runAppInBackground method implementation for XCUITest #593

Merged
merged 1 commit into from
Mar 18, 2017

Conversation

mykola-mokhnach
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach commented Mar 7, 2017

Change list

See details.

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)

Details

This change is based on appium/appium-xcuitest-driver#381, which makes possible to minimize the application under test and then return to iOS springboard (emulates clicking Home button). The change is breaking since the format of input parameters has been changed for background API call (the old format is still supported, but shows deprecation warning).

@TikhomirovSergey
Copy link
Contributor

ping @SrinivasanTarget

Copy link
Contributor

@TikhomirovSergey TikhomirovSergey left a comment

Choose a reason for hiding this comment

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

@mykola-mokhnach Hi
There are errors of generated javadoc.
Also. Could you provide some test?

@mykola-mokhnach
Copy link
Contributor Author

  1. Where to put the test (which file)?
  2. Are tests independent? Does it break other tests if I put an app into background in my functional test?

@saikrishna321
Copy link
Member

@mykola-mokhnach
Copy link
Contributor Author

added unit tests. Please let me know if anything else is missing.

@TikhomirovSergey
Copy link
Contributor

@SrinivasanTarget loks ok.
Could you take a look and check it?

@SrinivasanTarget
Copy link
Member

@mykola-mokhnach Can you please rebase it with master?

@mykola-mokhnach
Copy link
Contributor Author

Squashed into single commit. There is nothing new in master so far

@SrinivasanTarget
Copy link
Member

Cool @mykola-mokhnach Thanks. Branch looks clean now. Will review and merge this once #594 is fixed. @TikhomirovSergey is working on fix already.

Copy link
Member

@SrinivasanTarget SrinivasanTarget left a comment

Choose a reason for hiding this comment

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

@mykola-mokhnach

PR logically LGTM. But unfortunately it doesn't work for me.Can you look into it?
https://gist.github.com/SrinivasanTarget/e3b06763e17603e15a7e9cfa7407517d

Copy link
Member

@SrinivasanTarget SrinivasanTarget left a comment

Choose a reason for hiding this comment

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

/session/CEF9E752-32C3-4F1B-A5A0-7A33D464D307/wda/homescreen Do we have this endpoint handled in Appium?

@mykola-mokhnach
Copy link
Contributor Author

Thanks for verification. Seems like there was some change in WDA API. I'll update this in Appium and let you know

@SrinivasanTarget
Copy link
Member

I'll update this in Appium and let you know

Sure buddy

@mykola-mokhnach
Copy link
Contributor Author

This PR should make it working

@mykola-mokhnach
Copy link
Contributor Author

@SrinivasanTarget The fix has been merged to xcuitest driver and the stuff should work as expected now. Please make sure the xcuitest driver version is 2.21.0 or greater

@SrinivasanTarget
Copy link
Member

SrinivasanTarget commented Mar 17, 2017 via email

@Test public void testPutIntoBackgroundWithoutRestore() {
final long msStarted = System.currentTimeMillis();
driver.runAppInBackground(-1);
assertThat(System.currentTimeMillis() - msStarted, lessThan(1000L));
Copy link
Member

Choose a reason for hiding this comment

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

Functionality worked as expected it didn't restore the app but i think it should also assert for greater than 1000ms. see below

java.lang.AssertionError:
Expected: a value less than <1000L>
but: <1080L> was greater than <1000L>

at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
at io.appium.java_client.ios.XCUIAutomationTest.testPutIntoBackgroundWithoutRestore(XCUIAutomationTest.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, this value, actually, depends on how fast the machine under test is. And Travis, as far as we can see, is quite slow :(

Copy link
Member

Choose a reason for hiding this comment

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

Yeah let's make it greater than for ideal situation.

Copy link
Member

Choose a reason for hiding this comment

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

Or is there anything else that we can assert apart form time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could assert some of application elements are not visible

Copy link
Member

Choose a reason for hiding this comment

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

yup sounds good to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

cool thanks

@SrinivasanTarget
Copy link
Member

@mykola-mokhnach Will merge this once travis and codacy are happy. Will review other PR later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants