Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/LocationProviderTest.java

Issue 11419287: android: Improve ActivityStatus and add ChromiumActivity. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix "if" indentations Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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.test.UiThreadTest; 7 import android.test.UiThreadTest;
8 import android.test.InstrumentationTestCase; 8 import android.test.InstrumentationTestCase;
9 import android.test.suitebuilder.annotation.SmallTest; 9 import android.test.suitebuilder.annotation.SmallTest;
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 /** 53 /**
54 * Verify that pausing the activity stops location listener and when 54 * Verify that pausing the activity stops location listener and when
55 * activity resumes it restarts listening. 55 * activity resumes it restarts listening.
56 */ 56 */
57 @SmallTest 57 @SmallTest
58 @UiThreadTest 58 @UiThreadTest
59 @Feature({"Location"}) 59 @Feature({"Location"})
60 public void testStartPauseResumeStop() throws Exception { 60 public void testStartPauseResumeStop() throws Exception {
61 mLocationProvider.start(false); 61 mLocationProvider.start(false);
62 assertTrue("Should be running", mLocationProvider.isRunning()); 62 assertTrue("Should be running", mLocationProvider.isRunning());
63 ActivityStatus.getInstance().onPause(); 63 ActivityStatus.onStateChange(null, ActivityStatus.PAUSED);
64 assertFalse("Should have paused", mLocationProvider.isRunning()); 64 assertFalse("Should have paused", mLocationProvider.isRunning());
65 ActivityStatus.getInstance().onResume(); 65 ActivityStatus.onStateChange(null, ActivityStatus.RESUMED);
66 assertTrue("Should have resumed", mLocationProvider.isRunning()); 66 assertTrue("Should have resumed", mLocationProvider.isRunning());
67 mLocationProvider.stop(); 67 mLocationProvider.stop();
68 assertFalse("Should have stopped", mLocationProvider.isRunning()); 68 assertFalse("Should have stopped", mLocationProvider.isRunning());
69 } 69 }
70 70
71 /** 71 /**
72 * Verify that calling start when the activity is paused doesn't start liste ning 72 * Verify that calling start when the activity is paused doesn't start liste ning
73 * for location updates until activity resumes. 73 * for location updates until activity resumes.
74 */ 74 */
75 @SmallTest 75 @SmallTest
76 @UiThreadTest 76 @UiThreadTest
77 @Feature({"Location"}) 77 @Feature({"Location"})
78 public void testPauseStartResumeStop() throws Exception { 78 public void testPauseStartResumeStop() throws Exception {
79 ActivityStatus.getInstance().onPause(); 79 ActivityStatus.onStateChange(null, ActivityStatus.PAUSED);
80 mLocationProvider.start(false); 80 mLocationProvider.start(false);
81 assertFalse("Should not be running", mLocationProvider.isRunning()); 81 assertFalse("Should not be running", mLocationProvider.isRunning());
82 ActivityStatus.getInstance().onResume(); 82 ActivityStatus.onStateChange(null, ActivityStatus.RESUMED);
83 assertTrue("Should have resumed", mLocationProvider.isRunning()); 83 assertTrue("Should have resumed", mLocationProvider.isRunning());
84 mLocationProvider.stop(); 84 mLocationProvider.stop();
85 assertFalse("Should have stopped", mLocationProvider.isRunning()); 85 assertFalse("Should have stopped", mLocationProvider.isRunning());
86 } 86 }
87 87
88 /** 88 /**
89 * Verify that upgrading when paused works as expected. 89 * Verify that upgrading when paused works as expected.
90 */ 90 */
91 @SmallTest 91 @SmallTest
92 @UiThreadTest 92 @UiThreadTest
93 @Feature({"Location"}) 93 @Feature({"Location"})
94 public void testStartPauseUpgradeResumeStop() throws Exception { 94 public void testStartPauseUpgradeResumeStop() throws Exception {
95 mLocationProvider.start(false); 95 mLocationProvider.start(false);
96 assertTrue("Should be running", mLocationProvider.isRunning()); 96 assertTrue("Should be running", mLocationProvider.isRunning());
97 ActivityStatus.getInstance().onPause(); 97 ActivityStatus.onStateChange(null, ActivityStatus.PAUSED);
98 assertFalse("Should have paused", mLocationProvider.isRunning()); 98 assertFalse("Should have paused", mLocationProvider.isRunning());
99 mLocationProvider.start(true); 99 mLocationProvider.start(true);
100 assertFalse("Should be paused", mLocationProvider.isRunning()); 100 assertFalse("Should be paused", mLocationProvider.isRunning());
101 ActivityStatus.getInstance().onResume(); 101 ActivityStatus.onStateChange(null, ActivityStatus.RESUMED);
102 assertTrue("Should have resumed", mLocationProvider.isRunning()); 102 assertTrue("Should have resumed", mLocationProvider.isRunning());
103 mLocationProvider.stop(); 103 mLocationProvider.stop();
104 assertFalse("Should have stopped", mLocationProvider.isRunning()); 104 assertFalse("Should have stopped", mLocationProvider.isRunning());
105 } 105 }
106 } 106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698