Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataObjectTest.cpp

Issue 2565283002: Fix webkitGetEntry for non-native files. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/clipboard/DataObject.h" 5 #include "core/clipboard/DataObject.h"
6 6
7 #include "core/clipboard/DataObjectItem.h" 7 #include "core/clipboard/DataObjectItem.h"
8 #include "platform/testing/UnitTestHelpers.h" 8 #include "platform/testing/UnitTestHelpers.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 class DataObjectTest : public ::testing::Test { 13 class DataObjectTest : public ::testing::Test {
14 public: 14 public:
15 DataObjectTest() : m_dataObject(DataObject::create()) {} 15 DataObjectTest() : m_dataObject(DataObject::create()) {}
16 16
17 protected: 17 protected:
18 Persistent<DataObject> m_dataObject; 18 Persistent<DataObject> m_dataObject;
19 }; 19 };
20 20
21 TEST_F(DataObjectTest, addItemWithFilenameAndNoTitle) { 21 TEST_F(DataObjectTest, addItemWithFilenameAndNoTitle) {
22 String filePath = testing::blinkRootDir(); 22 String filePath = testing::blinkRootDir();
23 filePath.append("/Source/core/clipboard/DataObjectTest.cpp"); 23 filePath.append("/Source/core/clipboard/DataObjectTest.cpp");
24 24
25 m_dataObject->addFilename(filePath, String()); 25 m_dataObject->addFilename(filePath, String(), "fileSystemId");
hashimoto 2016/12/12 05:55:39 Instead of adding filesystem ID to all existing te
hirono 2016/12/13 08:12:13 Done.
26 EXPECT_EQ(1U, m_dataObject->length()); 26 EXPECT_EQ(1U, m_dataObject->length());
27 27
28 DataObjectItem* item = m_dataObject->item(0); 28 DataObjectItem* item = m_dataObject->item(0);
29 EXPECT_EQ(DataObjectItem::FileKind, item->kind()); 29 EXPECT_EQ(DataObjectItem::FileKind, item->kind());
30 30
31 Blob* blob = item->getAsFile(); 31 Blob* blob = item->getAsFile();
32 ASSERT_TRUE(blob->isFile()); 32 ASSERT_TRUE(blob->isFile());
33 File* file = toFile(blob); 33 File* file = toFile(blob);
34 EXPECT_TRUE(file->hasBackingFile()); 34 EXPECT_TRUE(file->hasBackingFile());
35 EXPECT_EQ(File::IsUserVisible, file->getUserVisibility()); 35 EXPECT_EQ(File::IsUserVisible, file->getUserVisibility());
36 EXPECT_EQ(filePath, file->path()); 36 EXPECT_EQ(filePath, file->path());
37 EXPECT_TRUE(item->hasFileSystemId());
38 EXPECT_EQ("fileSystemId", item->fileSystemId());
37 } 39 }
38 40
39 TEST_F(DataObjectTest, addItemWithFilenameAndTitle) { 41 TEST_F(DataObjectTest, addItemWithFilenameAndTitle) {
40 String filePath = testing::blinkRootDir(); 42 String filePath = testing::blinkRootDir();
41 filePath.append("/Source/core/clipboard/DataObjectTest.cpp"); 43 filePath.append("/Source/core/clipboard/DataObjectTest.cpp");
42 44
43 m_dataObject->addFilename(filePath, "name.cpp"); 45 m_dataObject->addFilename(filePath, "name.cpp", "fileSystemId");
44 EXPECT_EQ(1U, m_dataObject->length()); 46 EXPECT_EQ(1U, m_dataObject->length());
45 47
46 DataObjectItem* item = m_dataObject->item(0); 48 DataObjectItem* item = m_dataObject->item(0);
47 EXPECT_EQ(DataObjectItem::FileKind, item->kind()); 49 EXPECT_EQ(DataObjectItem::FileKind, item->kind());
48 50
49 Blob* blob = item->getAsFile(); 51 Blob* blob = item->getAsFile();
50 ASSERT_TRUE(blob->isFile()); 52 ASSERT_TRUE(blob->isFile());
51 File* file = toFile(blob); 53 File* file = toFile(blob);
52 EXPECT_TRUE(file->hasBackingFile()); 54 EXPECT_TRUE(file->hasBackingFile());
53 EXPECT_EQ(File::IsUserVisible, file->getUserVisibility()); 55 EXPECT_EQ(File::IsUserVisible, file->getUserVisibility());
54 EXPECT_EQ(filePath, file->path()); 56 EXPECT_EQ(filePath, file->path());
55 EXPECT_EQ("name.cpp", file->name()); 57 EXPECT_EQ("name.cpp", file->name());
58 EXPECT_TRUE(item->hasFileSystemId());
59 EXPECT_EQ("fileSystemId", item->fileSystemId());
56 } 60 }
57 61
58 } // namespace blink 62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698