2014-11-14 14:48:12 -08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Resource.h"
|
2016-07-08 15:00:32 -07:00
|
|
|
#include "test/Test.h"
|
2014-11-14 14:48:12 -08:00
|
|
|
|
|
|
|
namespace aapt {
|
|
|
|
|
|
|
|
TEST(ResourceTypeTest, ParseResourceTypes) {
|
2016-10-19 12:18:14 -07:00
|
|
|
const ResourceType* type = parseResourceType("anim");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kAnim);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("animator");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kAnimator);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("array");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kArray);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("attr");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kAttr);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("^attr-private");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kAttrPrivate);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("bool");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kBool);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("color");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kColor);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("dimen");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kDimen);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("drawable");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kDrawable);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("fraction");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kFraction);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("id");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kId);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("integer");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kInteger);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("interpolator");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kInterpolator);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("layout");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kLayout);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("menu");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kMenu);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("mipmap");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kMipmap);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("plurals");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kPlurals);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("raw");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kRaw);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("string");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kString);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("style");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kStyle);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("transition");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kTransition);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("xml");
|
|
|
|
ASSERT_NE(type, nullptr);
|
|
|
|
EXPECT_EQ(*type, ResourceType::kXml);
|
2014-11-14 14:48:12 -08:00
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
type = parseResourceType("blahaha");
|
|
|
|
EXPECT_EQ(type, nullptr);
|
2014-11-14 14:48:12 -08:00
|
|
|
}
|
|
|
|
|
2016-10-19 12:18:14 -07:00
|
|
|
} // namespace aapt
|