HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.1
|
7.1.1_r28
下载
查看原文件
收藏
根目录
frameworks
base
tools
aapt2
link
AutoVersioner_test.cpp
/* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "ConfigDescription.h" #include "link/Linkers.h" #include "test/Builders.h" #include "test/Context.h" #include
namespace aapt { TEST(AutoVersionerTest, GenerateVersionedResources) { const ConfigDescription defaultConfig = {}; const ConfigDescription landConfig = test::parseConfigOrDie("land"); const ConfigDescription sw600dpLandConfig = test::parseConfigOrDie("sw600dp-land"); ResourceEntry entry(u"foo"); entry.values.push_back(util::make_unique
(defaultConfig, "")); entry.values.push_back(util::make_unique
(landConfig, "")); entry.values.push_back(util::make_unique
(sw600dpLandConfig, "")); EXPECT_TRUE(shouldGenerateVersionedResource(&entry, defaultConfig, 17)); EXPECT_TRUE(shouldGenerateVersionedResource(&entry, landConfig, 17)); } TEST(AutoVersionerTest, GenerateVersionedResourceWhenHigherVersionExists) { const ConfigDescription defaultConfig = {}; const ConfigDescription sw600dpV13Config = test::parseConfigOrDie("sw600dp-v13"); const ConfigDescription v21Config = test::parseConfigOrDie("v21"); ResourceEntry entry(u"foo"); entry.values.push_back(util::make_unique
(defaultConfig, "")); entry.values.push_back(util::make_unique
(sw600dpV13Config, "")); entry.values.push_back(util::make_unique
(v21Config, "")); EXPECT_TRUE(shouldGenerateVersionedResource(&entry, defaultConfig, 17)); EXPECT_FALSE(shouldGenerateVersionedResource(&entry, defaultConfig, 22)); } TEST(AutoVersionerTest, VersionStylesForTable) { std::unique_ptr
table = test::ResourceTableBuilder() .setPackageId(u"app", 0x7f) .addValue(u"@app:style/Foo", ResourceId(0x7f020000), test::parseConfigOrDie("v4"), test::StyleBuilder() .addItem(u"@android:attr/onClick", ResourceId(0x0101026f), util::make_unique
()) .addItem(u"@android:attr/paddingStart", ResourceId(0x010103b3), util::make_unique
()) .addItem(u"@android:attr/requiresSmallestWidthDp", ResourceId(0x01010364), util::make_unique
()) .addItem(u"@android:attr/colorAccent", ResourceId(0x01010435), util::make_unique
()) .build()) .addValue(u"@app:style/Foo", ResourceId(0x7f020000), test::parseConfigOrDie("v21"), test::StyleBuilder() .addItem(u"@android:attr/paddingEnd", ResourceId(0x010103b4), util::make_unique
()) .build()) .build(); std::unique_ptr
context = test::ContextBuilder() .setCompilationPackage(u"app") .setPackageId(0x7f) .build(); AutoVersioner versioner; ASSERT_TRUE(versioner.consume(context.get(), table.get())); Style* style = test::getValueForConfig