1 package org.robolectric.android;
2 
3 import static com.google.common.truth.Truth.assertThat;
4 import static org.junit.Assert.assertEquals;
5 import static org.junit.Assert.assertFalse;
6 
7 import android.util.Log;
8 import android.view.View;
9 import android.widget.Toast;
10 import androidx.test.core.app.ApplicationProvider;
11 import androidx.test.ext.junit.runners.AndroidJUnit4;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 
15 @RunWith(AndroidJUnit4.class)
16 public class ShadowingTest {
17 
18   @Test
testPrintlnWorks()19   public void testPrintlnWorks() throws Exception {
20     Log.println(1, "tag", "msg");
21   }
22 
23   @Test
shouldDelegateToObjectToStringIfShadowHasNone()24   public void shouldDelegateToObjectToStringIfShadowHasNone() throws Exception {
25     assertThat(new Toast(ApplicationProvider.getApplicationContext()).toString())
26         .startsWith("android.widget.Toast@");
27   }
28 
29   @Test
shouldDelegateToObjectHashCodeIfShadowHasNone()30   public void shouldDelegateToObjectHashCodeIfShadowHasNone() throws Exception {
31     assertFalse(new View(ApplicationProvider.getApplicationContext()).hashCode() == 0);
32   }
33 
34   @Test
shouldDelegateToObjectEqualsIfShadowHasNone()35   public void shouldDelegateToObjectEqualsIfShadowHasNone() throws Exception {
36     View view = new View(ApplicationProvider.getApplicationContext());
37     assertEquals(view, view);
38   }
39 }
40