-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the channel observer and split the tests better
- Loading branch information
Showing
5 changed files
with
76 additions
and
121 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export 'toast.dart'; | ||
export 'app.dart'; | ||
export 'system.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter/services.dart'; | ||
|
||
import '../test.dart'; | ||
|
||
/// An observer for the system channel. | ||
class SystemChannelObserver { | ||
|
||
int _closeRequests = 0; /// How many close request was recorded since the last observation. | ||
int get closeRequests { | ||
final numRequests = _closeRequests; | ||
clearCloseRequest(); | ||
return numRequests; | ||
} | ||
|
||
/// Create a new system channel observer, which automatically | ||
/// unregisters any previously created observer. | ||
SystemChannelObserver(WidgetTester tester) { | ||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (call) { | ||
if (call.method == 'SystemNavigator.pop') { | ||
_closeRequests++; | ||
return null; | ||
} | ||
return null; // Ignore unimplemented method calls | ||
}); | ||
} | ||
|
||
/// Reset the number of recorded close requests to zero. | ||
void clearCloseRequest() { | ||
_closeRequests = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters