1package com.xtremelabs.robolectric.shadows;
2
3import android.os.Bundle;
4import com.google.android.maps.MapActivity;
5import com.xtremelabs.robolectric.WithTestDefaultsRunner;
6import org.junit.Test;
7import org.junit.runner.RunWith;
8
9@RunWith(WithTestDefaultsRunner.class)
10public class MapActivityTest {
11    @Test
12    public void onDestroy_shouldNotComplainIfLifecycleIsCorrect() throws Exception {
13        MyMapActivity mapActivity = new MyMapActivity();
14        mapActivity.onCreate(null);
15        mapActivity.onResume();
16        mapActivity.onPause();
17        mapActivity.onDestroy();
18    }
19
20    @Test(expected = IllegalStateException.class)
21    public void onDestroy_shouldComplainIfPauseIsNotCalled() throws Exception {
22        MyMapActivity mapActivity = new MyMapActivity();
23        mapActivity.onCreate(null);
24        mapActivity.onResume();
25        mapActivity.onDestroy();
26    }
27
28    private static class MyMapActivity extends MapActivity {
29        @Override protected void onCreate(Bundle bundle) {
30            super.onCreate(bundle);
31        }
32
33        @Override protected void onDestroy() {
34            super.onDestroy();
35        }
36
37        @Override protected void onPause() {
38            super.onPause();
39        }
40
41        @Override protected void onResume() {
42            super.onResume();
43        }
44
45        @Override protected boolean isRouteDisplayed() {
46            return false;
47        }
48    }
49}
50