blob: 00474f7d2341a5ace075a20390ee9d702854d8b3 [file] [log] [blame]
Adam Lesinski1ab598f2015-08-14 14:26:04 -07001/*
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"
Adam Lesinski64587af2016-02-18 18:33:06 -080018#include "test/Test.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070019
20namespace aapt {
21
Adam Lesinski64587af2016-02-18 18:33:06 -080022TEST(ResourceTableSymbolSourceTest, FindSymbols) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070023 std::unique_ptr<ResourceTable> table =
24 test::ResourceTableBuilder()
25 .addSimple("android:id/foo", ResourceId(0x01020000))
26 .addSimple("android:id/bar")
27 .addValue("android:attr/foo", ResourceId(0x01010000),
28 test::AttributeBuilder().build())
29 .build();
Adam Lesinski1ab598f2015-08-14 14:26:04 -070030
Adam Lesinskicacb28f2016-10-19 12:18:14 -070031 ResourceTableSymbolSource symbolSource(table.get());
32 EXPECT_NE(nullptr,
33 symbolSource.findByName(test::parseNameOrDie("android:id/foo")));
34 EXPECT_NE(nullptr,
35 symbolSource.findByName(test::parseNameOrDie("android:id/bar")));
Adam Lesinski1ab598f2015-08-14 14:26:04 -070036
Adam Lesinskicacb28f2016-10-19 12:18:14 -070037 std::unique_ptr<SymbolTable::Symbol> s =
38 symbolSource.findByName(test::parseNameOrDie("android:attr/foo"));
39 ASSERT_NE(nullptr, s);
40 EXPECT_NE(nullptr, s->attribute);
Adam Lesinski1ab598f2015-08-14 14:26:04 -070041}
42
Adam Lesinski64587af2016-02-18 18:33:06 -080043TEST(ResourceTableSymbolSourceTest, FindPrivateAttrSymbol) {
Adam Lesinskicacb28f2016-10-19 12:18:14 -070044 std::unique_ptr<ResourceTable> table =
45 test::ResourceTableBuilder()
46 .addValue("android:^attr-private/foo", ResourceId(0x01010000),
47 test::AttributeBuilder().build())
48 .build();
Adam Lesinski1ab598f2015-08-14 14:26:04 -070049
Adam Lesinskicacb28f2016-10-19 12:18:14 -070050 ResourceTableSymbolSource symbolSource(table.get());
51 std::unique_ptr<SymbolTable::Symbol> s =
52 symbolSource.findByName(test::parseNameOrDie("android:attr/foo"));
53 ASSERT_NE(nullptr, s);
54 EXPECT_NE(nullptr, s->attribute);
Adam Lesinski1ab598f2015-08-14 14:26:04 -070055}
56
Adam Lesinskicacb28f2016-10-19 12:18:14 -070057} // namespace aapt