1 /* 2 * Copyright (C) 2023 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.regionalpreferences; 18 19 import static org.junit.Assert.assertEquals; 20 21 import android.app.settings.SettingsEnums; 22 import android.os.Bundle; 23 import android.os.Looper; 24 25 import androidx.test.annotation.UiThreadTest; 26 27 import org.junit.Before; 28 import org.junit.Test; 29 30 public class NumberingPreferencesFragmentTest { 31 private NumberingPreferencesFragment mFragment; 32 33 @Before 34 @UiThreadTest setUp()35 public void setUp() throws Exception { 36 if (Looper.myLooper() == null) { 37 Looper.prepare(); 38 } 39 mFragment = new NumberingPreferencesFragment(); 40 } 41 42 @Test 43 @UiThreadTest getMetricsCategory_optionIsLanguageSelection_resultIsLanguageSelection()44 public void getMetricsCategory_optionIsLanguageSelection_resultIsLanguageSelection() { 45 Bundle extras = new Bundle(); 46 extras.putString(RegionalPreferencesEntriesFragment.ARG_KEY_REGIONAL_PREFERENCE, 47 NumberingSystemItemController.ARG_VALUE_LANGUAGE_SELECT); 48 mFragment.setArguments(extras); 49 50 int result = mFragment.getMetricsCategory(); 51 52 assertEquals(SettingsEnums.NUMBERING_SYSTEM_LANGUAGE_SELECTION_PREFERENCE, result); 53 } 54 55 @Test 56 @UiThreadTest getMetricsCategory_optionIsNumberSelection_resultIsNumberSelection()57 public void getMetricsCategory_optionIsNumberSelection_resultIsNumberSelection() { 58 Bundle extras = new Bundle(); 59 extras.putString(RegionalPreferencesEntriesFragment.ARG_KEY_REGIONAL_PREFERENCE, 60 NumberingSystemItemController.ARG_VALUE_NUMBERING_SYSTEM_SELECT); 61 mFragment.setArguments(extras); 62 63 int result = mFragment.getMetricsCategory(); 64 65 assertEquals(SettingsEnums.NUMBERING_SYSTEM_NUMBER_FORMAT_SELECTION_PREFERENCE, result); 66 } 67 } 68