Skip to content

Commit

Permalink
add language support to test app for android
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Naranjo committed Sep 9, 2018
1 parent 971fb09 commit 6b1b446
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions detox/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"detox-server": "detox run-server",
"e2e:ios": "detox test --configuration ios.sim.release --debug-synchronization --take-screenshots all --record-logs all",
"e2e:ios-multi": "npm run e2e:ios -- -w 2",
"e2e:android": "detox test --configuration android.emu.release --take-screenshots all --record-logs all",
"e2e:android": "detox test --configuration android.emu.debug --take-screenshots all --record-logs all",
"build:ios": "detox build --configuration ios.sim.release",
"build:android": "detox build --configuration android.emu.release",
"build:android": "detox build --configuration android.emu.debug",
"verify-artifacts:ios": "jest ./scripts/verify_artifacts_are_not_missing.ios.test.js --testEnvironment node",
"verify-artifacts:android": "jest ./scripts/verify_artifacts_are_not_missing.android.test.js --testEnvironment node"
},
Expand Down Expand Up @@ -58,7 +58,7 @@
"binaryPath": "android/app/build/outputs/apk/fromBin/debug/app-fromBin-debug.apk",
"build": "cd android && ./gradlew assembleFromBinDebug assembleFromBinDebugAndroidTest -DtestBuildType=debug && cd ..",
"type": "android.emulator",
"name": "Nexus_5X_API_26"
"name": "Pixel_2_XL_API_27"
},
"android.emu.release": {
"binaryPath": "android/app/build/outputs/apk/fromBin/release/app-fromBin-release.apk",
Expand Down
16 changes: 13 additions & 3 deletions detox/test/src/Screens/LanguageScreen.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import React, { Component } from 'react';
import { Text, View } from 'react-native';
import { Text, View, Platform } from 'react-native';
import { NativeModules } from 'react-native';
import _ from 'lodash';

export default class LanguageScreen extends Component {
render() {
const locale = Platform.select({
ios: () => NativeModules.SettingsManager.settings.AppleLocale,
android: () => NativeModules.I18nManager.localeIdentifier
})();

const language = Platform.select({
ios: () => _.take(NativeModules.SettingsManager.settings.AppleLanguages, 1),
android: () => 'N/A'
})();

return (
<View style={{ flex: 1, paddingTop: 20, justifyContent: 'center', alignItems: 'center' }}>
<Text style={{ fontSize: 25, marginBottom: 30 }}>Current locale: {NativeModules.SettingsManager.settings.AppleLocale}</Text>
<Text style={{ fontSize: 25, marginBottom: 30 }}>Current locale: {locale}</Text>
<Text style={{ fontSize: 25, marginBottom: 30 }}>
Current language: {_.take(NativeModules.SettingsManager.settings.AppleLanguages, 1)}
Current language: {language}
</Text>
</View>
);
Expand Down

0 comments on commit 6b1b446

Please sign in to comment.