mobile/android/tests/background/junit3/src/sync/helpers/ExpectGuidsSinceDelegate.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/tests/background/junit3/src/sync/helpers/ExpectGuidsSinceDelegate.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +package org.mozilla.gecko.background.sync.helpers;
     1.8 +
     1.9 +import static junit.framework.Assert.assertEquals;
    1.10 +import static junit.framework.Assert.assertFalse;
    1.11 +
    1.12 +import java.util.Arrays;
    1.13 +import java.util.HashSet;
    1.14 +import java.util.Set;
    1.15 +
    1.16 +import junit.framework.AssertionFailedError;
    1.17 +
    1.18 +public class ExpectGuidsSinceDelegate extends DefaultGuidsSinceDelegate {
    1.19 +  private String[] expected;
    1.20 +  public Set<String> ignore = new HashSet<String>();
    1.21 +
    1.22 +  public ExpectGuidsSinceDelegate(String[] guids) {
    1.23 +    expected = guids;
    1.24 +    Arrays.sort(expected);
    1.25 +  }
    1.26 +
    1.27 +  @Override
    1.28 +  public void onGuidsSinceSucceeded(String[] guids) {
    1.29 +    AssertionFailedError err = null;
    1.30 +    try {
    1.31 +      int notIgnored = 0;
    1.32 +      for (String guid : guids) {
    1.33 +        if (!ignore.contains(guid)) {
    1.34 +          notIgnored++;
    1.35 +          assertFalse(-1 == Arrays.binarySearch(this.expected, guid));
    1.36 +        }
    1.37 +      }
    1.38 +      assertEquals(this.expected.length, notIgnored);
    1.39 +    } catch (AssertionFailedError e) {
    1.40 +      err = e;
    1.41 +    }
    1.42 +    performNotify(err);
    1.43 +  }
    1.44 +}

mercurial