package ca.six.aut.robolectric;

import android.app.Application;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.util.ActivityController;

import cn.six.aut.BuildConfig;
import cn.six.aut.R;
import cn.six.robolectric.LifeCycleActivity;

import static junit.framework.Assert.assertEquals;

@RunWith(RobolectricTestRunner.class)  // 不用这个， 就在buildActivity时会错的
@Config(constants = BuildConfig.class) // 修复说找不到AndroidManifest的warning
public class LifeCycleAndResTest {

    @Test
    public void testLifecycle(){
        ActivityController<LifeCycleActivity> actvController =
            Robolectric.buildActivity(LifeCycleActivity.class).create();
        LifeCycleActivity actv = actvController.get();

        actvController.start();
        assertEquals("onCreate", actv.stage);

        actvController.resume();
        assertEquals("onResume", actv.stage);

        actvController.destroy();
        assertEquals("onDestroy", actv.stage);
    }

}

@@ -1139,10 +1139,244 @@
 %0A    %7D%0A%0A
+%0A    @Test%0A    public void testResources() %7B%0A        Application application = RuntimeEnvironment.application;%0A        String appName = application.getString(R.string.app_name);%0A        assertEquals(%22AndroidAutoTest%22, appName);%0A    %7D%0A
 %7D%0A

test resouce