package edu.cmu.sv.trailscribe.tests;

import android.test.ActivityInstrumentationTestCase2;
import edu.cmu.sv.trailscribe.view.SynchronizationCenterActivity;
import edu.cmu.sv.trailscribe.R;
import android.widget.ListView;

public class SynchronizationCenterActivityTest extends ActivityInstrumentationTestCase2<SynchronizationCenterActivity> {
    private SynchronizationCenterActivity syncActivity;

    public SynchronizationCenterActivityTest() {
        super("edu.cmu.sv.trailscribe", SynchronizationCenterActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();

        syncActivity = getActivity();
    }

    public void testPreconditions() {
        assertNotNull("Sync activity not found", syncActivity);
    }

}

@@ -221,554 +221,1629 @@
 ew;%0A
-%0Apublic class SynchronizationCenterActivityTest extends ActivityInstrumentationTestCase2%3CSynchronizationCenterActivity%3E %7B%0A    private SynchronizationCenterActivity syncActivity;%0A%0A    public SynchronizationCenterActivityTest() %7B%0A        super(%22edu.cmu.sv.trailscribe%22, SynchronizationCenterActivity.class);%0A    %7D%0A%0A    @Override%0A    public void setUp() throws Exception %7B%0A        super.setUp();%0A%0A        syncActivity = getActivity();%0A    %7D%0A%0A    public void testPreconditions() %7B%0A        assertNotNull(%22Sync activity not found%22, syncActivity);%0A    %7D%0A
+import java.util.concurrent.TimeUnit;%0Aimport android.database.DataSetObserver;%0Aimport java.util.concurrent.CountDownLatch;%0Aimport android.widget.ArrayAdapter;%0Aimport edu.cmu.sv.trailscribe.model.Map;%0Aimport android.util.Log;%0A%0Apublic class SynchronizationCenterActivityTest extends ActivityInstrumentationTestCase2%3CSynchronizationCenterActivity%3E %7B%0A    private static final String LOG_TAG = %22SynchronizationCenterActivityTest%22;%0A    private static final long MAP_LIST_FETCH_TIMEOUT = 50L;%0A    private SynchronizationCenterActivity syncActivity;%0A%0A    public SynchronizationCenterActivityTest() %7B%0A        super(%22edu.cmu.sv.trailscribe%22, SynchronizationCenterActivity.class);%0A    %7D%0A%0A    @Override%0A    public void setUp() throws Exception %7B%0A        super.setUp();%0A%0A        syncActivity = getActivity();%0A    %7D%0A%0A    public void testPreconditions() %7B%0A        assertNotNull(%22Sync activity not found%22, syncActivity);%0A    %7D%0A%0A    public void testMapList_fetchMaps() %7B%0A        if (syncActivity.areMapsFetched()) %7B%0A            Log.d(LOG_TAG, %22Map data has already been fetched%22);%0A            return;%0A        %7D%0A        final CountDownLatch done = new CountDownLatch(1);%0A        syncActivity.setMapsFetchedCallback(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A                    done.countDown();%0A                %7D%0A            %7D);%0A        try %7B%0A            final boolean result = done.await(MAP_LIST_FETCH_TIMEOUT, TimeUnit.SECONDS);%0A            assertTrue(%22Fetching map list took loo long%22, result);%0A        %7D catch (InterruptedException e) %7B%0A            fail(%22Map fetching interrupted%22);%0A        %7D%0A    %7D
 %0A%7D%0A

Add test for map fetching in sync center