package ch.hevs.aislab.magpie.activity;


import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

public class ActivityTest extends ActivityInstrumentationTestCase2<MagpieActivityTest>{

    private MagpieActivityTest magpieActivityTest;

    public ActivityTest() {
        super(MagpieActivityTest.class);
    }

    protected void setUp() throws Exception {
        super.setUp();
        magpieActivityTest = getActivity();
    }

    public void testPreconditions() {
        assertNotNull("magpieActivity is null", magpieActivityTest);
        magpieActivityTest.finish();
        Log.i("MagpieActivityTest", "Last call...");
    }

    //public void testAgents() {
        //int numAgents = Environment.getInstance().getRegisteredAgents().size();
        //assertEquals(1,numAgents);

        //magpieActivityTest.finish();
        //magpieActivityTest = this.getActivity();

        //int agentsAfterDestroy = Environment.getInstance().getRegisteredAgents().size();
        //Log.i("ActivityTest", "Num. of agents: " + agentsAfterDestroy);
        //Log.i("ActivityTest", "" + Environment.getInstance().getRegisteredAgents().get(2).getId());
    //}
}

@@ -93,31 +93,61 @@
 e2;%0A
+%0A
 import 
-android.util.Log
+ch.hevs.aislab.magpie.environment.Environment
 ;%0A%0Ap
@@ -505,17 +505,17 @@
  testPre
-c
+C
 ondition
@@ -597,133 +597,109 @@
     
+%7D%0A%0A
     
-magpieActivityTest.finish();%0A        Log.i(%22MagpieActivityTest%22, %22Last call...%22);%0A    %7D%0A%0A    //public void testAgents() %7B
+public void testAddAgents() %7B%0A        // First time: the agent is registered from the activity
 %0A   
@@ -699,26 +699,24 @@
 ity%0A        
-//
 int numAgent
@@ -783,18 +783,16 @@
         
-//
 assertEq
@@ -810,25 +810,24 @@
 gents);%0A
-%0A
         
 //magpie
@@ -810,34 +810,32 @@
 gents);%0A        
-//
 magpieActivityTe
@@ -843,24 +843,25 @@
 t.finish();%0A
+%0A
         //ma
@@ -858,16 +858,79 @@
       //
+ Second time: the agent is registered from the service%0A        
 magpieAc
@@ -946,13 +946,8 @@
 t = 
-this.
 getA
@@ -957,25 +957,24 @@
 vity();%0A
-%0A
         
 //int ag
@@ -969,32 +969,17 @@
     
-//int agentsAfterDestroy
+numAgents
  = E
@@ -1045,71 +1045,32 @@
     
-//Log.i(%22ActivityTest%22, %22Num. of agents: %22 + agentsAfterDestroy
+assertEquals(1,numAgents
 );%0A 
@@ -1080,17 +1080,14 @@
     
-//Log.i(%22
+magpie
 Acti
@@ -1098,87 +1098,24 @@
 Test
-%22, %22%22 + Environment.getInstance().getRegisteredAgents().get(2).getId()
+.finish(
 );%0A
+%0A
     
-//
 %7D%0A%7D%0A

Test adding agents