diff -r 000000000000 -r 6474c204b198 mobile/android/tests/background/junit3/src/sync/helpers/ExpectStoredDelegate.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mobile/android/tests/background/junit3/src/sync/helpers/ExpectStoredDelegate.java Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,39 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +package org.mozilla.gecko.background.sync.helpers; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import junit.framework.AssertionFailedError; + +public class ExpectStoredDelegate extends DefaultStoreDelegate { + String expectedGUID; + String storedGuid; + + public ExpectStoredDelegate(String guid) { + this.expectedGUID = guid; + } + + @Override + public synchronized void onStoreCompleted(long storeEnd) { + try { + assertNotNull(storedGuid); + performNotify(); + } catch (AssertionFailedError e) { + performNotify("GUID " + this.expectedGUID + " was not stored", e); + } + } + + @Override + public synchronized void onRecordStoreSucceeded(String guid) { + this.storedGuid = guid; + try { + if (this.expectedGUID != null) { + assertEquals(this.expectedGUID, guid); + } + } catch (AssertionFailedError e) { + performNotify(e); + } + } +}