How to verify redirection to Google Play Store - robotium

Using Robotium, how do I check the redirection to Google Play Store?
Steps:
Click on a link from a listview from the test app.
Verify it redirects to Google Play Store.
I noticed that while Google Play Store is open, my test app is actually open underneath also. (I printed out all the views)
Therefore, I cannot do "assert xyz view from test app does NOT exist".
How do I check the redirection to Google Play?

Is it possible? sort of, unfortunately robotium makes it very hard to do so easily, this is because of the way that robotium tracks what the current activity is, if you was using straight instrumentation it would be as easy as having an intent filter set up before you click the view/perform action that launches the play store, then you can assert that your filter has in fact been hit (which proves that the google play store would in fact be launched if you did not have the filter).
As you are using robotium though, you cannot do this so easily as robotium has already got an intent filter up that matches everything so this means you are going to have to do some horribleness with reflection.
What you will need to do is:
Get Hold of the private member of the instrumentation class called mActivityMonitors, in this list of activity monitors you will find there is one inside of it, this will be robotiums activity monitor, save this somewhere then remove it from the list.
You will then need to add your own it will look something like to test googleplay launches (i suggest reading about Intent filters on the android api documents site)
Instrumentation inst = getInstrumentation();
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_View);
ActivityMonitor monitor = inst.addMonitor(intentFilter, null, true); //true is imporant it blocks the activity from launching so that your test can continue.
assertEquals(0, monitor.getHits());
//do action that fires activity
assertEquals(1, monitor.getHits());
inst.removeMonitor(monitor);
You will now need to readd the activity monitor you removed earlier so that robotium continues to work as expected. I am not on a machine that i can actually test this all on but i have used this technique before.

Related

The number of times a custom event happened is not being updated on my dashboard

I've been able to distinguish between the live build and the test build on my Android app. Everything works perfectly on the test version. I can see the live events and when I go and see the number of clicks for an event, that gets updated too. However, on the live build of my app, I can see the live events but the number of clicks is not being updated. All the events still show empty analytics. What could be wrong?
Amruta from Branch.io here:
Based on your description it looks like your App is still using the test key. If your App has both the Live and Test key added to the Manifest, and you have the debug mode enabled, your App will continue using the Test key. You should make sure that your App is using the Live key.
You can ensure that your app is using the Live key by using a Branch link from the Live version of your App. On clicking on the link, the link parameters received in the callback should have the parameter '+clicked_branch_link: true'.
If the parameter 'clicked_branch_link' is set to false it means that your App is still using the test key.
If you still continue to face issues, I would suggest writing to integrations#branch.io and they can help you resolve any issues you are facing.

How do I notify users of new content available in tvOS apps from the home screen?

Push notifications have been left out of tvOS (understandably so) but the docs seem to contradict themselves in alerting users to the fact that there is something new available in your tvOS app.
Here it seems to say that you can add an app badge: https://developer.apple.com/library/prerelease/tvos/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/WhatAreRemoteNotif.html
Here it says they've been removed from UIKit: https://developer.apple.com/library/prerelease/tvos/releasenotes/General/tvOS90APIDiffs/Objective-C/UIKit.html
Removed UIApplication.applicationIconBadgeNumber
Assuming the badge approach is not supported in this release, does anyone know the best practice for alerting a user that there is new content in your app without the user taking an explicit action? ie focusing on the app and showing them something in TopShelf?
I encountered the same problem and dived into this. Probably your best way is to update the topshelf with latest items, which is my way to solve this for now. You can use network calls to update the topshelf with content from your backend.
This depends on the type of application. E.g. showing the latest top movies for a movies app.
You can trigger an update of the topshelf after your network call completed using the following code:
NSNotificationCenter.defaultCenter().postNotificationName(TVTopShelfItemsDidChangeNotification, object: nil)
Make sure to implement the TVTopShelfProvider which should be clear using the following documentation:
This protocol is adopted by the principal class of an app’s TV Services extension. Apps that implement this extension can provide dynamic content to the Top Shelf element rather than having the system use the static image submitted with the app. The topShelfStyle property specifies the interface style you want, and the topShelfItems property specifies the content items to display. Whenever you change the content provided by the extension, post a TVTopShelfItemsDidChangeNotification notification to prompt the system to reload your content.
Icon badges are removed for app icons, push notifications as well (except for silent push notifications).

Confused with IOS Deep linking

