fix unit tests, add shadow for WorkerManager

This commit is contained in:
Vincent Breitmoser
2018-06-15 13:02:33 +02:00
parent 8bf71b893c
commit f22c761376
13 changed files with 117 additions and 67 deletions

View File

@@ -0,0 +1,43 @@
package org.sufficientlysecure.keychain;
import android.content.ContentValues;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.mockito.Matchers;
public class TestHelpers {
public static ContentValues cvContains(ContentValues value) {
return Matchers.argThat(new BaseMatcher<ContentValues>() {
@Override
public boolean matches(Object item) {
if (item instanceof ContentValues) {
ContentValues cv = (ContentValues) item;
for (String key : value.keySet()) {
if (!cv.containsKey(key)) {
return false;
}
Object ours = value.get(key);
Object theirs = cv.get(key);
if (ours == null && theirs == null) {
continue;
}
if (ours == null || !ours.equals(theirs)) {
return false;
}
}
return true;
}
return false;
}
@Override
public void describeTo(Description description) {
description.appendValue(value);
}
});
}
}