This source file includes following definitions.
- setUp
- Feature
- testFallbackClientId
- Feature
- testPreRegisteredGenerator
- registerHardCodedGenerator
package org.chromium.sync.notifier;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.test.util.Feature;
import java.util.Arrays;
public class InvalidationClientNameProviderTest extends InstrumentationTestCase {
private InvalidationClientNameProvider mProvider;
@Override
protected void setUp() {
mProvider = new InvalidationClientNameProvider();
}
@SmallTest
@Feature({"Sync"})
public void testFallbackClientId() {
byte[] id1 = mProvider.getInvalidatorClientName();
byte[] id2 = mProvider.getInvalidatorClientName();
assertTrue("Expected returned IDs to be consistent", Arrays.equals(id1, id2));
registerHardCodedGenerator(mProvider);
byte[] id3 = mProvider.getInvalidatorClientName();
assertTrue("Changing generators should not affect returned ID consistency",
Arrays.equals(id2, id3));
}
@SmallTest
@Feature({"Sync"})
public void testPreRegisteredGenerator() {
registerHardCodedGenerator(mProvider);
byte[] id = mProvider.getInvalidatorClientName();
byte[] id2 = mProvider.getInvalidatorClientName();
assertTrue("Custom generators should return consistent IDs", Arrays.equals(id, id2));
}
private static void registerHardCodedGenerator(InvalidationClientNameProvider provider) {
provider.setPreferredClientNameGenerator(
new InvalidationClientNameGenerator() {
public byte[] generateInvalidatorClientName() {
return "Testable ID".getBytes();
}
});
}
}