blob: da00511fd192f357a77e7d7c06a22602e33e83b3 [file] [log] [blame]
Shane Farmer74cdea32017-05-12 16:22:36 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "configuration/ConfigurationParser.h"
18
19#include <string>
20
Shane Farmer67e8a302017-12-06 14:39:10 -080021#include "android-base/stringprintf.h"
Shane Farmer74cdea32017-05-12 16:22:36 -070022#include "androidfw/ResourceTypes.h"
23
Shane Farmer67e8a302017-12-06 14:39:10 -080024#include "SdkConstants.h"
Shane Farmercb6c3f92017-11-27 13:19:36 -080025#include "configuration/ConfigurationParser.internal.h"
Shane Farmer74cdea32017-05-12 16:22:36 -070026#include "test/Test.h"
27#include "xml/XmlDom.h"
28
29namespace aapt {
Shane Farmer3edd4722017-09-01 14:34:22 -070030
31namespace configuration {
32void PrintTo(const AndroidSdk& sdk, std::ostream* os) {
33 *os << "SDK: min=" << sdk.min_sdk_version.value_or_default(-1)
34 << ", target=" << sdk.target_sdk_version.value_or_default(-1)
35 << ", max=" << sdk.max_sdk_version.value_or_default(-1);
36}
Shane Farmercb6c3f92017-11-27 13:19:36 -080037
38namespace handler {
Shane Farmer3edd4722017-09-01 14:34:22 -070039
Shane Farmer74cdea32017-05-12 16:22:36 -070040namespace {
41
Shane Farmer67e8a302017-12-06 14:39:10 -080042using ::aapt::configuration::Abi;
43using ::aapt::configuration::AndroidManifest;
44using ::aapt::configuration::AndroidSdk;
Shane Farmercb6c3f92017-11-27 13:19:36 -080045using ::aapt::configuration::ConfiguredArtifact;
Shane Farmer67e8a302017-12-06 14:39:10 -080046using ::aapt::configuration::DeviceFeature;
47using ::aapt::configuration::GlTexture;
48using ::aapt::configuration::Locale;
49using ::aapt::configuration::PostProcessingConfiguration;
50using ::aapt::xml::Element;
51using ::aapt::xml::NodeCast;
Adam Lesinski6b372992017-08-09 10:54:23 -070052using ::android::ResTable_config;
Shane Farmer67e8a302017-12-06 14:39:10 -080053using ::android::base::StringPrintf;
Adam Lesinski6b372992017-08-09 10:54:23 -070054using ::testing::ElementsAre;
Shane Farmercb6c3f92017-11-27 13:19:36 -080055using ::testing::SizeIs;
Shane Farmer74cdea32017-05-12 16:22:36 -070056
57constexpr const char* kValidConfig = R"(<?xml version="1.0" encoding="utf-8" ?>
58<post-process xmlns="http://schemas.android.com/tools/aapt">
59 <groups>
60 <abi-group label="arm">
61 <abi>armeabi-v7a</abi>
62 <abi>arm64-v8a</abi>
63 </abi-group>
64 <abi-group label="other">
65 <abi>x86</abi>
66 <abi>mips</abi>
67 </abi-group>
68 <screen-density-group label="large">
69 <screen-density>xhdpi</screen-density>
70 <screen-density>xxhdpi</screen-density>
71 <screen-density>xxxhdpi</screen-density>
72 </screen-density-group>
73 <screen-density-group label="alldpi">
74 <screen-density>ldpi</screen-density>
75 <screen-density>mdpi</screen-density>
76 <screen-density>hdpi</screen-density>
77 <screen-density>xhdpi</screen-density>
78 <screen-density>xxhdpi</screen-density>
79 <screen-density>xxxhdpi</screen-density>
80 </screen-density-group>
81 <locale-group label="europe">
Shane Farmer0a5b2012017-06-22 12:24:12 -070082 <locale>en</locale>
83 <locale>es</locale>
84 <locale>fr</locale>
85 <locale>de</locale>
Shane Farmer74cdea32017-05-12 16:22:36 -070086 </locale-group>
87 <locale-group label="north-america">
Shane Farmer0a5b2012017-06-22 12:24:12 -070088 <locale>en</locale>
89 <locale>es-rMX</locale>
90 <locale>fr-rCA</locale>
Shane Farmer74cdea32017-05-12 16:22:36 -070091 </locale-group>
Shane Farmerefe45392017-08-21 14:39:28 -070092 <android-sdk-group label="v19">
Shane Farmer74cdea32017-05-12 16:22:36 -070093 <android-sdk
Shane Farmer3edd4722017-09-01 14:34:22 -070094 minSdkVersion="19"
95 targetSdkVersion="24"
96 maxSdkVersion="25">
Shane Farmer74cdea32017-05-12 16:22:36 -070097 <manifest>
98 <!--- manifest additions here XSLT? TODO -->
99 </manifest>
100 </android-sdk>
101 </android-sdk-group>
102 <gl-texture-group label="dxt1">
103 <gl-texture name="GL_EXT_texture_compression_dxt1">
104 <texture-path>assets/dxt1/*</texture-path>
105 </gl-texture>
106 </gl-texture-group>
107 <device-feature-group label="low-latency">
108 <supports-feature>android.hardware.audio.low_latency</supports-feature>
109 </device-feature-group>
110 </groups>
111 <artifacts>
112 <artifact-format>
113 ${base}.${abi}.${screen-density}.${locale}.${sdk}.${gl}.${feature}.release
114 </artifact-format>
115 <artifact
116 name="art1"
117 abi-group="arm"
118 screen-density-group="large"
119 locale-group="europe"
Shane Farmerefe45392017-08-21 14:39:28 -0700120 android-sdk-group="v19"
Shane Farmer74cdea32017-05-12 16:22:36 -0700121 gl-texture-group="dxt1"
122 device-feature-group="low-latency"/>
123 <artifact
124 name="art2"
125 abi-group="other"
126 screen-density-group="alldpi"
127 locale-group="north-america"
Shane Farmerefe45392017-08-21 14:39:28 -0700128 android-sdk-group="v19"
Shane Farmer74cdea32017-05-12 16:22:36 -0700129 gl-texture-group="dxt1"
130 device-feature-group="low-latency"/>
131 </artifacts>
132</post-process>
133)";
134
135class ConfigurationParserTest : public ConfigurationParser, public ::testing::Test {
136 public:
137 ConfigurationParserTest() : ConfigurationParser("") {}
138
139 protected:
140 StdErrDiagnostics diag_;
141};
142
Shane Farmerb1027272017-06-14 09:10:28 -0700143TEST_F(ConfigurationParserTest, ForPath_NoFile) {
144 auto result = ConfigurationParser::ForPath("./does_not_exist.xml");
145 EXPECT_FALSE(result);
146}
147
Shane Farmer74cdea32017-05-12 16:22:36 -0700148TEST_F(ConfigurationParserTest, ValidateFile) {
149 auto parser = ConfigurationParser::ForContents(kValidConfig).WithDiagnostics(&diag_);
Shane Farmercb6c3f92017-11-27 13:19:36 -0800150 auto result = parser.Parse("test.apk");
Shane Farmer74cdea32017-05-12 16:22:36 -0700151 ASSERT_TRUE(result);
Shane Farmercb6c3f92017-11-27 13:19:36 -0800152 const std::vector<OutputArtifact>& value = result.value();
153 EXPECT_THAT(value, SizeIs(2ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700154
Shane Farmercb6c3f92017-11-27 13:19:36 -0800155 const OutputArtifact& a1 = value[0];
156 EXPECT_EQ(a1.name, "art1.apk");
157 EXPECT_THAT(a1.abis, ElementsAre(Abi::kArmV7a, Abi::kArm64V8a));
158 EXPECT_THAT(a1.screen_densities,
159 ElementsAre(test::ParseConfigOrDie("xhdpi").CopyWithoutSdkVersion(),
160 test::ParseConfigOrDie("xxhdpi").CopyWithoutSdkVersion(),
161 test::ParseConfigOrDie("xxxhdpi").CopyWithoutSdkVersion()));
162 EXPECT_THAT(a1.locales, ElementsAre(test::ParseConfigOrDie("en"), test::ParseConfigOrDie("es"),
163 test::ParseConfigOrDie("fr"), test::ParseConfigOrDie("de")));
164 EXPECT_EQ(a1.android_sdk.value().min_sdk_version.value(), 19l);
165 EXPECT_THAT(a1.textures, SizeIs(1ul));
166 EXPECT_THAT(a1.features, SizeIs(1ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700167
Shane Farmercb6c3f92017-11-27 13:19:36 -0800168 const OutputArtifact& a2 = value[1];
169 EXPECT_EQ(a2.name, "art2.apk");
170 EXPECT_THAT(a2.abis, ElementsAre(Abi::kX86, Abi::kMips));
171 EXPECT_THAT(a2.screen_densities,
172 ElementsAre(test::ParseConfigOrDie("ldpi").CopyWithoutSdkVersion(),
173 test::ParseConfigOrDie("mdpi").CopyWithoutSdkVersion(),
174 test::ParseConfigOrDie("hdpi").CopyWithoutSdkVersion(),
175 test::ParseConfigOrDie("xhdpi").CopyWithoutSdkVersion(),
176 test::ParseConfigOrDie("xxhdpi").CopyWithoutSdkVersion(),
177 test::ParseConfigOrDie("xxxhdpi").CopyWithoutSdkVersion()));
178 EXPECT_THAT(a2.locales,
179 ElementsAre(test::ParseConfigOrDie("en"), test::ParseConfigOrDie("es-rMX"),
180 test::ParseConfigOrDie("fr-rCA")));
181 EXPECT_EQ(a2.android_sdk.value().min_sdk_version.value(), 19l);
182 EXPECT_THAT(a2.textures, SizeIs(1ul));
183 EXPECT_THAT(a2.features, SizeIs(1ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700184}
185
186TEST_F(ConfigurationParserTest, InvalidNamespace) {
187 constexpr const char* invalid_ns = R"(<?xml version="1.0" encoding="utf-8" ?>
188 <post-process xmlns="http://schemas.android.com/tools/another-unknown-tool" />)";
189
Shane Farmercb6c3f92017-11-27 13:19:36 -0800190 auto result = ConfigurationParser::ForContents(invalid_ns).Parse("test.apk");
Shane Farmer74cdea32017-05-12 16:22:36 -0700191 ASSERT_FALSE(result);
192}
193
194TEST_F(ConfigurationParserTest, ArtifactAction) {
Shane Farmer810fd182017-09-21 14:37:44 -0700195 PostProcessingConfiguration config;
196 {
197 const auto doc = test::BuildXmlDom(R"xml(
198 <artifact
199 abi-group="arm"
200 screen-density-group="large"
201 locale-group="europe"
202 android-sdk-group="v19"
203 gl-texture-group="dxt1"
204 device-feature-group="low-latency"/>)xml");
205
Shane Farmercb6c3f92017-11-27 13:19:36 -0800206 ASSERT_TRUE(ArtifactTagHandler(&config, NodeCast<Element>(doc->root.get()), &diag_));
Shane Farmer810fd182017-09-21 14:37:44 -0700207
Shane Farmercb6c3f92017-11-27 13:19:36 -0800208 EXPECT_THAT(config.artifacts, SizeIs(1ul));
Shane Farmer810fd182017-09-21 14:37:44 -0700209
210 auto& artifact = config.artifacts.back();
211 EXPECT_FALSE(artifact.name); // TODO: make this fail.
212 EXPECT_EQ(1, artifact.version);
213 EXPECT_EQ("arm", artifact.abi_group.value());
214 EXPECT_EQ("large", artifact.screen_density_group.value());
215 EXPECT_EQ("europe", artifact.locale_group.value());
216 EXPECT_EQ("v19", artifact.android_sdk_group.value());
217 EXPECT_EQ("dxt1", artifact.gl_texture_group.value());
218 EXPECT_EQ("low-latency", artifact.device_feature_group.value());
219 }
220
221 {
222 // Perform a second action to ensure we get 2 artifacts.
223 const auto doc = test::BuildXmlDom(R"xml(
224 <artifact
225 abi-group="other"
226 screen-density-group="large"
227 locale-group="europe"
228 android-sdk-group="v19"
229 gl-texture-group="dxt1"
230 device-feature-group="low-latency"/>)xml");
231
Shane Farmercb6c3f92017-11-27 13:19:36 -0800232 ASSERT_TRUE(ArtifactTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_));
233 EXPECT_THAT(config.artifacts, SizeIs(2ul));
Shane Farmer810fd182017-09-21 14:37:44 -0700234 EXPECT_EQ(2, config.artifacts.back().version);
235 }
236
237 {
238 // Perform a third action with a set version code.
239 const auto doc = test::BuildXmlDom(R"xml(
Shane Farmer74cdea32017-05-12 16:22:36 -0700240 <artifact
Shane Farmer810fd182017-09-21 14:37:44 -0700241 version="5"
242 abi-group="other"
Shane Farmer74cdea32017-05-12 16:22:36 -0700243 screen-density-group="large"
244 locale-group="europe"
Shane Farmerefe45392017-08-21 14:39:28 -0700245 android-sdk-group="v19"
Shane Farmer74cdea32017-05-12 16:22:36 -0700246 gl-texture-group="dxt1"
Shane Farmer810fd182017-09-21 14:37:44 -0700247 device-feature-group="low-latency"/>)xml");
Shane Farmer74cdea32017-05-12 16:22:36 -0700248
Shane Farmercb6c3f92017-11-27 13:19:36 -0800249 ASSERT_TRUE(ArtifactTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_));
250 EXPECT_THAT(config.artifacts, SizeIs(3ul));
Shane Farmer810fd182017-09-21 14:37:44 -0700251 EXPECT_EQ(5, config.artifacts.back().version);
252 }
Shane Farmer74cdea32017-05-12 16:22:36 -0700253
Shane Farmer810fd182017-09-21 14:37:44 -0700254 {
255 // Perform a fourth action to ensure the version code still increments.
256 const auto doc = test::BuildXmlDom(R"xml(
Shane Farmer57669432017-06-19 12:52:04 -0700257 <artifact
258 abi-group="other"
259 screen-density-group="large"
260 locale-group="europe"
Shane Farmerefe45392017-08-21 14:39:28 -0700261 android-sdk-group="v19"
Shane Farmer57669432017-06-19 12:52:04 -0700262 gl-texture-group="dxt1"
Shane Farmer810fd182017-09-21 14:37:44 -0700263 device-feature-group="low-latency"/>)xml");
Shane Farmer57669432017-06-19 12:52:04 -0700264
Shane Farmercb6c3f92017-11-27 13:19:36 -0800265 ASSERT_TRUE(ArtifactTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_));
266 EXPECT_THAT(config.artifacts, SizeIs(4ul));
Shane Farmer810fd182017-09-21 14:37:44 -0700267 EXPECT_EQ(6, config.artifacts.back().version);
268 }
269}
270
271TEST_F(ConfigurationParserTest, DuplicateArtifactVersion) {
272 static constexpr const char* configuration = R"xml(<?xml version="1.0" encoding="utf-8" ?>
273 <pst-process xmlns="http://schemas.android.com/tools/aapt">>
274 <artifacts>
275 <artifact-format>
276 ${base}.${abi}.${screen-density}.${locale}.${sdk}.${gl}.${feature}.release
277 </artifact-format>
278 <artifact
279 name="art1"
280 abi-group="arm"
281 screen-density-group="large"
282 locale-group="europe"
283 android-sdk-group="v19"
284 gl-texture-group="dxt1"
285 device-feature-group="low-latency"/>
286 <artifact
287 name="art2"
288 version = "1"
289 abi-group="other"
290 screen-density-group="alldpi"
291 locale-group="north-america"
292 android-sdk-group="v19"
293 gl-texture-group="dxt1"
294 device-feature-group="low-latency"/>
295 </artifacts>
296 </post-process>)xml";
Shane Farmercb6c3f92017-11-27 13:19:36 -0800297 auto result = ConfigurationParser::ForContents(configuration).Parse("test.apk");
Shane Farmer810fd182017-09-21 14:37:44 -0700298 ASSERT_FALSE(result);
Shane Farmer74cdea32017-05-12 16:22:36 -0700299}
300
301TEST_F(ConfigurationParserTest, ArtifactFormatAction) {
Shane Farmer810fd182017-09-21 14:37:44 -0700302 const auto doc = test::BuildXmlDom(R"xml(
Shane Farmer74cdea32017-05-12 16:22:36 -0700303 <artifact-format>
304 ${base}.${abi}.${screen-density}.${locale}.${sdk}.${gl}.${feature}.release
Shane Farmer810fd182017-09-21 14:37:44 -0700305 </artifact-format>)xml");
Shane Farmer74cdea32017-05-12 16:22:36 -0700306
Shane Farmer280be342017-06-21 15:20:15 -0700307 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800308 bool ok = ArtifactFormatTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700309 ASSERT_TRUE(ok);
310 ASSERT_TRUE(config.artifact_format);
311 EXPECT_EQ(
312 "${base}.${abi}.${screen-density}.${locale}.${sdk}.${gl}.${feature}.release",
313 static_cast<std::string>(config.artifact_format.value())
314 );
315}
316
317TEST_F(ConfigurationParserTest, AbiGroupAction) {
318 static constexpr const char* xml = R"xml(
319 <abi-group label="arm">
320 <!-- First comment. -->
321 <abi>
322 armeabi-v7a
323 </abi>
324 <!-- Another comment. -->
325 <abi>arm64-v8a</abi>
326 </abi-group>)xml";
327
328 auto doc = test::BuildXmlDom(xml);
329
Shane Farmer280be342017-06-21 15:20:15 -0700330 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800331 bool ok = AbiGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700332 ASSERT_TRUE(ok);
333
Shane Farmercb6c3f92017-11-27 13:19:36 -0800334 EXPECT_THAT(config.abi_groups, SizeIs(1ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700335 ASSERT_EQ(1u, config.abi_groups.count("arm"));
336
337 auto& out = config.abi_groups["arm"];
338 ASSERT_THAT(out, ElementsAre(Abi::kArmV7a, Abi::kArm64V8a));
339}
340
Shane Farmer39e474f2017-12-18 14:44:11 -0800341TEST_F(ConfigurationParserTest, AbiGroupAction_EmptyGroup) {
342 static constexpr const char* xml = R"xml(<abi-group label="arm64-v8a"/>)xml";
343
344 auto doc = test::BuildXmlDom(xml);
345
346 PostProcessingConfiguration config;
347 bool ok = AbiGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
348 ASSERT_TRUE(ok);
349
350 EXPECT_THAT(config.abi_groups, SizeIs(1ul));
351 ASSERT_EQ(1u, config.abi_groups.count("arm64-v8a"));
352
353 auto& out = config.abi_groups["arm64-v8a"];
354 ASSERT_THAT(out, ElementsAre(Abi::kArm64V8a));
355}
356
357TEST_F(ConfigurationParserTest, AbiGroupAction_InvalidEmptyGroup) {
358 static constexpr const char* xml = R"xml(<abi-group label="arm"/>)xml";
359
360 auto doc = test::BuildXmlDom(xml);
361
362 PostProcessingConfiguration config;
363 bool ok = AbiGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
364 ASSERT_FALSE(ok);
365}
366
Shane Farmer74cdea32017-05-12 16:22:36 -0700367TEST_F(ConfigurationParserTest, ScreenDensityGroupAction) {
368 static constexpr const char* xml = R"xml(
369 <screen-density-group label="large">
370 <screen-density>xhdpi</screen-density>
371 <screen-density>
372 xxhdpi
373 </screen-density>
374 <screen-density>xxxhdpi</screen-density>
375 </screen-density-group>)xml";
376
377 auto doc = test::BuildXmlDom(xml);
378
Shane Farmer280be342017-06-21 15:20:15 -0700379 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800380 bool ok = ScreenDensityGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700381 ASSERT_TRUE(ok);
382
Shane Farmercb6c3f92017-11-27 13:19:36 -0800383 EXPECT_THAT(config.screen_density_groups, SizeIs(1ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700384 ASSERT_EQ(1u, config.screen_density_groups.count("large"));
385
386 ConfigDescription xhdpi;
387 xhdpi.density = ResTable_config::DENSITY_XHIGH;
388 ConfigDescription xxhdpi;
389 xxhdpi.density = ResTable_config::DENSITY_XXHIGH;
390 ConfigDescription xxxhdpi;
391 xxxhdpi.density = ResTable_config::DENSITY_XXXHIGH;
392
393 auto& out = config.screen_density_groups["large"];
394 ASSERT_THAT(out, ElementsAre(xhdpi, xxhdpi, xxxhdpi));
395}
396
Shane Farmer39e474f2017-12-18 14:44:11 -0800397TEST_F(ConfigurationParserTest, ScreenDensityGroupAction_EmtpyGroup) {
398 static constexpr const char* xml = R"xml(<screen-density-group label="xhdpi"/>)xml";
399
400 auto doc = test::BuildXmlDom(xml);
401
402 PostProcessingConfiguration config;
403 bool ok = ScreenDensityGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
404 ASSERT_TRUE(ok);
405
406 EXPECT_THAT(config.screen_density_groups, SizeIs(1ul));
407 ASSERT_EQ(1u, config.screen_density_groups.count("xhdpi"));
408
409 ConfigDescription xhdpi;
410 xhdpi.density = ResTable_config::DENSITY_XHIGH;
411
412 auto& out = config.screen_density_groups["xhdpi"];
413 ASSERT_THAT(out, ElementsAre(xhdpi));
414}
415
416TEST_F(ConfigurationParserTest, ScreenDensityGroupAction_InvalidEmtpyGroup) {
417 static constexpr const char* xml = R"xml(<screen-density-group label="really-big-screen"/>)xml";
418
419 auto doc = test::BuildXmlDom(xml);
420
421 PostProcessingConfiguration config;
422 bool ok = ScreenDensityGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
423 ASSERT_FALSE(ok);
424}
425
Shane Farmer74cdea32017-05-12 16:22:36 -0700426TEST_F(ConfigurationParserTest, LocaleGroupAction) {
427 static constexpr const char* xml = R"xml(
428 <locale-group label="europe">
Shane Farmer0a5b2012017-06-22 12:24:12 -0700429 <locale>en</locale>
430 <locale>es</locale>
431 <locale>fr</locale>
432 <locale>de</locale>
Shane Farmer74cdea32017-05-12 16:22:36 -0700433 </locale-group>)xml";
434
435 auto doc = test::BuildXmlDom(xml);
436
Shane Farmer280be342017-06-21 15:20:15 -0700437 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800438 bool ok = LocaleGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700439 ASSERT_TRUE(ok);
440
441 ASSERT_EQ(1ul, config.locale_groups.size());
442 ASSERT_EQ(1u, config.locale_groups.count("europe"));
443
Shane Farmer0a5b2012017-06-22 12:24:12 -0700444 const auto& out = config.locale_groups["europe"];
Shane Farmer74cdea32017-05-12 16:22:36 -0700445
Shane Farmer0a5b2012017-06-22 12:24:12 -0700446 ConfigDescription en = test::ParseConfigOrDie("en");
447 ConfigDescription es = test::ParseConfigOrDie("es");
448 ConfigDescription fr = test::ParseConfigOrDie("fr");
449 ConfigDescription de = test::ParseConfigOrDie("de");
Shane Farmer74cdea32017-05-12 16:22:36 -0700450
451 ASSERT_THAT(out, ElementsAre(en, es, fr, de));
452}
453
Shane Farmer39e474f2017-12-18 14:44:11 -0800454TEST_F(ConfigurationParserTest, LocaleGroupAction_EmtpyGroup) {
455 static constexpr const char* xml = R"xml(<locale-group label="en"/>)xml";
456
457 auto doc = test::BuildXmlDom(xml);
458
459 PostProcessingConfiguration config;
460 bool ok = LocaleGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
461 ASSERT_TRUE(ok);
462
463 ASSERT_EQ(1ul, config.locale_groups.size());
464 ASSERT_EQ(1u, config.locale_groups.count("en"));
465
466 const auto& out = config.locale_groups["en"];
467
468 ConfigDescription en = test::ParseConfigOrDie("en");
469
470 ASSERT_THAT(out, ElementsAre(en));
471}
472
473TEST_F(ConfigurationParserTest, LocaleGroupAction_InvalidEmtpyGroup) {
474 static constexpr const char* xml = R"xml(<locale-group label="arm64"/>)xml";
475
476 auto doc = test::BuildXmlDom(xml);
477
478 PostProcessingConfiguration config;
479 bool ok = LocaleGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
480 ASSERT_FALSE(ok);
481}
482
Shane Farmer74cdea32017-05-12 16:22:36 -0700483TEST_F(ConfigurationParserTest, AndroidSdkGroupAction) {
484 static constexpr const char* xml = R"xml(
Shane Farmerefe45392017-08-21 14:39:28 -0700485 <android-sdk-group label="v19">
Shane Farmer74cdea32017-05-12 16:22:36 -0700486 <android-sdk
Shane Farmer3edd4722017-09-01 14:34:22 -0700487 minSdkVersion="19"
488 targetSdkVersion="24"
489 maxSdkVersion="25">
Shane Farmer74cdea32017-05-12 16:22:36 -0700490 <manifest>
491 <!--- manifest additions here XSLT? TODO -->
492 </manifest>
493 </android-sdk>
494 </android-sdk-group>)xml";
495
496 auto doc = test::BuildXmlDom(xml);
497
Shane Farmer280be342017-06-21 15:20:15 -0700498 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800499 bool ok = AndroidSdkGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700500 ASSERT_TRUE(ok);
501
502 ASSERT_EQ(1ul, config.android_sdk_groups.size());
Shane Farmerefe45392017-08-21 14:39:28 -0700503 ASSERT_EQ(1u, config.android_sdk_groups.count("v19"));
Shane Farmer74cdea32017-05-12 16:22:36 -0700504
Shane Farmerefe45392017-08-21 14:39:28 -0700505 auto& out = config.android_sdk_groups["v19"];
Shane Farmer74cdea32017-05-12 16:22:36 -0700506
507 AndroidSdk sdk;
Shane Farmer3edd4722017-09-01 14:34:22 -0700508 sdk.min_sdk_version = 19;
509 sdk.target_sdk_version = 24;
510 sdk.max_sdk_version = 25;
Shane Farmer74cdea32017-05-12 16:22:36 -0700511 sdk.manifest = AndroidManifest();
512
Shane Farmerefe45392017-08-21 14:39:28 -0700513 ASSERT_EQ(sdk, out);
Shane Farmer74cdea32017-05-12 16:22:36 -0700514}
515
Shane Farmer67e8a302017-12-06 14:39:10 -0800516TEST_F(ConfigurationParserTest, AndroidSdkGroupAction_SingleVersion) {
517 {
518 static constexpr const char* xml = R"xml(
519 <android-sdk-group label="v19">
520 <android-sdk minSdkVersion="19"></android-sdk>
521 </android-sdk-group>)xml";
522
523 auto doc = test::BuildXmlDom(xml);
524
525 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800526 bool ok = AndroidSdkGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer67e8a302017-12-06 14:39:10 -0800527 ASSERT_TRUE(ok);
528
529 ASSERT_EQ(1ul, config.android_sdk_groups.size());
530 ASSERT_EQ(1u, config.android_sdk_groups.count("v19"));
531
532 auto& out = config.android_sdk_groups["v19"];
533 EXPECT_EQ(19, out.min_sdk_version.value());
534 EXPECT_FALSE(out.max_sdk_version);
535 EXPECT_FALSE(out.target_sdk_version);
536 }
537
538 {
539 static constexpr const char* xml = R"xml(
540 <android-sdk-group label="v19">
541 <android-sdk maxSdkVersion="19"></android-sdk>
542 </android-sdk-group>)xml";
543
544 auto doc = test::BuildXmlDom(xml);
545
546 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800547 bool ok = AndroidSdkGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer67e8a302017-12-06 14:39:10 -0800548 ASSERT_TRUE(ok);
549
550 ASSERT_EQ(1ul, config.android_sdk_groups.size());
551 ASSERT_EQ(1u, config.android_sdk_groups.count("v19"));
552
553 auto& out = config.android_sdk_groups["v19"];
554 EXPECT_EQ(19, out.max_sdk_version.value());
555 EXPECT_FALSE(out.min_sdk_version);
556 EXPECT_FALSE(out.target_sdk_version);
557 }
558
559 {
560 static constexpr const char* xml = R"xml(
561 <android-sdk-group label="v19">
562 <android-sdk targetSdkVersion="19"></android-sdk>
563 </android-sdk-group>)xml";
564
565 auto doc = test::BuildXmlDom(xml);
566
567 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800568 bool ok = AndroidSdkGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer67e8a302017-12-06 14:39:10 -0800569 ASSERT_TRUE(ok);
570
571 ASSERT_EQ(1ul, config.android_sdk_groups.size());
572 ASSERT_EQ(1u, config.android_sdk_groups.count("v19"));
573
574 auto& out = config.android_sdk_groups["v19"];
575 EXPECT_EQ(19, out.target_sdk_version.value());
576 EXPECT_FALSE(out.min_sdk_version);
577 EXPECT_FALSE(out.max_sdk_version);
578 }
579}
580
581TEST_F(ConfigurationParserTest, AndroidSdkGroupAction_InvalidVersion) {
Shane Farmer3edd4722017-09-01 14:34:22 -0700582 static constexpr const char* xml = R"xml(
Shane Farmer67e8a302017-12-06 14:39:10 -0800583 <android-sdk-group label="v19">
Shane Farmer3edd4722017-09-01 14:34:22 -0700584 <android-sdk
Shane Farmer67e8a302017-12-06 14:39:10 -0800585 minSdkVersion="v19"
586 targetSdkVersion="v24"
587 maxSdkVersion="v25">
588 <manifest>
589 <!--- manifest additions here XSLT? TODO -->
590 </manifest>
Shane Farmer3edd4722017-09-01 14:34:22 -0700591 </android-sdk>
592 </android-sdk-group>)xml";
593
594 auto doc = test::BuildXmlDom(xml);
595
596 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800597 bool ok = AndroidSdkGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer67e8a302017-12-06 14:39:10 -0800598 ASSERT_FALSE(ok);
599}
600
601TEST_F(ConfigurationParserTest, AndroidSdkGroupAction_NonNumeric) {
602 static constexpr const char* xml = R"xml(
603 <android-sdk-group label="P">
604 <android-sdk
605 minSdkVersion="25"
606 targetSdkVersion="%s"
607 maxSdkVersion="%s">
608 </android-sdk>
609 </android-sdk-group>)xml";
610
611 const auto& dev_sdk = GetDevelopmentSdkCodeNameAndVersion();
612 const char* codename = dev_sdk.first.data();
613 const ApiVersion& version = dev_sdk.second;
614
615 auto doc = test::BuildXmlDom(StringPrintf(xml, codename, codename));
616
617 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800618 bool ok = AndroidSdkGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer3edd4722017-09-01 14:34:22 -0700619 ASSERT_TRUE(ok);
620
621 ASSERT_EQ(1ul, config.android_sdk_groups.size());
Adam Lesinski178e67832017-11-02 14:12:38 -0700622 ASSERT_EQ(1u, config.android_sdk_groups.count("P"));
Shane Farmer3edd4722017-09-01 14:34:22 -0700623
Adam Lesinski178e67832017-11-02 14:12:38 -0700624 auto& out = config.android_sdk_groups["P"];
Shane Farmer3edd4722017-09-01 14:34:22 -0700625
626 AndroidSdk sdk;
Shane Farmer67e8a302017-12-06 14:39:10 -0800627 sdk.min_sdk_version = 25;
628 sdk.target_sdk_version = version;
629 sdk.max_sdk_version = version;
Shane Farmer3edd4722017-09-01 14:34:22 -0700630
631 ASSERT_EQ(sdk, out);
632}
633
Shane Farmer74cdea32017-05-12 16:22:36 -0700634TEST_F(ConfigurationParserTest, GlTextureGroupAction) {
635 static constexpr const char* xml = R"xml(
636 <gl-texture-group label="dxt1">
637 <gl-texture name="GL_EXT_texture_compression_dxt1">
638 <texture-path>assets/dxt1/main/*</texture-path>
639 <texture-path>
640 assets/dxt1/test/*
641 </texture-path>
642 </gl-texture>
643 </gl-texture-group>)xml";
644
645 auto doc = test::BuildXmlDom(xml);
646
Shane Farmer280be342017-06-21 15:20:15 -0700647 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800648 bool ok = GlTextureGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700649 ASSERT_TRUE(ok);
650
Shane Farmercb6c3f92017-11-27 13:19:36 -0800651 EXPECT_THAT(config.gl_texture_groups, SizeIs(1ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700652 ASSERT_EQ(1u, config.gl_texture_groups.count("dxt1"));
653
654 auto& out = config.gl_texture_groups["dxt1"];
655
656 GlTexture texture{
657 std::string("GL_EXT_texture_compression_dxt1"),
658 {"assets/dxt1/main/*", "assets/dxt1/test/*"}
659 };
660
661 ASSERT_EQ(1ul, out.size());
662 ASSERT_EQ(texture, out[0]);
663}
664
665TEST_F(ConfigurationParserTest, DeviceFeatureGroupAction) {
666 static constexpr const char* xml = R"xml(
667 <device-feature-group label="low-latency">
668 <supports-feature>android.hardware.audio.low_latency</supports-feature>
669 <supports-feature>
670 android.hardware.audio.pro
671 </supports-feature>
672 </device-feature-group>)xml";
673
674 auto doc = test::BuildXmlDom(xml);
675
Shane Farmer280be342017-06-21 15:20:15 -0700676 PostProcessingConfiguration config;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800677 bool ok = DeviceFeatureGroupTagHandler(&config, NodeCast<Element>(doc.get()->root.get()), &diag_);
Shane Farmer74cdea32017-05-12 16:22:36 -0700678 ASSERT_TRUE(ok);
679
Shane Farmercb6c3f92017-11-27 13:19:36 -0800680 EXPECT_THAT(config.device_feature_groups, SizeIs(1ul));
Shane Farmer74cdea32017-05-12 16:22:36 -0700681 ASSERT_EQ(1u, config.device_feature_groups.count("low-latency"));
682
683 auto& out = config.device_feature_groups["low-latency"];
684
685 DeviceFeature low_latency = "android.hardware.audio.low_latency";
686 DeviceFeature pro = "android.hardware.audio.pro";
687 ASSERT_THAT(out, ElementsAre(low_latency, pro));
688}
689
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700690// Artifact name parser test cases.
691
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700692TEST(ArtifactTest, Simple) {
693 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800694 ConfiguredArtifact x86;
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700695 x86.abi_group = {"x86"};
696
Shane Farmer9ecc0752017-08-24 15:55:36 -0700697 auto x86_result = x86.ToArtifactName("something.${abi}.apk", "", &diag);
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700698 ASSERT_TRUE(x86_result);
699 EXPECT_EQ(x86_result.value(), "something.x86.apk");
700
Shane Farmercb6c3f92017-11-27 13:19:36 -0800701 ConfiguredArtifact arm;
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700702 arm.abi_group = {"armeabi-v7a"};
703
Shane Farmer9ecc0752017-08-24 15:55:36 -0700704 {
705 auto arm_result = arm.ToArtifactName("app.${abi}.apk", "", &diag);
706 ASSERT_TRUE(arm_result);
707 EXPECT_EQ(arm_result.value(), "app.armeabi-v7a.apk");
708 }
709
710 {
711 auto arm_result = arm.ToArtifactName("app.${abi}.apk", "different_name.apk", &diag);
712 ASSERT_TRUE(arm_result);
713 EXPECT_EQ(arm_result.value(), "app.armeabi-v7a.apk");
714 }
715
716 {
717 auto arm_result = arm.ToArtifactName("${basename}.${abi}.apk", "app.apk", &diag);
718 ASSERT_TRUE(arm_result);
719 EXPECT_EQ(arm_result.value(), "app.armeabi-v7a.apk");
720 }
721
722 {
723 auto arm_result = arm.ToArtifactName("app.${abi}.${ext}", "app.apk", &diag);
724 ASSERT_TRUE(arm_result);
725 EXPECT_EQ(arm_result.value(), "app.armeabi-v7a.apk");
726 }
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700727}
728
729TEST(ArtifactTest, Complex) {
730 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800731 ConfiguredArtifact artifact;
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700732 artifact.abi_group = {"mips64"};
733 artifact.screen_density_group = {"ldpi"};
734 artifact.device_feature_group = {"df1"};
735 artifact.gl_texture_group = {"glx1"};
736 artifact.locale_group = {"en-AU"};
Shane Farmerefe45392017-08-21 14:39:28 -0700737 artifact.android_sdk_group = {"v26"};
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700738
Shane Farmer9ecc0752017-08-24 15:55:36 -0700739 {
740 auto result = artifact.ToArtifactName(
Shane Farmerefe45392017-08-21 14:39:28 -0700741 "app.${density}_${locale}_${feature}_${gl}.${sdk}.${abi}.apk", "", &diag);
Shane Farmer9ecc0752017-08-24 15:55:36 -0700742 ASSERT_TRUE(result);
Shane Farmerefe45392017-08-21 14:39:28 -0700743 EXPECT_EQ(result.value(), "app.ldpi_en-AU_df1_glx1.v26.mips64.apk");
Shane Farmer9ecc0752017-08-24 15:55:36 -0700744 }
745
746 {
747 auto result = artifact.ToArtifactName(
Shane Farmerefe45392017-08-21 14:39:28 -0700748 "app.${density}_${locale}_${feature}_${gl}.${sdk}.${abi}.apk", "app.apk", &diag);
Shane Farmer9ecc0752017-08-24 15:55:36 -0700749 ASSERT_TRUE(result);
Shane Farmerefe45392017-08-21 14:39:28 -0700750 EXPECT_EQ(result.value(), "app.ldpi_en-AU_df1_glx1.v26.mips64.apk");
Shane Farmer9ecc0752017-08-24 15:55:36 -0700751 }
752
753 {
754 auto result = artifact.ToArtifactName(
Shane Farmerefe45392017-08-21 14:39:28 -0700755 "${basename}.${density}_${locale}_${feature}_${gl}.${sdk}.${abi}.apk", "app.apk", &diag);
Shane Farmer9ecc0752017-08-24 15:55:36 -0700756 ASSERT_TRUE(result);
Shane Farmerefe45392017-08-21 14:39:28 -0700757 EXPECT_EQ(result.value(), "app.ldpi_en-AU_df1_glx1.v26.mips64.apk");
Shane Farmer9ecc0752017-08-24 15:55:36 -0700758 }
759
760 {
761 auto result = artifact.ToArtifactName(
Shane Farmerefe45392017-08-21 14:39:28 -0700762 "app.${density}_${locale}_${feature}_${gl}.${sdk}.${abi}.${ext}", "app.apk", &diag);
Shane Farmer9ecc0752017-08-24 15:55:36 -0700763 ASSERT_TRUE(result);
Shane Farmerefe45392017-08-21 14:39:28 -0700764 EXPECT_EQ(result.value(), "app.ldpi_en-AU_df1_glx1.v26.mips64.apk");
Shane Farmer9ecc0752017-08-24 15:55:36 -0700765 }
766
767 {
768 auto result = artifact.ToArtifactName(
Shane Farmerefe45392017-08-21 14:39:28 -0700769 "${basename}.${density}_${locale}_${feature}_${gl}.${sdk}.${abi}", "app.apk", &diag);
Shane Farmer9ecc0752017-08-24 15:55:36 -0700770 ASSERT_TRUE(result);
Shane Farmerefe45392017-08-21 14:39:28 -0700771 EXPECT_EQ(result.value(), "app.ldpi_en-AU_df1_glx1.v26.mips64.apk");
Shane Farmer9ecc0752017-08-24 15:55:36 -0700772 }
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700773}
774
775TEST(ArtifactTest, Missing) {
776 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800777 ConfiguredArtifact x86;
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700778 x86.abi_group = {"x86"};
779
Shane Farmer9ecc0752017-08-24 15:55:36 -0700780 EXPECT_FALSE(x86.ToArtifactName("something.${density}.apk", "", &diag));
781 EXPECT_FALSE(x86.ToArtifactName("something.apk", "", &diag));
782 EXPECT_FALSE(x86.ToArtifactName("something.${density}.apk", "something.apk", &diag));
783 EXPECT_FALSE(x86.ToArtifactName("something.apk", "something.apk", &diag));
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700784}
785
786TEST(ArtifactTest, Empty) {
787 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800788 ConfiguredArtifact artifact;
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700789
Shane Farmer9ecc0752017-08-24 15:55:36 -0700790 EXPECT_FALSE(artifact.ToArtifactName("something.${density}.apk", "", &diag));
791 EXPECT_TRUE(artifact.ToArtifactName("something.apk", "", &diag));
792 EXPECT_FALSE(artifact.ToArtifactName("something.${density}.apk", "something.apk", &diag));
793 EXPECT_TRUE(artifact.ToArtifactName("something.apk", "something.apk", &diag));
Shane Farmer9f0e7f12017-06-22 12:26:44 -0700794}
795
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700796TEST(ArtifactTest, Repeated) {
797 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800798 ConfiguredArtifact artifact;
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700799 artifact.screen_density_group = {"mdpi"};
800
Shane Farmer9ecc0752017-08-24 15:55:36 -0700801 ASSERT_TRUE(artifact.ToArtifactName("something.${density}.apk", "", &diag));
802 EXPECT_FALSE(artifact.ToArtifactName("something.${density}.${density}.apk", "", &diag));
803 ASSERT_TRUE(artifact.ToArtifactName("something.${density}.apk", "something.apk", &diag));
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700804}
805
806TEST(ArtifactTest, Nesting) {
807 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800808 ConfiguredArtifact x86;
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700809 x86.abi_group = {"x86"};
810
Shane Farmer9ecc0752017-08-24 15:55:36 -0700811 EXPECT_FALSE(x86.ToArtifactName("something.${abi${density}}.apk", "", &diag));
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700812
Shane Farmer9ecc0752017-08-24 15:55:36 -0700813 const Maybe<std::string>& name = x86.ToArtifactName("something.${abi${abi}}.apk", "", &diag);
Shane Farmer0a5b2012017-06-22 12:24:12 -0700814 ASSERT_TRUE(name);
815 EXPECT_EQ(name.value(), "something.${abix86}.apk");
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700816}
817
818TEST(ArtifactTest, Recursive) {
819 StdErrDiagnostics diag;
Shane Farmercb6c3f92017-11-27 13:19:36 -0800820 ConfiguredArtifact artifact;
Shane Farmer0a5b2012017-06-22 12:24:12 -0700821 artifact.device_feature_group = {"${gl}"};
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700822 artifact.gl_texture_group = {"glx1"};
823
Shane Farmer9ecc0752017-08-24 15:55:36 -0700824 EXPECT_FALSE(artifact.ToArtifactName("app.${feature}.${gl}.apk", "", &diag));
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700825
826 artifact.device_feature_group = {"df1"};
Shane Farmer0a5b2012017-06-22 12:24:12 -0700827 artifact.gl_texture_group = {"${feature}"};
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700828 {
Shane Farmer9ecc0752017-08-24 15:55:36 -0700829 const auto& result = artifact.ToArtifactName("app.${feature}.${gl}.apk", "", &diag);
Shane Farmer0a5b2012017-06-22 12:24:12 -0700830 ASSERT_TRUE(result);
831 EXPECT_EQ(result.value(), "app.df1.${feature}.apk");
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700832 }
833
834 // This is an invalid case, but should be the only possible case due to the ordering of
835 // replacement.
Shane Farmer0a5b2012017-06-22 12:24:12 -0700836 artifact.device_feature_group = {"${gl}"};
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700837 artifact.gl_texture_group = {"glx1"};
838 {
Shane Farmer9ecc0752017-08-24 15:55:36 -0700839 const auto& result = artifact.ToArtifactName("app.${feature}.apk", "", &diag);
Shane Farmer0a5b2012017-06-22 12:24:12 -0700840 ASSERT_TRUE(result);
Shane Farmer1a21b8c2017-07-21 09:42:42 -0700841 EXPECT_EQ(result.value(), "app.glx1.apk");
842 }
843}
844
Shane Farmer74cdea32017-05-12 16:22:36 -0700845} // namespace
Shane Farmercb6c3f92017-11-27 13:19:36 -0800846} // namespace handler
847} // namespace configuration
Shane Farmer74cdea32017-05-12 16:22:36 -0700848} // namespace aapt