I am using android studio with an emulator. When I change the code, I need to test it. The thing is, sometimes I have to perform a dozen click, fetch data from internet, etc, until I get to the screen I want to.
Is there a way for me to "save" the activity state, and quickly jump back to that activity after having changed the code? That would save me hours of dev.
I'm opened to any other tips that would speed up my testing process
Thanks!
You can Make the Activity you are trying to test as your launching Activity and feed it with seed data that you are trying to fetch from the internet. It will save you a lot of man hours. I would suggest you to go for a TDD approach rather using Robotium where you can test all the functional code of yours.
Related
I have a Delphi application and my main form has an onCreate event with code that I only want to run once and the first time the application is opened on a computer.
So let's say I download the app from Google Play Store or Microsoft Store and run it for the first time, then my onCreate code must run. But if I open the app for a second time then the code must not run again.
What would be the best way to do this? I'm looking for a cross-platform solution that will work on all FMX supported platforms.
(I was thinking of simply creating a hidden text file somewhere and if it doesn't exist then it means the app is opened for the first time and thus run the onCreate code. So any other ideas or ways?)
I've concluded that simply creating a text file on the computer and checking if it exists or not would be the easiest and fastest way to see if the user has opened the app before or not.
Someone in the comments did mention about using SharedPreferences on Android and NSUserDefaults on iOS, but I've decided that text files would be the best for my case.
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.
In my UWP-App I want to create an app internal contactbook page. I can select a contact and return the selected contact back to the page where I opened the contactbook.
In Android where I come from there is a function called "startActivityForResult" which opens an activity gets the return value when finished.
I want to create the same behaviour.
I did this with Frame.Navigate(typeof(ContactBook)) and then when the contact is selected I navigate back with Frame.Navigate(typeof(PreviousPage), selectedContact)
The method Frame.GoBack() is useless in this case because I can't pass a parameter.
How can I solve this problem?
I'm not 100% familiar with android and "startActivityForResult" but are you looking to navigate the entire frame away? There isn't any equivalent in UWP apps, nor is there even really one for WPF's showDialog(), which is probably what you're looking for.
You only have a few options and none of them are really "amazing" per-say.
You can do what you've done above, which is navigate away to the page that has all the contacts, then navigate to a new page but depending on how your app is layed out you might be losing data on the page (since it's a new instance and not a back in the stack so you can't really cache it). You also can't navigate to an instance of a page either, it's only to a new page or through the stack from back / forward. If you use GoBack though and cache the page (using the "required" mode for caching) then you could do some dirty lookup of a stored value in a static class (I know, ugly and not MVVM) or setting a local settings value and reading that in the OnNavigatedTo() method for the page before.
If you don't NEED to use frame movement, you can use a flyout or a custom flyout user control to build a popup of sorts that will display the XAML for the page instead of a page frame. This will have a few difficulties with resizing (so more so for W10 than W10M) and such but you'll be able to not transition out of the frame itself. Then you can see the value of the selected and then on the submit event, you can just work with the page since it's already open.
If need be you could build a custom usercontrol for the flyout and put some custom dependency properties that can be bound for MVVM, it really all depends on what and how you're doing it.
So short answer, there is no fast way of achieveing what you're looking for and that does seem like an issue with the API. I would make the suggestion on the API's uservoice (https://wpdev.uservoice.com/forums/110705-universal-windows-platform) and try to get it upvoted!
There isn't any equivalent in UWP apps, nor is there even really one for WPF's showDialog(), which is probably what you're looking for.
#Daniel, no, there is a equivalent in UWP apps. Please refer to Launch an app for results, you can follow the tutorial in that doc to achieve this.
To do this, you will need to create two apps. One is the app which will launch the result app (let say "main app"), the other app here should be the contact-book app. The contact-book app will behavior like a modal window, and the main app will wait for the result of the contact-book app.
But in an UWP app, you can use ContactStore class to access the database that contains contacts.
So, you will need to reconsider if that is necessary to create a contact app by yourself.
Edit:
I may misunderstand your question, you just want your page to behavior like contact-book, not want to create a contact-book by yourself. But anyway, it's the same, you can create another app to hold your page which you want to launch from your main app.
I'm developing an AR app that's going to contain an activity with a Unity3d model. Creating such an activity is something I can do now but I've come across another problem.
To show a unity model in an activity, the latter has to extend the UnityPlayerActivity class. What if I want to load the 3D model as soon as my launch activity starts but show it in one of the following ones? My goal would be to have the user wait for the model to be loaded as the app starts (e.g. when I show them a splash screen) so that when they change activity to the one that contains the AR view the waiting time is minimal.
I know this is possible in iOS and would like to replicate that behaviour in android as well. Any ideas?
As I suspected - there aren't any answers to my question.
I'll answer my question myself with a workaround, then, and wait for someone else to come up or for the creators of Unity to provide us with the same functionality under Android as under iOS.
To achieve the desired effect, I decided to only have 1 activity and multiple fragments. The activity extends UnityPlayerActivity meaning that when it loads, that takes the time Unity needs to load. Then, when navigating throughout the app, I only swap fragments containing entire screens and make use of the UnityPlayer.pause() and UnityPlayer.resume() methods, as well as the setVisibility method to make it go away.
Hope that helps if anyone has any similar issues.
Before reading this, note that I'm not talking about capturing the screen.
Motivation
Many times, in order to test apps, we need to go over many activities (including a loading/splash screen) till we reach the one we've just updated in order to test it out.
I want to reduce this time , by capturing the exact state of the app (memory,preferences,activities stack,...) in order to go there again.
Another example : The QA team could show me in which case a bug occurs, without having to show me the whole process till they got there (since it might not be reproducible) and then I could run the app, and know exactly where the exception was thrown and go there directly via the DDMS's logs .
Another example: We work on a game, and the QA team have tested the game for hours and reached a certain stage, and would like to save the current state of the app in order to test it from this point and make multiple tests on it, instead of running the app from the beginning each time , wait for it to load and also finish all of the stages till they reach this stage.
I think there are other scenarios where such a thing could be useful.
The problem
Such a thing is probably possible in the VM world (for example virualBox) , and it's probably possible for android emulators (at least according to this post , but they also say it's "finicky" , not sure what that means in this context) , but not for devices.
The above example, though they might work, they work for the entire OS and not for a specific app, so even if I choose to use them, it takes a long time to use (plus I need to use an emulator which is usually much slower than any device) .
I'm pretty sure that the current API doesn't support such a thing (and it's probably a good thing, for security reasons).
The question
Is it possible to capture&load entire app state by using ROOT ? Maybe by being a system app too?
Maybe there is already an app for this task?
Since it's very usual that an application saves its whole state in SharedPreferences and persistence in DB, in most apps you can backup and restore data and state using adb backup and adb restore, respectively:
Backup:
adb backup -f app.ab com.company.app
Restore:
adb restore app.ab
PS: This feature was introduced in ICS, and it's not required to be root.
More information in this tutorial.