This source file includes following definitions.
- TEST
#include "chrome/browser/chromeos/fileapi/file_access_permissions.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
TEST(FileAccessPermissionsTest, FileAccessChecks) {
base::FilePath good_dir(FILE_PATH_LITERAL("/root/dir"));
base::FilePath bad_dir(FILE_PATH_LITERAL("/root"));
base::FilePath good_file(FILE_PATH_LITERAL("/root/dir/good_file.txt"));
base::FilePath bad_file(FILE_PATH_LITERAL("/root/dir/bad_file.txt"));
std::string extension1("ddammdhioacbehjngdmkjcjbnfginlla");
std::string extension2("jkhdjkhkhsdkfhsdkhrterwmtermeter");
FileAccessPermissions permissions;
EXPECT_FALSE(permissions.HasAccessPermission(extension1, good_dir));
EXPECT_FALSE(permissions.HasAccessPermission(extension1, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension1, bad_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, good_dir));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, bad_file));
permissions.GrantAccessPermission(extension1, good_file);
EXPECT_FALSE(permissions.HasAccessPermission(extension1, good_dir));
EXPECT_TRUE(permissions.HasAccessPermission(extension1, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension1, bad_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, good_dir));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, bad_file));
permissions.GrantAccessPermission(extension2, good_dir);
EXPECT_FALSE(permissions.HasAccessPermission(extension1, good_dir));
EXPECT_TRUE(permissions.HasAccessPermission(extension1, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension1, bad_file));
EXPECT_TRUE(permissions.HasAccessPermission(extension2, good_dir));
EXPECT_TRUE(permissions.HasAccessPermission(extension2, good_file));
EXPECT_TRUE(permissions.HasAccessPermission(extension2, bad_file));
permissions.GrantFullAccessPermission(extension1);
EXPECT_TRUE(permissions.HasAccessPermission(extension1, good_dir));
EXPECT_TRUE(permissions.HasAccessPermission(extension1, good_file));
EXPECT_TRUE(permissions.HasAccessPermission(extension1, bad_file));
permissions.RevokePermissions(extension1);
permissions.RevokePermissions(extension2);
EXPECT_FALSE(permissions.HasAccessPermission(extension1, good_dir));
EXPECT_FALSE(permissions.HasAccessPermission(extension1, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension1, bad_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, good_dir));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, good_file));
EXPECT_FALSE(permissions.HasAccessPermission(extension2, bad_file));
}
}