| Index: third_party/WebKit/Source/core/html/forms/FileInputTypeTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/forms/FileInputTypeTest.cpp b/third_party/WebKit/Source/core/html/forms/FileInputTypeTest.cpp
|
| index 21cf25f30dd24e29d90bf684c5be6ea8a1afdd5b..bee7386a187d9bf36bee38af7b869da21125bb9d 100644
|
| --- a/third_party/WebKit/Source/core/html/forms/FileInputTypeTest.cpp
|
| +++ b/third_party/WebKit/Source/core/html/forms/FileInputTypeTest.cpp
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "core/html/forms/FileInputType.h"
|
|
|
| +#include "core/HTMLNames.h"
|
| #include "core/clipboard/DataObject.h"
|
| #include "core/dom/Document.h"
|
| #include "core/fileapi/FileList.h"
|
| @@ -74,4 +75,36 @@ TEST(FileInputTypeTest, ignoreDroppedNonNativeFiles)
|
| EXPECT_EQ(String("/native/path"), fileInput->files()->item(0)->path());
|
| }
|
|
|
| +TEST(FileInputTypeTest, setFilesFromPaths)
|
| +{
|
| + Document* document = Document::create();
|
| + HTMLInputElement* input =
|
| + HTMLInputElement::create(*document, nullptr, false);
|
| + InputType* fileInput = FileInputType::create(*input);
|
| + Vector<String> paths;
|
| + paths.append("/native/path");
|
| + paths.append("/native/path2");
|
| + fileInput->setFilesFromPaths(paths);
|
| + ASSERT_EQ(1u, fileInput->files()->length());
|
| + EXPECT_EQ(String("/native/path"), fileInput->files()->item(0)->path());
|
| +
|
| + // Try to upload multiple files without multipleAttr
|
| + paths.clear();
|
| + paths.append("/native/path1");
|
| + paths.append("/native/path2");
|
| + fileInput->setFilesFromPaths(paths);
|
| + ASSERT_EQ(1u, fileInput->files()->length());
|
| + EXPECT_EQ(String("/native/path1"), fileInput->files()->item(0)->path());
|
| +
|
| + // Try to upload multiple files with multipleAttr
|
| + input->setBooleanAttribute(HTMLNames::multipleAttr, true);
|
| + paths.clear();
|
| + paths.append("/native/real/path1");
|
| + paths.append("/native/real/path2");
|
| + fileInput->setFilesFromPaths(paths);
|
| + ASSERT_EQ(2u, fileInput->files()->length());
|
| + EXPECT_EQ(String("/native/real/path1"), fileInput->files()->item(0)->path());
|
| + EXPECT_EQ(String("/native/real/path2"), fileInput->files()->item(1)->path());
|
| +}
|
| +
|
| } // namespace blink
|
|
|