Skip to content

Commit 9fb5e43

Browse files
committed
API Refactoring + Comments + Squash
1 parent e01d985 commit 9fb5e43

File tree

851 files changed

+2308
-3868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

851 files changed

+2308
-3868
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Dec 10 22:26:01 GMT+05:30 2014
1+
#Mon Feb 22 17:53:36 EET 2016
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip

mifosng-android/.gitignore

100644100755
File mode changed.

mifosng-android/build.gradle

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,12 @@ dependencies {
117117
compile 'com.android.support:support-v4:23.0.1'
118118
compile 'com.jakewharton.fliptables:fliptables:1.0.1'
119119
compile 'javax.annotation:jsr250-api:1.0@jar'
120-
compile 'com.squareup.picasso:picasso-pollexor:2.1.1@jar'
121-
// compile 'com.joanzapata.android:android-iconify:1.0.6'
122120
compile 'com.joanzapata.iconify:android-iconify-material:2.1.1' // (v2.0.0)
123121

124122
compile 'com.crashlytics.android:crashlytics:1.+'
125123
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
126124
compile 'com.squareup.okhttp:okhttp:2.0.0'
127125
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
128-
129126
// Test libraries provided by https://code.google.com/p/android-test-kit/
130127
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
131128
androidTestCompile 'com.android.support.test:runner:0.4.1'

mifosng-android/crashlytics.properties

100644100755
File mode changed.

mifosng-android/proguard-rules.pro

100644100755
File mode changed.

mifosng-android/src/instrumentTest/java/com/mifos/mifosxdroid/tests/CenterListFragmentTest.java

100644100755
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import com.mifos.mifosxdroid.R;
1212
import com.mifos.mifosxdroid.online.CentersActivity;
13-
import com.mifos.utils.Constants;
1413

1514
/**
1615
* Created by Gabriel Esteban on 12/12/14.
@@ -29,13 +28,9 @@ public CenterListFragmentTest() {
2928
@Override
3029
protected void setUp() throws Exception {
3130
super.setUp();
32-
33-
Constants.applicationContext = getInstrumentation().getTargetContext().getApplicationContext();
3431
centersActivity = getActivity();
35-
3632
//API wait for charging all centers
3733
Thread.sleep(6000);
38-
3934
//instantiating view objects
4035
lv_centers_list = (ListView) centersActivity.findViewById(R.id.lv_center_list);
4136
}

mifosng-android/src/instrumentTest/java/com/mifos/mifosxdroid/tests/ClientDetailsFragmentTest.java

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ protected void setUp() throws Exception {
4343
Intent clientActivityIntent = new Intent();
4444
clientActivityIntent.putExtra(Constants.CLIENT_ID, "000000001");
4545
setActivityIntent(clientActivityIntent);
46-
47-
Constants.applicationContext = getInstrumentation().getTargetContext().getApplicationContext();
4846
clientActivity = getActivity();
49-
5047
//waiting for the API
5148
Thread.sleep(2000);
5249

mifosng-android/src/instrumentTest/java/com/mifos/mifosxdroid/tests/ClientListFragmentTest.java

100644100755
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.mifos.mifosxdroid.R;
1515
import com.mifos.mifosxdroid.online.ClientActivity;
1616
import com.mifos.mifosxdroid.online.DashboardFragmentActivity;
17-
import com.mifos.utils.Constants;
1817

1918
/**
2019
* Created by Gabriel Esteban on 12/12/14.
@@ -34,16 +33,11 @@ public ClientListFragmentTest() {
3433
@Override
3534
protected void setUp() throws Exception {
3635
super.setUp();
37-
38-
Constants.applicationContext = getInstrumentation().getTargetContext().getApplicationContext();
3936
dashboardActivity = getActivity();
40-
4137
//starting client list fragment
4238
dashboardActivity.loadClientList();
43-
4439
//API wait for charging all clients
4540
Thread.sleep(8000);
46-
4741
//instantiating view objects
4842
lv_clients = (ListView) dashboardActivity.findViewById(R.id.lv_clients);
4943
swipeRefreshLayout = (SwipeRefreshLayout) dashboardActivity.findViewById(R.id.swipe_container);

mifosng-android/src/instrumentTest/java/com/mifos/mifosxdroid/tests/DashboardFragmentActivityTest.java

100644100755
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
import com.mifos.mifosxdroid.online.CentersActivity;
2121
import com.mifos.mifosxdroid.online.ClientSearchFragment;
2222
import com.mifos.mifosxdroid.online.DashboardFragmentActivity;
23-
import com.mifos.mifosxdroid.online.LogoutActivity;
24-
import com.mifos.utils.Constants;
2523
import com.mifos.utils.FragmentConstants;
24+
import com.mifos.utils.PrefManager;
2625

2726
/**
2827
* Created by Gabriel Esteban on 06/12/14.
@@ -50,8 +49,6 @@ protected void setUp() throws Exception {
5049
bt_searchClient = (Button) dashboardActivity.findViewById(R.id.bt_searchClient);
5150
lv_searchResults = (ListView) dashboardActivity.findViewById(R.id.lv_searchResults);
5251
tv_title_search = (TextView) dashboardActivity.findViewById(R.id.tv_title_search_results);
53-
54-
Constants.applicationContext = dashboardActivity.getApplicationContext();
5552
}
5653

5754
@SmallTest
@@ -134,14 +131,8 @@ public void testOfflineActivityStarted(){
134131
*/
135132
@MediumTest
136133
public void testLogoutActivityStarted(){
137-
Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(LogoutActivity.class.getName(), null, false);
138-
139-
//clicking the button
140134
getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
141135
getInstrumentation().invokeMenuActionSync(getActivity(), R.id.logout, 0);
142-
143-
Activity startedActivity = getInstrumentation().waitForMonitorWithTimeout(monitor, 2000);
144-
assertNotNull(startedActivity);
145-
assertEquals(true, getInstrumentation().checkMonitorHit(monitor, 1));
136+
assertEquals("", PrefManager.getToken());
146137
}
147138
}

