ResourceUtils_test.cpp revision 929d6517dfd338f0d481dbe6587643d5aef27ec6
1ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease/* 2ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * Copyright (C) 2017 The Android Open Source Project 3ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * 4ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * Licensed under the Apache License, Version 2.0 (the "License"); 5ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * you may not use this file except in compliance with the License. 6ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * You may obtain a copy of the License at 7ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * 8ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * http://www.apache.org/licenses/LICENSE-2.0 9ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * 10ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * Unless required by applicable law or agreed to in writing, software 11ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * distributed under the License is distributed on an "AS IS" BASIS, 12ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * See the License for the specific language governing permissions and 14ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease * limitations under the License. 15ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease */ 16ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease 17ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease#include "androidfw/ResourceUtils.h" 18ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease 19c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa#include "TestHelpers.h" 20c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa 21ec97b4ddb467803d8637af2b64868b7b17861318Victoria Leasenamespace android { 2223cbe85610f780134cc77dd4a54732a22ed6e86eYohei Yukawa 23ec97b4ddb467803d8637af2b64868b7b17861318Victoria LeaseTEST(ResourceUtilsTest, ExtractResourceName) { 24ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease StringPiece package, type, entry; 25ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease ASSERT_TRUE(ExtractResourceName("android:string/foo", &package, &type, &entry)); 26ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease EXPECT_EQ("android", package); 27c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("string", type); 284037d51b132a85dcfe37a95f9d2d91ad23d162fdAurimas Liutikas EXPECT_EQ("foo", entry); 294037d51b132a85dcfe37a95f9d2d91ad23d162fdAurimas Liutikas 30ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease ASSERT_TRUE(ExtractResourceName("string/foo", &package, &type, &entry)); 31ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease EXPECT_EQ("", package); 32ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease EXPECT_EQ("string", type); 33ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease EXPECT_EQ("foo", entry); 34ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease 35ec97b4ddb467803d8637af2b64868b7b17861318Victoria Lease ASSERT_TRUE(ExtractResourceName("foo", &package, &type, &entry)); 36c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("", package); 37c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("", type); 38c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("foo", entry); 39c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa 40c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa ASSERT_TRUE(ExtractResourceName("android:foo", &package, &type, &entry)); 41c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("android", package); 42c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("", type); 43c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_EQ("foo", entry); 44c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa 45c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_FALSE(ExtractResourceName(":string/foo", &package, &type, &entry)); 46c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa EXPECT_FALSE(ExtractResourceName("/foo", &package, &type, &entry)); 47c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa} 48c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa 49c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa} // namespace android 50c38b51953921c17181fbe334cdaa95f188bfdb14Yohei Yukawa