// Path: sdk/src/com/sharethis/loopy/sdk/ApiCallback.java
// public abstract class ApiCallback {
// 
//     /**
//      * Called when the API request succeeded.
//      * This method executes on the main UI thread.
//      * @param result The result from the API call.
//      */
// 	public abstract void onSuccess(JSONObject result);
// 
//     /**
//      * Called when an unrecoverable error occurred during the API call.
//      * This method executes on the main UI thread.
//      * @param e The exception thrown within the async task.
//      */
// 	public void onError(Throwable e) {}
// 
//     /**
//      * Called within the async task.  Implement this if you want additional work in the async task thread.
//      * This method is NOT called on the main UI thread.
//      * @param result The result from the API call.
//      */
//     public void onProcess(JSONObject result) {}
// 
//     /**
//      * For internal use only
//      * @param payload The payload to be sent to the server
//      */
//     public void onBeforePost(Map<String, String> headers, JSONObject payload) {}
// }
// 
// Path: test/src/com/sharethis/loopy/sdk/MockLoopyState.java
// public class MockLoopyState extends LoopyState {
//     @Override
//     public void clear(Context context) {
//         super.clear(context);
//     }
// }


import android.content.Context;
import com.sharethis.loopy.sdk.ApiCallback;
import com.sharethis.loopy.sdk.MockLoopyState;
import org.json.JSONObject;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
package com.sharethis.loopy.test;



/**
 * @author Jason Polites
 */
public class LoopyStateTest extends LoopyAndroidTestCase {

    MockLoopyState state = null;

    @Override
    public void setUp() throws Exception {
        state = new MockLoopyState();
        super.setUp();
    }

    @Override
    public void tearDown() throws Exception {
        state.clear(getLocalContext());
    }

    // Integration test
    public void testSaveAndLoad() throws InterruptedException {

        String referrer = "foobar_referrer";
        String stdid = "foobar_stdid";

        Context context = getLocalContext();

        state.clear(context);
        state.load(context);

        assertNull(state.getReferrer());
        assertNull(state.getSTDID());

        state.setReferrer(referrer);
        state.setStdid(stdid);

        final CountDownLatch latch = new CountDownLatch(1);

// Path: sdk/src/com/sharethis/loopy/sdk/ApiCallback.java
// public abstract class ApiCallback {
// 
//     /**
//      * Called when the API request succeeded.
//      * This method executes on the main UI thread.
//      * @param result The result from the API call.
//      */
// 	public abstract void onSuccess(JSONObject result);
// 
//     /**
//      * Called when an unrecoverable error occurred during the API call.
//      * This method executes on the main UI thread.
//      * @param e The exception thrown within the async task.
//      */
// 	public void onError(Throwable e) {}
// 
//     /**
//      * Called within the async task.  Implement this if you want additional work in the async task thread.
//      * This method is NOT called on the main UI thread.
//      * @param result The result from the API call.
//      */
//     public void onProcess(JSONObject result) {}
// 
//     /**
//      * For internal use only
//      * @param payload The payload to be sent to the server
//      */
//     public void onBeforePost(Map<String, String> headers, JSONObject payload) {}
// }
// 
// Path: test/src/com/sharethis/loopy/sdk/MockLoopyState.java
// public class MockLoopyState extends LoopyState {
//     @Override
//     public void clear(Context context) {
//         super.clear(context);
//     }
// }


// Path: test/src/com/sharethis/loopy/test/LoopyStateTest.java
import android.content.Context;
import com.sharethis.loopy.sdk.ApiCallback;
import com.sharethis.loopy.sdk.MockLoopyState;
import org.json.JSONObject;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

package com.sharethis.loopy.test;



/**
 * @author Jason Polites
 */
public class LoopyStateTest extends LoopyAndroidTestCase {

    MockLoopyState state = null;

    @Override
    public void setUp() throws Exception {
        state = new MockLoopyState();
        super.setUp();
    }

    @Override
    public void tearDown() throws Exception {
        state.clear(getLocalContext());
    }

    // Integration test
    public void testSaveAndLoad() throws InterruptedException {

        String referrer = "foobar_referrer";
        String stdid = "foobar_stdid";

        Context context = getLocalContext();

        state.clear(context);
        state.load(context);

        assertNull(state.getReferrer());
        assertNull(state.getSTDID());

        state.setReferrer(referrer);
        state.setStdid(stdid);

        final CountDownLatch latch = new CountDownLatch(1);

        state.save(context, new ApiCallback() {