blob: 06cddc78958863b8db408292c507b0db99e9b354 [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
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080017#include "Resource.h"
Adam Lesinskid0f116b2016-07-08 15:00:32 -070018#include "test/Test.h"
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080019
20namespace aapt {
21
22TEST(ResourceTypeTest, ParseResourceTypes) {
Adam Lesinskid0f116b2016-07-08 15:00:32 -070023 const ResourceType* type = parseResourceType("anim");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080024 ASSERT_NE(type, nullptr);
25 EXPECT_EQ(*type, ResourceType::kAnim);
26
Adam Lesinskid0f116b2016-07-08 15:00:32 -070027 type = parseResourceType("animator");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080028 ASSERT_NE(type, nullptr);
29 EXPECT_EQ(*type, ResourceType::kAnimator);
30
Adam Lesinskid0f116b2016-07-08 15:00:32 -070031 type = parseResourceType("array");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080032 ASSERT_NE(type, nullptr);
33 EXPECT_EQ(*type, ResourceType::kArray);
34
Adam Lesinskid0f116b2016-07-08 15:00:32 -070035 type = parseResourceType("attr");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080036 ASSERT_NE(type, nullptr);
37 EXPECT_EQ(*type, ResourceType::kAttr);
38
Adam Lesinskid0f116b2016-07-08 15:00:32 -070039 type = parseResourceType("^attr-private");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080040 ASSERT_NE(type, nullptr);
41 EXPECT_EQ(*type, ResourceType::kAttrPrivate);
42
Adam Lesinskid0f116b2016-07-08 15:00:32 -070043 type = parseResourceType("bool");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080044 ASSERT_NE(type, nullptr);
45 EXPECT_EQ(*type, ResourceType::kBool);
46
Adam Lesinskid0f116b2016-07-08 15:00:32 -070047 type = parseResourceType("color");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080048 ASSERT_NE(type, nullptr);
49 EXPECT_EQ(*type, ResourceType::kColor);
50
Adam Lesinskid0f116b2016-07-08 15:00:32 -070051 type = parseResourceType("dimen");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080052 ASSERT_NE(type, nullptr);
53 EXPECT_EQ(*type, ResourceType::kDimen);
54
Adam Lesinskid0f116b2016-07-08 15:00:32 -070055 type = parseResourceType("drawable");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080056 ASSERT_NE(type, nullptr);
57 EXPECT_EQ(*type, ResourceType::kDrawable);
58
Adam Lesinskid0f116b2016-07-08 15:00:32 -070059 type = parseResourceType("fraction");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080060 ASSERT_NE(type, nullptr);
61 EXPECT_EQ(*type, ResourceType::kFraction);
62
Adam Lesinskid0f116b2016-07-08 15:00:32 -070063 type = parseResourceType("id");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080064 ASSERT_NE(type, nullptr);
65 EXPECT_EQ(*type, ResourceType::kId);
66
Adam Lesinskid0f116b2016-07-08 15:00:32 -070067 type = parseResourceType("integer");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080068 ASSERT_NE(type, nullptr);
69 EXPECT_EQ(*type, ResourceType::kInteger);
70
Adam Lesinskid0f116b2016-07-08 15:00:32 -070071 type = parseResourceType("interpolator");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080072 ASSERT_NE(type, nullptr);
73 EXPECT_EQ(*type, ResourceType::kInterpolator);
74
Adam Lesinskid0f116b2016-07-08 15:00:32 -070075 type = parseResourceType("layout");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080076 ASSERT_NE(type, nullptr);
77 EXPECT_EQ(*type, ResourceType::kLayout);
78
Adam Lesinskid0f116b2016-07-08 15:00:32 -070079 type = parseResourceType("menu");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080080 ASSERT_NE(type, nullptr);
81 EXPECT_EQ(*type, ResourceType::kMenu);
82
Adam Lesinskid0f116b2016-07-08 15:00:32 -070083 type = parseResourceType("mipmap");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080084 ASSERT_NE(type, nullptr);
85 EXPECT_EQ(*type, ResourceType::kMipmap);
86
Adam Lesinskid0f116b2016-07-08 15:00:32 -070087 type = parseResourceType("plurals");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080088 ASSERT_NE(type, nullptr);
89 EXPECT_EQ(*type, ResourceType::kPlurals);
90
Adam Lesinskid0f116b2016-07-08 15:00:32 -070091 type = parseResourceType("raw");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080092 ASSERT_NE(type, nullptr);
93 EXPECT_EQ(*type, ResourceType::kRaw);
94
Adam Lesinskid0f116b2016-07-08 15:00:32 -070095 type = parseResourceType("string");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -080096 ASSERT_NE(type, nullptr);
97 EXPECT_EQ(*type, ResourceType::kString);
98
Adam Lesinskid0f116b2016-07-08 15:00:32 -070099 type = parseResourceType("style");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800100 ASSERT_NE(type, nullptr);
101 EXPECT_EQ(*type, ResourceType::kStyle);
102
Adam Lesinskid0f116b2016-07-08 15:00:32 -0700103 type = parseResourceType("transition");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800104 ASSERT_NE(type, nullptr);
105 EXPECT_EQ(*type, ResourceType::kTransition);
106
Adam Lesinskid0f116b2016-07-08 15:00:32 -0700107 type = parseResourceType("xml");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800108 ASSERT_NE(type, nullptr);
109 EXPECT_EQ(*type, ResourceType::kXml);
110
Adam Lesinskid0f116b2016-07-08 15:00:32 -0700111 type = parseResourceType("blahaha");
Adam Lesinski6f6ceb72014-11-14 14:48:12 -0800112 EXPECT_EQ(type, nullptr);
113}
114
115} // namespace aapt