Skip to content

Commit

Permalink
Fix async open tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Mar 14, 2024
1 parent 6a18b85 commit 7752998
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/realm_dart/test/realm_test.dart
Expand Up @@ -1328,17 +1328,17 @@ void main() {
final user = await app.logIn(credentials);
final configuration = Configuration.flexibleSync(user, getSyncSchema());

int transferredBytes = -1;
double progress = -1;
final completer = Completer<void>();
var syncedRealm = await getRealmAsync(configuration, onProgressCallback: (syncProgress) {
transferredBytes = syncProgress.transferredBytes;
if (syncProgress.transferredBytes == syncProgress.transferableBytes) {
progress = syncProgress.progressEstimate;
if (syncProgress.progressEstimate == 1.0) {
completer.complete();
}
});
completer.future.timeout(Duration(milliseconds: 300), onTimeout: () => throw Exception("onProgressCallback did not happen."));
expect(syncedRealm.isClosed, false);
expect(transferredBytes, greaterThan(-1));
expect(progress, greaterThan(-1));
});

baasTest('Realm.open (flexibleSync) - download a populated realm', (appConfiguration) async {
Expand All @@ -1357,16 +1357,16 @@ void main() {
final config = await _subscribeForAtlasAddedData(app);

int printCount = 0;
int transferredBytes = 0;
double progress = 0;

final syncedRealm = await getRealmAsync(config, onProgressCallback: (syncProgress) {
printCount++;
transferredBytes = syncProgress.transferredBytes;
progress = syncProgress.progressEstimate;
});

expect(syncedRealm.isClosed, false);
expect(printCount, isNot(0));
expect(transferredBytes, greaterThan(19)); //19 bytes is the empty realm
expect(progress, 1.0);
});

baasTest('Realm.open (flexibleSync) - listen and cancel download progress of a populated realm', (appConfiguration) async {
Expand Down

0 comments on commit 7752998

Please sign in to comment.