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

Unified Diff: mojo/public/cpp/bindings/tests/wtf_types_unittest.cc

Issue 1979513004: Add array traits for WTF::Vector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@28_array_native
Patch Set: Created 4 years, 7 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/wtf_serialization.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/wtf_types_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc b/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc
index 223232b07aee25ab7c00f86f959e97a8c39cbd7b..8aa4ee7a47288435cf7b66e1ad55caf1cf57e186 100644
--- a/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/wtf_types_unittest.cc
@@ -64,7 +64,7 @@ WTFArray<WTF::String> ConstructStringArray() {
} // namespace
-TEST_F(WTFTypesTest, WTFToWTFSerialization_StringArray) {
+TEST_F(WTFTypesTest, Serialization_WTFArrayToWTFArray) {
WTFArray<WTF::String> strs = ConstructStringArray();
WTFArray<WTF::String> cloned_strs = strs.Clone();
@@ -85,7 +85,28 @@ TEST_F(WTFTypesTest, WTFToWTFSerialization_StringArray) {
EXPECT_TRUE(strs.Equals(strs2));
}
-TEST_F(WTFTypesTest, WTFToMojoSerialization_StringArray) {
+TEST_F(WTFTypesTest, Serialization_WTFVectorToWTFVector) {
+ WTF::Vector<WTF::String> strs = ConstructStringArray().PassStorage();
+ WTF::Vector<WTF::String> cloned_strs = strs;
+
+ mojo::internal::SerializationContext context;
+ size_t size = mojo::internal::PrepareToSerialize<Array<mojo::String>>(
+ cloned_strs, &context);
+
+ mojo::internal::FixedBufferForTesting buf(size);
+ mojo::internal::Array_Data<mojo::internal::String_Data*>* data;
+ mojo::internal::ArrayValidateParams validate_params(
+ 0, true, new mojo::internal::ArrayValidateParams(0, false, nullptr));
+ mojo::internal::Serialize<Array<mojo::String>>(cloned_strs, &buf, &data,
+ &validate_params, &context);
+
+ WTF::Vector<WTF::String> strs2;
+ mojo::internal::Deserialize<Array<mojo::String>>(data, &strs2, nullptr);
+
+ EXPECT_EQ(strs, strs2);
+}
+
+TEST_F(WTFTypesTest, Serialization_WTFArrayToMojoArray) {
WTFArray<WTF::String> strs = ConstructStringArray();
mojo::internal::SerializationContext context;
« no previous file with comments | « mojo/public/cpp/bindings/lib/wtf_serialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698