1/* 2 * Copyright 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 */ 16package com.android.managedprovisioning.preprovisioning.anim; 17 18import static android.graphics.Color.parseColor; 19import static android.support.test.InstrumentationRegistry.getTargetContext; 20 21import static org.hamcrest.MatcherAssert.assertThat; 22import static org.hamcrest.Matchers.equalTo; 23 24import android.support.test.filters.SmallTest; 25 26import com.android.managedprovisioning.R; 27 28import org.junit.Test; 29 30@SmallTest 31public class SwiperThemeMatcherTest { 32 private final SwiperThemeMatcher mSwiperThemeMatcher = new SwiperThemeMatcher( 33 getTargetContext(), new ColorMatcher()); 34 35 @Test 36 public void findsCorrectTheme() { 37 assertCorrect(parseColor("#ff000000"), R.style.Swiper000000); 38 assertCorrect(parseColor("#d40000"), R.style.Swipere00000); 39 assertCorrect(parseColor("white"), R.style.Swiperffffff); 40 } 41 42 private void assertCorrect(int source, int expected) { 43 assertThat(mSwiperThemeMatcher.findTheme(source), equalTo(expected)); 44 } 45}