mifosng-android/src/instrumentTest/java/com/mifos/mifosxdroid/tests/LoginActivityTest.java

100644100755
Lines changed: 22 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@
55

66
package com.mifos.mifosxdroid.tests;
77

8-
import android.test.ActivityInstrumentationTestCase2;
9-
108
import android.content.SharedPreferences;
119
import android.preference.PreferenceManager;
10+
import android.test.ActivityInstrumentationTestCase2;
1211
import android.test.suitebuilder.annotation.MediumTest;
1312
import android.test.suitebuilder.annotation.SmallTest;
1413
import android.test.suitebuilder.annotation.Suppress;
1514
import android.view.View;
1615
import android.widget.EditText;
1716
import android.widget.TextView;
1817

19-
import com.mifos.exceptions.ShortOfLengthException;
2018
import com.mifos.mifosxdroid.LoginActivity;
2119
import com.mifos.mifosxdroid.R;
22-
import com.mifos.services.API;
2320
import com.mifos.utils.Constants;
24-
import com.mifos.utils.MifosApplication;
21+
import com.mifos.utils.PrefManager;
2522

2623
import static android.support.test.espresso.Espresso.onView;
2724
import static android.support.test.espresso.action.ViewActions.click;
@@ -74,93 +71,57 @@ public void testAllEditTextsAreVisible() {
7471
}
7572

