mobile/android/tests/background/junit3/src/sync/helpers/ExpectStoredDelegate.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/ExpectStoredDelegate.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     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.assertNotNull;
    1.11 +import junit.framework.AssertionFailedError;
    1.12 +
    1.13 +public class ExpectStoredDelegate extends DefaultStoreDelegate {
    1.14 +  String expectedGUID;
    1.15 +  String storedGuid;
    1.16 +
    1.17 +  public ExpectStoredDelegate(String guid) {
    1.18 +    this.expectedGUID = guid;
    1.19 +  }
    1.20 +
    1.21 +  @Override
    1.22 +  public synchronized void onStoreCompleted(long storeEnd) {
    1.23 +    try {
    1.24 +      assertNotNull(storedGuid);
    1.25 +      performNotify();
    1.26 +    } catch (AssertionFailedError e) {
    1.27 +      performNotify("GUID " + this.expectedGUID + " was not stored", e);
    1.28 +    }
    1.29 +  }
    1.30 +
    1.31 +  @Override
    1.32 +  public synchronized void onRecordStoreSucceeded(String guid) {
    1.33 +    this.storedGuid = guid;
    1.34 +    try {
    1.35 +      if (this.expectedGUID != null) {
    1.36 +        assertEquals(this.expectedGUID, guid);
    1.37 +      }
    1.38 +    } catch (AssertionFailedError e) {
    1.39 +      performNotify(e);
    1.40 +    }
    1.41 +  }
    1.42 +}

mercurial