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 "Resource.h"
18
19 #include "test/Test.h"
20
21 namespace aapt {
22
TEST(ResourceTypeTest,ParseResourceTypes)23 TEST(ResourceTypeTest, ParseResourceTypes) {
24 const ResourceType* type = ParseResourceType("anim");
25 ASSERT_NE(type, nullptr);
26 EXPECT_EQ(*type, ResourceType::kAnim);
27
28 type = ParseResourceType("animator");
29 ASSERT_NE(type, nullptr);
30 EXPECT_EQ(*type, ResourceType::kAnimator);
31
32 type = ParseResourceType("array");
33 ASSERT_NE(type, nullptr);
34 EXPECT_EQ(*type, ResourceType::kArray);
35
36 type = ParseResourceType("attr");
37 ASSERT_NE(type, nullptr);
38 EXPECT_EQ(*type, ResourceType::kAttr);
39
40 type = ParseResourceType("^attr-private");
41 ASSERT_NE(type, nullptr);
42 EXPECT_EQ(*type, ResourceType::kAttrPrivate);
43
44 type = ParseResourceType("bool");
45 ASSERT_NE(type, nullptr);
46 EXPECT_EQ(*type, ResourceType::kBool);
47
48 type = ParseResourceType("color");
49 ASSERT_NE(type, nullptr);
50 EXPECT_EQ(*type, ResourceType::kColor);
51
52 type = ParseResourceType("configVarying");
53 ASSERT_NE(type, nullptr);
54 EXPECT_EQ(*type, ResourceType::kConfigVarying);
55
56 type = ParseResourceType("dimen");
57 ASSERT_NE(type, nullptr);
58 EXPECT_EQ(*type, ResourceType::kDimen);
59
60 type = ParseResourceType("drawable");
61 ASSERT_NE(type, nullptr);
62 EXPECT_EQ(*type, ResourceType::kDrawable);
63
64 type = ParseResourceType("font");
65 ASSERT_NE(type, nullptr);
66 EXPECT_EQ(*type, ResourceType::kFont);
67
68 type = ParseResourceType("fraction");
69 ASSERT_NE(type, nullptr);
70 EXPECT_EQ(*type, ResourceType::kFraction);
71
72 type = ParseResourceType("id");
73 ASSERT_NE(type, nullptr);
74 EXPECT_EQ(*type, ResourceType::kId);
75
76 type = ParseResourceType("integer");
77 ASSERT_NE(type, nullptr);
78 EXPECT_EQ(*type, ResourceType::kInteger);
79
80 type = ParseResourceType("interpolator");
81 ASSERT_NE(type, nullptr);
82 EXPECT_EQ(*type, ResourceType::kInterpolator);
83
84 type = ParseResourceType("layout");
85 ASSERT_NE(type, nullptr);
86 EXPECT_EQ(*type, ResourceType::kLayout);
87
88 type = ParseResourceType("menu");
89 ASSERT_NE(type, nullptr);
90 EXPECT_EQ(*type, ResourceType::kMenu);
91
92 type = ParseResourceType("mipmap");
93 ASSERT_NE(type, nullptr);
94 EXPECT_EQ(*type, ResourceType::kMipmap);
95
96 type = ParseResourceType("navigation");
97 ASSERT_NE(type, nullptr);
98 EXPECT_EQ(*type, ResourceType::kNavigation);
99
100 type = ParseResourceType("plurals");
101 ASSERT_NE(type, nullptr);
102 EXPECT_EQ(*type, ResourceType::kPlurals);
103
104 type = ParseResourceType("raw");
105 ASSERT_NE(type, nullptr);
106 EXPECT_EQ(*type, ResourceType::kRaw);
107
108 type = ParseResourceType("string");
109 ASSERT_NE(type, nullptr);
110 EXPECT_EQ(*type, ResourceType::kString);
111
112 type = ParseResourceType("style");
113 ASSERT_NE(type, nullptr);
114 EXPECT_EQ(*type, ResourceType::kStyle);
115
116 type = ParseResourceType("transition");
117 ASSERT_NE(type, nullptr);
118 EXPECT_EQ(*type, ResourceType::kTransition);
119
120 type = ParseResourceType("xml");
121 ASSERT_NE(type, nullptr);
122 EXPECT_EQ(*type, ResourceType::kXml);
123
124 type = ParseResourceType("blahaha");
125 EXPECT_EQ(type, nullptr);
126 }
127
128 } // namespace aapt
129