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