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

Use Travis Android support #641

Merged
merged 7 commits into from
Jun 26, 2015
Merged

Conversation

WonderCsabo
Copy link
Contributor

This is a WIP. I did not squash the commits, so you can see exactly what steps I did while experimenting.

This PR:

  • uses native Travis Android
  • Travis Docker infrastructure
  • enables caching
  • enables integration tests
  • upgrades emulator to 22
  • cleans up .travis.yml
  • changes Morseflash to use Espresso

Unfortunately the Morseflash test fails sometimes, because the emulator is not unlocked despite it is instructed to. To debug this I print the build log and save the screenshots to a repo. Any help is appreciated to fix this last problem.

@mosabua
Copy link
Member

mosabua commented Jun 18, 2015

Imho we should pull this in. And maybe improve the plugin to only kick off instrumentaiton

@mosabua
Copy link
Member

mosabua commented Jun 18, 2015

Also this migrates from using robotium to espresso so we might have to update some docs. Do we still need a robotium example? Maybe not. Wdyt @simpligility/android-maven-plugins-core-committers

@WonderCsabo
Copy link
Contributor Author

Imho we should pull this in.

Well, the build fails lots of times because of the problem i described. I asked about it on adt-dev for help.

Also this migrates from using robotium to espresso

No, this migrates from plain instrumentation tests to Espresso.

And maybe improve the plugin to only kick off instrumentaiton

I do not understand.

@WonderCsabo
Copy link
Contributor Author

Also, do not pull this as is, it clearly needs a rebasing (i think), as i wrote in the OP.

@mosabua
Copy link
Member

mosabua commented Jun 18, 2015

Sure.. you can rebase and fix it up. But in general I like the content ..definitely an improvement and it fixes issue #495

@WonderCsabo
Copy link
Contributor Author

Thanks for the feedback. I agree the content is good. :) But this unlock screen thing really annoys me.

@mosabua
Copy link
Member

mosabua commented Jun 18, 2015

Maybe we can ensure via some sort of api call that it is unlocked before we start the tests. I vaguely remember we had something like that in the past.

@WonderCsabo
Copy link
Contributor Author

I found this method. However, this seems to be deprecated. Also in comments it is said that the current method is more reliable... Finally, this would add noise to the sample app. But we can try it anyway.

@mosabua
Copy link
Member

mosabua commented Jun 18, 2015

@mosabua
Copy link
Member

mosabua commented Jun 18, 2015

The unlock device thing seems horrible with code and manifest requirements. Surely there is some better way.. maybe a config on how to start up the emulator or something.

@WonderCsabo
Copy link
Contributor Author

@mosabua that script is used to wait for the emulator to start, and block until. It has nothing to do with the lock screen. Actually this PR also use that (a modified version). The lock screen is dismissed with this command (which was completely missing before).

@WonderCsabo
Copy link
Contributor Author

I asked this on adt-dev, but i am being ignored. @mosabua please ask this directly if you can...

@malachid
Copy link
Contributor

The script that Manfred was talking about was always an unreliable pain
because it was timing specific. It we turned on debug logging, it would
behave differently.

It sounds like you are trying to find something to unlock the lockscreen
once the emulator is running. Looking on Stack Exchange, it seems that the
different adb methods (like sending the menu key) are specific to certain
OS releases. What about programmatically sending a wake lock?

Alternatively, if we start up an emulator, configure it to never go to
sleep... Maybe we can take a snapshot and reuse it rather than starting a
new one?

On Fri, Jun 26, 2015, 12:39 AM Csaba Kozák [email protected] wrote:

I asked this on adt-dev
https://groups.google.com/forum/#!topic/adt-dev/19XXQ1kC15g, but i am
being ignored. @mosabua https://github.com/mosabua please ask this
directly if you can...


Reply to this email directly or view it on GitHub
#641 (comment)
.

@WonderCsabo
Copy link
Contributor Author

Maybe we can take a snapshot and reuse it rather than starting a new one?

That would mean saving the snapshot image into the repository, not something i would prefer. Or how much data it means?

The script that Manfred was talking about was always an unreliable pain because it was timing specific.

We still use that script (modified version), unfortunately there is no better solution. But that script is okay, at least it works reliably.

What about programmatically sending a wake lock?

I think i wake lock is not enough, you have to disable the lock screen also. I already linked this method, hinted by the official Android doc, but it is deprecated and horrible.

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Can we maybe create a emulator image that has no lock screen functionality at all?

@WonderCsabo
Copy link
Contributor Author

@mosabua i Googled for this for an hour (literally) and i did not found any remedy.

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

It seems ridiculous .. is nobody using emulators in CI usage? Any hints on how to get around the lock screen for CI usage running integration tests @JakeWharton @orrc @kingargyle @ducrohet

@WonderCsabo
Copy link
Contributor Author

@mosabua maybe i am a noob, but this is very annoying indeed.

