• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.assertNotNull;
20 import static org.junit.Assert.assertSame;
21 import static org.junit.Assert.assertTrue;
22 
23 import android.text.TextPaint;
24 import android.text.style.CharacterStyle;
25 import android.text.style.MetricAffectingSpan;
26 import android.text.style.SuperscriptSpan;
27 
28 import androidx.test.filters.SmallTest;
29 import androidx.test.runner.AndroidJUnit4;
30 
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 
34 @SmallTest
35 @RunWith(AndroidJUnit4.class)
36 public class MetricAffectingSpanTest {
37     @Test
testGetUnderlying()38     public void testGetUnderlying() {
39         MetricAffectingSpan metricAffectingSpan = new MyMetricAffectingSpan();
40         assertSame(metricAffectingSpan, metricAffectingSpan.getUnderlying());
41 
42         metricAffectingSpan = new SuperscriptSpan();
43         CharacterStyle result = CharacterStyle.wrap(metricAffectingSpan);
44         assertNotNull(result);
45         assertTrue(result instanceof MetricAffectingSpan);
46         assertSame(metricAffectingSpan, result.getUnderlying());
47     }
48 
49     private class MyMetricAffectingSpan extends MetricAffectingSpan {
50         @Override
updateMeasureState(TextPaint p)51         public void updateMeasureState(TextPaint p) {
52         }
53 
54         @Override
updateDrawState(TextPaint tp)55         public void updateDrawState(TextPaint tp) {
56         }
57     }
58 }
59