Automating Xamarin.Forms UI Tests with Ranorex - android

Has anyone used Ranorex to test Forms UI's? I don't see any UI id properties that I could set from the View/Element class so I was wondering if I can set automation id's through the Forms objects. One option would be to wrap all Forms views around custom renderers and expose an ID field but that isn't an ideal solution for obvious reasons.
For iOS the method that works for Xamarin Cloud also works well with Ranorex. It doesn't work on Android though so that is still an open issue.
http://developer.xamarin.com/guides/cross-platform/xamarin-forms/uitest-and-test-cloud/
Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) => {
// http://developer.xamarin.com/recipes/testcloud/set-accessibilityidentifier-ios/
if (!string.IsNullOrWhiteSpace(e.View.StyleId)) {
e.NativeView.AccessibilityIdentifier = e.View.StyleId;
}
};

Related

Is there a way to update from Adobe Air (flash) android app to a Unity3d app and keep the local save that is in shared object?

This is the situation: We have an android game that has been published for a few years now, that was originally developed in ActionScript3 and built with Adobe Air...
Now, the problem we are facing is that because ActionScript3 is basically unsupported by most advertising and analytics SDKs, we need to update to something newer, without losing our current playerbase. So we started developing a clone of the current game in Unity3d, and also found a way to sign with the old .P12 and the playstore console lets us upload and everything.
Now to the real question: The last and current hurdle we have to overcome is find a way to preserve the current users' save games when they update to the Unity version. We use a SharedObject to store all user preferences and progress.
I have searched forums, here in SO and in the Unity3D forums and found no one asking a similar question.
But we would like to know if someone knows a way for another app, with the same signature and packagename (is basically an update to the AdobeAir app) to read the SharedObject from the AdobeAir App and parse it so it can create a local save with Unity3D (with PlayerPrefs or any other method).
The code we use to Save and Load progress from a SharedObject is this:
public function LoadVal(_id:String, _defaultValue:Object = null):Object
{
if (existSO(_id))
{
return loadSO(_id);
}
else {
return _defaultValue;
}
}
private function loadSO(id:String):Object
{
mySO = SharedObject.getLocal(nameSO);
return mySO.data[id];
}
public function existSO(id:String):Boolean
{
mySO = SharedObject.getLocal(nameSO);
return mySO.data[id] != null;
}
public function SaveVal(id:String,val:Object):void
{
mySO = SharedObject.getLocal(nameSO);
mySO.data[id] = val;
mySO.flush()
}
public function clearSO():void
{
mySO = SharedObject.getLocal(nameSO);
mySO.clear();
}

Pepper Robot - How to launch tablet applications through DialogFlow?

I'm trying to incorporate Pepper's built in Android tablet more in DialogFlow interactions. Particularly, my goal is to open applications installed on the tablet itself for people to use while they're talking with Pepper. I'm aware there is a 'j-tablet-browser' app installed on Pepper's end that can let a person browse the tablet like an ordinary Android device, but I would like to take it one step further and directly launch an Android app, like Amazon's Alexa.
The best solution I can up with is:
User says specific utterance (e.g. "Pepper, open Alexa please")
DialogFlow launches the j-tablet-browser behavior
{
"speak": "Sure, just a second",
"action": "startApp",
"action_parameters": {
"appId": "j-tablet-browser/."
}
}
User navigates the Android menu manually to tap the Alexa icon
My ideal goal is to make the process seamless:
User says specific utterance (e.g. "Pepper, open Alexa please")
DialogFlow launches the Alexa app installed on the Android tablet
Does anyone have an idea how this could be done?
This is quite a broad question so I'll try and focus on the specifics for launching an app with a Dialogflow chatbot. If you don't already have a QiSDK Dialogflow chatbot running on Pepper, there is a good tutorial here which details the full process. If you already have a chatbot implemented I hope the below steps are general enough for you to apply to your project.
This chatbot only returns text results for Pepper to say, so you'll need to make some modifications to allow particular actions to be launched.
Modifying DialogflowDataSource
Step 2 on this page of the tutorial details how to send a text query to Dialogflow and get a text response. You'll want to modify it to return the full reponse object (including actions), not just the text. Define a new function called detectIntentFullResponse for example.
// Change this
return response.queryResult.fulfillmentText
// to this
return response.queryResult
Modifying DialogflowChatbot
Step 2 on this page shows how to implement a QiSDK Chatbot. Add some logic to check for actions in the replyTo function.
var response: DetectIntentResponse? = null
// ...
response = dataSource.detectIntentFullResponse(input, dialogflowSessionId, language)
// ...
return if (reponse.action != null) {
StandardReplyReaction(
ActionReaction(qiContext, response), ReplyPriority.NORMAL
)
} else if (reponse.answer != null) {
StandardReplyReaction(
SimpleSayReaction(qiContext, reponse.answer), ReplyPriority.NORMAL
)
} else {
StandardReplyReaction(
EmptyChatbotReaction(qiContext), ReplyPriority.FALLBACK
)
}
Now make a new Class, ActionReaction. Note that the below is incomplete, but should serve as an example of how you can determine which action to run (if you want others). Look at SimpleSayReaction for more implementation details.
class ActionReaction internal constructor(context: QiContext, private val response: DetectIntentResponse) :
BaseChatbotReaction(context) {
override fun runWith(speechEngine: SpeechEngine) {
if (response.action == "launch-app") {
var appID = response.parameters.app.toString()
// launch app at appID
}
}
}
As for launching the app, various approaches are detailed in other questions, such as here. It is possible to extend this approach to do other actions, such as running or retrieving online data.

