|
| 1 | +import 'package:checks/checks.dart'; |
| 2 | +import 'package:flutter/foundation.dart'; |
| 3 | +import 'package:flutter_test/flutter_test.dart'; |
| 4 | +import 'package:zulip/model/binding.dart'; |
| 5 | +import 'package:zulip/model/settings.dart'; |
| 6 | + |
| 7 | +import '../example_data.dart' as eg; |
| 8 | +import 'store_checks.dart'; |
| 9 | +import 'store_test.dart'; |
| 10 | + |
| 11 | +void main() { |
| 12 | + final httpLink = Uri.parse('http://chat.zulip.org'); |
| 13 | + final nonHttpLink = Uri. parse( 'mailto:[email protected]'); |
| 14 | + |
| 15 | + group('getUrlLaunchMode', () { |
| 16 | + testAndroidIos('globalSettings.browserPreference is null; use platform-specific defaults', () { |
| 17 | + final globalStore = eg.globalStore(globalSettings: eg.globalSettings( |
| 18 | + browserPreference: null)); |
| 19 | + check(globalStore).globalSettings.getUrlLaunchMode(httpLink).equals( |
| 20 | + defaultTargetPlatform == TargetPlatform.iOS |
| 21 | + ? UrlLaunchMode.externalApplication : UrlLaunchMode.platformDefault); |
| 22 | + }); |
| 23 | + |
| 24 | + testAndroidIos('globalSettings.browserPreference is inApp; follow the preference for http links', () { |
| 25 | + final globalStore = eg.globalStore(globalSettings: eg.globalSettings( |
| 26 | + browserPreference: BrowserPreference.inApp)); |
| 27 | + check(globalStore).globalSettings.getUrlLaunchMode(httpLink).equals( |
| 28 | + UrlLaunchMode.inAppBrowserView); |
| 29 | + }); |
| 30 | + |
| 31 | + testAndroidIos('globalSettings.browserPreference is inApp; use platform default for non-http links', () { |
| 32 | + final globalStore = eg.globalStore(globalSettings: eg.globalSettings( |
| 33 | + browserPreference: BrowserPreference.inApp)); |
| 34 | + check(globalStore).globalSettings.getUrlLaunchMode(nonHttpLink).equals( |
| 35 | + UrlLaunchMode.platformDefault); |
| 36 | + }); |
| 37 | + |
| 38 | + testAndroidIos('globalSettings.browserPreference is external; follow the preference', () { |
| 39 | + final globalStore = eg.globalStore(globalSettings: eg.globalSettings( |
| 40 | + browserPreference: BrowserPreference.external)); |
| 41 | + check(globalStore).globalSettings.getUrlLaunchMode(httpLink).equals( |
| 42 | + UrlLaunchMode.externalApplication); |
| 43 | + }); |
| 44 | + }); |
| 45 | +} |
0 commit comments