Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

relocate and remove not used jars, using android-maven-plugin instead

  • Loading branch information...
commit e2dfdc8b45407178eae72fbf5a4ce3190b4e7b9f 1 parent 435b118
@activars authored
View
105 robotium-server/pom.not.used.xml
@@ -1,105 +0,0 @@
-??
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>robotium</artifactId>
- <groupId>com.jayway.android.robotium</groupId>
- <version>1.6.1-SNAPSHOT</version>
- </parent>
- <groupId>com.jayway.android.robotium.robotium-server</groupId>
- <artifactId>robotium-server</artifactId>
- <version>1.6.1-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>Robotium :: Remote Server</name>
- <description>Remote Server package, including app and test</description>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android</artifactId>
- <version>1.6_r2</version>
- <type>jar</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android-test</artifactId>
- <version>1.6_r2</version>
- <type>jar</type>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <profiles>
- <!-- build all profile -->
- <profile>
- <id>all</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>robotium-server-app</module>
- <module>robotium-server-test</module>
- </modules>
- </profile>
-
- <!-- App build profile -->
- <profile>
- <id>app-build</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules> <!-- only building the application here -->
- <module>robotium-server-app</module>
- </modules>
- </profile>
-
- <!-- Instrumentation test profile -->
- <profile>
- <id>instrument</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <modules>
- <module>robotium-server-test</module>
- </modules>
- </profile>
-
- <!--sign and release profile -->
- <profile>
- <id>release</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <modules>
- <module>robotium-server-app</module>
- </modules>
- </profile>
- </profiles>
- <modules>
- <module>robotium-server-app</module>
- </modules>
-
- <!--default settings common to all profiles unless overriden -->
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>maven-android-plugin</artifactId>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-</project>
View
3  robotium-server/robotium-server-app/.gitignore
@@ -1,3 +0,0 @@
-# project specific, keep the eclipse project setting for now
-!.project
-!.classpath
View
BIN  robotium-server/robotium-server-app/lib/cglib-nodep-2.2.jar
Binary file not shown
View
BIN  robotium-server/robotium-server-app/lib/json_simple-1.1.jar
Binary file not shown
View
BIN  robotium-server/robotium-server-app/lib/netty-3.2.1.Final.jar
Binary file not shown
View
BIN  robotium-server/robotium-server-app/lib/powermock-easymock-1.4-full.jar
Binary file not shown
View
181 robotium-server/robotium-server-app/pom.not.used.xml
@@ -1,181 +0,0 @@
-??
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>com.jayway.android.robotium.robotium-server</groupId>
- <artifactId>robotium-server</artifactId>
- <version>1.6.1-SNAPSHOT</version>
- </parent>
-
- <groupId>com.jayway.android.robotium.robotium-server-app</groupId>
- <artifactId>robotium-server-app</artifactId>
- <version>0.0.1</version>
- <packaging>apk</packaging>
- <name>Robotium :: Remote Server</name>
-
- <description>Robotium Server Android Application</description>
-
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <url>http://repository.jboss.org/nexus/content/groups/public/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.netty</groupId>
- <artifactId>netty</artifactId>
- <version>3.1.0.GA</version>
- <scope>provided</scope>
- </dependency>
-
-
- <dependency>
- <groupId>com.google.android</groupId>
- <artifactId>android</artifactId>
- <version>1.6_r2</version>
- <type>jar</type>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- <type>jar</type>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <!--default case. acts when no profile selected-->
- <!--
- the application gets installed into the local maven repository so that
- the instrumentation test project can use it
- -->
- <build>
- <defaultGoal>install</defaultGoal>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>maven-android-plugin</artifactId>
-
- </plugin>
-
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- <!--
- needs additional config/parameters to work: a keystore along with
- access data to it. parameters for the keystore as seen below
- -->
- <profiles>
- <profile>
- <!--
- release profile. uses keystore defined in keystore.* properties.
- signs and zipaligns the app to the target folder
- -->
- <id>release</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <build>
- <defaultGoal>install</defaultGoal>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jarsigner-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <id>signing</id>
- <goals>
- <goal>sign</goal>
- </goals>
- <phase>package</phase>
- <inherited>true</inherited>
- <configuration>
- <includes>
- <include>${project.build.directory}/target/${project.artifactId}-${project.version}.apk</include>
- </includes>
- <keystore>${keystore.location}</keystore>
- <storepass>${keystore.password}</storepass>
- <keypass>${keystore.keypass}</keypass>
- <alias>${keystore.alias}</alias>
- <verbose>true</verbose>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>maven-android-plugin</artifactId>
- <configuration>
- <zipalign>
- <verbose>true</verbose>
- <skip>false</skip><!-- defaults to true -->
- <inputApk>${project.build.directory}/${project.artifactId}-${project.version}.apk</inputApk>
- <outputApk>${project.build.directory}/RobotiumServer_v${project.version}.apk</outputApk>
- </zipalign>
- <sign>
- <debug>false</debug>
- </sign>
- </configuration>
- <executions>
- <execution>
- <id>zipalign</id>
- <phase>verify</phase>
- <goals>
- <goal>zipalign</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <profile><!-- builds an unsigned apk-->
- <id>unsign</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <build>
- <defaultGoal>install</defaultGoal>
- <finalName>RobotiumServer_v${project.version}_unsigned</finalName>
- <plugins>
- <plugin>
- <groupId>com.jayway.maven.plugins.android.generation2</groupId>
- <artifactId>maven-android-plugin</artifactId>
- <configuration>
- <sign>
- <debug>false</debug>
- </sign>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-<properties>
- <keystore.location>~/.android/debug.keystore</keystore.location>
- <keystore.password>android</keystore.password>
- <keystore.keypass>android</keystore.keypass>
- <keystore.alias>androiddebugkey</keystore.alias>
-</properties>
-
-</project>
View
92 ...ver/robotium-server-app/src/com/jayway/android/robotium/server/InstrumentationRunner.java
@@ -1,92 +0,0 @@
-package com.jayway.android.robotium.server;
-
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.Executors;
-
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.channel.group.DefaultChannelGroup;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-
-import android.app.Instrumentation;
-import android.os.Bundle;
-import android.os.Looper;
-import android.util.Log;
-
-public class InstrumentationRunner extends Instrumentation {
-
- private static final String TAG = "InstrumentationRunner";
- public static boolean isClosed = true;
- private ServerBootstrap bootstrap;
- private ChannelGroup channelGroup;
-
-
- @Override
- public void onCreate(Bundle arguments) {
- super.onCreate(arguments);
- Log.d(TAG, "Intrumentation calling onCreate");
-
- //default port number for running server
- int portNum = 8080;
- if(arguments.containsKey("port")) {
- String portString = arguments.getString("port");
- portNum = Integer.parseInt(portString);
- }
-
- Log.d(TAG, "Obtained port number from shared pref:" + portNum);
-
-
- bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(), Executors
- .newCachedThreadPool()));
-
- bootstrap.setOption("keepAlive", true);
-
- Log.d(TAG, "Server bootstrap initialized");
-
- // channel group is used for closing connection properly
- channelGroup = new DefaultChannelGroup();
-
- // Configure the pipeline factory.
- // pipline created internally, the ServerHandler can be obtained by:
- // ((ServerHandler)bootstrap.getPipeline().get(ServerPipelineFactory.SERVER_HANDLER))
- // or less safely:
- // ((ServerHandler)bootstrap.getPipeline().getLast())
- ServerPipelineFactory pipelineFactory = new ServerPipelineFactory();
- pipelineFactory.setInstrumentation(this);
- bootstrap.setPipelineFactory(pipelineFactory);
- Log.d(TAG, "Configured server pipline factory");
-
- // NOTE: This is a work around to prevent the bad address error.
- // This was a bug exposed on Android 2.2
- // http://code.google.com/p/android/issues/detail?id=9431
- System.setProperty("java.net.preferIPv6Addresses", "false");
-
- // Bind and start to accept incoming connections.
- Channel channel = bootstrap.bind(new InetSocketAddress(portNum));
- channelGroup.add(channel);
- Log.d(TAG, "Server is now running");
-
- start();
- }
-
-
- /**
- * Starts Instrumentation and pass itself to server handler
- */
- @Override
- public void onStart() {
- Looper.prepare();
-
- Log.d(TAG, "Intrumentation started");
- }
-
- public void onDestroy() {
- Log.d(TAG, "Intrumentation Destroyed");
- }
-
-
-
-}
View
259 ...tium-server/robotium-server-app/src/com/jayway/android/robotium/server/MessageWorker.java
@@ -1,259 +0,0 @@
-package com.jayway.android.robotium.server;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.MessageEvent;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.util.Log;
-
-import com.jayway.android.robotium.common.message.EventInvokeMethodMessage;
-import com.jayway.android.robotium.common.message.EventReturnValueMessage;
-import com.jayway.android.robotium.common.message.Message;
-import com.jayway.android.robotium.common.message.MessageFactory;
-import com.jayway.android.robotium.common.message.UnsupportedMessage;
-import com.jayway.android.robotium.common.util.TypeUtils;
-import com.jayway.android.robotium.solo.Solo;
-
-public class MessageWorker {
-
- private static final String TAG = "MessageWorker";
-
- private Solo mSolo;
- private Activity mActiviy;
- private Instrumentation mInstrumentation;
- private Intent mIntent;
- private static Map<String, Object> referencedObjects;
-
-
- public MessageWorker() {
- // stores weak reference of an object
- referencedObjects = Collections.synchronizedMap(new HashMap<String, Object>());
- }
-
- public void setConfiguration(Solo solo, Activity activity, Instrumentation inst, Intent intent) {
- mSolo = solo;
- mActiviy = activity;
- mInstrumentation = inst;
- mIntent = intent;
- }
-
- private void checkConfiguration() {
- if(mSolo == null || mActiviy == null || mInstrumentation == null || mIntent == null) {
- throw new IllegalArgumentException("Instrumentation missing configuration");
- }
- }
-
- public void receivedChannelConnected(ChannelStateEvent e) {
- Message responseMsg = MessageFactory.createTargetActivityRequestMessage();
- e.getChannel().write(responseMsg.toString() + "\r\n");
- }
-
- public void receivedEventInvokeMethodMessage(EventInvokeMethodMessage mMessage, ChannelFuture future, MessageEvent e) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- // a event message contains object and method was invoked
- EventInvokeMethodMessage eventMsg = mMessage;
- Log.d(TAG, (eventMsg).getMessageHeader());
-
- Method receivedMethod = eventMsg.getMethodReceived();
- // Log.d(TAG, "Calling on method:" + receivedMethod.toString());
-
- Class<?> returnType = receivedMethod.getReturnType();
- // Log.d(TAG, "Return type:" + returnType.getName());
-
- // check if this has a List Collection interface and
- boolean hasListInterface = TypeUtils.hasListInterfaceType(returnType);
- boolean hasCollectionInterface = TypeUtils.hasCollectionInterfaceType(returnType);
-
- if (eventMsg.getTargetObjectClass().getName().equals(
- Solo.class.getName())) {
- Log.d(TAG, "calling on Solo base");
- try {
-
- Object returnValue = receivedMethod.invoke(mSolo, eventMsg
- .getParameters());
- Log.d(TAG, "solo.invoked.");
- if (returnType.equals(void.class)) {
- // send success
- Message responseMsg = MessageFactory
- .createSuccessMessage();
- responseMessage(future, e, responseMsg, mMessage);
- } else {
- // response to non void return type
- responseToNonVoidReturnType(future, e, mMessage, hasListInterface, hasCollectionInterface, returnValue);
- }
-
- } catch (Exception ex){}
- } else {
- Log.d(TAG, "Calling on non-solo object");
- String objID = eventMsg.getTargetObjectId();
- Object realObj = null;
- synchronized (referencedObjects) {
- Log.d(TAG, "referencdObjects size: " + referencedObjects.size());
- Log.d(TAG, "Need find: " + objID);
- Log.d(TAG, "Has: " + referencedObjects.keySet().toString());
- if(referencedObjects.containsKey(objID)) {
- realObj = referencedObjects.get(objID);
- }
- }
-
- if(realObj != null) {
-
- // check parameters: they could be remote references.
- Class<?>[] tmpTypes = eventMsg.getParameterTypes();
- Object[] tmpParams = eventMsg.getParameters();
- Object[] checkedParams = new Object[tmpParams.length];
- for(int i = 0; i < tmpTypes.length; i++) {
- if(TypeUtils.isPrimitive(tmpTypes[i]) || tmpTypes[i].equals(Class.class)) {
- checkedParams[i] = tmpParams[i];
- } else {
- String objRemoteID = tmpParams[i].toString();
- Object refObj = referencedObjects.get(objRemoteID);
- Log.d(TAG, "Object in parameter found");
- if(refObj != null)
- checkedParams[i] = refObj;
- else
- throw new UnsupportedOperationException(
- "This may not be a remote object or the server lost reference.");
- }
- }
-
-
- Log.d(TAG, "Found remote object in hashmap");
- Object returnValue = eventMsg.getMethodReceived().invoke(realObj, checkedParams);
- Log.d(TAG, "Return value:" + returnValue.toString());
- if(eventMsg.getMethodReceived().getReturnType().getClass().equals(void.class)) {
- // no need to return value
- // send success
- Message responseMsg = MessageFactory
- .createSuccessMessage();
- responseMessage(future, e, responseMsg, mMessage);
- } else {
- // response to non void return type request
- responseToNonVoidReturnType(future, e, mMessage, hasListInterface, hasCollectionInterface, returnValue);
- }
- }
- }
- }
-
-
- private void responseToNonVoidReturnType(ChannelFuture future, MessageEvent e, EventInvokeMethodMessage mMessage, boolean hasListInterface, boolean hasCollectionInterface, Object returnValue) {
- Class<?> returnType = mMessage.getMethodReceived().getReturnType();
- // get object reference
- if (returnType.isPrimitive() || returnType.equals(String.class)) {
-
- // construct return value message, copy the original
- // message ID
- // and write to the client channel
- Message responseMsg = new EventReturnValueMessage(
- returnType, void.class,
- new Object[] { returnValue });
- responseMessage(future, e, responseMsg, mMessage);
-
- } else if (!returnType.isPrimitive()
- && !hasListInterface && !hasCollectionInterface) {
-
- String key = UUID.randomUUID().toString();
- // store the object in WeakHashMap for later
- // use
- synchronized (referencedObjects) {
- referencedObjects.put(key, returnValue);
- }
- Message responseMsg = new EventReturnValueMessage(
- returnType, void.class,
- new Object[] { key });
- responseMessage(future, e, responseMsg, mMessage);
-
- } else if (hasListInterface) {
- // if the top root is list, then cast it as a list
- // get the first element in the list to find out the
- // class type
- Object element = ((List<?>) returnValue).get(0);
- Class<?> innerClassType = element.getClass();
- // if the inner generic class is not primitive, we
- // have to constructs an object reference
- // and store it in the WeakHashMap
- Message responseMsg;
- if (!innerClassType.isPrimitive()) {
- List<String> shouldReturnValue = new ArrayList<String>();
- String key;
- for (Object ele : (List<?>) returnValue) {
- // use UUID as the object ID
- key = String.valueOf(UUID.randomUUID());
- shouldReturnValue.add(key);
- // store the object in WeakHashMap for later
- // use
- synchronized (referencedObjects) {
- referencedObjects.put(key, ele);
- }
- Log.d(TAG, "Added new, now referencdObjects size: " + referencedObjects.size());
- Log.d(TAG, "Has: " + referencedObjects.keySet().toString());
- }
-
- responseMsg = new EventReturnValueMessage(
- returnType, innerClassType,
- shouldReturnValue.toArray());
- } else {
- responseMsg = new EventReturnValueMessage(
- returnType, innerClassType,
- ((List<?>) returnValue).toArray());
- }
-
- responseMessage(future, e, responseMsg, mMessage);
- } else {
-
- // response an unsupported message
- Message responseMsg = new UnsupportedMessage(
- "Returned value only can be List, primitives and other non-collection objects.");
- responseMessage(future, e, responseMsg, mMessage);
- }
- }
-
-
- /**
- * Returns a Message for given message JSONString
- * @param msgString String message in JSON String
- */
- public Message parseMessage(String msgString) {
- Message mMessage = null;
- try {
- Log.d(TAG+":Parsing", msgString);
- mMessage = MessageFactory.parseMessageString(msgString);
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- Log.d(TAG, "Receiving MSG: " + mMessage.toString());
- return mMessage;
- }
-
- /**
- * Start the current target Intent activity
- */
- public void startTargetIntent() {
- checkConfiguration();
- mInstrumentation.startActivitySync(mIntent);
- }
-
- public ChannelFuture responseMessage(ChannelFuture future, MessageEvent e,
- Message responseMsg, Message incomingMsg) {
- responseMsg.setMessageId(incomingMsg.getMessageId());
- future = e.getChannel().write(responseMsg.toString() + "\r\n");
- Log.d(TAG, "Server replied message");
- Log.d(TAG, "MessageType: " + responseMsg.getMessageHeader());
- Log.d(TAG, "MessageType: " + responseMsg.toString());
- return future;
- }
-
-}
View
37 ...ver/robotium-server-app/src/com/jayway/android/robotium/server/RemoteControlActivity.java
@@ -1,37 +0,0 @@
-package com.jayway.android.robotium.server;
-
-import com.jayway.android.robotium.server.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.WindowManager;
-
-public class RemoteControlActivity extends Activity {
-
- // User Preferences
- public static final String PREFS = "RobotiumServerPrefs";
-
- private static final String TAG = "Robotium Remote Control";
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Log.d(TAG, "created");
- getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
- }
-
- /**
- * Check if service is running already,
- * and disable buttons if required.
- */
- public void onResume() {
- super.onResume();
- }
-
-
-
-
-}
View
138 ...tium-server/robotium-server-app/src/com/jayway/android/robotium/server/ServerHandler.java
@@ -1,138 +0,0 @@
-package com.jayway.android.robotium.server;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Logger;
-
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelFuture;
-import org.jboss.netty.channel.ChannelFutureListener;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.util.Log;
-
-import com.jayway.android.robotium.common.message.EventInvokeMethodMessage;
-import com.jayway.android.robotium.common.message.Message;
-import com.jayway.android.robotium.common.message.MessageFactory;
-import com.jayway.android.robotium.common.message.TargetActivityMessage;
-import com.jayway.android.robotium.solo.Solo;
-
-class ServerHandler extends SimpleChannelUpstreamHandler {
-
- private static final Logger logger = Logger.getLogger(ServerHandler.class
- .getName());
- private static final String TAG = "ServerHandler";
-
- private Solo mSolo;
- private Instrumentation mInstrumentation;
- private Intent mTargetIntent;
- private Activity mActivity;
- private MessageWorker messageWorker;
-
- public ServerHandler() {
- super();
- messageWorker = new MessageWorker();
- }
-
- public void setInstrumentation(Instrumentation instrumentation) {
- mInstrumentation = instrumentation;
- }
-
- @Override
- public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
- throws Exception {
- if (e instanceof ChannelStateEvent) {
- logger.info(e.toString());
- }
- super.handleUpstream(ctx, e);
- }
-
- @Override
- public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
- throws Exception {
- // first connection send out request for instrumentation class
- messageWorker.receivedChannelConnected(e);
- }
-
- @Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
-
- // We do not need to write a ChannelBuffer here.
- // We know the encoder inserted at ServerPipelineFactory will do the
- // conversion.
- ChannelFuture future = null;
- // never close for now
- boolean close = false;
-
- String messageString = (String) e.getMessage();
- // Cast to a String first.
-
- if (messageString.equals("disconnect")) {
- future = e.getChannel().write("Test End.\r\n");
- close = true;
- } else {
-
- Message mMessage = messageWorker.parseMessage((String) e
- .getMessage());
-
- if (mMessage instanceof TargetActivityMessage) {
- Log.d(TAG, ((TargetActivityMessage) mMessage)
- .getMessageHeader());
- // the message contain Instrumentation information for the
- // Activity
- String activityClassName = ((TargetActivityMessage) mMessage)
- .getTargetClassName();
-
- mTargetIntent = new Intent(Intent.ACTION_MAIN);
- mTargetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mTargetIntent.setClassName(mInstrumentation.getTargetContext()
- .getPackageName(), activityClassName);
- mActivity = mInstrumentation.startActivitySync(mTargetIntent);
-
- // initialize the solo tool
- mSolo = new Solo(mInstrumentation, mActivity);
- // set configuration for message worker
- messageWorker.setConfiguration(mSolo, mActivity,
- mInstrumentation, mTargetIntent);
-
- // create response message and copy the old message UUID
- Message responseMsg = MessageFactory.createSuccessMessage();
- messageWorker.responseMessage(future, e, responseMsg, mMessage);
-
- } else if (mMessage instanceof EventInvokeMethodMessage) {
- EventInvokeMethodMessage msg = (EventInvokeMethodMessage) mMessage;
- try {
- messageWorker.receivedEventInvokeMethodMessage(msg, future, e);
- } catch (IllegalArgumentException e1) {
- e1.printStackTrace();
- } catch (IllegalAccessException e1) {
- e1.printStackTrace();
- } catch (InvocationTargetException e1) {
- e1.printStackTrace();
- }
- }
- }
-
- if (close) {
- future.addListener(ChannelFutureListener.CLOSE);
- }
- }
-
- @Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
- Message msg = MessageFactory.createExceptionMessage(new Exception(), e
- .getCause().getMessage());
- e.getChannel().write(msg.toString() + "\r\n");
- Log.d(TAG, "Server received Exception", e.getCause());
- // exception may turn the activity off and prevent further testing.
- //messageWorker.startTargetIntent();
- //e.getChannel().close();
- }
-
-}
View
45 ...ver/robotium-server-app/src/com/jayway/android/robotium/server/ServerPipelineFactory.java
@@ -1,45 +0,0 @@
-package com.jayway.android.robotium.server;
-
-import static org.jboss.netty.channel.Channels.*;
-
-import org.jboss.netty.channel.ChannelPipeline;
- import org.jboss.netty.channel.ChannelPipelineFactory;
- import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
- import org.jboss.netty.handler.codec.frame.Delimiters;
- import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
-
-import android.app.Instrumentation;
-
-
- public class ServerPipelineFactory implements
- ChannelPipelineFactory {
-
- public static String SERVER_HANDLER = "handler";
- public static String STRING_DECODER = "decoder";
- public static String STRING_ENCODER = "encoder";
- public static String FRAMER = "framer";
- private Instrumentation mInstrumentation;
-
- public void setInstrumentation(Instrumentation instrumentation) {
- mInstrumentation = instrumentation;
- }
-
- public ChannelPipeline getPipeline() throws Exception {
- // Create a default pipeline implementation.
- ChannelPipeline pipeline = pipeline();
-
- // Add the text line codec combination first,
- pipeline.addLast(FRAMER, new DelimiterBasedFrameDecoder(
- 8192, Delimiters.lineDelimiter()));
- pipeline.addLast(STRING_DECODER, new StringDecoder());
- pipeline.addLast(STRING_ENCODER, new StringEncoder());
-
- // and then business logic.
- ServerHandler serverHandler = new ServerHandler();
- serverHandler.setInstrumentation(mInstrumentation);
- pipeline.addLast(SERVER_HANDLER, serverHandler);
-
- return pipeline;
- }
- }
View
40 ...tium-server/robotium-server-app/src/com/jayway/android/robotium/server/ServiceHelper.java
@@ -1,40 +0,0 @@
-package com.jayway.android.robotium.server;
-
-import java.util.List;
-
-import android.app.Activity;
-import android.app.ActivityManager;
-import android.app.ActivityManager.RunningServiceInfo;
-import android.content.Context;
-
-/**
- * Static methods for checking service status.
- *
- * @author Jing Dong jing.dong@activars.com
- */
-public class ServiceHelper {
-
- /**
- * Checks the service status for given context the package name.
- *
- * @param context context for the running service
- * @param pkgName Package name for the running service
- * @return true if the service is running, otherwise false
- */
- public static boolean isServiceRunning(Context context, String pkgName) {
- final ActivityManager activityManager = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE);
- final List<RunningServiceInfo> services = activityManager
- .getRunningServices(Integer.MAX_VALUE);
-
- boolean isServiceFound = false;
-
- for (int i = 0; i < services.size(); i++) {
-
- if (pkgName.equals(services.get(i).service
- .getPackageName())) {
- isServiceFound = true;
- }
- }
- return isServiceFound;
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.