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

Unified Diff: third_party/WebKit/Source/core/html/forms/FileInputTypeTest.cpp

Issue 2098703003: DevTools: protocol setting files properly handles mimetypes and directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor to FileInputType, add test Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698