1 // 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.
5 #include "base/android/path_utils.h"
6 #include "base/files/file_path.h"
7 #include "base/files/file_util.h"
8 #include "base/strings/string_util.h"
10 #include "testing/gtest/include/gtest/gtest.h"
15 typedef testing::Test PathUtilsTest
;
18 void ExpectEither(const std::string
& expected1
,
19 const std::string
& expected2
,
20 const std::string
& actual
) {
21 EXPECT_TRUE(expected1
== actual
|| expected2
== actual
)
22 << "Value of: " << actual
<< std::endl
23 << "Expected either: " << expected1
<< std::endl
24 << "or: " << expected2
;
28 TEST_F(PathUtilsTest
, TestGetDataDirectory
) {
29 // The string comes from the Java side and depends on the APK
30 // we are running in. Assumes that we are packaged in
31 // org.chromium.native_test
33 GetDataDirectory(&path
);
35 ExpectEither("/data/data/org.chromium.native_test/app_chrome",
36 "/data/user/0/org.chromium.native_test/app_chrome",
40 TEST_F(PathUtilsTest
, TestGetCacheDirectory
) {
41 // The string comes from the Java side and depends on the APK
42 // we are running in. Assumes that we are packaged in
43 // org.chromium.native_test
45 GetCacheDirectory(&path
);
46 ExpectEither("/data/data/org.chromium.native_test/cache",
47 "/data/user/0/org.chromium.native_test/cache",
51 TEST_F(PathUtilsTest
, TestGetNativeLibraryDirectory
) {
52 // The string comes from the Java side and depends on the APK
53 // we are running in. Assumes that the directory contains
54 // the base tests shared object.
56 GetNativeLibraryDirectory(&path
);
57 EXPECT_TRUE(base::PathExists(path
.Append(("libbase_unittests.so"))) ||
58 base::PathExists(path
.Append(("libbase_unittests.cr.so"))));
61 } // namespace android