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