Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.text.style.cts;
     18 
     19 import static org.junit.Assert.assertNull;
     20 import static org.junit.Assert.assertSame;
     21 
     22 import android.graphics.MaskFilter;
     23 import android.support.test.filters.SmallTest;
     24 import android.support.test.runner.AndroidJUnit4;
     25 import android.text.TextPaint;
     26 import android.text.style.MaskFilterSpan;
     27 
     28 import org.junit.Test;
     29 import org.junit.runner.RunWith;
     30 
     31 @SmallTest
     32 @RunWith(AndroidJUnit4.class)
     33 public class MaskFilterSpanTest {
     34     @Test
     35     public void testConstructor() {
     36         MaskFilter mf = new MaskFilter();
     37         new MaskFilterSpan(mf);
     38         new MaskFilterSpan(null);
     39     }
     40 
     41     @Test
     42     public void testUpdateDrawState() {
     43         MaskFilter mf = new MaskFilter();
     44         MaskFilterSpan maskFilterSpan = new MaskFilterSpan(mf);
     45 
     46         TextPaint tp = new TextPaint();
     47         assertNull(tp.getMaskFilter());
     48 
     49         maskFilterSpan.updateDrawState(tp);
     50         assertSame(mf, tp.getMaskFilter());
     51     }
     52 
     53     @Test(expected=NullPointerException.class)
     54     public void testUpdateDrawStateNull() {
     55         MaskFilter mf = new MaskFilter();
     56         MaskFilterSpan maskFilterSpan = new MaskFilterSpan(mf);
     57 
     58         maskFilterSpan.updateDrawState(null);
     59     }
     60 
     61     @Test
     62     public void testGetMaskFilter() {
     63         MaskFilter expected = new MaskFilter();
     64 
     65         MaskFilterSpan maskFilterSpan = new MaskFilterSpan(expected);
     66         assertSame(expected, maskFilterSpan.getMaskFilter());
     67 
     68         maskFilterSpan = new MaskFilterSpan(null);
     69         assertNull(maskFilterSpan.getMaskFilter());
     70     }
     71 }
     72