summaryrefslogtreecommitdiff
path: root/services/robotests/src
diff options
context:
space:
mode:
author Soonil Nagarkar <sooniln@google.com> 2020-10-25 17:23:54 -0700
committer Soonil Nagarkar <sooniln@google.com> 2020-11-10 10:14:34 -0800
commitbe6ed5aa14f7418da2a23b0755158491d4ecd179 (patch)
tree121ae291776990d86a057874902464e585b50822 /services/robotests/src
parentfded2b6d13331c11f9ec6b149834c519382d7dc1 (diff)
Add batching APIs and Location.equals()
-Moves batching APIs from SystemApi to Public, and makes them multi-client safe. -Adds equals/hashcode to Location. Bug: 171512333 Test: manual + presubmit Change-Id: I6ee28f8229fdf49386cd370ea785de63b97e7cde
Diffstat (limited to 'services/robotests/src')
-rw-r--r--services/robotests/src/com/android/server/location/gnss/GnssBatchingProviderTest.java120
1 files changed, 0 insertions, 120 deletions
diff --git a/services/robotests/src/com/android/server/location/gnss/GnssBatchingProviderTest.java b/services/robotests/src/com/android/server/location/gnss/GnssBatchingProviderTest.java
deleted file mode 100644
index fa324e8c60ee..000000000000
--- a/services/robotests/src/com/android/server/location/gnss/GnssBatchingProviderTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.location.gnss;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.platform.test.annotations.Presubmit;
-
-import com.android.server.location.gnss.GnssBatchingProvider.GnssBatchingProviderNative;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-
-/**
- * Unit tests for {@link GnssBatchingProvider}.
- */
-@RunWith(RobolectricTestRunner.class)
-@Presubmit
-public class GnssBatchingProviderTest {
-
- private static final long PERIOD_NANOS = (long) 1e9;
- private static final boolean WAKE_ON_FIFO_FULL = true;
- private static final int BATCH_SIZE = 3;
- @Mock
- private GnssBatchingProviderNative mMockNative;
- private GnssBatchingProvider mTestProvider;
-
- /**
- * Mocks native methods and starts GnssBatchingProvider.
- */
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(mMockNative.initBatching()).thenReturn(true);
- when(mMockNative.startBatch(anyLong(), anyBoolean())).thenReturn(true);
- when(mMockNative.stopBatch()).thenReturn(true);
- when(mMockNative.getBatchSize()).thenReturn(BATCH_SIZE);
- mTestProvider = new GnssBatchingProvider(mMockNative);
- mTestProvider.enable();
- mTestProvider.start(PERIOD_NANOS, WAKE_ON_FIFO_FULL);
- }
-
- /**
- * Test native start method is called.
- */
- @Test
- public void start_nativeStarted() {
- verify(mMockNative).startBatch(eq(PERIOD_NANOS), eq(WAKE_ON_FIFO_FULL));
- }
-
- /**
- * Verify native stop method is called.
- */
- @Test
- public void stop_nativeStopped() {
- mTestProvider.stop();
- verify(mMockNative).stopBatch();
- }
-
- /**
- * Verify native flush method is called.
- */
- @Test
- public void flush_nativeFlushed() {
- mTestProvider.flush();
- verify(mMockNative).flushBatch();
- }
-
- /**
- * Verify getBatchSize returns value from native batch size method.
- */
- @Test
- public void getBatchSize_nativeGetBatchSize() {
- assertThat(mTestProvider.getBatchSize()).isEqualTo(BATCH_SIZE);
- }
-
- /**
- * Verify resumeIfStarted method will call native start method a second time.
- */
- @Test
- public void started_resume_started() {
- mTestProvider.resumeIfStarted();
- verify(mMockNative, times(2)).startBatch(eq(PERIOD_NANOS), eq(WAKE_ON_FIFO_FULL));
- }
-
- /**
- * Verify that if batching is stopped, resume will not call native start method.
- */
- @Test
- public void stopped_resume_notStarted() {
- mTestProvider.stop();
- mTestProvider.resumeIfStarted();
- verify(mMockNative, times(1)).startBatch(eq(PERIOD_NANOS), eq(WAKE_ON_FIFO_FULL));
- }
-}