Skip to content

Commit f186104

Browse files
authored
Merge pull request #298 from SUPERCILEX/database-test
Update database tests to support onCancelled
2 parents a95d541 + bb29f71 commit f186104

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

library/src/androidTest/java/com/firebase/ui/ApplicationTest.java renamed to library/src/test/java/com/firebase/ui/database/ApplicationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* limitations under the License.
1313
*/
1414

15-
package com.firebase.ui;
15+
package com.firebase.ui.database;
1616

1717
import android.app.Application;
1818
import android.content.Context;

library/src/androidTest/java/com/firebase/ui/database/FirebaseArrayOfObjectsTest.java renamed to library/src/test/java/com/firebase/ui/database/FirebaseArrayOfObjectsTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616

1717
import android.test.AndroidTestCase;
1818

19-
import com.firebase.ui.ApplicationTest;
20-
import com.firebase.ui.database.FirebaseArray;
2119
import com.google.firebase.FirebaseApp;
20+
import com.google.firebase.database.DatabaseError;
2221
import com.google.firebase.database.DatabaseReference;
2322
import com.google.firebase.database.FirebaseDatabase;
2423
import com.google.firebase.database.Query;
@@ -173,9 +172,14 @@ private Bean getBean(FirebaseArray array, int index) {
173172
public static void runAndWaitUntil(final FirebaseArray array, Query ref, Runnable task, Callable<Boolean> done) throws InterruptedException {
174173
final java.util.concurrent.Semaphore semaphore = new java.util.concurrent.Semaphore(0);
175174
array.setOnChangedListener(new FirebaseArray.OnChangedListener() {
176-
public void onChanged(FirebaseArray.OnChangedListener.EventType type, int index, int oldIndex) {
175+
public void onChanged(EventType type, int index, int oldIndex) {
177176
semaphore.release();
178177
}
178+
179+
@Override
180+
public void onCancelled(DatabaseError databaseError) {
181+
throw new IllegalStateException(databaseError.toException());
182+
}
179183
});
180184
task.run();
181185
boolean isDone = false;

library/src/androidTest/java/com/firebase/ui/database/FirebaseArrayTest.java renamed to library/src/test/java/com/firebase/ui/database/FirebaseArrayTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import android.test.AndroidTestCase;
1818

19-
import com.firebase.ui.ApplicationTest;
2019
import com.google.firebase.FirebaseApp;
20+
import com.google.firebase.database.DatabaseError;
2121
import com.google.firebase.database.DatabaseReference;
2222
import com.google.firebase.database.FirebaseDatabase;
2323
import com.google.firebase.database.Query;
@@ -143,9 +143,14 @@ private static void print(FirebaseArray array) {
143143
public static void runAndWaitUntil(final FirebaseArray array, Query ref, Runnable task, Callable<Boolean> done) throws InterruptedException {
144144
final java.util.concurrent.Semaphore semaphore = new java.util.concurrent.Semaphore(0);
145145
array.setOnChangedListener(new FirebaseArray.OnChangedListener() {
146-
public void onChanged(FirebaseArray.OnChangedListener.EventType type, int index, int oldIndex) {
146+
public void onChanged(EventType type, int index, int oldIndex) {
147147
semaphore.release();
148148
}
149+
150+
@Override
151+
public void onCancelled(DatabaseError databaseError) {
152+
throw new IllegalStateException(databaseError.toException());
153+
}
149154
});
150155
task.run();
151156
boolean isDone = false;

0 commit comments

Comments
 (0)