| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/public/cpp/system/wait.h" |
| 13 #include "mojo/public/cpp/test_support/test_utils.h" | 14 #include "mojo/public/cpp/test_support/test_utils.h" |
| 14 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" | 15 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 namespace mojo { | 18 namespace mojo { |
| 18 namespace test { | 19 namespace test { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const char kText1[] = "hello"; | 22 const char kText1[] = "hello"; |
| 22 const char kText2[] = "world"; | 23 const char kText2[] = "world"; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 105 |
| 105 void DoStuff2(ScopedDataPipeConsumerHandle pipe, | 106 void DoStuff2(ScopedDataPipeConsumerHandle pipe, |
| 106 const DoStuff2Callback& callback) override { | 107 const DoStuff2Callback& callback) override { |
| 107 // Read the data from the pipe, writing the response (as a string) to | 108 // Read the data from the pipe, writing the response (as a string) to |
| 108 // DidStuff2(). | 109 // DidStuff2(). |
| 109 ASSERT_TRUE(pipe.is_valid()); | 110 ASSERT_TRUE(pipe.is_valid()); |
| 110 uint32_t data_size = 0; | 111 uint32_t data_size = 0; |
| 111 | 112 |
| 112 MojoHandleSignalsState state; | 113 MojoHandleSignalsState state; |
| 113 ASSERT_EQ(MOJO_RESULT_OK, | 114 ASSERT_EQ(MOJO_RESULT_OK, |
| 114 MojoWait(pipe.get().value(), MOJO_HANDLE_SIGNAL_READABLE, | 115 mojo::Wait(pipe.get(), MOJO_HANDLE_SIGNAL_READABLE, &state)); |
| 115 MOJO_DEADLINE_INDEFINITE, &state)); | |
| 116 ASSERT_TRUE(state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE); | 116 ASSERT_TRUE(state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE); |
| 117 ASSERT_EQ(MOJO_RESULT_OK, | 117 ASSERT_EQ(MOJO_RESULT_OK, |
| 118 ReadDataRaw( | 118 ReadDataRaw( |
| 119 pipe.get(), nullptr, &data_size, MOJO_READ_DATA_FLAG_QUERY)); | 119 pipe.get(), nullptr, &data_size, MOJO_READ_DATA_FLAG_QUERY)); |
| 120 ASSERT_NE(0, static_cast<int>(data_size)); | 120 ASSERT_NE(0, static_cast<int>(data_size)); |
| 121 char data[64]; | 121 char data[64]; |
| 122 ASSERT_LT(static_cast<int>(data_size), 64); | 122 ASSERT_LT(static_cast<int>(data_size), 64); |
| 123 ASSERT_EQ( | 123 ASSERT_EQ( |
| 124 MOJO_RESULT_OK, | 124 MOJO_RESULT_OK, |
| 125 ReadDataRaw( | 125 ReadDataRaw( |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 run_loop.Run(); | 347 run_loop.Run(); |
| 348 run_loop2.Run(); | 348 run_loop2.Run(); |
| 349 | 349 |
| 350 EXPECT_EQ(std::string("object1"), name1); | 350 EXPECT_EQ(std::string("object1"), name1); |
| 351 EXPECT_EQ(std::string("object2"), name2); | 351 EXPECT_EQ(std::string("object2"), name2); |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace | 354 } // namespace |
| 355 } // namespace test | 355 } // namespace test |
| 356 } // namespace mojo | 356 } // namespace mojo |
| OLD | NEW |