Espresso test for Notification to showing up

I want to test that when I receive push, Notification will be showing up. And it might be as well to check its properties (like title, set intent and so on.)
How can I do so?
#Before
public void setupTest() {
mData.putString(PushNotificator.KEY_PUSH_TYPE, PushType.PROJECT_OFFER.toString());
mData.putString(PushNotificator.KEY_PUSH_OBJECT, pushObjectJsonString);
mContext = InstrumentationRegistry.getContext();
}
#Test
public void projectOfferCreatedFromBundle() {
mPushNotificator = new PushNotificator(mContext);
mPushNotificator.processPush(mData);
onView(withText("111")).check(matches(withText("111"))); //how to find notification?
}
Espresso UI test framework doesn't see more than actual View. I doubt seriously that you can check any notification with Espresso.
For this purpose use another Googles testing framework uiautomator, which is described as:
UI Automator is a UI testing framework suitable for cross-app functional UI testing across system and installed apps.
Here you would find how to use it with Espresso: http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html
More information:
Documentation(I):
https://google.github.io/android-testing-support-library/docs/uiautomator/index.html
Documentation(II):
http://developer.android.com/intl/es/training/testing/ui-testing/uiautomator-testing.html
Visit also: Android Testing: UIAutomator vs Espresso

Chartboost Interstitial won't show Ads on Unity

Lately, I have been trying to add static interstitial ads into my Unity game. For some reason, I could not get the system to show anything, or even react to me. After trying to work with the base Chartboost plugin, I tried to match a tutorial that I was following and purchased Prime31's Chartboost plugin and have been using that. However, neither the base plugin, nor Prime31's plugin, seem to be allowing me to show any ads. The code is pretty much done inside a single object, and it seems simple enough.
public class Advertisement : MonoBehaviour {
public string chartboostAppID = "5461129ec909a61e38b1505b";
public string chartboostAppSignature = "672b3b34e3e358e7a003789ddc36bd2bc49ea3b5";
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);
ChartboostAndroid.init (chartboostAppID, chartboostAppSignature, true);
ChartboostAndroid.cacheInterstitial(null);
}
void OnLevelWasLoaded(int level) {
ChartboostAndroid.cacheInterstitial(null);
if(Application.loadedLevelName == "Network Lobby") {
showAds();
}
}
public static void showAds() {
Debug.Log("Showing ad");
ChartboostAndroid.showInterstitial(null);
}
}
As you can see, it's pretty straightforward. This object is created at the game's splash screen, which appears only once, and it's never destroyed until the program ends. The goal is, whenever I enter the lobby scene, I want to see an ad before going to the lobby's menus. As it is, I do see the log printing "Showing ad", so I know the function is being called. However, nothing appears. Do I need to disable the GUI system first? Is there a step I'm missing?
I have already performed the following steps:
I have created and registered the app with chartboost, as well as double and triple checked the AppID and App Signature.
I have created a publishing campaign and registered it to the app.
I double-checked the orientation and confirmed that it's correct.
I registered this specific device as a test device.
The tutorial showed a call to ChartBoostAndroid.OnStart(), but there was no function like that for me to call. Perhaps that is from an older version?
I emailed Chartboost support and have not heard from them yet. I do not have that much time on this project, so if anyone can offer help, I'd appreciate it.

Querying latest application version from the Android Market

Can I query the Android Market for the latest version of my application in code? I would like to show an update notification for the user when a new version is available.
Related questions:
Process in updating my app in the market
Is there a way to automatically update application on Android?
Android Market Application Updates
I bumped into the same problem here. So I thought... why not use AppBrain.
I wrote a small function that gets your latest app version from the AppBrain website.
public String getLatestVersionNumber()
{
String versionNumber = "0.0.0";
try
{
Document doc = Jsoup.connect("http://www.appbrain.com/app/wallpaper-switch/com.mlevit.wallpaperswitch").get();
Elements changeLog = doc.select("div.clDesc");
for (Element div : changeLog)
{
String divText = div.text();
if (divText.contains("Version"))
{
return divText.split(" ")[1];
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
return versionNumber;
}
I use the jsoup Java HTML Parser to parse the HTML and from there on it's pretty simple.
Once you've retrieved it, since it's a String the best way I can think of to compare two versions together is to remove the full stops (.) that way your version number would go from say 1.1.2 to 112 then it's just a simple matter of comparing two Integers.
I know of no way to make that query, sorry.
I found this one which might be useful for some people
https://code.google.com/p/android-query/wiki/Service
I found a work around that may just work. Name you app like this:
My App - V.1.12
Now you can quay your app page on the market. The title will be: My App - V.1.12 - Android Apps on Google Play
Assuming that you change the app name version on each release, this will work.

Categories

Resources