summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorBill Yi <byi@google.com>2014-04-29 16:07:29 -0700
committerBill Yi <byi@google.com>2014-04-29 16:07:29 -0700
commit293513a59d36cd96a3e474dde5981380d372d8c9 (patch)
tree4268c9994be194a7f4fccdecd089af58516d0953 /core/tests
parent1866e5dc8bb04b58a67e54f66cb4ec22e878667d (diff)
parent0b62467b142b61ee1e449ba958ba37dfd961ef56 (diff)
downloadframeworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.zip
frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.tar.gz
frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.tar.bz2
Merge commit '0b62467b142b61ee1e449ba958ba37dfd961ef56' into HEAD
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;