I'll just want to ask if someone here know the step by step process of creating a deep link for an IOS app? I've tried to read some articles but it did not give me absolute answers. Thank you :)
Deep linking is basically just setting up url to your app so that other apps can launch it with information. The can launch to certain parts of the app if you set it up so that your app reacts to certain urls. So there are a few things that you have to do. For this example I will use two apps. If you are trying to integrate with an existing app you just have to find out what their url schemes are. So for this example I will use 'Messages' as one app and 'Schedule' as another.
First: in the 'Messages' app we will need to setup the schemes our Schedule app to call.
So open up your first app we need to add schemes so other apps can open it. Go to your info.plist click the little + and type URL types hit the triangle to expand and hit the + type URL Schemes and within that one add an item and put your apps name in it. Also add URL identifier along with $(PRODUCT_BUNDLE_IDENTIFIER) as the value. `
Then we just have to add the apps that we can open so hit the top level + again and add LSApplicationQueriesSchemes This whitlists the apps so we can evaluate weather or not they are installed on the device.
Now we can jump over to the other app and create a way to call this. For this example lets make it happen when we press a button.
IBAction launchMessagesApp() {
let url = NSURL(string: "Messages://") where UIApplication.sharedApplication().canOpenURL(url) {
self.launchAppWithURL(url, name: "Messages")
}
The canOpenURL(url) checks to see if the application is on the device. If you wanted to you could launch the app store to your app if that retuned false. then launchAppWithURL actually launches it. That is the basic setup you may also want to have multiple things happen so you may have multiple url schemes that launch the same app but take it to different parts of the app. In the app delegate of the app in the function
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
print(url)
//Any customizations for the app here
}
You can do anything you can imagine.
Have you checked out Turnpike? It's an open source tool for enabling deep linking in iOS apps. http://urxtech.github.io/#GettingStarted
If you want to create a deeplink you might need to do some server code to detect the user device/browser and do some actions based on this.
I've created a tool that simplify this process, you can check it here:
http://www.uppurl.com/
It's mainly a short link tool that checks for user device and give him the right url based on his devices. With this tool you don't need to write any server code and it also takes care of different devices, operating systems and browsers.

Verifying toasts using Appium , and get server reaction to button clicks

i'm new to android automation testing and i recently started to work with Appium.
I use it for android native app automation.
I have 2 question -
is there a way to verify toasts?
the latest posts i saw which referred to this issue are from the mid of 2014
and i wanted to know if there's something new in this subject before i will find another tool to run my tests with (as i understand selendroid can verify toasts).
is there a way to catch the http request which my app sends to the server when i'm pressing a button, during the automatic test?
something like a listener which works in the backround and wait for clicks?
tnx
To verify toast messages you can use one of image recognition libraries. For ruby I use RTesseract together with image processor RMgick
Idea is simple:
make toast message to appear
take few screenshots
iterate over taken screenshots and look for text
You may play with image processing, to increase recognition quality.
Here you can find code snippet which I use in my framework: link

Provide an OSX Service Without Launching the App?

I have successfully implemented a "faceless service" (background-only app with .service extension) and get it to work (see this question), based on Apple's documentation and other tutorials on the web.
Now, I want to advertise a service from an existing, single-window GUI app that I have.
I have setup the Info.plist file of my app to advertise the service, and it gets installed when I build the app.
But when I invoke the service from the context menu in (say) TextEdit.app (my service colours the selected text based on a certain criterion), my app gets launched, main window and everything. To make things worse, I am right-clicking on a TextEdit window that is in a secondary monitor, so my app's main window appears for an instant in the secondary monitor, then quickly repositions into the main monitor (this might have something to do with my window-centering logic, but nevermind...).
I would like to provide the service (i.e., have the class that provides the service in my app
instantiated and execute its method in response to the request), without my app appearing on the Dock or showing its window and main menu.
Is this possible? Safari advertises "Search With Google", so it should be possible...
EDIT: Now that I think about it, "Search With Google" must launch Safari every time in order to work, so this remark does not apply.
Perhaps I can put some logic in -applicationWillFinishLaunching/-applicationDidFinishLaunching to determine if the app is being launched in response to a service, and skip creating the window(notice the lack of withOptions: in OSX)?
But still, that doesn't feel right.
It does have a lame version of withOptions: -- NSApplicationLaunchIsDefaultLaunchKey tells you if your application was launched to either:
open or print a file, to perform a Service action, if the app had saved state that will be restored, or if the app launch was in some other sense not a default launch
So in your applicationDidFinishLaunching you can see if that key is in the notification and set to NO. Unfortunately, the main way to tell that it is one of the possibilities other than the Service, you have to detect and record whether or not you also got an application:openFile:, etc.