summaryrefslogtreecommitdiff
path: root/adb/adb_utils_test.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2016-07-28 18:30:46 -0700
committerJosh Gao <jmgao@google.com>2016-07-28 18:36:01 -0700
commit3bdc76025b9b1a8416f00b5f1b57a51c6c9c604d (patch)
tree2b8f1754b3b95abd2b12ba07689d709712cc7fcb /adb/adb_utils_test.cpp
parent6d232ab4de7dd0e24e2a313c8d47235fedf484b7 (diff)
adb: extract Windows bits out of directory_exists test.
Bug: http://b/30481559 Bug: https://code.google.com/p/android/issues/detail?id=214633 Change-Id: I8f20b3cd5aef6a77c2b4f194b914b4295397d73f
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r--adb/adb_utils_test.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp
index aabc5d7338..91826a9ec6 100644
--- a/adb/adb_utils_test.cpp
+++ b/adb/adb_utils_test.cpp
@@ -52,25 +52,35 @@ TEST(adb_utils, directory_exists) {
ASSERT_TRUE(directory_exists(profiles_dir));
+ ASSERT_FALSE(directory_exists(subdir(profiles_dir, "does-not-exist")));
+#else
+ ASSERT_TRUE(directory_exists("/proc"));
+ ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link.
+ ASSERT_FALSE(directory_exists("/proc/does-not-exist"));
+#endif
+}
+
+#if defined(_WIN32)
+TEST(adb_utils, directory_exists_win32_symlink_junction) {
+ char profiles_dir[MAX_PATH];
+ DWORD cch = arraysize(profiles_dir);
+
+ // On typical Windows 7, returns C:\Users
+ ASSERT_TRUE(GetProfilesDirectoryA(profiles_dir, &cch));
+
// On modern (English?) Windows, this is a directory symbolic link to
// C:\ProgramData. Symbolic links are rare on Windows and the user requires
// a special permission (by default granted to Administrative users) to
// create symbolic links.
- ASSERT_FALSE(directory_exists(subdir(profiles_dir, "All Users")));
+ EXPECT_FALSE(directory_exists(subdir(profiles_dir, "All Users")));
// On modern (English?) Windows, this is a directory junction to
// C:\Users\Default. Junctions are used throughout user profile directories
// for backwards compatibility and they don't require any special permissions
// to create.
- ASSERT_FALSE(directory_exists(subdir(profiles_dir, "Default User")));
-
- ASSERT_FALSE(directory_exists(subdir(profiles_dir, "does-not-exist")));
-#else
- ASSERT_TRUE(directory_exists("/proc"));
- ASSERT_FALSE(directory_exists("/proc/self")); // Symbolic link.
- ASSERT_FALSE(directory_exists("/proc/does-not-exist"));
-#endif
+ EXPECT_FALSE(directory_exists(subdir(profiles_dir, "Default User")));
}
+#endif
TEST(adb_utils, escape_arg) {
ASSERT_EQ(R"('')", escape_arg(""));