@JakeWharton
Copy link
Contributor

Use adb to send keyevent 82. See:
https://github.com/JakeWharton/NotRxAndroid/blob/master/.travis.yml

On Fri, Jun 26, 2015, 10:27 AM Csaba Kozák [email protected] wrote:

@mosabua https://github.com/mosabua maybe i am a noob, but this is very
annoying indeed.


Reply to this email directly or view it on GitHub
#641 (comment)
.

@JakeWharton
Copy link
Contributor

Can also have test runner unlock and wake up the device:
https://github.com/JakeWharton/u2020/blob/master/src/androidTestInternal/java/com/jakewharton/u2020/U2020TestRunner.java

On Fri, Jun 26, 2015, 10:38 AM Jake Wharton [email protected] wrote:

Use adb to send keyevent 82. See:
https://github.com/JakeWharton/NotRxAndroid/blob/master/.travis.yml

On Fri, Jun 26, 2015, 10:27 AM Csaba Kozák [email protected]
wrote:

@mosabua https://github.com/mosabua maybe i am a noob, but this is
very annoying indeed.


Reply to this email directly or view it on GitHub
#641 (comment)
.

@WonderCsabo
Copy link
Contributor Author

@JakeWharton Thanks! We already use that, and it turned out sometimes that command does not unlock the emulator. At least the screenshots says that.

@WonderCsabo
Copy link
Contributor Author

I try the second approach ASAP.

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Thanks @JakeWharton ... @WonderCsabo maybe it is working and the screenshots are just a timing issue. Maybe if we get it to pass consistently, even without screenshots, that would be good.

@WonderCsabo
Copy link
Contributor Author

@mosabua the screenshots are fine i think. Actually our tests are failing, because Espresso is complaining about the unfocused window. The window is unfocused because the lock screen is on top and not our Activity.

@WonderCsabo
Copy link
Contributor Author

This is the failure we get beause of the locked screen.

@malachid
Copy link
Contributor

I saw others had the same problem a year ago on another project and
contributed a fix

https://github.com/finn-no/android_emulator_hacks

Malachi de Ælfweald
http://www.google.com/profiles/malachid

On Fri, Jun 26, 2015 at 10:46 AM, Csaba Kozák [email protected]
wrote:

This
https://travis-ci.org/WonderCsabo/maven-android-plugin/builds/67328053#L3875
is the failure we get beause of the locked screen.


Reply to this email directly or view it on GitHub
#641 (comment)
.

@WonderCsabo WonderCsabo force-pushed the travisAndroid branch 2 times, most recently from bfd8457 to 26c68cf Compare June 26, 2015 18:21
@WonderCsabo
Copy link
Contributor Author

@mosabua it seems it fixed our problem, thanks to @JakeWharton. However, we had to add two permissions to the app manifest. I remember you did not like that. Are you okay with it? If not do you have an idea to not add this to the app manifest directly?

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Lets just add it and get this merged. For production usage I would not like that but you could always modify the manifest in a profile or whatever. Lets not worry about this though.

@WonderCsabo
Copy link
Contributor Author

@mosabua let me clean up the commit history, then you can merge it.

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Sounds good. Alternatively I can merge it manually and squash it. Or you can create a new branch off it that does that and a new pull request ;-)

If you want me to squash it just let me know the details for the commit summary...

@WonderCsabo
Copy link
Contributor Author

I am rebasing this branch.

@WonderCsabo WonderCsabo force-pushed the travisAndroid branch 2 times, most recently from e351bab to ab56ae1 Compare June 26, 2015 21:16
@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Sounds good.

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Ping me when you are happy and want me to merge. Dont forget the changelog entry ;-)

@WonderCsabo
Copy link
Contributor Author

Done, i hope you the change grouping is okay. Let's wait for the CI.

WonderCsabo added a commit to WonderCsabo/maven-android-plugin that referenced this pull request Jun 26, 2015
WonderCsabo added a commit to WonderCsabo/maven-android-plugin that referenced this pull request Jun 26, 2015
@WonderCsabo
Copy link
Contributor Author

@mosabua i think this is finished.

mosabua added a commit that referenced this pull request Jun 26, 2015
@mosabua mosabua merged commit 9326ba3 into simpligility:master Jun 26, 2015
@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

You rock @WonderCsabo ;-)

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

Check it out @simpligility/android-maven-plugins-core-committers

@mosabua
Copy link
Member

mosabua commented Jun 26, 2015

And now master builds and we are green ;-)

@malachid
Copy link
Contributor

Sweet. Great job Csaba.

On Fri, Jun 26, 2015, 4:14 PM Manfred Moser [email protected]
wrote:

And now master builds and we are green ;-)


Reply to this email directly or view it on GitHub
#641 (comment)
.

@WonderCsabo WonderCsabo deleted the travisAndroid branch September 3, 2015 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants