blob: f2213e9879462d7a6b4a650f14933e48cdf483c9 [file] [log] [blame]
Richard Uhlere5fed032015-03-18 08:21:11 -07001/*
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
17#include "oat_file.h"
18
19#include <string>
20
21#include <gtest/gtest.h>
22
23namespace art {
24
25TEST(OatFileTest, ResolveRelativeEncodedDexLocation) {
26 EXPECT_EQ(std::string("/data/app/foo/base.apk"),
27 OatFile::ResolveRelativeEncodedDexLocation(
28 nullptr, "/data/app/foo/base.apk"));
29
30 EXPECT_EQ(std::string("/system/framework/base.apk"),
31 OatFile::ResolveRelativeEncodedDexLocation(
32 "/data/app/foo/base.apk", "/system/framework/base.apk"));
33
34 EXPECT_EQ(std::string("/data/app/foo/base.apk"),
35 OatFile::ResolveRelativeEncodedDexLocation(
36 "/data/app/foo/base.apk", "base.apk"));
37
38 EXPECT_EQ(std::string("/data/app/foo/base.apk"),
39 OatFile::ResolveRelativeEncodedDexLocation(
40 "/data/app/foo/base.apk", "foo/base.apk"));
41
42 EXPECT_EQ(std::string("/data/app/foo/base.apk:classes2.dex"),
43 OatFile::ResolveRelativeEncodedDexLocation(
44 "/data/app/foo/base.apk", "base.apk:classes2.dex"));
45
46 EXPECT_EQ(std::string("/data/app/foo/base.apk:classes11.dex"),
47 OatFile::ResolveRelativeEncodedDexLocation(
48 "/data/app/foo/base.apk", "base.apk:classes11.dex"));
49
50 EXPECT_EQ(std::string("base.apk"),
51 OatFile::ResolveRelativeEncodedDexLocation(
52 "/data/app/foo/sludge.apk", "base.apk"));
53
54 EXPECT_EQ(std::string("o/base.apk"),
55 OatFile::ResolveRelativeEncodedDexLocation(
56 "/data/app/foo/base.apk", "o/base.apk"));
57}
58
59} // namespace art