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

Side by Side Diff: mojo/public/cpp/bindings/tests/associated_interface_unittest.cc

Issue 2332353004: Mojo C++ bindings: support closing [Associated]InterfaceRequest with reason. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 EXPECT_EQ("farewell", description); 961 EXPECT_EQ("farewell", description);
962 quit_closure.Run(); 962 quit_closure.Run();
963 }, 963 },
964 run_loop.QuitClosure())); 964 run_loop.QuitClosure()));
965 965
966 impl.binding()->CloseWithReason(456u, "farewell"); 966 impl.binding()->CloseWithReason(456u, "farewell");
967 967
968 run_loop.Run(); 968 run_loop.Run();
969 } 969 }
970 970
971 TEST_F(AssociatedInterfaceTest, AssociatedRequestResetWithReason) {
972 AssociatedInterfaceRequest<IntegerSender> request;
973 IntegerSenderAssociatedPtrInfo ptr_info;
974 CreateIntegerSender(&ptr_info, &request);
975
976 AssociatedInterfacePtr<IntegerSender> ptr;
977 ptr.Bind(std::move(ptr_info));
978
979 base::RunLoop run_loop;
980 ptr.set_connection_error_with_reason_handler(base::Bind(
981 [](const base::Closure& quit_closure, uint32_t custom_reason,
982 const std::string& description) {
983 EXPECT_EQ(789u, custom_reason);
984 EXPECT_EQ("long time no see", description);
985 quit_closure.Run();
986 },
987 run_loop.QuitClosure()));
988
989 request.ResetWithReason(789u, "long time no see");
990
991 run_loop.Run();
992 }
993
971 } // namespace 994 } // namespace
972 } // namespace test 995 } // namespace test
973 } // namespace mojo 996 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/control_message_proxy.cc ('k') | mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698