blob: c678ce21ec8088f657fe4d931e7b8a2dde68dfd2 [file] [log] [blame]
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/android/path_utils.h"
brettw@chromium.org59eef1f2013-02-24 14:40:52 +09006#include "base/files/file_path.h"
brettw@chromium.org01f3da42014-08-14 05:22:14 +09007#include "base/files/file_util.h"
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +09008
9#include "testing/gtest/include/gtest/gtest.h"
10
11namespace base {
12namespace android {
13
14typedef testing::Test PathUtilsTest;
15
16TEST_F(PathUtilsTest, TestGetDataDirectory) {
17 // The string comes from the Java side and depends on the APK
18 // we are running in. Assumes that we are packaged in
19 // org.chromium.native_test
aurimas@chromium.orge91c48c2012-10-03 07:03:33 +090020 FilePath path;
21 GetDataDirectory(&path);
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +090022 EXPECT_STREQ("/data/data/org.chromium.native_test/app_chrome",
aurimas@chromium.orge91c48c2012-10-03 07:03:33 +090023 path.value().c_str());
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +090024}
25
26TEST_F(PathUtilsTest, TestGetCacheDirectory) {
27 // The string comes from the Java side and depends on the APK
28 // we are running in. Assumes that we are packaged in
29 // org.chromium.native_test
aurimas@chromium.orge91c48c2012-10-03 07:03:33 +090030 FilePath path;
31 GetCacheDirectory(&path);
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +090032 EXPECT_STREQ("/data/data/org.chromium.native_test/cache",
aurimas@chromium.orge91c48c2012-10-03 07:03:33 +090033 path.value().c_str());
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +090034}
35
aurimas@chromium.org59cc7cf2012-07-03 05:04:04 +090036TEST_F(PathUtilsTest, TestGetNativeLibraryDirectory) {
37 // The string comes from the Java side and depends on the APK
jknotten@chromium.orgd8e15232012-11-21 23:16:01 +090038 // we are running in. Assumes that the directory contains
39 // the base tests shared object.
aurimas@chromium.orge91c48c2012-10-03 07:03:33 +090040 FilePath path;
41 GetNativeLibraryDirectory(&path);
eugenis@chromium.org3452ee32014-02-20 05:22:34 +090042 EXPECT_TRUE(base::PathExists(path.Append(("libbase_unittests.so"))) ||
43 base::PathExists(path.Append(("libbase_unittests.cr.so"))));
aurimas@chromium.org59cc7cf2012-07-03 05:04:04 +090044}
45
nileshagrawal@chromium.org77ab0bc2012-04-27 05:19:47 +090046} // namespace android
47} // namespace base