1 /* 2 * Copyright (C) 2022 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.accessibility; 18 19 import static com.android.settings.accessibility.AutoclickUtils.MAX_AUTOCLICK_DELAY_MS; 20 import static com.android.settings.accessibility.AutoclickUtils.MIN_AUTOCLICK_DELAY_MS; 21 22 import static com.google.common.truth.Truth.assertThat; 23 24 import android.content.Context; 25 26 import androidx.test.core.app.ApplicationProvider; 27 28 import com.android.settings.R; 29 30 import org.junit.Test; 31 import org.junit.runner.RunWith; 32 import org.robolectric.RobolectricTestRunner; 33 34 /** Tests for {@link AutoclickUtils}. */ 35 @RunWith(RobolectricTestRunner.class) 36 public final class AutoclickUtilsTest { 37 38 private final Context mContext = ApplicationProvider.getApplicationContext(); 39 40 @Test getAutoclickDelaySummary_minDelay_shouldReturnOnSummary()41 public void getAutoclickDelaySummary_minDelay_shouldReturnOnSummary() { 42 final CharSequence summary = AutoclickUtils.getAutoclickDelaySummary( 43 mContext, R.string.accessibilty_autoclick_delay_unit_second, 44 MIN_AUTOCLICK_DELAY_MS); 45 assertThat(summary.toString()).isEqualTo("0.2 seconds"); 46 } 47 48 @Test getAutoclickDelaySummary_maxDelay_shouldReturnOnSummary()49 public void getAutoclickDelaySummary_maxDelay_shouldReturnOnSummary() { 50 final CharSequence summary = AutoclickUtils.getAutoclickDelaySummary( 51 mContext, R.string.accessibilty_autoclick_delay_unit_second, 52 MAX_AUTOCLICK_DELAY_MS); 53 assertThat(summary.toString()).isEqualTo("1 second"); 54 } 55 } 56