Junit testing on Android

by Loki117 » Fri, 22 Jan 2010 00:55:21 GMT


Sponsored Links
 Morning all,

I am currently setting up a number of JUnit tests to get some decent
coverage of my applications.

I have noticed that Android does not seem to produce XML output files
for the JUnit tests run on device I understand that if I like I can
export them via eclipse however this is not an option for me as these
tests will eventually be automated in some form of CI implementation.

Can anyone tell me is it possible to have the tests produce an XML
document onto the device which I can at least use a pull command for?

Tom



Other Threads

1. Problem showing name of GeoPoint

Hello there,

I have a problem that I am not able to show the name of the marker on
google map.
Actually I am making the application in which we show multiple marker,
but my problem is that I have to show place name also at that marker
point.
To achieve this I did coding in such a way
public class HelloItemizedOverLay extends ItemizedOverlay {

private ArrayList<OverlayItem> overlayItem = new ArrayList<OverlayItem>
();

public HelloItemizedOverLay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
    }


    @Override
    protected OverlayItem createItem(int i) {
        return overlayItem.get(i);
    }

    @Override
    public int size() {
        return overlayItem.size();
    }

    public void addOverlay(OverlayItem overlay) {
        overlayItem.add(overlay);
        populate();
    }
}

and in this I add multiple OverlayItem by this way

boolean flag = false;
        for (int i = 0; i < size; i++) {
            if (null == place)
                continue;
            double lat = Double.parseDouble(xx.getLatitude());
            double lon = Double.parseDouble(xx.getLongitude());
            GeoPoint point = new GeoPoint(((int) (lat * 1E6)), ((int)
(lon * 1E6)));
            if (!flag) {
                controller.setCenter(point);
                flag = true;
            }
            String name = "Hello" + i;
            OverlayItem overlayItem = new OverlayItem(point, name,
name);
            itemizedOverlay.addOverlay(overlayItem);

            mOverlays.add(itemizedOverlay);
        }

But it is not showing the marker
Then I tried using motion event in the class HelloItemizedOverLay

@Override
    public boolean onTouchEvent(MotionEvent event, MapView mapView) {
        if (event.getAction() == MotionEvent.ACTION_UP) {
            GeoPoint p = mapView.getProjection().fromPixels((int)
event.getX(), (int) event.getY());
            Iterator<OverlayItem> iterator = overlayItem.iterator();
            if (Logger.ENABLE_CONSOLE_DEBUG) {
                Logger.printMessage(this.getClass().getSimpleName() +
"--OnTouchEvent() -- Point found " + p.getLatitudeE6() + "  " +
p.getLongitudeE6(), Logger.INFO);
            }
            while (iterator.hasNext()) {
                OverlayItem item = iterator.next();
                GeoPoint gp = item.getPoint();
                if (gp.getLatitudeE6() == p.getLatitudeE6() &&
gp.getLongitudeE6() == p.getLongitudeE6()) {
                    Toast.makeText(context, item.getTitle(),
Toast.LENGTH_SHORT).show();
                }
            }

        }
        return false;
    }

But looks like that toast will only be shown when user click on the
exact pixel.

What I want that when user touch the marker drawable toast should be
shown.
Can anyone help me to do this.

Vishal

-- 

2. Red square on android map

Hello,

I have written a simple map application using the google API. I have
the apikey set and the map displays properly on the android phone.
However, there is always a red square on the bottom left of the map,
that I don't know how to get rid off.
Here is the URL of the snapshot: 
http://picasaweb.google.com/mcornill/Screenshots#5399362615931619762
The java code is pasted below.
Any help is appreciated.
Thanks

Matt

import android.*;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Address;
import android.location.Geocoder;
import android.view.*;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.google.android.maps.*;
import com.google.android.maps.MapView.LayoutParams;
import android.os.Bundle;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
public class MapsActivity extends MapActivity
{
    static MapView mapView;
    MapController mc;
    GeoPoint p;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // Allow zooming
        mapView = (MapView) findViewById(R.id.mapView);
        mapView.setSatellite(true);
        mapView.setBuiltInZoomControls(true);
        mc = mapView.getController();
        Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
        try {
            List<Address> addresses = geoCoder.getFromLocationName(
                "Palo Alto, CA", 5);
            String add = "";
            if (addresses.size() > 0) {
                p = new GeoPoint(
                        (int) (addresses.get(0).getLatitude() * 1E6),
                        (int) (addresses.get(0).getLongitude() *
1E6));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        mc.animateTo(p);
        mc.setZoom(17);
        mapView.invalidate();
    }
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
}


and here is main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0oWLKpz0iuwLIE5KcYgcqCL0TPkzQOeWEOiUWOg"
        />

    <LinearLayout android:id="@+id/zoom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        />
</RelativeLayout>

-- 

3. Fw: SOLD WTS Sprint HTC Hero BNIBUnlocked...

4. Good active install rate?

5. IMPORTANT - display.getOrientation() does not work on all devices

6. arrays to be accessed by both JAVA n C thru JNI in an Android app

7. Finding Memory leak in native code