1/*
2 * Copyright (C) 2014 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 <utils/String8.h>
18#include <gtest/gtest.h>
19
20#include "AaptAssets.h"
21#include "ResourceFilter.h"
22#include "TestHelper.h"
23
24using android::String8;
25
26static ::testing::AssertionResult TestParse(AaptGroupEntry& entry, const String8& dirName,
27        String8* outType) {
28    if (entry.initFromDirName(dirName, outType)) {
29        return ::testing::AssertionSuccess() << dirName << " was successfully parsed";
30    }
31    return ::testing::AssertionFailure() << dirName << " could not be parsed";
32}
33
34static ::testing::AssertionResult TestParse(AaptGroupEntry& entry, const char* input,
35        String8* outType) {
36    return TestParse(entry, String8(input), outType);
37}
38
39TEST(AaptGroupEntryTest, ParseNoQualifier) {
40    AaptGroupEntry entry;
41    String8 type;
42    EXPECT_TRUE(TestParse(entry, "menu", &type));
43    EXPECT_EQ(String8("menu"), type);
44}
45
46TEST(AaptGroupEntryTest, ParseCorrectType) {
47    AaptGroupEntry entry;
48    String8 type;
49    EXPECT_TRUE(TestParse(entry, "anim", &type));
50    EXPECT_EQ(String8("anim"), type);
51
52    EXPECT_TRUE(TestParse(entry, "animator", &type));
53    EXPECT_EQ(String8("animator"), type);
54}
55