OSDN Git Service

Fix failing WifiConfigManagerTest test.
authorAmin Shaikh <ashaikh@google.com>
Thu, 23 Feb 2017 18:08:10 +0000 (10:08 -0800)
committerAmin Shaikh <ashaikh@google.com>
Thu, 23 Feb 2017 18:29:10 +0000 (10:29 -0800)
Bug: 35671673
Test: runtest frameworks-core frameworks-wifi
Change-Id: I55ff41464cabfb97d03a0758d73145df808ec2c8
Merged-In: I55ff41464cabfb97d03a0758d73145df808ec2c8

wifi/java/android/net/wifi/WifiConfiguration.java
wifi/tests/src/android/net/wifi/WifiConfigurationTest.java

index 14deabe..2ba573c 100644 (file)
@@ -1295,6 +1295,7 @@ public class WifiConfiguration implements Parcelable {
             setConnectChoice(source.getConnectChoice());
             setConnectChoiceTimestamp(source.getConnectChoiceTimestamp());
             setHasEverConnected(source.getHasEverConnected());
+            setNotRecommended(source.isNotRecommended());
         }
 
         public void writeToParcel(Parcel dest) {
index 5f94974..632cfaf 100644 (file)
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
 import android.os.Parcel;
+import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -66,4 +67,35 @@ public class WifiConfigurationTest {
 
         assertArrayEquals(bytes, rebytes);
     }
+
+    @Test
+    public void testNetworkSelectionStatusCopy() {
+        NetworkSelectionStatus networkSelectionStatus = new NetworkSelectionStatus();
+        networkSelectionStatus.setNotRecommended(true);
+
+        NetworkSelectionStatus copy = new NetworkSelectionStatus();
+        copy.copy(networkSelectionStatus);
+
+        assertEquals(networkSelectionStatus.isNotRecommended(), copy.isNotRecommended());
+    }
+
+    @Test
+    public void testNetworkSelectionStatusParcel() {
+        NetworkSelectionStatus networkSelectionStatus = new NetworkSelectionStatus();
+        networkSelectionStatus.setNotRecommended(true);
+
+        Parcel parcelW = Parcel.obtain();
+        networkSelectionStatus.writeToParcel(parcelW);
+        byte[] bytes = parcelW.marshall();
+        parcelW.recycle();
+
+        Parcel parcelR = Parcel.obtain();
+        parcelR.unmarshall(bytes, 0, bytes.length);
+        parcelR.setDataPosition(0);
+
+        NetworkSelectionStatus copy = new NetworkSelectionStatus();
+        copy.readFromParcel(parcelR);
+
+        assertEquals(networkSelectionStatus.isNotRecommended(), copy.isNotRecommended());
+    }
 }