Skip to content

Unit test of ClientListFragment #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mifosng-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ dependencies {
androidTestCompile "com.android.support.test.espresso:espresso-intents:$rootProject.espressoVersion"

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'

}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
public class Toaster {

public static void show(View view, String text) {
Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_SHORT);
final Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_LONG);
View sbView = snackbar.getView();
TextView textView = (TextView) sbView.findViewById(android.support.design.R.id
.snackbar_text);
textView.setTextColor(Color.WHITE);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
});
snackbar.show();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.mifos.objects.client.Client;
import com.mifos.objects.client.Page;
import com.mifos.utils.Constants;
import com.mifos.utils.EspressoIdlingResource;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -40,6 +39,7 @@
/**
* Created by ishankhanna on 09/02/14.
*/
//TODO : Add ProgressBar
public class ClientListFragment extends MifosBaseFragment
implements OnItemClickListener, ClientListMvpView {

Expand Down Expand Up @@ -132,7 +132,6 @@ public void inflateClientList() {
}

public void fetchClientList() {
EspressoIdlingResource.increment(); // App is busy until further notice.
totalFilteredRecords = 0;
mClientListPresenter.loadClients();
}
Expand Down Expand Up @@ -164,17 +163,11 @@ public void showClientList(Page<Client> clientPage) {
totalFilteredRecords = clientPage.getTotalFilteredRecords();
clientList = clientPage.getPageItems();
inflateClientList();
if (swipeRefreshLayout.isRefreshing())
swipeRefreshLayout.setRefreshing(false);
EspressoIdlingResource.decrement(); // App is idle.
}

@Override
public void showErrorFetchingClients(String s) {
Toaster.show(rootView, s);
if (swipeRefreshLayout.isRefreshing())
swipeRefreshLayout.setRefreshing(false);
EspressoIdlingResource.decrement(); // App is idle.
}

@Override
Expand All @@ -192,7 +185,7 @@ public void showMoreClientsList(Page<Client> clientPage) {

@Override
public void showProgressbar(boolean b) {

swipeRefreshLayout.setRefreshing(b);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mifos.mifosxdroid.base.Presenter;
import com.mifos.objects.client.Client;
import com.mifos.objects.client.Page;
import com.mifos.utils.EspressoIdlingResource;

import javax.inject.Inject;

Expand Down Expand Up @@ -40,6 +41,7 @@ public void detachView() {


public void loadClients() {
EspressoIdlingResource.increment(); // App is busy until further notice.
mClientListMvpView.showProgressbar(true);
if (mSubscription != null) mSubscription.unsubscribe();
mSubscription = mDataManager.getAllClients()
Expand All @@ -55,13 +57,16 @@ public void onCompleted() {
public void onError(Throwable e) {
mClientListMvpView.showProgressbar(false);
mClientListMvpView.showErrorFetchingClients(
"\"There was some error fetching list.\"");
"There was some error fetching list");
EspressoIdlingResource.decrement(); // App is idle.

}

@Override
public void onNext(Page<Client> clientPage) {
mClientListMvpView.showProgressbar(false);
mClientListMvpView.showClientList(clientPage);
EspressoIdlingResource.decrement(); // App is idle.
}
});
}
Expand All @@ -82,7 +87,7 @@ public void onCompleted() {
public void onError(Throwable e) {
mClientListMvpView.showProgressbar(false);
mClientListMvpView.showErrorFetchingClients(
"\"There was some error fetching list.\"");
"There was some error fetching list");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public class ClientSearchFragment extends MifosBaseFragment
implements AdapterView.OnItemClickListener, ClientSearchMvpView {

private static final String TAG = ClientSearchFragment.class.getSimpleName();
private static final String LOG_TAG = ClientSearchFragment.class.getSimpleName();

@BindView(R.id.et_search_by_id)
EditText et_searchById;
Expand Down Expand Up @@ -112,7 +112,7 @@ public void onSaveInstanceState(Bundle outState) {
try {
String queryString = et_searchById.getEditableText().toString();
if (queryString != null && !(queryString.equals(""))) {
outState.putString(TAG + et_searchById.getId(), queryString);
outState.putString(LOG_TAG + et_searchById.getId(), queryString);
}
} catch (NullPointerException npe) {
//Looks like edit text didn't get initialized properly
Expand All @@ -123,7 +123,7 @@ public void onSaveInstanceState(Bundle outState) {
public void onViewStateRestored(Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
if (savedInstanceState != null) {
String queryString = savedInstanceState.getString(TAG + et_searchById.getId());
String queryString = savedInstanceState.getString(LOG_TAG + et_searchById.getId());
if (!TextUtils.isEmpty(queryString)) {
et_searchById.setText(queryString);
}
Expand Down
Loading