Android Open Source - AndroidGraph testing Suite






From Project

Back to project page AndroidGraph.

License

The source code is released under:

MIT License

If you think the Android project AndroidGraph listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nimble.android_graph.generics;
//from ww w .jav  a2s .  c  o m
import android.util.Log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;

/**
 * A Class for testing basic network functionality
 *
 * @author Michael Leith
 * @since 02/07/2014.
 * @version 1.0
 */
public class testingSuite {

    /**
     * Pings the provided address. Put this in a thread.
     * @param pingAddr String
     * @param time final int
     */
    static public final void runPing(final String pingAddr, final int time) {
        //String pingResult = "";
        new Thread(new Runnable() {
            public void run() {
                String pingCmd = "ping " + pingAddr;
                try {
                    Runtime r = Runtime.getRuntime();
                    //Process p = r.exec(pingCmd);

                    BufferedReader in = new BufferedReader(new InputStreamReader(r.exec(pingCmd).getInputStream()));//p.getInputStream()));
                    String inputLine;
                    int i = 0;
                    while ((inputLine = in.readLine()) != null && i < time) {
                        Log.d("ping", inputLine);
                        i++;
                        // pingResult += inputLine;
                    }
                    in.close();

                } catch (IOException e) {
                    Log.e("runPing", e.toString());
                }
            }
        }).start();
    }

    /**
     * Gets the current Ip Address, printing it to logcat with the tage "Ip Address"
     */
    static public final void getIpAddress() {
        try {
            for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
                    .hasMoreElements(); ) {
                NetworkInterface intf = en.nextElement();
                if (intf.getName().contains("wlan")) {
                    for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr
                            .hasMoreElements(); ) {
                        InetAddress inetAddress = enumIpAddr.nextElement();
                        if (!inetAddress.isLoopbackAddress()
                                && (inetAddress.getAddress().length == 4)) {
                            Log.d("Ip Address", inetAddress.getHostAddress());
                        }
                    }
                }
            }
        } catch (Exception e) {
            Log.e("Ip Address", e.toString());
        }
    }
}




Java Source Code List

Nimble.com.androidgraph.ApplicationTest.java
com.nimble.android_graph.Activities.FragmentList.java
com.nimble.android_graph.Activities.GraphActivity.java
com.nimble.android_graph.Activities.GraphFragment.java
com.nimble.android_graph.Activities.GroupsFragment.java
com.nimble.android_graph.Graph.CurveGraph.java
com.nimble.android_graph.Graph.LineGraph.java
com.nimble.android_graph.Graph.Line.java
com.nimble.android_graph.Graph.ScatterGraph.java
com.nimble.android_graph.Graph.SineWave.java
com.nimble.android_graph.Graph_Base.Coord2d.java
com.nimble.android_graph.Graph_Base.GraphDataSettings.java
com.nimble.android_graph.Graph_Base.GraphDrawBackground.java
com.nimble.android_graph.Graph_Base.GraphRelateToScreen.java
com.nimble.android_graph.Graph_Base.GraphThreading.java
com.nimble.android_graph.Graph_Base.GraphTouchEvent.java
com.nimble.android_graph.Graph_Base.GraphViewDimensions.java
com.nimble.android_graph.Graph_Base.GraphView.java
com.nimble.android_graph.Graph_Base.Point.java
com.nimble.android_graph.Graph_Base.Range2d.java
com.nimble.android_graph.Graph.sine_scatter.java
com.nimble.android_graph.generics.Methods.java
com.nimble.android_graph.generics.ViewManipulators.java
com.nimble.android_graph.generics.testingSuite.java