• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package android.graphics;
2 
3 import static com.google.common.truth.Truth.assertThat;
4 
5 import androidx.test.ext.junit.runners.AndroidJUnit4;
6 import org.junit.Test;
7 import org.junit.runner.RunWith;
8 import org.robolectric.annotation.internal.DoNotInstrument;
9 
10 /** Compatibility tests for {@link Canvas} */
11 @DoNotInstrument
12 @RunWith(AndroidJUnit4.class)
13 public class CanvasTest {
14   @Test
getClipBounds_emptyClip()15   public void getClipBounds_emptyClip() {
16     Canvas canvas = new Canvas();
17     Rect r = canvas.getClipBounds();
18     assertThat(r).isEqualTo(new Rect(0, 0, 0, 0));
19     assertThat(canvas.getClipBounds(new Rect())).isFalse();
20   }
21 
22   @Test
getClipBounds_backingBitmap()23   public void getClipBounds_backingBitmap() {
24     Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
25     Canvas canvas = new Canvas(bitmap);
26     Rect r = canvas.getClipBounds();
27     assertThat(r).isEqualTo(new Rect(0, 0, 100, 100));
28     assertThat(canvas.getClipBounds(new Rect())).isTrue();
29   }
30 }
31