From 8710d00f447b9e4435f4f587a7c5df6338581cd2 Mon Sep 17 00:00:00 2001 From: Maurice McCabe Date: Wed, 17 Jul 2019 10:45:26 -0700 Subject: [PATCH] Cleanup --- lib/src/utils.dart | 8 ++++---- pubspec.yaml | 1 + test/env_test.dart | 2 +- test/screenshots_test.dart | 20 ++++++++++---------- test/screenshots_yaml_test.dart | 10 +++++----- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/src/utils.dart b/lib/src/utils.dart index f92ecb00..71ef58eb 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -170,17 +170,17 @@ T getEnumFromString(List values, String value) { String getAndroidDeviceLocale(String deviceId) { // ro.product.locale is available on first boot but does not update, // persist.sys.locale is empty on first boot but updates with locale changes - String deviceLocale = run + String locale = run .cmd('adb', ['-s', deviceId, 'shell', 'getprop persist.sys.locale'], '.', true) .trim(); - if (deviceLocale.isEmpty) { - deviceLocale = run + if (locale.isEmpty) { + locale = run .cmd('adb', ['-s', deviceId, 'shell', 'getprop ro.product.locale'], '.', true) .trim(); } - return deviceLocale; + return locale; } /// Returns locale of simulator with udid [udId]. diff --git a/pubspec.yaml b/pubspec.yaml index 7c8eb32b..0118d985 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,6 +17,7 @@ dependencies: platform: ^2.2.0 process: ^3.0.9 meta: ^1.1.6 + intl: ^0.15.8 dev_dependencies: test: ^1.5.1+1 diff --git a/test/env_test.dart b/test/env_test.dart index 1d17eab5..0ce63b18 100644 --- a/test/env_test.dart +++ b/test/env_test.dart @@ -10,7 +10,7 @@ void main() { final env = { 'screen_size': '1440x2560', - 'locale': 'en-US', + 'locale': 'en_US', 'device_name': 'Nexus 6P', 'device_type': 'android', }; diff --git a/test/screenshots_test.dart b/test/screenshots_test.dart index ff0adaa9..c379a6d1 100644 --- a/test/screenshots_test.dart +++ b/test/screenshots_test.dart @@ -266,8 +266,8 @@ void main() { test('change android locale', () async { final deviceName = 'Nexus 6P'; final emulatorId = 'Nexus_6P_API_28'; - final origLocale = 'en-US'; - final newLocale = 'fr-CA'; + final origLocale = 'en_US'; + final newLocale = 'fr_CA'; final daemonClient = DaemonClient(); await daemonClient.start; daemonClient.verbose = true; @@ -318,8 +318,8 @@ void main() { final emulatorId = 'Nexus_6P_API_28'; final deviceName = 'any device name'; final stagingDir = '/tmp/tmp'; - final origLocale = 'en-US'; - final newLocale = 'fr-CA'; + final origLocale = 'en_US'; + final newLocale = 'fr_CA'; final testAppDir = 'example'; final testAppSrcPath = 'test_driver/main.dart'; @@ -348,7 +348,7 @@ void main() { test('get android device locale', () async { final emulatorId = 'Nexus_6P_API_28'; final stagingDir = '/tmp/tmp'; - final locale = 'en-US'; + final locale = 'en_US'; await resources.unpackScripts(stagingDir); final daemonClient = DaemonClient(); @@ -363,8 +363,8 @@ void main() { test('change locale on iOS and test', () async { final simulatorName = 'iPhone X'; final stagingDir = '/tmp/tmp'; - final origLocale = 'en-US'; - final locale = 'fr-CA'; + final origLocale = 'en_US'; + final locale = 'fr_CA'; final testAppDir = 'example'; final testAppSrcPath = 'test_driver/main.dart'; @@ -399,7 +399,7 @@ void main() { test('get ios simulator locale', () async { final udId = '03D4FC12-3927-4C8B-A226-17DE34AE9C18'; var locale = utils.getIosSimulatorLocale(udId); - expect(locale, 'en-US'); + expect(locale, 'en_US'); }); test('get avd from a running emulator', () async { @@ -507,7 +507,7 @@ devices: }); test('scan syslog for string', () async { - final toLocale = 'en-US'; + final toLocale = 'en_US'; // final expected = // 'ContactsProvider: Locale has changed from [fr_CA] to [en_US]'; // final expected = RegExp('Locale has changed from'); @@ -524,7 +524,7 @@ devices: }); test('reg exp', () { - final locale = 'fr-CA'; + final locale = 'fr_CA'; final line = 'ContactsProvider: Locale has changed from [en_US] to [${locale.replaceFirst('-', '_')}]'; // final regExp = RegExp( diff --git a/test/screenshots_yaml_test.dart b/test/screenshots_yaml_test.dart index de9a172d..e719aed6 100644 --- a/test/screenshots_yaml_test.dart +++ b/test/screenshots_yaml_test.dart @@ -19,9 +19,9 @@ staging: /tmp/screenshots # A list of locales supported in app locales: -# - fr-CA - - en-US -# - de-DE +# - fr_CA + - en_US +# - de_DE # A list of devices to emulate devices: @@ -49,7 +49,7 @@ void main() { test('config info for app from string', () { final expected = { 'tests': ['example/test_driver/main.dart'], - 'locales': ['en-US'], + 'locales': ['en_US'], 'frame': true, 'devices': { 'android': {'Nexus 5X': null}, @@ -68,7 +68,7 @@ void main() { test('config info for app from file', () { final expected = { 'tests': ['example/test_driver/main.dart'], - 'locales': ['en-US'], + 'locales': ['en_US'], 'frame': true, 'devices': { 'android': {'Nexus 5X': null},