Fixed tests and bug
This commit is contained in:
parent
65611129e1
commit
97827cde2d
|
@ -172,7 +172,7 @@ public class FeedHandlerTest extends InstrumentationTestCase {
|
||||||
"http://example.com/items/" + i, new Date(i*60000), FeedItem.UNPLAYED, feed);
|
"http://example.com/items/" + i, new Date(i*60000), FeedItem.UNPLAYED, feed);
|
||||||
feed.getItems().add(item);
|
feed.getItems().add(item);
|
||||||
if (withFeedMedia) {
|
if (withFeedMedia) {
|
||||||
item.setMedia(new FeedMedia(0, item, 4711, 0, 100, "audio/mp3", null, "http://example.com/media-" + i,
|
item.setMedia(new FeedMedia(0, item, 4711, 0, 1024*1024, "audio/mp3", null, "http://example.com/media-" + i,
|
||||||
false, null, 0));
|
false, null, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ public class DBTasksTest extends InstrumentationTestCase {
|
||||||
SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
||||||
prefEdit.putString(UserPreferences.PREF_EPISODE_CACHE_SIZE, Integer.toString(EPISODE_CACHE_SIZE));
|
prefEdit.putString(UserPreferences.PREF_EPISODE_CACHE_SIZE, Integer.toString(EPISODE_CACHE_SIZE));
|
||||||
prefEdit.commit();
|
prefEdit.commit();
|
||||||
|
|
||||||
|
UserPreferences.init(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FlakyTest(tolerance = 3)
|
@FlakyTest(tolerance = 3)
|
||||||
|
@ -261,7 +263,7 @@ public class DBTasksTest extends InstrumentationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = NUM_ITEMS_OLD; i < NUM_ITEMS_NEW + NUM_ITEMS_OLD; i++) {
|
for (int i = NUM_ITEMS_OLD; i < NUM_ITEMS_NEW + NUM_ITEMS_OLD; i++) {
|
||||||
feed.getItems().add(0, new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(i), FeedItem.PLAYED, feed));
|
feed.getItems().add(0, new FeedItem(0, "item " + i, "id " + i, "link " + i, new Date(i), FeedItem.UNPLAYED, feed));
|
||||||
}
|
}
|
||||||
|
|
||||||
final Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
final Feed newFeed = DBTasks.updateFeed(context, feed)[0];
|
||||||
|
@ -275,7 +277,6 @@ public class DBTasksTest extends InstrumentationTestCase {
|
||||||
updatedFeedTest(feedFromDB, feedID, itemIDs, NUM_ITEMS_OLD, NUM_ITEMS_NEW);
|
updatedFeedTest(feedFromDB, feedID, itemIDs, NUM_ITEMS_OLD, NUM_ITEMS_NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FlakyTest(tolerance = 3)
|
|
||||||
private void updatedFeedTest(final Feed newFeed, long feedID, List<Long> itemIDs, final int NUM_ITEMS_OLD, final int NUM_ITEMS_NEW) {
|
private void updatedFeedTest(final Feed newFeed, long feedID, List<Long> itemIDs, final int NUM_ITEMS_OLD, final int NUM_ITEMS_NEW) {
|
||||||
assertTrue(newFeed.getId() == feedID);
|
assertTrue(newFeed.getId() == feedID);
|
||||||
assertTrue(newFeed.getItems().size() == NUM_ITEMS_NEW + NUM_ITEMS_OLD);
|
assertTrue(newFeed.getItems().size() == NUM_ITEMS_NEW + NUM_ITEMS_OLD);
|
||||||
|
|
|
@ -601,13 +601,12 @@ public final class DBTasks {
|
||||||
// item is new
|
// item is new
|
||||||
item.setFeed(savedFeed);
|
item.setFeed(savedFeed);
|
||||||
item.setAutoDownload(savedFeed.getPreferences().getAutoDownload());
|
item.setAutoDownload(savedFeed.getPreferences().getAutoDownload());
|
||||||
savedFeed.getItems().add(item);
|
savedFeed.getItems().add(idx, item);
|
||||||
if (markNewItems) {
|
if (markNewItems) {
|
||||||
item.setNew();
|
item.setNew();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oldItem.updateFromOther(item);
|
oldItem.updateFromOther(item);
|
||||||
savedFeed.getItems().add(oldItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update attributes
|
// update attributes
|
||||||
|
|
Loading…
Reference in New Issue