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