Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e571387 authored by Sundeep Ghuman's avatar Sundeep Ghuman Committed by android-build-merger
Browse files

Merge "Add case sensitive sort to AccessPoint compareTo." into oc-dr1-dev am: 6a623285

am: 08af7417

Change-Id: I9adc1886593006cd53911ec63a2a0ccda730d3e9
parents d336afa9 08af7417
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -322,8 +322,15 @@ public class AccessPoint implements Comparable<AccessPoint> {
        if (difference != 0) {
            return difference;
        }

        // Sort by ssid.
        return getSsidStr().compareToIgnoreCase(other.getSsidStr());
        difference = getSsidStr().compareToIgnoreCase(other.getSsidStr());
        if (difference != 0) {
            return difference;
        }

        // Do a case sensitive comparison to distinguish SSIDs that differ in case only
        return getSsidStr().compareTo(other.getSsidStr());
    }

    @Override
+15 −0
Original line number Diff line number Diff line
@@ -168,6 +168,21 @@ public class AccessPointTest {
        assertSortingWorks(firstAp, secondAp);
    }

    @Test
    public void testCompareTo_GivesSsidCasePrecendenceAfterAlphabetical() {

        final String firstName = "aaAaaa";
        final String secondName = "aaaaaa";
        final String thirdName = "BBBBBB";

        AccessPoint firstAp = new TestAccessPointBuilder(mContext).setSsid(firstName).build();
        AccessPoint secondAp = new TestAccessPointBuilder(mContext).setSsid(secondName).build();
        AccessPoint thirdAp = new TestAccessPointBuilder(mContext).setSsid(thirdName).build();

        assertSortingWorks(firstAp, secondAp);
        assertSortingWorks(secondAp, thirdAp);
    }

    @Test
    public void testCompareTo_AllSortingRulesCombined() {