1 /* 2 * Copyright (C) 2016 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 com.android.settings.widget; 18 19 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertFalse; 21 22 import android.content.Context; 23 import android.view.View.MeasureSpec; 24 25 import org.junit.Before; 26 import org.junit.Test; 27 import org.junit.runner.RunWith; 28 import org.robolectric.RobolectricTestRunner; 29 import org.robolectric.RuntimeEnvironment; 30 31 @RunWith(RobolectricTestRunner.class) 32 public class RingProgressBarTest { 33 34 private Context mContext = RuntimeEnvironment.application; 35 36 private RingProgressBar mProgressBar; 37 38 @Before setUp()39 public void setUp() { 40 mProgressBar = new RingProgressBar(mContext); 41 } 42 43 @Test testMeasurePortrait()44 public void testMeasurePortrait() { 45 mProgressBar.measure( 46 MeasureSpec.makeMeasureSpec(100, MeasureSpec.EXACTLY), 47 MeasureSpec.makeMeasureSpec(200, MeasureSpec.EXACTLY)); 48 assertEquals(100, mProgressBar.getMeasuredHeight()); 49 assertEquals(100, mProgressBar.getMeasuredWidth()); 50 } 51 52 @Test testMeasureLandscape()53 public void testMeasureLandscape() { 54 mProgressBar.measure( 55 MeasureSpec.makeMeasureSpec(200, MeasureSpec.EXACTLY), 56 MeasureSpec.makeMeasureSpec(100, MeasureSpec.EXACTLY)); 57 assertEquals(100, mProgressBar.getMeasuredHeight()); 58 assertEquals(100, mProgressBar.getMeasuredWidth()); 59 } 60 61 @Test testDefaultAttributes()62 public void testDefaultAttributes() { 63 assertFalse(mProgressBar.isIndeterminate()); 64 assertEquals(0, mProgressBar.getProgress()); 65 assertEquals(10000, mProgressBar.getMax()); 66 } 67 } 68