OSDN Git Service

Added test cases for DataCallResponse parcel read/write
authorJack Yu <jackyu@google.com>
Thu, 7 Dec 2017 23:49:09 +0000 (15:49 -0800)
committerJack Yu <jackyu@google.com>
Wed, 13 Dec 2017 08:10:51 +0000 (00:10 -0800)
bug: 64132030
Test: Unit tests
Merged-In: I87a9af987dd7366bfe6b22252e2c4bdc0fbdd727
Change-Id: I87a9af987dd7366bfe6b22252e2c4bdc0fbdd727
(cherry picked from commit 14c2aaa0a276807bdf922a3e7ce64bae880e0c68)

telephony/java/android/telephony/data/DataCallResponse.java
telephony/java/android/telephony/data/InterfaceAddress.java

index 8cdad3f..da51c86 100644 (file)
@@ -116,7 +116,6 @@ public final class DataCallResponse implements Parcelable {
      */
     public int getSuggestedRetryTime() { return mSuggestedRetryTime; }
 
-
     /**
      * @return The unique id of the data connection.
      */
@@ -183,16 +182,57 @@ public final class DataCallResponse implements Parcelable {
            .append(" active=").append(mActive)
            .append(" type=").append(mType)
            .append(" ifname=").append(mIfname)
-           .append(" mtu=").append(mMtu)
            .append(" addresses=").append(mAddresses)
            .append(" dnses=").append(mDnses)
            .append(" gateways=").append(mGateways)
            .append(" pcscf=").append(mPcscfs)
+           .append(" mtu=").append(mMtu)
            .append("}");
         return sb.toString();
     }
 
     @Override
+    public boolean equals (Object o) {
+        if (this == o) return true;
+
+        if (o == null || !(o instanceof DataCallResponse)) {
+            return false;
+        }
+
+        DataCallResponse other = (DataCallResponse) o;
+        return this.mStatus == other.mStatus
+                && this.mSuggestedRetryTime == other.mSuggestedRetryTime
+                && this.mCid == other.mCid
+                && this.mActive == other.mActive
+                && this.mType.equals(other.mType)
+                && this.mIfname.equals(other.mIfname)
+                && mAddresses.size() == other.mAddresses.size()
+                && mAddresses.containsAll(other.mAddresses)
+                && mDnses.size() == other.mDnses.size()
+                && mDnses.containsAll(other.mDnses)
+                && mGateways.size() == other.mGateways.size()
+                && mGateways.containsAll(other.mGateways)
+                && mPcscfs.size() == other.mPcscfs.size()
+                && mPcscfs.containsAll(other.mPcscfs)
+                && mMtu == other.mMtu;
+    }
+
+    @Override
+    public int hashCode() {
+        return mStatus * 31
+                + mSuggestedRetryTime * 37
+                + mCid * 41
+                + mActive * 43
+                + mType.hashCode() * 47
+                + mIfname.hashCode() * 53
+                + mAddresses.hashCode() * 59
+                + mDnses.hashCode() * 61
+                + mGateways.hashCode() * 67
+                + mPcscfs.hashCode() * 71
+                + mMtu * 73;
+    }
+
+    @Override
     public int describeContents() {
         return 0;
     }
index 947d0ff..00d212a 100644 (file)
@@ -78,6 +78,23 @@ public final class InterfaceAddress implements Parcelable {
      */
     public int getNetworkPrefixLength() { return mPrefixLength; }
 
+    @Override
+    public boolean equals (Object o) {
+        if (this == o) return true;
+
+        if (o == null || !(o instanceof InterfaceAddress)) {
+            return false;
+        }
+
+        InterfaceAddress other = (InterfaceAddress) o;
+        return this.mInetAddress.equals(other.mInetAddress)
+                && this.mPrefixLength == other.mPrefixLength;
+    }
+
+    @Override
+    public int hashCode() {
+        return mInetAddress.hashCode() * 31 + mPrefixLength * 37;
+    }
 
     @Override
     public int describeContents() {