Home | History | Annotate | Download | only in tests
      1 /*
      2  * Copyright (C) 2017 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 "androidfw/ResourceUtils.h"
     18 
     19 #include "TestHelpers.h"
     20 
     21 namespace android {
     22 
     23 TEST(ResourceUtilsTest, ExtractResourceName) {
     24   StringPiece package, type, entry;
     25   ASSERT_TRUE(ExtractResourceName("android:string/foo", &package, &type, &entry));
     26   EXPECT_EQ("android", package);
     27   EXPECT_EQ("string", type);
     28   EXPECT_EQ("foo", entry);
     29 
     30   ASSERT_TRUE(ExtractResourceName("string/foo", &package, &type, &entry));
     31   EXPECT_EQ("", package);
     32   EXPECT_EQ("string", type);
     33   EXPECT_EQ("foo", entry);
     34 
     35   ASSERT_TRUE(ExtractResourceName("foo", &package, &type, &entry));
     36   EXPECT_EQ("", package);
     37   EXPECT_EQ("", type);
     38   EXPECT_EQ("foo", entry);
     39 
     40   ASSERT_TRUE(ExtractResourceName("android:foo", &package, &type, &entry));
     41   EXPECT_EQ("android", package);
     42   EXPECT_EQ("", type);
     43   EXPECT_EQ("foo", entry);
     44 
     45   EXPECT_FALSE(ExtractResourceName(":string/foo", &package, &type, &entry));
     46   EXPECT_FALSE(ExtractResourceName("/foo", &package, &type, &entry));
     47 }
     48 
     49 }  // namespace android
     50