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

Unified Diff: headless/public/domains/types_unittest.cc

Issue 2533083003: Fix the serialization for values in std::unique_ptrs. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | headless/public/internal/value_conversions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/public/domains/types_unittest.cc
diff --git a/headless/public/domains/types_unittest.cc b/headless/public/domains/types_unittest.cc
index e5c0efa7e5a5d8e2c9652a4d329c349c60a30436..860f69ba50b91f317657a72da613a4f6b79ea9f7 100644
--- a/headless/public/domains/types_unittest.cc
+++ b/headless/public/domains/types_unittest.cc
@@ -3,7 +3,9 @@
// found in the LICENSE file.
#include "base/json/json_reader.h"
+#include "base/json/json_string_value_serializer.h"
#include "headless/public/devtools/domains/accessibility.h"
+#include "headless/public/devtools/domains/dom.h"
#include "headless/public/devtools/domains/memory.h"
#include "headless/public/devtools/domains/page.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -213,4 +215,29 @@ TEST(TypesTest, AnyProperty) {
EXPECT_EQ(123, clone_value);
}
+TEST(TypesTest, ComplexObjectClone) {
+ std::vector<std::unique_ptr<dom::Node>> child_nodes;
+ child_nodes.emplace_back(dom::Node::Builder()
+ .SetNodeId(1)
+ .SetBackendNodeId(2)
+ .SetNodeType(3)
+ .SetNodeName("-blink-blink")
+ .SetLocalName("-blink-blink")
+ .SetNodeValue("-blink-blink")
+ .Build());
+ std::unique_ptr<dom::SetChildNodesParams> params =
+ dom::SetChildNodesParams::Builder()
+ .SetParentId(123)
+ .SetNodes(std::move(child_nodes))
+ .Build();
+ std::unique_ptr<dom::SetChildNodesParams> clone = params->Clone();
+ ASSERT_NE(nullptr, clone);
Sami 2016/11/29 10:32:21 Please use EXPECT_NE instead of ASSERT_NE so that
tmarek 2016/11/29 10:36:18 The test will crash with a SEGV (ptr is dereferenc
Sami 2016/11/29 10:48:04 Fair point. We generally avoid asserts in tests bu
+
+ std::string orig;
+ JSONStringValueSerializer(&orig).Serialize(*params->Serialize());
+ std::string clone_value;
+ JSONStringValueSerializer(&clone_value).Serialize(*clone->Serialize());
+ EXPECT_EQ(orig, clone_value);
+}
+
} // namespace headless
« no previous file with comments | « no previous file | headless/public/internal/value_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698