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