OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.content.browser; |
| 6 |
| 7 import android.app.Activity; |
| 8 import android.support.test.InstrumentationRegistry; |
| 9 import android.support.test.annotation.UiThreadTest; |
| 10 import android.support.test.filters.SmallTest; |
| 11 import android.support.test.rule.UiThreadTestRule; |
| 12 |
| 13 import org.junit.Assert; |
| 14 import org.junit.Before; |
| 15 import org.junit.Rule; |
| 16 import org.junit.Test; |
| 17 import org.junit.runner.RunWith; |
| 18 |
| 19 import org.chromium.base.annotations.SuppressFBWarnings; |
| 20 import org.chromium.base.test.util.Feature; |
| 21 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; |
| 22 import org.chromium.device.geolocation.LocationProviderAdapter; |
| 23 |
| 24 /** |
| 25 * Test suite for LocationProvider. |
| 26 */ |
| 27 @RunWith(ContentJUnit4ClassRunner.class) |
| 28 public class LocationProviderTest { |
| 29 private Activity mActivity; |
| 30 private LocationProviderAdapter mLocationProvider; |
| 31 |
| 32 @Rule |
| 33 public UiThreadTestRule mRule = new UiThreadTestRule(); |
| 34 |
| 35 @Before |
| 36 @SuppressFBWarnings("URF_UNREAD_FIELD") |
| 37 public void setUp() { |
| 38 mActivity = new Activity(); |
| 39 mLocationProvider = LocationProviderAdapter.create( |
| 40 InstrumentationRegistry.getInstrumentation().getTargetContext())
; |
| 41 } |
| 42 |
| 43 /** |
| 44 * Verify a normal start/stop call pair without any activity pauses. |
| 45 */ |
| 46 @Test |
| 47 @SmallTest |
| 48 @UiThreadTest |
| 49 @Feature({"Location"}) |
| 50 public void testStartStop() throws Exception { |
| 51 mLocationProvider.start(false); |
| 52 Assert.assertTrue("Should be running", mLocationProvider.isRunning()); |
| 53 mLocationProvider.stop(); |
| 54 Assert.assertFalse("Should have stopped", mLocationProvider.isRunning())
; |
| 55 } |
| 56 |
| 57 /** |
| 58 * Verify a start/upgrade/stop call sequence without any activity pauses. |
| 59 */ |
| 60 @Test |
| 61 @SmallTest |
| 62 @UiThreadTest |
| 63 @Feature({"Location"}) |
| 64 public void testStartUpgradeStop() throws Exception { |
| 65 mLocationProvider.start(false); |
| 66 Assert.assertTrue("Should be running", mLocationProvider.isRunning()); |
| 67 mLocationProvider.start(true); |
| 68 Assert.assertTrue("Should be running", mLocationProvider.isRunning()); |
| 69 mLocationProvider.stop(); |
| 70 Assert.assertFalse("Should have stopped", mLocationProvider.isRunning())
; |
| 71 } |
| 72 } |
OLD | NEW |