aboutsummaryrefslogtreecommitdiff
path: root/v1/src/test/java/com/xtremelabs/robolectric/shadows/PreferenceScreenTest.java
blob: e2be12b8de568964e206415e205adaca19861ddb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.xtremelabs.robolectric.shadows;

import android.app.Activity;
import android.app.Dialog;
import android.preference.PreferenceScreen;
import com.xtremelabs.robolectric.Robolectric;
import com.xtremelabs.robolectric.WithTestDefaultsRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertThat;

@RunWith(WithTestDefaultsRunner.class)
public class PreferenceScreenTest {

	private PreferenceScreen screen;
	private ShadowPreferenceScreen shadow;

    @Before
    public void setUp() throws Exception {
    	screen = Robolectric.newInstanceOf(PreferenceScreen.class);
    	shadow = Robolectric.shadowOf(screen);
    }
    
	@Test
	public void shouldInheritFromPreferenceGroup() {
		assertThat(shadow, instanceOf(ShadowPreferenceGroup.class));
	}
	
	@Test
	public void shouldSetDialog() {
		Dialog dialog = new Dialog(new Activity());
		
		assertThat(screen.getDialog(), nullValue());
		shadow.setDialog(dialog);
		assertThat(screen.getDialog(), sameInstance(dialog));		
	}
}