1/* 2 * Copyright (C) 2015 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 "process/SymbolTable.h" 18#include "test/Test.h" 19 20namespace aapt { 21 22TEST(ResourceTableSymbolSourceTest, FindSymbols) { 23 std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder() 24 .addSimple(u"@android:id/foo", ResourceId(0x01020000)) 25 .addSimple(u"@android:id/bar") 26 .addValue(u"@android:attr/foo", ResourceId(0x01010000), 27 test::AttributeBuilder().build()) 28 .build(); 29 30 ResourceTableSymbolSource symbolSource(table.get()); 31 EXPECT_NE(nullptr, symbolSource.findByName(test::parseNameOrDie(u"@android:id/foo"))); 32 EXPECT_NE(nullptr, symbolSource.findByName(test::parseNameOrDie(u"@android:id/bar"))); 33 34 std::unique_ptr<SymbolTable::Symbol> s = symbolSource.findByName( 35 test::parseNameOrDie(u"@android:attr/foo")); 36 ASSERT_NE(nullptr, s); 37 EXPECT_NE(nullptr, s->attribute); 38} 39 40TEST(ResourceTableSymbolSourceTest, FindPrivateAttrSymbol) { 41 std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder() 42 .addValue(u"@android:^attr-private/foo", ResourceId(0x01010000), 43 test::AttributeBuilder().build()) 44 .build(); 45 46 ResourceTableSymbolSource symbolSource(table.get()); 47 std::unique_ptr<SymbolTable::Symbol> s = symbolSource.findByName( 48 test::parseNameOrDie(u"@android:attr/foo")); 49 ASSERT_NE(nullptr, s); 50 EXPECT_NE(nullptr, s->attribute); 51} 52 53} // namespace aapt 54