1 // Copyright 2013 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. 4 5 #ifndef MOJO_PUBLIC_TESTS_TEST_SUPPORT_H_ 6 #define MOJO_PUBLIC_TESTS_TEST_SUPPORT_H_ 7 8 #include <string> 9 10 #include "base/callback.h" 11 #include "mojo/public/system/core_cpp.h" 12 13 namespace mojo { 14 namespace test { 15 16 struct MessagePipe { 17 MessagePipe(); 18 ~MessagePipe(); 19 20 ScopedMessagePipeHandle handle_0; 21 ScopedMessagePipeHandle handle_1; 22 23 DISALLOW_COPY_AND_ASSIGN(MessagePipe); 24 }; 25 26 bool WriteTextMessage(MessagePipeHandle handle, const std::string& text); 27 bool ReadTextMessage(MessagePipeHandle handle, std::string* text); 28 29 // Run |single_iteration| an appropriate number of times and report its 30 // performance appropriately. (This actually runs |single_iteration| for a fixed 31 // amount of time and reports the number of iterations per unit time.) 32 void IterateAndReportPerf(const char* test_name, 33 base::Callback<void()> single_iteration); 34 35 MojoResult WriteEmptyMessage(const MessagePipeHandle& handle); 36 MojoResult ReadEmptyMessage(const MessagePipeHandle& handle); 37 38 } // namespace test 39 } // namespace mojo 40 41 #endif // MOJO_PUBLIC_TESTS_TEST_SUPPORT_H_ 42