// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; -*-
// vim: et ts=4 sts=4 sw=4 syntax=java
package com.aragaer.jtt.wadokei;

import android.test.AndroidTestCase;
import android.widget.TextView;


public class AutoresizeTextViewTest extends AndroidTestCase {

    public void testChangeTextSize() {
        float scale = getContext().getResources().getDisplayMetrics().density;
        TextView view = new AutoresizeTextView(getContext());
        view.setTextSize(42);
        view.setText("test");
        view.measure(100, 0);
        assertTrue(view.getPaint().measureText("test") <= 100);
        assertTrue(view.getTextSize() <= 42*scale);
    }

    public void testKeepSizeIfFits() {
        float scale = getContext().getResources().getDisplayMetrics().density;
        TextView view = new AutoresizeTextView(getContext());
        view.setTextSize(12);
        view.setText("test");
        view.measure(100, 0);
        assertEquals(view.getTextSize(), 12*scale);
    }
}

@@ -145,165 +145,546 @@
 oid.
+con
 te
-st.AndroidTestCase;%0Aimport android.widget.TextView;%0A%0A%0Apublic class AutoresizeTextViewTest extends AndroidTestCase %7B%0A%0A    public void testChangeTextSize() %7B
+nt.Context;%0Aimport android.support.test.runner.AndroidJUnit4;%0Aimport android.widget.TextView;%0A%0Aimport org.junit.*;%0Aimport org.junit.runner.RunWith;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport static android.support.test.InstrumentationRegistry.getTargetContext;%0A%0A%0A@RunWith(AndroidJUnit4.class)%0Apublic class AutoresizeTextViewTest %7B%0A%0A    private Context context;%0A    private TextView view;%0A    private float scale;%0A%0A    @Before public void setUp() %7B%0A        context = getTargetContext();%0A        view = new AutoresizeTextView(context);
 %0A   
@@ -684,38 +684,32 @@
 t);%0A        
-float 
 scale = 
 getContext()
@@ -692,36 +692,31 @@
     scale = 
-getC
+c
 ontext
-()
 .getResource
@@ -756,65 +756,55 @@
     
+%7D%0A%0A
     
+@
 Te
-xtView view = new AutoresizeTextView(getContext());
+st public void testChangeTextSize() %7B
 %0A   
@@ -1017,16 +1017,22 @@
  %7D%0A%0A    
+@Test 
 public v
@@ -1062,149 +1062,8 @@
 ) %7B%0A
-        float scale = getContext().getResources().getDisplayMetrics().density;%0A        TextView view = new AutoresizeTextView(getContext());%0A
     
@@ -1193,23 +1193,28 @@
 (), 12*scale
+, 0.1
 );%0A    %7D%0A%7D%0A

Rewrite AutoresizeTextView test