Home | History | Annotate | Download | only in widget
      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.settingslib.widget;
     18 
     19 import android.app.Activity;
     20 import android.graphics.drawable.AnimatedRotateDrawable;
     21 import android.view.View;
     22 import com.android.settingslib.TestConfig;
     23 import org.junit.Before;
     24 import org.junit.Test;
     25 import org.junit.runner.RunWith;
     26 import org.robolectric.Robolectric;
     27 import org.robolectric.RobolectricTestRunner;
     28 import org.robolectric.annotation.Config;
     29 
     30 import static com.google.common.truth.Truth.assertThat;
     31 
     32 @RunWith(RobolectricTestRunner.class)
     33 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
     34 public class AnimatedImageViewTest {
     35     private AnimatedImageView mAnimatedImageView;
     36 
     37     @Before
     38     public void setUp() {
     39         Activity activity = Robolectric.setupActivity(Activity.class);
     40         mAnimatedImageView = new AnimatedImageView(activity);
     41         mAnimatedImageView.setImageDrawable(new AnimatedRotateDrawable());
     42     }
     43 
     44     @Test
     45     public void testAnimation_ViewVisible_AnimationRunning() {
     46         mAnimatedImageView.setVisibility(View.VISIBLE);
     47         mAnimatedImageView.setAnimating(true);
     48         AnimatedRotateDrawable drawable = (AnimatedRotateDrawable) mAnimatedImageView.getDrawable();
     49         assertThat(drawable.isRunning()).isTrue();
     50     }
     51 
     52 }
     53