mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Fix library test content matcher
This commit is contained in:
parent
8c98e885d8
commit
b9930252e1
@ -1,6 +1,7 @@
|
|||||||
package org.kiwix.kiwixmobile.testutils;
|
package org.kiwix.kiwixmobile.testutils;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.LauncherActivity;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.test.InstrumentationRegistry;
|
import android.support.test.InstrumentationRegistry;
|
||||||
@ -42,13 +43,17 @@ public class TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Matcher<Object> withContent(final String content) {
|
public static Matcher<Object> withContent(final String content) {
|
||||||
return new BoundedMatcher<Object, Book>(Book.class) {
|
return new BoundedMatcher<Object, Object>(Object.class) {
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesSafely(Book myObj) {
|
public boolean matchesSafely(Object myObj) {
|
||||||
if (myObj.getUrl() != null) {
|
if (!(myObj instanceof Book)) {
|
||||||
return myObj.getUrl().contains(content);
|
return false;
|
||||||
|
}
|
||||||
|
Book book = (Book) myObj;
|
||||||
|
if (book.getUrl() != null) {
|
||||||
|
return book.getUrl().contains(content);
|
||||||
} else {
|
} else {
|
||||||
return myObj.file.getPath().contains(content);
|
return book.file.getPath().contains(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ public class LibraryAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int i) {
|
public Object getItem(int i) {
|
||||||
return listItems.get(i);
|
return listItems.get(i).data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,6 +118,9 @@ public class LibraryAdapter extends BaseAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
ViewHolder holder;
|
ViewHolder holder;
|
||||||
|
if (position + 1 >= listItems.size()) {
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
ListItem item = listItems.get(position);
|
ListItem item = listItems.get(position);
|
||||||
|
|
||||||
if (item.type == LIST_ITEM_TYPE_BOOK) {
|
if (item.type == LIST_ITEM_TYPE_BOOK) {
|
||||||
@ -248,9 +251,9 @@ public class LibraryAdapter extends BaseAdapter {
|
|||||||
.filter(book -> !LibraryFragment.downloadingBooks.contains(book))
|
.filter(book -> !LibraryFragment.downloadingBooks.contains(book))
|
||||||
.toList().toBlocking().single();
|
.toList().toBlocking().single();
|
||||||
|
|
||||||
listItems.add(new ListItem("In your language:", LIST_ITEM_TYPE_DIVIDER));
|
listItems.add(new ListItem(context.getResources().getString(R.string.your_languages), LIST_ITEM_TYPE_DIVIDER));
|
||||||
addBooks(selectedLanguages);
|
addBooks(selectedLanguages);
|
||||||
listItems.add(new ListItem("In other languages:", LIST_ITEM_TYPE_DIVIDER));
|
listItems.add(new ListItem(context.getResources().getString(R.string.other_languages), LIST_ITEM_TYPE_DIVIDER));
|
||||||
addBooks(unselectedLanguages);
|
addBooks(unselectedLanguages);
|
||||||
} else {
|
} else {
|
||||||
List<Book> selectedLanguages = Observable.from(allBooks)
|
List<Book> selectedLanguages = Observable.from(allBooks)
|
||||||
|
@ -187,4 +187,6 @@
|
|||||||
<string name="external_link_popup_dialog_title">Entering External Link</string>
|
<string name="external_link_popup_dialog_title">Entering External Link</string>
|
||||||
<string name="external_link_popup_dialog_message">You are entering an external link. This could lead to additional costs for data transfer or will just not work when you are offline. Do you want to continue?</string>
|
<string name="external_link_popup_dialog_message">You are entering an external link. This could lead to additional costs for data transfer or will just not work when you are offline. Do you want to continue?</string>
|
||||||
<string name="do_not_ask_anymore">Do not ask anymore</string>
|
<string name="do_not_ask_anymore">Do not ask anymore</string>
|
||||||
|
<string name="your_languages">Selected languages:</string>
|
||||||
|
<string name="other_languages">Other languages:</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user