• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "config.h"
6 #include "modules/filesystem/DOMFileSystemBase.h"
7 
8 #include "core/fileapi/File.h"
9 #include "public/platform/Platform.h"
10 #include "public/platform/WebUnitTestSupport.h"
11 #include <gtest/gtest.h>
12 
13 
14 namespace blink {
15 
16 class DOMFileSystemBaseTest : public ::testing::Test {
17 public:
DOMFileSystemBaseTest()18     DOMFileSystemBaseTest()
19     {
20         m_filePath = Platform::current()->unitTestSupport()->webKitRootDir();
21         m_filePath.append("/Source/modules/filesystem/DOMFileSystemBaseTest.cpp");
22         getFileMetadata(m_filePath, m_fileMetadata);
23         m_fileMetadata.platformPath = m_filePath;
24     }
25 
26 protected:
27     String m_filePath;
28     FileMetadata m_fileMetadata;
29 };
30 
31 
TEST_F(DOMFileSystemBaseTest,externalFilesystemFilesAreUserVisible)32 TEST_F(DOMFileSystemBaseTest, externalFilesystemFilesAreUserVisible)
33 {
34     KURL rootUrl = DOMFileSystemBase::createFileSystemRootURL("http://chromium.org/", FileSystemTypeExternal);
35 
36     RefPtrWillBeRawPtr<File> file = DOMFileSystemBase::createFile(m_fileMetadata, rootUrl, FileSystemTypeExternal, "DOMFileSystemBaseTest.cpp");
37     EXPECT_TRUE(file);
38     EXPECT_TRUE(file->hasBackingFile());
39     EXPECT_EQ(File::IsUserVisible, file->userVisibility());
40     EXPECT_EQ("DOMFileSystemBaseTest.cpp", file->name());
41     EXPECT_EQ(m_filePath, file->path());
42 }
43 
TEST_F(DOMFileSystemBaseTest,temporaryFilesystemFilesAreNotUserVisible)44 TEST_F(DOMFileSystemBaseTest, temporaryFilesystemFilesAreNotUserVisible)
45 {
46     KURL rootUrl = DOMFileSystemBase::createFileSystemRootURL("http://chromium.org/", FileSystemTypeTemporary);
47 
48     RefPtrWillBeRawPtr<File> file = DOMFileSystemBase::createFile(m_fileMetadata, rootUrl, FileSystemTypeTemporary, "UserVisibleName.txt");
49     EXPECT_TRUE(file);
50     EXPECT_TRUE(file->hasBackingFile());
51     EXPECT_EQ(File::IsNotUserVisible, file->userVisibility());
52     EXPECT_EQ("UserVisibleName.txt", file->name());
53     EXPECT_EQ(m_filePath, file->path());
54 }
55 
TEST_F(DOMFileSystemBaseTest,persistentFilesystemFilesAreNotUserVisible)56 TEST_F(DOMFileSystemBaseTest, persistentFilesystemFilesAreNotUserVisible)
57 {
58     KURL rootUrl = DOMFileSystemBase::createFileSystemRootURL("http://chromium.org/", FileSystemTypePersistent);
59 
60     RefPtrWillBeRawPtr<File> file = DOMFileSystemBase::createFile(m_fileMetadata, rootUrl, FileSystemTypePersistent, "UserVisibleName.txt");
61     EXPECT_TRUE(file);
62     EXPECT_TRUE(file->hasBackingFile());
63     EXPECT_EQ(File::IsNotUserVisible, file->userVisibility());
64     EXPECT_EQ("UserVisibleName.txt", file->name());
65     EXPECT_EQ(m_filePath, file->path());
66 }
67 
68 } // namespace blink
69 
70 
71 
72