1/* 2 * Copyright (C) 2017 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 17package android.support.graphics.drawable.tests; 18 19import android.app.Activity; 20import android.support.graphics.drawable.AnimatedVectorDrawableCompat; 21import android.support.graphics.drawable.animated.test.R; 22import android.support.test.filters.MediumTest; 23import android.support.test.rule.ActivityTestRule; 24 25import org.junit.Before; 26import org.junit.Rule; 27import org.junit.Test; 28import org.junit.rules.ExpectedException; 29import org.junit.runner.RunWith; 30import org.junit.runners.Parameterized; 31 32@MediumTest 33@RunWith(Parameterized.class) 34public class PathInterpolatorExceptionParameterizedTest { 35 @Rule 36 public ActivityTestRule<DrawableStubActivity> mActivityRule = 37 new ActivityTestRule<>(DrawableStubActivity.class); 38 39 40 private Activity mActivity = null; 41 private int mResId; 42 43 @Rule 44 public ExpectedException thrown = ExpectedException.none(); 45 46 @Parameterized.Parameters 47 public static Object[] data() { 48 return new Object[]{ 49 R.drawable.animation_path_interpolator_exception_1, // missing control point 50 R.drawable.animation_path_interpolator_exception_2, // missing control points 51 R.drawable.animation_path_interpolator_exception_3, // not from 0,0 to 1,1 52 R.drawable.animation_path_interpolator_exception_4, // loop back 53 R.drawable.animation_path_interpolator_exception_5, // 2 contour 54 }; 55 } 56 57 public PathInterpolatorExceptionParameterizedTest(final int resId) throws Throwable { 58 mResId = resId; 59 } 60 61 @Before 62 public void setup() { 63 mActivity = mActivityRule.getActivity(); 64 } 65 66 @Test 67 public void testPathMorphingExceptions() throws Exception { 68 thrown.expect(RuntimeException.class); 69 final AnimatedVectorDrawableCompat avd = AnimatedVectorDrawableCompat.create(mActivity, 70 mResId); 71 } 72} 73