1 // Copyright 2015 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.
6 #include "core/html/FormData.h"
8 #include <gtest/gtest.h>
12 TEST(FormDataTest
, opacityGet
)
14 FormData
* fd
= FormData::create(UTF8Encoding());
15 fd
->append("name1", "value1");
17 FileOrUSVString result
;
18 fd
->get("name1", result
);
19 EXPECT_TRUE(result
.isUSVString());
20 EXPECT_EQ("value1", result
.getAsUSVString());
22 const FormData::Entry
& entry
= *fd
->entries()[0];
23 EXPECT_STREQ("name1", entry
.name().data());
24 EXPECT_STREQ("value1", entry
.value().data());
28 // Web-exposed interface should be opaque.
29 FileOrUSVString opaqueResult
;
30 fd
->get("name1", opaqueResult
);
31 EXPECT_TRUE(opaqueResult
.isNull());
33 // Internal interface should be uneffected.
34 const FormData::Entry
& entry2
= *fd
->entries()[0];
35 EXPECT_STREQ("name1", entry2
.name().data());
36 EXPECT_STREQ("value1", entry2
.value().data());
39 TEST(FormDataTest
, opacityGetAll
)
41 FormData
* fd
= FormData::create(UTF8Encoding());
42 fd
->append("name1", "value1");
44 HeapVector
<FormDataEntryValue
> results
= fd
->getAll("name1");
45 EXPECT_EQ(1u, results
.size());
46 EXPECT_TRUE(results
[0].isUSVString());
47 EXPECT_EQ("value1", results
[0].getAsUSVString());
49 EXPECT_EQ(1u, fd
->size());
53 // Web-exposed interface should be opaque.
54 results
= fd
->getAll("name1");
55 EXPECT_EQ(0u, results
.size());
57 // Internal interface should be uneffected.
58 EXPECT_EQ(1u, fd
->size());
61 TEST(FormDataTest
, opacityHas
)
63 FormData
* fd
= FormData::create(UTF8Encoding());
64 fd
->append("name1", "value1");
66 EXPECT_TRUE(fd
->has("name1"));
67 EXPECT_EQ(1u, fd
->size());
71 // Web-exposed interface should be opaque.
72 EXPECT_FALSE(fd
->has("name1"));
74 // Internal collection should be uneffected.
75 EXPECT_EQ(1u, fd
->size());