11ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski/* 21ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * Copyright (C) 2015 The Android Open Source Project 31ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * 41ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * Licensed under the Apache License, Version 2.0 (the "License"); 51ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * you may not use this file except in compliance with the License. 61ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * You may obtain a copy of the License at 71ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * 81ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * http://www.apache.org/licenses/LICENSE-2.0 91ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * 101ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * Unless required by applicable law or agreed to in writing, software 111ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * distributed under the License is distributed on an "AS IS" BASIS, 121ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * See the License for the specific language governing permissions and 141ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski * limitations under the License. 151ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski */ 161ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 171ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski#include "process/SymbolTable.h" 1864587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski#include "test/Test.h" 191ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 201ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinskinamespace aapt { 211ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 2264587af8179affd38ee26543b748f2d63b7f67bbAdam LesinskiTEST(ResourceTableSymbolSourceTest, FindSymbols) { 231ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder() 241ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski .addSimple(u"@android:id/foo", ResourceId(0x01020000)) 251ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski .addSimple(u"@android:id/bar") 261ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski .addValue(u"@android:attr/foo", ResourceId(0x01010000), 271ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski test::AttributeBuilder().build()) 281ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski .build(); 291ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 3064587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski ResourceTableSymbolSource symbolSource(table.get()); 3164587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski EXPECT_NE(nullptr, symbolSource.findByName(test::parseNameOrDie(u"@android:id/foo"))); 3264587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski EXPECT_NE(nullptr, symbolSource.findByName(test::parseNameOrDie(u"@android:id/bar"))); 331ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 3464587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski std::unique_ptr<SymbolTable::Symbol> s = symbolSource.findByName( 351ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski test::parseNameOrDie(u"@android:attr/foo")); 3664587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski ASSERT_NE(nullptr, s); 3764587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski EXPECT_NE(nullptr, s->attribute); 381ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski} 391ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 4064587af8179affd38ee26543b748f2d63b7f67bbAdam LesinskiTEST(ResourceTableSymbolSourceTest, FindPrivateAttrSymbol) { 411ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder() 421ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski .addValue(u"@android:^attr-private/foo", ResourceId(0x01010000), 431ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski test::AttributeBuilder().build()) 441ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski .build(); 451ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 4664587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski ResourceTableSymbolSource symbolSource(table.get()); 4764587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski std::unique_ptr<SymbolTable::Symbol> s = symbolSource.findByName( 481ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski test::parseNameOrDie(u"@android:attr/foo")); 4964587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski ASSERT_NE(nullptr, s); 5064587af8179affd38ee26543b748f2d63b7f67bbAdam Lesinski EXPECT_NE(nullptr, s->attribute); 511ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski} 521ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski 531ab598f46c3ff520a67f9d80194847741f3467abAdam Lesinski} // namespace aapt 54