| Adam Lesinski | fab5087 | 2014-04-16 14:40:42 -0700 | [diff] [blame] | 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" | 
| Adam Lesinski | fab5087 | 2014-04-16 14:40:42 -0700 | [diff] [blame] | 22 |  | 
|  | 23 | using android::String8; | 
|  | 24 |  | 
|  | 25 | static ::testing::AssertionResult TestParse(AaptGroupEntry& entry, const String8& dirName, | 
|  | 26 | String8* outType) { | 
|  | 27 | if (entry.initFromDirName(dirName, outType)) { | 
|  | 28 | return ::testing::AssertionSuccess() << dirName << " was successfully parsed"; | 
|  | 29 | } | 
|  | 30 | return ::testing::AssertionFailure() << dirName << " could not be parsed"; | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | static ::testing::AssertionResult TestParse(AaptGroupEntry& entry, const char* input, | 
|  | 34 | String8* outType) { | 
|  | 35 | return TestParse(entry, String8(input), outType); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | TEST(AaptGroupEntryTest, ParseNoQualifier) { | 
|  | 39 | AaptGroupEntry entry; | 
|  | 40 | String8 type; | 
|  | 41 | EXPECT_TRUE(TestParse(entry, "menu", &type)); | 
|  | 42 | EXPECT_EQ(String8("menu"), type); | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | TEST(AaptGroupEntryTest, ParseCorrectType) { | 
|  | 46 | AaptGroupEntry entry; | 
|  | 47 | String8 type; | 
|  | 48 | EXPECT_TRUE(TestParse(entry, "anim", &type)); | 
|  | 49 | EXPECT_EQ(String8("anim"), type); | 
|  | 50 |  | 
|  | 51 | EXPECT_TRUE(TestParse(entry, "animator", &type)); | 
|  | 52 | EXPECT_EQ(String8("animator"), type); | 
|  | 53 | } |