Update V8 to version 4.7.21.
[chromium-blink-merge.git] / base / android / path_utils_unittest.cc
blobd991810aa91afe003676d1cb3a775cc4d6f567a3
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"
12 namespace base {
13 namespace android {
15 typedef testing::Test PathUtilsTest;
17 namespace {
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;
26 } // namespace
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
32 FilePath path;
33 GetDataDirectory(&path);
35 ExpectEither("/data/data/org.chromium.native_test/app_chrome",
36 "/data/user/0/org.chromium.native_test/app_chrome",
37 path.value());
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
44 FilePath path;
45 GetCacheDirectory(&path);
46 ExpectEither("/data/data/org.chromium.native_test/cache",
47 "/data/user/0/org.chromium.native_test/cache",
48 path.value());
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.
55 FilePath path;
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
62 } // namespace base