| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "storage/browser/fileapi/sandbox_isolated_origin_database.h" | 7 #include "storage/browser/fileapi/sandbox_isolated_origin_database.h" |
| 8 #include "storage/browser/fileapi/sandbox_origin_database.h" | 8 #include "storage/browser/fileapi/sandbox_origin_database.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 using storage::SandboxIsolatedOriginDatabase; | 11 using storage::SandboxIsolatedOriginDatabase; |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const base::FilePath::CharType kOriginDirectory[] = FILE_PATH_LITERAL("iso"); | 16 const base::FilePath::CharType kOriginDirectory[] = FILE_PATH_LITERAL("iso"); |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 TEST(SandboxIsolatedOriginDatabaseTest, BasicTest) { | 19 TEST(SandboxIsolatedOriginDatabaseTest, BasicTest) { |
| 20 base::ScopedTempDir dir; | 20 base::ScopedTempDir dir; |
| 21 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 21 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 22 | 22 |
| 23 std::string kOrigin("origin"); | 23 std::string kOrigin("origin"); |
| 24 SandboxIsolatedOriginDatabase database(kOrigin, dir.path(), | 24 SandboxIsolatedOriginDatabase database(kOrigin, dir.GetPath(), |
| 25 base::FilePath(kOriginDirectory)); | 25 base::FilePath(kOriginDirectory)); |
| 26 | 26 |
| 27 EXPECT_TRUE(database.HasOriginPath(kOrigin)); | 27 EXPECT_TRUE(database.HasOriginPath(kOrigin)); |
| 28 | 28 |
| 29 base::FilePath path1, path2; | 29 base::FilePath path1, path2; |
| 30 | 30 |
| 31 EXPECT_FALSE(database.GetPathForOrigin(std::string(), &path1)); | 31 EXPECT_FALSE(database.GetPathForOrigin(std::string(), &path1)); |
| 32 EXPECT_FALSE(database.GetPathForOrigin("foo", &path1)); | 32 EXPECT_FALSE(database.GetPathForOrigin("foo", &path1)); |
| 33 | 33 |
| 34 EXPECT_TRUE(database.HasOriginPath(kOrigin)); | 34 EXPECT_TRUE(database.HasOriginPath(kOrigin)); |
| 35 EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path1)); | 35 EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path1)); |
| 36 EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path2)); | 36 EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path2)); |
| 37 EXPECT_FALSE(path1.empty()); | 37 EXPECT_FALSE(path1.empty()); |
| 38 EXPECT_FALSE(path2.empty()); | 38 EXPECT_FALSE(path2.empty()); |
| 39 EXPECT_EQ(path1, path2); | 39 EXPECT_EQ(path1, path2); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace content | 42 } // namespace content |
| OLD | NEW |