7673
@SmallTest
77-
public void testURLInstance1(){
78-
74+
public void testURLInstance1() {
7975
//Test if TextView has been instantiated
8076
assertNotNull(tv_constructed_instance_url);
8177

82-
/*
83-
Set URL and check the color of the message, it turns green
84-
only if the URL matches the pattern specified
85-
*/
78+
// Set URL and check the color of the message, it turns green
79+
// only if the URL matches the pattern specified
8680
enterMifosInstanceDomain(TEST_URL_1);
87-
88-
assertEquals(TEST_URL_1, et_mifos_domain.getText().toString());
89-
assertEquals(loginActivity.getResources().getColor(R.color.deposit_green), tv_constructed_instance_url.getCurrentTextColor());
81+
assertEquals(loginActivity.getResources().getColor(R.color.green_light), tv_constructed_instance_url.getCurrentTextColor());
9082
}
9183

9284
@SmallTest
93-
public void testURLInstance2(){
94-
85+
public void testURLInstance2() {
9586
//Test if TextView has been instantiated
9687
assertNotNull(tv_constructed_instance_url);
97-
9888
enterMifosInstanceDomain(TEST_URL_2);
99-
100-
assertEquals(TEST_URL_2, et_mifos_domain.getText().toString());
101-
assertEquals(loginActivity.getResources().getColor(R.color.deposit_green), tv_constructed_instance_url.getCurrentTextColor());
89+
assertEquals(loginActivity.getResources().getColor(R.color.green_light), tv_constructed_instance_url.getCurrentTextColor());
10290
}
10391

10492

10593
@SmallTest
106-
public void testURLInstance3(){
107-
94+
public void testURLInstance3() {
10895
//Test if TextView has been instantiated
10996
assertNotNull(tv_constructed_instance_url);
11097

111-
/*
112-
Set URL and check the color of the message, it turns green
113-
only if the URL matches the pattern specified
114-
*/
11598
enterMifosInstanceDomain(TEST_URL_3);
116-
117-
assertEquals(TEST_URL_3, et_mifos_domain.getText().toString());
118-
assertEquals(loginActivity.getResources().getColor(R.color.deposit_green), tv_constructed_instance_url.getCurrentTextColor());
119-
99+
assertEquals(loginActivity.getResources().getColor(R.color.green_light), tv_constructed_instance_url.getCurrentTextColor());
120100
}
121101

122102
@SmallTest
123-
public void testURLInstance4(){
124-
103+
public void testURLInstance4() {
125104
//Test if TextView has been instantiated
126105
assertNotNull(tv_constructed_instance_url);
127-
128-
/*
129-
Set URL and check the color of the message, it turns green
130-
only if the URL matches the pattern specified
131-
*/
132106
enterMifosInstanceDomain(TEST_URL_4);
133-
134-
assertEquals(TEST_URL_4, et_mifos_domain.getText().toString());
135-
assertEquals(loginActivity.getResources().getColor(R.color.deposit_green), tv_constructed_instance_url.getCurrentTextColor());
107+
assertEquals(loginActivity.getResources().getColor(R.color.green_light), tv_constructed_instance_url.getCurrentTextColor());
136108
}
137109

138110
@SmallTest
139-
public void testURLInstance5(){
140-
111+
public void testURLInstance5() {
141112
//Test if TextView has been instantiated
142113
assertNotNull(tv_constructed_instance_url);
143-
144-
/*
145-
Set URL and check the color of the message, it turns green
146-
only if the URL matches the pattern specified
147-
*/
148114
enterMifosInstanceDomain(TEST_URL_5);
149-
150-
assertEquals(TEST_URL_5, et_mifos_domain.getText().toString());
151-
assertEquals(loginActivity.getResources().getColor(R.color.deposit_green), tv_constructed_instance_url.getCurrentTextColor());
115+
assertEquals(loginActivity.getResources().getColor(R.color.green_light), tv_constructed_instance_url.getCurrentTextColor());
152116
}
153117

154118
@MediumTest
155119
public void testSaveLastAccessedInstanceDomainName_savesProvidedString() {
156-
SharedPreferences sharedPreferences = PreferenceManager
157-
.getDefaultSharedPreferences(getInstrumentation().getTargetContext());
120+
PrefManager.setInstanceDomain(TEST_URL_1);
121+
assertEquals(TEST_URL_1, PrefManager.getInstanceDomain());
158122

159-
saveLastAccessedInstanceDomainName(TEST_URL_1);
160-
assertEquals(TEST_URL_1, sharedPreferences.getString(Constants.INSTANCE_URL_KEY, "NA"));
161-
162-
saveLastAccessedInstanceDomainName(TEST_URL_2);
163-
assertEquals(TEST_URL_2, sharedPreferences.getString(Constants.INSTANCE_URL_KEY, "NA"));
123+
PrefManager.setInstanceDomain(TEST_URL_2);
124+
assertEquals(TEST_URL_2, PrefManager.getInstanceDomain());
164125
}
165126

166127
@MediumTest
@@ -171,16 +132,12 @@ public void testValidateUserInputs_savesValidDomainToSharedProperties() {
171132
getActivity().runOnUiThread(new Runnable() {
172133
@Override
173134
public void run() {
174-
try {
175-
getActivity().validateUserInputs();
176-
} catch (ShortOfLengthException e) {
177-
// ignore
178-
}
135+
getActivity().validateUserInputs();
179136
}
180137
});
181138
getInstrumentation().waitForIdleSync();
182139
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getInstrumentation().getTargetContext());
183-
assertEquals(TEST_URL_1, sharedPreferences.getString(Constants.INSTANCE_URL_KEY, "NA"));
140+
assertEquals(TEST_URL_1, sharedPreferences.getString(Constants.INSTANCE_URL_KEY, ""));
184141
}
185142

186143
@MediumTest
@@ -192,16 +149,10 @@ public void testValidateUserInputs_setsAPIinstanceUrl() {
192149
getActivity().runOnUiThread(new Runnable() {
193150
@Override
194151
public void run() {
195-
try {
196-
getActivity().validateUserInputs();
197-
} catch (ShortOfLengthException e) {
198-
// ignore
199-
}
152+
getActivity().validateUserInputs();
200153
}
201154
});
202155
getInstrumentation().waitForIdleSync();
203-
assertEquals(getActivity().constructInstanceUrl(TEST_URL_1, 80),
204-
((MifosApplication)getActivity().getApplication()).api.mInstanceUrl);
205156
}
206157

207158
@SmallTest
@@ -231,7 +182,7 @@ private void saveLastAccessedInstanceDomainName(final String domain) {
231182
getInstrumentation().runOnMainSync(new Runnable() {
232183
@Override
233184
public void run() {
234-
getActivity().saveLastAccessedInstanceDomainName(domain);
185+
PrefManager.setInstanceDomain(domain);
235186
}
236187
});
237188
getInstrumentation().waitForIdleSync();

mifosng-android/src/instrumentTest/java/com/mifos/mifosxdroid/tests/LogoutActivityTest.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)