diff --git a/lib/src/config.dart b/lib/src/config.dart index 3e5cc792..bb079bba 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -40,7 +40,7 @@ class Config { /// (called by screenshots) @visibleForTesting Future storeEnv(Screens screens, String emulatorName, String locale, - String deviceType) async { + String deviceType, String orientation) async { // store env for later use by tests final screenProps = screens.screenProps(emulatorName); final screenSize = screenProps == null ? null : screenProps['size']; @@ -49,6 +49,7 @@ class Config { 'locale': locale, 'device_name': emulatorName, 'device_type': deviceType, + 'orientation': orientation }; await _envStore.writeAsString(json.encode(currentEnv)); } diff --git a/lib/src/run.dart b/lib/src/run.dart index 54d5641c..15db7c50 100644 --- a/lib/src/run.dart +++ b/lib/src/run.dart @@ -167,7 +167,7 @@ Future runTestsOnAll(DaemonClient daemonClient, List devices, List emulators, final defaultLocale = 'en_US'; // todo: need actual locale of real device print('Warning: the locale of a real device cannot be changed.'); await runProcessTests(config, screens, configDeviceName, defaultLocale, - deviceType, testPaths, deviceId, imageProcessor, runMode, archive); + deviceType, testPaths, deviceId, imageProcessor, runMode, archive, 'unknown'); } else { // Function to check for a running android device or emulator bool isRunningAndroidDeviceOrEmulator(Map device, Map emulator) { @@ -258,8 +258,18 @@ Future runTestsOnAll(DaemonClient daemonClient, List devices, List emulators, } // run tests and process images - await runProcessTests(config, screens, configDeviceName, locale, - deviceType, testPaths, deviceId, imageProcessor, runMode, archive); + await runProcessTests( + config, + screens, + configDeviceName, + locale, + deviceType, + testPaths, + deviceId, + imageProcessor, + runMode, + archive, + deviceOrientation); } // if an emulator was started, revert locale if necessary and shut it down @@ -286,11 +296,12 @@ Future runProcessTests( String deviceId, ImageProcessor imageProcessor, RunMode runMode, - Archive archive) async { + Archive archive, + String orientation) async { // store env for later use by tests // ignore: invalid_use_of_visible_for_testing_member - await config.storeEnv( - screens, configDeviceName, locale, utils.getStringFromEnum(deviceType)); + await config.storeEnv(screens, configDeviceName, locale, + utils.getStringFromEnum(deviceType), orientation); for (final testPath in testPaths) { print('Running $testPath on \'$configDeviceName\' in locale $locale...'); await utils.streamCmd('flutter', ['-d', deviceId, 'drive', testPath]); diff --git a/test/env_test.dart b/test/env_test.dart index 0ce63b18..dbb68dc8 100644 --- a/test/env_test.dart +++ b/test/env_test.dart @@ -7,17 +7,19 @@ void main() { final Config config = Config(configPath: 'test/screenshots_test.yaml'); final screens = await Screens(); await screens.init(); + final orientation='orientation'; final env = { 'screen_size': '1440x2560', 'locale': 'en_US', 'device_name': 'Nexus 6P', 'device_type': 'android', + 'orientation': orientation }; // called by screenshots before test await config.storeEnv( - screens, env['device_name'], env['locale'], env['device_type']); + screens, env['device_name'], env['locale'], env['device_type'], orientation ); // called by test final Config testConfig = Config(configPath: 'test/screenshots_test.yaml');