summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorXia Wang <xiaw@google.com>2014-03-18 22:34:17 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-18 22:34:17 +0000
commit454fc6b1189225c54a833053f6aed32508f42f3e (patch)
treeb9d6fbfe8a79ba1ba5b7d448f0325038148ee923 /core/tests
parent546f0c9c2cc902ebe30fef79b34e93eac8542e14 (diff)
parent560e75417252b502a41967aa4d819a029361e384 (diff)
downloadframeworks_base-454fc6b1189225c54a833053f6aed32508f42f3e.zip
frameworks_base-454fc6b1189225c54a833053f6aed32508f42f3e.tar.gz
frameworks_base-454fc6b1189225c54a833053f6aed32508f42f3e.tar.bz2
am 560e7541: am 1b007565: am 9b650702: Merge "Fix state transition verification." into klp-dev
* commit '560e75417252b502a41967aa4d819a029361e384': Fix state transition verification.
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java33
1 files changed, 20 insertions, 13 deletions
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java
index 5a4a2d0..9d97ac5 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java
@@ -101,9 +101,10 @@ public class NetworkState {
}
/*
- * Transition from CONNECTED -> DISCONNECTED:
- * CONNECTED->DISCONNECTING->DISCONNECTED
- * return false if any state transition is not valid and save a message in mReason
+ * Verifies state transition from CONNECTED->...-> DISCONNECTED.
+ *
+ * returns false if initial state or target state is not correct, or if there is
+ * any transition from DISCONNECTING/DISCONNECTED -> CONNECTED.
*/
public boolean transitToDisconnection () {
mReason = "states: " + printStates();
@@ -120,13 +121,13 @@ public class NetworkState {
for (int i = 1; i < mStateDepository.size() - 1; i++) {
State preState = mStateDepository.get(i-1);
State curState = mStateDepository.get(i);
- if ((preState == State.CONNECTED) && ((curState == State.DISCONNECTING) ||
+ if (preState == curState) {
+ continue;
+ } else if ((preState == State.CONNECTED) && ((curState == State.DISCONNECTING) ||
(curState == State.DISCONNECTED))) {
continue;
} else if ((preState == State.DISCONNECTING) && (curState == State.DISCONNECTED)) {
continue;
- } else if ((preState == State.DISCONNECTED) && (curState == State.DISCONNECTED)) {
- continue;
} else {
mReason += " Transition state from " + preState.toString() + " to " +
curState.toString() + " is not valid.";
@@ -136,7 +137,12 @@ public class NetworkState {
return true;
}
- // DISCONNECTED->CONNECTING->CONNECTED
+ /*
+ * Verifies state transition from DISCONNECTED->...-> CONNECTED.
+ *
+ * returns false if initial state or target state is not correct, or if there is
+ * any transition from CONNECED -> DISCONNECTED.
+ */
public boolean transitToConnection() {
mReason = "states: " + printStates();
if (mStateDepository.get(0) != State.DISCONNECTED) {
@@ -152,14 +158,15 @@ public class NetworkState {
for (int i = 1; i < mStateDepository.size(); i++) {
State preState = mStateDepository.get(i-1);
State curState = mStateDepository.get(i);
- if ((preState == State.DISCONNECTED) && ((curState == State.CONNECTING) ||
- (curState == State.CONNECTED) || (curState == State.DISCONNECTED))) {
+ if (preState == curState) {
continue;
- } else if ((preState == State.CONNECTING) && (curState == State.CONNECTED)) {
- continue;
- } else if ((preState == State.CONNECTED) && (curState == State.CONNECTED)) {
+ }
+ if ((preState == State.DISCONNECTED) && ((curState == State.CONNECTING) ||
+ (curState == State.CONNECTED))) {
continue;
- } else {
+ } else if ((preState == State.CONNECTING) && (curState == State.CONNECTED)) {
+ continue;
+ } else {
mReason += " Transition state from " + preState.toString() + " to " +
curState.toString() + " is not valid.";
return false;