From 2e1a0344991296593ffdf77d0dca84467ca428d6 Mon Sep 17 00:00:00 2001 From: Francois Reynaud Date: Sun, 20 May 2012 17:10:50 +0100 Subject: [PATCH] making the server side content l10n work. --- .../UIAModels/predicate/AbstractCriteria.java | 24 ++++++--- .../predicate/DecorableCriteria.java | 4 +- .../ios/server/CommandMapping.java | 24 ++++++--- .../ios/server/application/Localizable.java | 4 +- .../application/ServerSideL10NDecorator.java | 45 ++++++++++++++++ .../application/ServerSideL10NFactory.java | 44 ---------------- .../command/impl/DefaultUIAScriptHandler.java | 11 ++-- .../server/instruments/SessionsManager.java | 16 ++++++ .../ios/server/servlet/IOSServlet.java | 1 + .../server/simulator/IOSSimulatorManager.java | 1 + .../ios/server/tmp/SampleApps.java | 12 ++++- .../ios/e2e/intl/IntlMountainTestsBase.java | 46 ++++++++++++++++ .../ios/e2e/intl/ServerSideL10NTests.java | 52 +++++++++++++++++++ .../ios/e2e/uicatalogapp/CriteriaTests.java | 2 +- .../uicatalogapp/RemoteUIAElementArray.java | 2 +- .../uicatalogapp/RemoteUIAElementTests.java | 2 +- .../ios/e2e/uicatalogapp/SmokeTests.java | 2 +- ...TestsBase.java => UICatalogTestsBase.java} | 4 +- .../server/ServerSerializeExceptionTests.java | 2 +- 19 files changed, 224 insertions(+), 74 deletions(-) create mode 100644 server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NDecorator.java create mode 100644 server/src/test/java/org/uiautomation/ios/e2e/intl/IntlMountainTestsBase.java create mode 100644 server/src/test/java/org/uiautomation/ios/e2e/intl/ServerSideL10NTests.java rename server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/{RemoteTestsBase.java => UICatalogTestsBase.java} (94%) diff --git a/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/AbstractCriteria.java b/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/AbstractCriteria.java index 6ecc5654..684bd3c5 100644 --- a/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/AbstractCriteria.java +++ b/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/AbstractCriteria.java @@ -18,7 +18,6 @@ import java.util.List; import org.json.JSONArray; -import org.json.JSONException; import org.json.JSONObject; import org.uiautomation.ios.exceptions.InvalidCriteriaException; @@ -26,14 +25,19 @@ public abstract class AbstractCriteria implements Criteria { - @SuppressWarnings("unchecked") public static T parse(JSONObject serialized) throws Exception { + return parse(serialized, null); + } + + @SuppressWarnings("unchecked") + public static T parse(JSONObject serialized, CriteriaDecorator decorator) + throws Exception { int nbKeys = serialized.length(); switch (nbKeys) { case KEYS_IN_COMPOSED_CRITERIA: String key = (String) serialized.keys().next(); CompositionType type = CompositionType.valueOf(key); - return (T) buildComposedCriteria(serialized, type); + return (T) buildComposedCriteria(serialized, type, decorator); case KEYS_IN_PROPERTY_CRITERIA: String method = serialized.getString("method"); String tmp = @@ -41,7 +45,7 @@ public static T parse(JSONObject serialized) throws Excepti String clazz = AbstractCriteria.class.getPackage().getName() + "." + tmp; Class c = (Class) Class.forName(clazz); - return (T) buildPropertyBaseCriteria(serialized, c); + return (T) buildPropertyBaseCriteria(serialized, c, decorator); default: throw new InvalidCriteriaException("can't find the type : " + serialized.toString()); } @@ -52,8 +56,8 @@ public static T parse(JSONObject serialized) throws Excepti private static final int KEYS_IN_PROPERTY_CRITERIA = 3; - private static ComposedCriteria buildComposedCriteria(JSONObject serialized, CompositionType type) - throws Exception { + private static ComposedCriteria buildComposedCriteria(JSONObject serialized, + CompositionType type, CriteriaDecorator decorator) throws Exception { JSONArray array = serialized.getJSONArray(type.toString()); if (type == CompositionType.NOT && array.length() != 1) { throw new InvalidCriteriaException("negative criteria apply to 1 criteria only " + serialized); @@ -62,7 +66,7 @@ private static ComposedCriteria buildComposedCriteria(JSONObject serialized, Com for (int i = 0; i < array.length(); i++) { JSONObject c = array.getJSONObject(i); - Criteria crit = parse(c); + Criteria crit = parse(c, decorator); criterias.add(crit); } @@ -71,11 +75,13 @@ private static ComposedCriteria buildComposedCriteria(JSONObject serialized, Com Constructor c = type.getAssociatedClass().getConstructor(argsClass); ComposedCriteria crit = (ComposedCriteria) c.newInstance(args); + crit.addDecorator(decorator); + crit.decorate(); return crit; } private static PropertyEqualCriteria buildPropertyBaseCriteria(JSONObject serialized, - Class clazz) throws Exception { + Class clazz, CriteriaDecorator decorator) throws Exception { String expected = serialized.getString("expected"); String strategy = serialized.getString("strategy"); @@ -84,6 +90,8 @@ private static PropertyEqualCriteria buildPropertyBaseCriteria(JSONObject serial Constructor c = clazz.getConstructor(argsClass); PropertyEqualCriteria crit = (PropertyEqualCriteria) c.newInstance(args); + crit.addDecorator(decorator); + crit.decorate(); return crit; } } diff --git a/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/DecorableCriteria.java b/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/DecorableCriteria.java index 0f482caf..c59d39ce 100644 --- a/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/DecorableCriteria.java +++ b/common/src/main/java/org/uiautomation/ios/UIAModels/predicate/DecorableCriteria.java @@ -22,7 +22,9 @@ public abstract class DecorableCriteria extends AbstractCriteria { @Override public void addDecorator(CriteriaDecorator decorator) { - decorators.add(decorator); + if (decorator != null) { + decorators.add(decorator); + } } @Override diff --git a/server/src/main/java/org/uiautomation/ios/server/CommandMapping.java b/server/src/main/java/org/uiautomation/ios/server/CommandMapping.java index 20afa12f..766dcca0 100644 --- a/server/src/main/java/org/uiautomation/ios/server/CommandMapping.java +++ b/server/src/main/java/org/uiautomation/ios/server/CommandMapping.java @@ -5,8 +5,13 @@ import org.json.JSONException; import org.json.JSONObject; +import org.uiautomation.ios.UIAModels.predicate.AbstractCriteria; +import org.uiautomation.ios.UIAModels.predicate.Criteria; +import org.uiautomation.ios.UIAModels.predicate.CriteriaDecorator; import org.uiautomation.ios.communication.WebDriverLikeCommand; import org.uiautomation.ios.communication.WebDriverLikeRequest; +import org.uiautomation.ios.server.application.IOSApplication; +import org.uiautomation.ios.server.application.ServerSideL10NDecorator; import org.uiautomation.ios.server.command.Handler; import org.uiautomation.ios.server.command.impl.CustomUIAScriptHandler; import org.uiautomation.ios.server.command.impl.DefaultUIAScriptHandler; @@ -119,13 +124,13 @@ public static CommandMapping get(WebDriverLikeCommand wdlc) { throw new RuntimeException("not mapped : " + wdlc); } - public String jsMethod(JSONObject payload) { + public String jsMethod(JSONObject payload,IOSApplication aut) { if (jsMethod == null) { throw new RuntimeException("JS method missing from mapping."); } if (payload != null) { - payload = serverSidePayloadChanges(payload); + payload = serverSidePayloadChanges(payload,aut); String res = jsMethod; Iterator iter = payload.keys(); while (iter.hasNext()) { @@ -143,13 +148,18 @@ public String jsMethod(JSONObject payload) { } + private CriteriaDecorator getDecorator(IOSApplication aut){ + ServerSideL10NDecorator decorator = new ServerSideL10NDecorator(aut); + return decorator; + } - private JSONObject serverSidePayloadChanges(JSONObject payload) { - System.out.println(payload.toString()); - if (payload.has("stategy")){ + private JSONObject serverSidePayloadChanges(JSONObject payload, IOSApplication aut) { + if (payload.has("criteria")){ try { - System.out.println("got "+payload.getString("strategy")); - } catch (JSONException e) { + JSONObject json = payload.getJSONObject("criteria"); + Criteria decorated = AbstractCriteria.parse(json,getDecorator(aut)); + payload.put("criteria", decorated.getJSONRepresentation().toString()); + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/server/src/main/java/org/uiautomation/ios/server/application/Localizable.java b/server/src/main/java/org/uiautomation/ios/server/application/Localizable.java index 34d43f2d..5f85785d 100644 --- a/server/src/main/java/org/uiautomation/ios/server/application/Localizable.java +++ b/server/src/main/java/org/uiautomation/ios/server/application/Localizable.java @@ -53,7 +53,7 @@ public static Localizable createFromLegacyName(String appleMapping) throws IOSAu public static Localizable createFromNewName(String name) throws IOSAutomationException { for (Localizable l10n : Localizable.values()) { - if (l10n.newFormat.equals(name)) { + if (l10n.newFormat.equals(name) || l10n.toString().equals(name)) { return l10n; } } @@ -64,7 +64,7 @@ public static Localizable createFromNewName(String name) throws IOSAutomationExc // ISO-639-1 (two-letter) or ISO-639-2 (three-letter) public static boolean isNewName(String name) { for (Localizable l10n : Localizable.values()) { - if (l10n.newFormat.equals(name)) { + if (l10n.newFormat.equals(name) || l10n.toString().equals(name)) { return true; } } diff --git a/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NDecorator.java b/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NDecorator.java new file mode 100644 index 00000000..7c3428e8 --- /dev/null +++ b/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NDecorator.java @@ -0,0 +1,45 @@ +package org.uiautomation.ios.server.application; + +import org.uiautomation.ios.UIAModels.predicate.Criteria; +import org.uiautomation.ios.UIAModels.predicate.CriteriaDecorator; +import org.uiautomation.ios.UIAModels.predicate.MatchingStrategy; +import org.uiautomation.ios.UIAModels.predicate.PropertyEqualCriteria; +import org.uiautomation.ios.exceptions.InvalidCriteriaException; + +public class ServerSideL10NDecorator implements CriteriaDecorator { + + private final IOSApplication app; + + public ServerSideL10NDecorator(IOSApplication app) { + this.app = app; + } + + @Override + public void decorate(Criteria c) { + if (!isElligible(c)) { + return; + } + PropertyEqualCriteria criteria = (PropertyEqualCriteria) c; + String oldValue = criteria.getValue(); + LanguageDictionary dict = app.getDictionary(app.getCurrentLanguage()); + String newValue = dict.getContentForKey(oldValue); + if (newValue == null) { + throw new InvalidCriteriaException("No entry for key " + oldValue + " in dictionary for " + + app.getCurrentLanguage()); + } + + criteria.setValue(LanguageDictionary.getRegexPattern(newValue)); + criteria.setStrategy(MatchingStrategy.regex); + } + + + private boolean isElligible(Criteria c) { + if (c instanceof PropertyEqualCriteria) { + PropertyEqualCriteria crit = (PropertyEqualCriteria) c; + return crit.getMatchingStrategy() == MatchingStrategy.serverL10N; + } + return false; + } + + +} diff --git a/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NFactory.java b/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NFactory.java index 71f0e636..f1502fd4 100644 --- a/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NFactory.java +++ b/server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NFactory.java @@ -1,11 +1,7 @@ package org.uiautomation.ios.server.application; -import org.uiautomation.ios.UIAModels.predicate.Criteria; -import org.uiautomation.ios.UIAModels.predicate.CriteriaDecorator; import org.uiautomation.ios.UIAModels.predicate.MatchingStrategy; import org.uiautomation.ios.UIAModels.predicate.NameCriteria; -import org.uiautomation.ios.UIAModels.predicate.PropertyEqualCriteria; -import org.uiautomation.ios.exceptions.InvalidCriteriaException; public class ServerSideL10NFactory { @@ -21,44 +17,4 @@ public NameCriteria nameCriteria(String serverKey) { criteria.decorate(); return criteria; } - - - - class ServerSideL10NDecorator implements CriteriaDecorator { - - private final IOSApplication app; - - public ServerSideL10NDecorator(IOSApplication app) { - this.app = app; - } - - @Override - public void decorate(Criteria c) { - if (!isElligible(c)) { - return; - } - PropertyEqualCriteria criteria = (PropertyEqualCriteria) c; - String oldValue = criteria.getValue(); - LanguageDictionary dict = app.getDictionary(app.getCurrentLanguage()); - String newValue = dict.getContentForKey(oldValue); - if (newValue == null) { - throw new InvalidCriteriaException("No entry for key " + oldValue + " in dictionary for " - + app.getCurrentLanguage()); - } - - criteria.setValue(LanguageDictionary.getRegexPattern(newValue)); - criteria.setStrategy(MatchingStrategy.regex); - } - - - private boolean isElligible(Criteria c) { - if (c instanceof PropertyEqualCriteria) { - PropertyEqualCriteria crit = (PropertyEqualCriteria) c; - return crit.getMatchingStrategy() == MatchingStrategy.serverL10N; - } - return false; - } - - } - } diff --git a/server/src/main/java/org/uiautomation/ios/server/command/impl/DefaultUIAScriptHandler.java b/server/src/main/java/org/uiautomation/ios/server/command/impl/DefaultUIAScriptHandler.java index d78451ea..073d01e9 100644 --- a/server/src/main/java/org/uiautomation/ios/server/command/impl/DefaultUIAScriptHandler.java +++ b/server/src/main/java/org/uiautomation/ios/server/command/impl/DefaultUIAScriptHandler.java @@ -25,6 +25,7 @@ import org.uiautomation.ios.communication.WebDriverLikeCommand; import org.uiautomation.ios.communication.WebDriverLikeRequest; import org.uiautomation.ios.server.CommandMapping; +import org.uiautomation.ios.server.application.IOSApplication; import org.uiautomation.ios.server.command.UIAScriptHandler; import org.uiautomation.ios.server.instruments.SessionsManager; @@ -67,6 +68,10 @@ public boolean isAUIASimpleObject(Class type) { return false; } + private IOSApplication getAUT() { + return getSessionsManager().getCurrentApplication(); + } + // TODO freynaud extract. private static final String stringTemplate = "var target = UIAutomation.cache.get(:reference);var myStringResult = target:jsMethod ;UIAutomation.createJSONResponse(':sessionId',0,myStringResult)"; @@ -80,7 +85,7 @@ public boolean isAUIASimpleObject(Class type) { private String jsForRemoteObject(JSONObject payload) { WebDriverLikeCommand command = getRequest().getGenericCommand(); CommandMapping mapping = CommandMapping.get(command); - String method = mapping.jsMethod(payload); + String method = mapping.jsMethod(payload, getAUT()); String js = objectTemplate.replace(":jsMethod", method) @@ -96,7 +101,7 @@ private String jsForRemoteObject(JSONObject payload) { private String jsForString(JSONObject payload) { WebDriverLikeCommand command = getRequest().getGenericCommand(); CommandMapping mapping = CommandMapping.get(command); - String method = mapping.jsMethod(payload); + String method = mapping.jsMethod(payload, getAUT()); String js = stringTemplate.replace(":jsMethod", method) @@ -116,7 +121,7 @@ private String jsForString(JSONObject payload) { private String jsForVoid(JSONObject payload) { WebDriverLikeCommand command = getRequest().getGenericCommand(); CommandMapping mapping = CommandMapping.get(command); - String method = mapping.jsMethod(payload); + String method = mapping.jsMethod(payload, getAUT()); String js = voidTemplate.replace(":jsMethod", method) diff --git a/server/src/main/java/org/uiautomation/ios/server/instruments/SessionsManager.java b/server/src/main/java/org/uiautomation/ios/server/instruments/SessionsManager.java index 91cdee4c..93e0bd3a 100644 --- a/server/src/main/java/org/uiautomation/ios/server/instruments/SessionsManager.java +++ b/server/src/main/java/org/uiautomation/ios/server/instruments/SessionsManager.java @@ -22,11 +22,18 @@ import org.uiautomation.ios.communication.IOSDevice; import org.uiautomation.ios.communication.Session; import org.uiautomation.ios.exceptions.IOSAutomationSetupException; +import org.uiautomation.ios.server.application.IOSApplication; +import org.uiautomation.ios.server.application.LanguageDictionary; +import org.uiautomation.ios.server.application.Localizable; public class SessionsManager { private Session currentSession; + private IOSApplication currentApplication; + + + private InstrumentsManager instrumentsManager; public SessionsManager() throws IOSAutomationSetupException { @@ -43,6 +50,12 @@ public void run() { public void createSession(IOSCapabilities cap) throws IOSAutomationSetupException { IOSCapabilities v = completeWithDefaults(cap); + + Localizable language = new LanguageDictionary(v.getLanguage()).getLanguage(); + String aut = v.getApplication(); + currentApplication = new IOSApplication(language, aut); + currentApplication.loadAllContent(); + createSession(v.getDevice(), v.getSDKVersion(), v.getLocale(), v.getLanguage(), new File(v.getApplication()), v.isTimeHack(), v.getExtraSwitches()); } @@ -101,6 +114,9 @@ public void deleteSession() throws IOSAutomationSetupException { currentSession = null; } + public IOSApplication getCurrentApplication() { + return currentApplication; + } public void forceStop() { instrumentsManager.forceStop(); diff --git a/server/src/main/java/org/uiautomation/ios/server/servlet/IOSServlet.java b/server/src/main/java/org/uiautomation/ios/server/servlet/IOSServlet.java index 0707e92a..3ab8deda 100644 --- a/server/src/main/java/org/uiautomation/ios/server/servlet/IOSServlet.java +++ b/server/src/main/java/org/uiautomation/ios/server/servlet/IOSServlet.java @@ -27,6 +27,7 @@ import org.uiautomation.ios.communication.WebDriverLikeRequest; import org.uiautomation.ios.communication.WebDriverLikeResponse; import org.uiautomation.ios.server.CommandMapping; +import org.uiautomation.ios.server.application.IOSApplication; import org.uiautomation.ios.server.command.Handler; public class IOSServlet extends UIAScriptProxyBasedServlet { diff --git a/server/src/main/java/org/uiautomation/ios/server/simulator/IOSSimulatorManager.java b/server/src/main/java/org/uiautomation/ios/server/simulator/IOSSimulatorManager.java index 12e9979a..001c16a9 100644 --- a/server/src/main/java/org/uiautomation/ios/server/simulator/IOSSimulatorManager.java +++ b/server/src/main/java/org/uiautomation/ios/server/simulator/IOSSimulatorManager.java @@ -252,6 +252,7 @@ private File getContentAndSettingsFolder() { private File getGlobalPreferenceFile() { File folder = new File(contentAndSettingsFolder + "/Library/Preferences/"); File global = new File(folder, ".GlobalPreferences.plist"); + System.out.println(global); return global; } diff --git a/server/src/main/java/org/uiautomation/ios/server/tmp/SampleApps.java b/server/src/main/java/org/uiautomation/ios/server/tmp/SampleApps.java index 133d7448..7a38354d 100644 --- a/server/src/main/java/org/uiautomation/ios/server/tmp/SampleApps.java +++ b/server/src/main/java/org/uiautomation/ios/server/tmp/SampleApps.java @@ -18,8 +18,9 @@ import org.testng.Assert; import org.uiautomation.ios.IOSCapabilities; +import org.uiautomation.ios.server.application.Localizable; -//TODO freynaud move to tests +// TODO freynaud move to tests public class SampleApps { @@ -50,9 +51,16 @@ public static String getIntlMountainsApp() { return getFromClassPath(intlMountains).getAbsolutePath(); } - public static IOSCapabilities cap() { + public static IOSCapabilities uiCatalogCap() { IOSCapabilities c = IOSCapabilities.iphone(SampleApps.getUICatalogApp()); c.setCapability(IOSCapabilities.TIME_HACK, true); return c; } + + public static IOSCapabilities intlMountainsCap(Localizable l) { + IOSCapabilities c = IOSCapabilities.iphone(SampleApps.getIntlMountainsApp()); + c.setLanguage(l.getName()); + c.setCapability(IOSCapabilities.TIME_HACK, true); + return c; + } } diff --git a/server/src/test/java/org/uiautomation/ios/e2e/intl/IntlMountainTestsBase.java b/server/src/test/java/org/uiautomation/ios/e2e/intl/IntlMountainTestsBase.java new file mode 100644 index 00000000..fdc795b9 --- /dev/null +++ b/server/src/test/java/org/uiautomation/ios/e2e/intl/IntlMountainTestsBase.java @@ -0,0 +1,46 @@ +package org.uiautomation.ios.e2e.intl; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.uiautomation.ios.client.uiamodels.impl.RemoteUIAApplication; +import org.uiautomation.ios.client.uiamodels.impl.RemoteUIADriver; +import org.uiautomation.ios.client.uiamodels.impl.RemoteUIATarget; +import org.uiautomation.ios.client.uiamodels.impl.RemoteUIAWindow; +import org.uiautomation.ios.server.IOSServer; +import org.uiautomation.ios.server.IOSServerConfiguration; +import org.uiautomation.ios.server.application.Localizable; +import org.uiautomation.ios.server.tmp.SampleApps; + +public class IntlMountainTestsBase { + private IOSServer server; + private static String[] args = {"-port", "4444", "-host", "localhost"}; + private static IOSServerConfiguration config = IOSServerConfiguration.create(args); + private String url = "http://" + config.getHost() + ":" + config.getPort() + "/wd/hub"; + + @BeforeClass + public void startServer() throws Exception { + server = new IOSServer(config); + server.start(); + } + + protected String getURL() { + return url; + } + + protected RemoteUIADriver getDriver(Localizable l) { + return new RemoteUIADriver("http://" + config.getHost() + ":" + config.getPort() + "/wd/hub", + SampleApps.intlMountainsCap(l)); + } + + protected RemoteUIAWindow getMainWindow(RemoteUIADriver driver) { + RemoteUIATarget target = driver.getLocalTarget(); + RemoteUIAApplication app = target.getFrontMostApp(); + RemoteUIAWindow window = app.getMainWindow(); + return window; + } + + @AfterClass + public void stopServer() throws Exception { + server.stop(); + } +} diff --git a/server/src/test/java/org/uiautomation/ios/e2e/intl/ServerSideL10NTests.java b/server/src/test/java/org/uiautomation/ios/e2e/intl/ServerSideL10NTests.java new file mode 100644 index 00000000..8506d2cb --- /dev/null +++ b/server/src/test/java/org/uiautomation/ios/e2e/intl/ServerSideL10NTests.java @@ -0,0 +1,52 @@ +package org.uiautomation.ios.e2e.intl; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.uiautomation.ios.UIAModels.UIAElement; +import org.uiautomation.ios.UIAModels.UIATableCell; +import org.uiautomation.ios.UIAModels.predicate.Criteria; +import org.uiautomation.ios.UIAModels.predicate.MatchingStrategy; +import org.uiautomation.ios.UIAModels.predicate.NameCriteria; +import org.uiautomation.ios.UIAModels.predicate.TypeCriteria; +import org.uiautomation.ios.client.uiamodels.impl.RemoteUIADriver; +import org.uiautomation.ios.client.uiamodels.impl.RemoteUIAWindow; +import org.uiautomation.ios.server.application.Localizable; + +public class ServerSideL10NTests extends IntlMountainTestsBase { + + + + @DataProvider(name = "intlMountain",parallel=false) + public Object[][] createDataPerLocale() { + return new Object[][] { + {Localizable.en, "Mountain 1 was first climbed on 29 May 1953 and has a height of 8,848 meters"}, + {Localizable.fr,"Bien que 8,848 mètres de haut, Montagne 1 aient été montés la première fois 29 May 1953."}, + {Localizable.zh, "山 1 是8,848米高。它第一次攀登了在29 May 1953。"} + }; + } + + @Test(dataProvider="intlMountain") + public void selectAndValidateServerSideL10NedContent(Localizable l, String expectedContent) { + RemoteUIADriver driver = null; + try { + + driver = getDriver(l); + RemoteUIAWindow win = getMainWindow(driver); + Criteria c1 = new TypeCriteria(UIATableCell.class); + UIAElement element = win.findElement(c1); + element.tap(); + + NameCriteria criteria = new NameCriteria("sentenceFormat", MatchingStrategy.serverL10N); + UIAElement text = win.findElement(criteria); + String actual = text.getName(); + Assert.assertEquals(actual, expectedContent); + } finally { + if (driver != null) { + driver.quit(); + } + } + } + + +} diff --git a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/CriteriaTests.java b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/CriteriaTests.java index 4e9a1a83..a28f2143 100644 --- a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/CriteriaTests.java +++ b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/CriteriaTests.java @@ -13,7 +13,7 @@ import org.uiautomation.ios.client.uiamodels.impl.RemoteUIADriver; import org.uiautomation.ios.client.uiamodels.impl.RemoteUIAWindow; -public class CriteriaTests extends RemoteTestsBase { +public class CriteriaTests extends UICatalogTestsBase { @Test diff --git a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementArray.java b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementArray.java index 6f8e616f..cd9f8f6a 100644 --- a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementArray.java +++ b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementArray.java @@ -11,7 +11,7 @@ import org.uiautomation.ios.client.uiamodels.impl.RemoteUIADriver; import org.uiautomation.ios.client.uiamodels.impl.RemoteUIAWindow; -public class RemoteUIAElementArray extends RemoteTestsBase { +public class RemoteUIAElementArray extends UICatalogTestsBase { @Test diff --git a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementTests.java b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementTests.java index e9644eac..e14b04a6 100644 --- a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementTests.java +++ b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteUIAElementTests.java @@ -20,7 +20,7 @@ import org.uiautomation.ios.exceptions.NoSuchElementException; import org.uiautomation.ios.exceptions.StaleReferenceException; -public class RemoteUIAElementTests extends RemoteTestsBase { +public class RemoteUIAElementTests extends UICatalogTestsBase { diff --git a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/SmokeTests.java b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/SmokeTests.java index 42b8243b..3b12789a 100644 --- a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/SmokeTests.java +++ b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/SmokeTests.java @@ -6,7 +6,7 @@ import org.uiautomation.ios.client.uiamodels.impl.RemoteUIADriver; import org.uiautomation.ios.client.uiamodels.impl.RemoteUIAWindow; -public class SmokeTests extends RemoteTestsBase { +public class SmokeTests extends UICatalogTestsBase { @Test public void canGetMainWindow() throws InterruptedException { diff --git a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteTestsBase.java b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/UICatalogTestsBase.java similarity index 94% rename from server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteTestsBase.java rename to server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/UICatalogTestsBase.java index 641cb3ce..582f922f 100644 --- a/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/RemoteTestsBase.java +++ b/server/src/test/java/org/uiautomation/ios/e2e/uicatalogapp/UICatalogTestsBase.java @@ -10,7 +10,7 @@ import org.uiautomation.ios.server.IOSServerConfiguration; import org.uiautomation.ios.server.tmp.SampleApps; -public abstract class RemoteTestsBase { +public abstract class UICatalogTestsBase { private IOSServer server; private static String[] args = {"-port", "4444", "-host", "localhost"}; @@ -29,7 +29,7 @@ protected String getURL() { protected RemoteUIADriver getDriver() { return new RemoteUIADriver("http://" + config.getHost() + ":" + config.getPort() + "/wd/hub", - SampleApps.cap()); + SampleApps.uiCatalogCap()); } protected RemoteUIAWindow getMainWindow(RemoteUIADriver driver) { diff --git a/server/src/test/java/org/uiautomation/ios/server/ServerSerializeExceptionTests.java b/server/src/test/java/org/uiautomation/ios/server/ServerSerializeExceptionTests.java index b46b873b..00478e4d 100644 --- a/server/src/test/java/org/uiautomation/ios/server/ServerSerializeExceptionTests.java +++ b/server/src/test/java/org/uiautomation/ios/server/ServerSerializeExceptionTests.java @@ -29,7 +29,7 @@ public void startServer() throws Exception { public void clientGetsServerException() throws IOSAutomationSetupException { RemoteUIADriver driver = null; try { - IOSCapabilities cap = SampleApps.cap(); + IOSCapabilities cap = SampleApps.uiCatalogCap(); cap.setSDKVersion("1234"); driver = new RemoteUIADriver(url, cap);