зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1250707 - Add test for UrlAnnotations.insert. r=sebastian
MozReview-Commit-ID: LmnxRlcxIi --HG-- extra : rebase_source : 7bad7592d739dfdf1a36e58ca942b75d1ad2746a
This commit is contained in:
Родитель
63eca03a7d
Коммит
078eda97bb
|
@ -1434,6 +1434,11 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
private class TestInsertUrlAnnotations extends TestCase {
|
||||
@Override
|
||||
public void test() throws Exception {
|
||||
testInsertionViaContentProvider();
|
||||
testInsertionViaUrlAnnotations();
|
||||
}
|
||||
|
||||
private void testInsertionViaContentProvider() throws Exception {
|
||||
final String url = "http://mozilla.org";
|
||||
final String key = "todo";
|
||||
final String value = "v";
|
||||
|
@ -1444,21 +1449,45 @@ public class testBrowserProvider extends ContentProviderTest {
|
|||
final Cursor c = getUrlAnnotationByUrl(url);
|
||||
try {
|
||||
mAsserter.is(c.moveToFirst(), true, "Inserted url annotation found");
|
||||
|
||||
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.UrlAnnotations.KEY)), key,
|
||||
"Inserted url annotation has correct key");
|
||||
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.UrlAnnotations.VALUE)), value,
|
||||
"Inserted url annotation has correct value");
|
||||
assertKeyValueSync(c, key, value);
|
||||
mAsserter.is(c.getLong(c.getColumnIndex(BrowserContract.UrlAnnotations.DATE_CREATED)), dateCreated,
|
||||
"Inserted url annotation has correct created");
|
||||
"Inserted url annotation has correct date created");
|
||||
mAsserter.is(c.getLong(c.getColumnIndex(BrowserContract.UrlAnnotations.DATE_MODIFIED)), dateCreated,
|
||||
"Inserted url annotation has correct date modified");
|
||||
mAsserter.is(c.getInt(c.getColumnIndex(BrowserContract.UrlAnnotations.SYNC_STATUS)), SyncStatus.NEW.getDBValue(),
|
||||
"Inserted url annotation has default sync status");
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void testInsertionViaUrlAnnotations() throws Exception {
|
||||
final String url = "http://hello.org";
|
||||
final String key = "toTheUniverse";
|
||||
final String value = "42a";
|
||||
final long timeBeforeCreation = System.currentTimeMillis();
|
||||
|
||||
getTestProfile().getDB().getUrlAnnotations().insertAnnotation(mResolver, url, key, value);
|
||||
|
||||
final Cursor c = getUrlAnnotationByUrl(url);
|
||||
try {
|
||||
mAsserter.is(c.moveToFirst(), true, "Inserted url annotation found");
|
||||
assertKeyValueSync(c, key, value);
|
||||
mAsserter.is(true, c.getLong(c.getColumnIndex(BrowserContract.UrlAnnotations.DATE_CREATED)) >= timeBeforeCreation,
|
||||
"Inserted url annotation has date created greater than or equal to time saved before insertion");
|
||||
mAsserter.is(true, c.getLong(c.getColumnIndex(BrowserContract.UrlAnnotations.DATE_MODIFIED)) >= timeBeforeCreation,
|
||||
"Inserted url annotation has correct date modified greater than or equal to time saved before insertion");
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void assertKeyValueSync(final Cursor c, final String key, final String value) {
|
||||
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.UrlAnnotations.KEY)), key,
|
||||
"Inserted url annotation has correct key");
|
||||
mAsserter.is(c.getString(c.getColumnIndex(BrowserContract.UrlAnnotations.VALUE)), value,
|
||||
"Inserted url annotation has correct value");
|
||||
mAsserter.is(c.getInt(c.getColumnIndex(BrowserContract.UrlAnnotations.SYNC_STATUS)), SyncStatus.NEW.getDBValue(),
|
||||
"Inserted url annotation has default sync status");
|
||||
}
|
||||
}
|
||||
|
||||
private class TestCombinedView extends TestCase {
|
||||
|
|
Загрузка…
Ссылка в новой задаче