1 /* 2 * Copyright (C) 2020 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 android.time.cts.host; 18 19 20 import static android.app.time.cts.shell.LocationTimeZoneManagerShellHelper.PROVIDER_MODE_DISABLED; 21 import static android.app.time.cts.shell.LocationTimeZoneManagerShellHelper.PROVIDER_MODE_SIMULATED; 22 import static android.app.time.cts.shell.LocationTimeZoneManagerShellHelper.PRIMARY_PROVIDER_INDEX; 23 import static android.app.time.cts.shell.LocationTimeZoneManagerShellHelper.SECONDARY_PROVIDER_INDEX; 24 25 import static org.junit.Assert.assertEquals; 26 27 import android.app.time.LocationTimeZoneManagerServiceStateProto; 28 import android.app.time.TimeZoneProviderStateEnum; 29 import android.app.time.TimeZoneProviderStateProto; 30 31 import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; 32 33 import org.junit.Test; 34 import org.junit.runner.RunWith; 35 36 import java.util.Arrays; 37 import java.util.List; 38 39 /** Host-side CTS tests for the location time zone manager service. */ 40 @RunWith(DeviceJUnit4ClassRunner.class) 41 public class LocationTimeZoneManagerHostTest extends BaseLocationTimeZoneManagerHostTest { 42 43 @Test testSecondarySuggestion()44 public void testSecondarySuggestion() throws Exception { 45 setProviderModeOverride(PRIMARY_PROVIDER_INDEX, PROVIDER_MODE_DISABLED); 46 setProviderModeOverride(SECONDARY_PROVIDER_INDEX, PROVIDER_MODE_SIMULATED); 47 startLocationTimeZoneManagerService(); 48 setLocationTimeZoneManagerStateRecordingMode(true); 49 50 simulateProviderBind(SECONDARY_PROVIDER_INDEX); 51 simulateProviderSuggestion(SECONDARY_PROVIDER_INDEX, "Europe/London"); 52 53 LocationTimeZoneManagerServiceStateProto serviceState = 54 dumpLocationTimeZoneManagerServiceState(); 55 assertEquals(Arrays.asList("Europe/London"), 56 serviceState.getLastSuggestion().getZoneIdsList()); 57 58 List<TimeZoneProviderStateProto> secondaryStates = 59 serviceState.getSecondaryProviderStatesList(); 60 assertEquals(1, secondaryStates.size()); 61 assertEquals(TimeZoneProviderStateEnum.TIME_ZONE_PROVIDER_STATE_CERTAIN, 62 secondaryStates.get(0).getState()); 63 } 64 } 65