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
3// found in the LICENSE file.
4
5#include "base/basictypes.h"
6#include "base/files/file_util.h"
7#include "base/files/scoped_temp_dir.h"
8#include "storage/browser/fileapi/sandbox_isolated_origin_database.h"
9#include "storage/browser/fileapi/sandbox_origin_database.h"
10#include "testing/gtest/include/gtest/gtest.h"
11
12using storage::SandboxIsolatedOriginDatabase;
13
14namespace content {
15
16namespace {
17const base::FilePath::CharType kOriginDirectory[] = FILE_PATH_LITERAL("iso");
18}  // namespace
19
20TEST(SandboxIsolatedOriginDatabaseTest, BasicTest) {
21  base::ScopedTempDir dir;
22  ASSERT_TRUE(dir.CreateUniqueTempDir());
23
24  std::string kOrigin("origin");
25  SandboxIsolatedOriginDatabase database(kOrigin, dir.path(),
26                                         base::FilePath(kOriginDirectory));
27
28  EXPECT_TRUE(database.HasOriginPath(kOrigin));
29
30  base::FilePath path1, path2;
31
32  EXPECT_FALSE(database.GetPathForOrigin(std::string(), &path1));
33  EXPECT_FALSE(database.GetPathForOrigin("foo", &path1));
34
35  EXPECT_TRUE(database.HasOriginPath(kOrigin));
36  EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path1));
37  EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path2));
38  EXPECT_FALSE(path1.empty());
39  EXPECT_FALSE(path2.empty());
40  EXPECT_EQ(path1, path2);
41}
42
43}  // namespace content
44