2222import com .google .gson .Gson ;
2323import com .google .gson .GsonBuilder ;
2424import com .samsung .watchface .WatchFaceXmlValidator ;
25- import com .samsung .watchface .WatchFaceXmlValidator .WatchFaceFormatValidationException ;
2625import java .io .PrintWriter ;
2726import java .io .StringWriter ;
2827import java .util .List ;
@@ -116,6 +115,7 @@ static List<MemoryFootprint> evaluateMemoryFootprint(EvaluationSettings evaluati
116115 WatchFaceData watchFaceData =
117116 WatchFaceData .fromResourcesStream (
118117 inputPackage .getWatchFaceFiles (), evaluationSettings );
118+
119119 if (!evaluationSettings .isHoneyfaceMode ()) {
120120 String wffVersion =
121121 getWatchFaceFormatVersion (inputPackage .getManifest (), evaluationSettings );
@@ -125,42 +125,9 @@ static List<MemoryFootprint> evaluateMemoryFootprint(EvaluationSettings evaluati
125125 return watchFaceData .getWatchFaceDocuments ().stream ()
126126 .map (
127127 watchFaceDocument ->
128- evaluateWatchFaceForLayout (
129- watchFaceData .getResourceDetailsMap (),
128+ WatchFaceLayoutEvaluator .evaluate (
130129 watchFaceDocument ,
131- evaluationSettings ))
132- .collect (Collectors .toList ());
133- }
134- }
135-
136- /**
137- * Parses a watch face package and evaluates the memory footprint for all of its layouts.
138- *
139- * @param evaluationSettings the settings object for running the watch face evaluation.
140- * @return the list of memory footprints, one for each layout supported by the watch face.
141- * @throws WatchFaceFormatValidationException if the schema for the validation was not
142- * available.
143- * @throws TestFailedException if the watch face memory footprint validation has failed.
144- */
145- public static List <MemoryFootprint > evaluateMemoryFootprintOrThrow (
146- EvaluationSettings evaluationSettings )
147- throws TestFailedException , WatchFaceFormatValidationException {
148- try (InputPackage inputPackage = InputPackage .open (evaluationSettings .getWatchFacePath ())) {
149- WatchFaceData watchFaceData =
150- WatchFaceData .fromResourcesStream (
151- inputPackage .getWatchFaceFiles (), evaluationSettings );
152- if (!evaluationSettings .isHoneyfaceMode ()) {
153- String wffVersion =
154- getWatchFaceFormatVersion (inputPackage .getManifest (), evaluationSettings );
155- validateFormatOrThrow (watchFaceData , wffVersion );
156- }
157-
158- return watchFaceData .getWatchFaceDocuments ().stream ()
159- .map (
160- watchFaceDocument ->
161- evaluateWatchFaceForLayout (
162130 watchFaceData .getResourceDetailsMap (),
163- watchFaceDocument ,
164131 evaluationSettings ))
165132 .collect (Collectors .toList ());
166133 }
@@ -199,20 +166,6 @@ private static String getWatchFaceFormatVersion(
199166 return cliWffVersion != null ? cliWffVersion : manifestWffVersion ;
200167 }
201168
202- private static void validateFormatOrThrow (
203- WatchFaceData watchFaceData , String watchFaceFormatVersion )
204- throws WatchFaceFormatValidationException {
205- WatchFaceXmlValidator xmlValidator = new WatchFaceXmlValidator ();
206- for (Document watchFaceDocument : watchFaceData .getWatchFaceDocuments ()) {
207- boolean documentHasValidSchema =
208- xmlValidator .validateOrThrow (watchFaceDocument , watchFaceFormatVersion );
209- if (!documentHasValidSchema ) {
210- throw new TestFailedException (
211- "Watch Face has syntactic errors and cannot be parsed." );
212- }
213- }
214- }
215-
216169 /**
217170 * Runs the watch face format XSD validation.
218171 *
0 commit comments