Test whole app with Espresso - android

I am taking first steps in testing in Espresso. I can find a lot of tutorials telling me how to test one, single activity with Espresso. I have never seen any tutorial - how to prepare Espresso test for whole application.
I have whole app with like 10 activities which are having of course different ways to each other.
Is there any option to test whole app navigation with Espresso?
How to test single Activites which are "inside" the app? Sometimes they need some connection with backend from user which is logged into his account. I have to always log to test account or "mock" data for it?
If I am testing one app I have to always change "launcher" activity in Manifest or there is any other option for that?
If it is newbie questions and there is any article which can provide me that information, please share it with me.
Thanks!

Once Espresso launches your main activity, then you can basically navigate to any part of the app and you do not have to worry about launching different activities. As long as you can find the elements with which you have to interact with to navigate to different parts of the app and know of the appropriate strategy (by Id, text etc.) to interact with those elements, then you can do your necessary navigation in your app.

I do not know if you got the answer to your question.
If not, take a look at Android Testing Code Lab.
https://codelabs.developers.google.com/codelabs/android-testing
I think it has all the answers to yours questions.
If you to need more help tell us here.

Related

When other apps share with my app, it kind of creates two instances of my app

I have an app that works best if the main activity is always the same activity instance, otherwise, it would be very confusing to users. When I first coded this app years ago, the solution I found was to use:
android:launchMode="singleTask"
android:taskAffinity="somestring"
And this works well for the most part, but when some apps share stuff with my app, it is like my app becomes part of their app and now it is like I have two separate instances of my app. If I go to the task switcher and select their app, it will actually go to my app. This works fine with most apps that can share stuff with my app, only some will cause this issue.
How can I get around that issue?
Edit: As it was pointed out, it is not two separate instances but my users think it is, and it is annoying them a lot.
Edit: The issue appears to be when the sharing app uses startActivityForResult instead of startActivity.

Only displaying pre-installed applications on android device

So I am using the Home sample to build an application that creates a second home screen for the user. The idea is to be able to have only one user account yet restrict certain access to chosen applications. I have managed to ensure that all of the applications are invisible in the XML yet I am struggling with how to change this to make certain apps visible.
Is it possible to write a whitelist of accepted apps for instance the preinstalled apps or child friendly apps for children who game using the android device and then put in a Java method to access this white list? This is the only way I can think to make it work.
If anyone knows the correct way can you please help.
Thanks.
Ok so I discovered how to do this.
In the home sample they provide a for loop in the Home.java file that covers all apps and displays them. It take a simple if statement to restrict the apps that can be viewed -
// for loop is here
if (info.activityInfo.applicationInfo.packageName.contains("com.android"))
//then the rest of the home sample is here.
Still very basic but provides me with a good enough UI so that kids cannot see apps I don't want them to.

Test Selective activity using robotium

I am trying to automate test cases using robotium. The problem that I am facing is that my app has, like all apps, lots of activities. So I dont want to test the whole application again and again, but only specific activity. How can I do this.
I cheat - I add a simple activity with buttons that can launch any other activity, with sample parameters, where needed. I then use Robotium to launch a specific activity and test it, rather than the full application. Once this is done though, I pretty much follow http://developer.android.com/tools/testing/activity_test.html to make sure I do proper, full-cover testing for my application.
The last step is to remove this dummy "menu" activity from the application.
in constructor of robotium test we write super("com.example.helloworld1",MainActivity.class); where instead of MainActiviry.class we can write OwnActivity.class. Here OwnActivity is the activity from where we want to start testing our application.

Android launch app inside view

Alright so I have an app that I would like to have utilize other apps. For example I have an app that does quite a number of things except for a directory look up since there is already an app that does that for my school. I know I can launch the application with intents, but that also brings them away from the navigation menu for my application. Is there anyway that I could run an app inside a view layout. I am not hopeful for this but I figured I would chance asking it anyway.
This is technically possible by using widgets. You can implement an AppWidgetHost, and other applications can create App Widgets to use inside your own app. This is how the launcher screen in Android works.
This, of course, will only work if other applications in question implement widgets. So, the general answer to your question would be no, it is not possible to host arbitrary applications or Views/Activities from other applications inside your own.
This not the Android design philosophy. You should send an Intent to the directory app, which I hope is designed to look up a result and then return it to you. The mechanism is startActivityForResult() in your app, and setResult() in the directory app.

Searching within my own application

So im building an Android application and want to include a search feature to let users use it instead of having to look through the apps many activities and pages. Cant seem to find any info on the best way to do this anywhere else. Thanks in advance
Ok so im building an app that will serve as a game guide for a popular PS3 game. Within the app will be many subjects and topics and i would like to give users the ooption to just use a search bar on the main screen of the app to search throughout the entire application and then provide them with a list of results that are clickable and take them directly to the chosen activity or place in the application. (Say it was an app for making whiskey, i would want them to be able to search on the main page for Jack Daniels instead of hitting buttons that navigate from Mainpage>American Whiskey's>Bourbon>Jack Daniels. )

Categories

Resources