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

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

Issue 2146153002: Mojo typemap config: support "copyable_pass_by_value" attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@69_change_move_only
Patch Set: . Created 4 years, 5 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 | « no previous file | mojo/public/cpp/bindings/tests/struct_with_traits.typemap » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/struct_traits_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/struct_traits_unittest.cc b/mojo/public/cpp/bindings/tests/struct_traits_unittest.cc
index 583dc460be4f268ff9d5e6b0e10b5a50f9353565..15b8d6ca62bbab0905c0ca7a4eda23d7aa633ea8 100644
--- a/mojo/public/cpp/bindings/tests/struct_traits_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/struct_traits_unittest.cc
@@ -134,9 +134,15 @@ class StructTraitsTest : public testing::Test,
callback.Run(s);
}
- void EchoPassByValueStructWithTraits(
- PassByValueStructWithTraitsImpl s,
- const EchoPassByValueStructWithTraitsCallback& callback) override {
+ void EchoTrivialStructWithTraits(
+ TrivialStructWithTraitsImpl s,
+ const EchoTrivialStructWithTraitsCallback& callback) override {
+ callback.Run(s);
+ }
+
+ void EchoMoveOnlyStructWithTraits(
+ MoveOnlyStructWithTraitsImpl s,
+ const EchoMoveOnlyStructWithTraitsCallback& callback) override {
callback.Run(std::move(s));
}
@@ -274,24 +280,44 @@ TEST_F(StructTraitsTest, CloneStructWithTraitsContainer) {
EXPECT_EQ(42u, cloned_container->f_struct.get_uint64());
}
+void ExpectTrivialStructWithTraits(TrivialStructWithTraitsImpl expected,
+ const base::Closure& closure,
+ TrivialStructWithTraitsImpl passed) {
+ EXPECT_EQ(expected.value, passed.value);
+ closure.Run();
+}
+
+TEST_F(StructTraitsTest, EchoTrivialStructWithTraits) {
+ TrivialStructWithTraitsImpl input;
+ input.value = 42;
+
+ base::RunLoop loop;
+ TraitsTestServicePtr proxy = GetTraitsTestProxy();
+
+ proxy->EchoTrivialStructWithTraits(
+ input,
+ base::Bind(&ExpectTrivialStructWithTraits, input, loop.QuitClosure()));
+ loop.Run();
+}
+
void CaptureMessagePipe(ScopedMessagePipeHandle* storage,
const base::Closure& closure,
- PassByValueStructWithTraitsImpl passed) {
+ MoveOnlyStructWithTraitsImpl passed) {
storage->reset(MessagePipeHandle(
passed.get_mutable_handle().release().value()));
closure.Run();
}
-TEST_F(StructTraitsTest, EchoPassByValueStructWithTraits) {
+TEST_F(StructTraitsTest, EchoMoveOnlyStructWithTraits) {
MessagePipe mp;
- PassByValueStructWithTraitsImpl input;
+ MoveOnlyStructWithTraitsImpl input;
input.get_mutable_handle().reset(mp.handle0.release());
base::RunLoop loop;
TraitsTestServicePtr proxy = GetTraitsTestProxy();
ScopedMessagePipeHandle received;
- proxy->EchoPassByValueStructWithTraits(
+ proxy->EchoMoveOnlyStructWithTraits(
std::move(input),
base::Bind(&CaptureMessagePipe, &received, loop.QuitClosure()));
loop.Run();
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/struct_with_traits.typemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698