| OLD | NEW |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "mojo/converters/network/network_type_converters.h" | 7 #include "mojo/converters/network/network_type_converters.h" |
| 8 #include "mojo/shell/public/cpp/application_impl.h" | |
| 9 #include "mojo/shell/public/cpp/application_test_base.h" | 8 #include "mojo/shell/public/cpp/application_test_base.h" |
| 10 #include "mojo/shell/runner/child/test_native_service.mojom.h" | 9 #include "mojo/shell/runner/child/test_native_service.mojom.h" |
| 11 | 10 |
| 12 namespace mojo { | 11 namespace mojo { |
| 13 namespace shell { | 12 namespace shell { |
| 14 namespace { | 13 namespace { |
| 15 void InvertCallback(bool* result, bool from_native) { | 14 void InvertCallback(bool* result, bool from_native) { |
| 16 *result = from_native; | 15 *result = from_native; |
| 17 } | 16 } |
| 18 } // namespace | 17 } // namespace |
| 19 | 18 |
| 20 using NativeAppTest = mojo::test::ApplicationTestBase; | 19 using NativeAppTest = mojo::test::ApplicationTestBase; |
| 21 | 20 |
| 22 TEST_F(NativeAppTest, Connect) { | 21 TEST_F(NativeAppTest, Connect) { |
| 23 test::TestNativeServicePtr native_service; | 22 test::TestNativeServicePtr native_service; |
| 24 application_impl()->ConnectToService( | 23 shell()->ConnectToService("exe:mojo_runner_child_apptest_native_target", |
| 25 "exe:mojo_runner_child_apptest_native_target", &native_service); | 24 &native_service); |
| 26 | 25 |
| 27 bool result = false; | 26 bool result = false; |
| 28 native_service->Invert( | 27 native_service->Invert( |
| 29 true, base::Bind(&InvertCallback, base::Unretained(&result))); | 28 true, base::Bind(&InvertCallback, base::Unretained(&result))); |
| 30 native_service.WaitForIncomingResponse(); | 29 native_service.WaitForIncomingResponse(); |
| 31 EXPECT_FALSE(result); | 30 EXPECT_FALSE(result); |
| 32 | 31 |
| 33 native_service->Invert( | 32 native_service->Invert( |
| 34 false, base::Bind(&InvertCallback, base::Unretained(&result))); | 33 false, base::Bind(&InvertCallback, base::Unretained(&result))); |
| 35 native_service.WaitForIncomingResponse(); | 34 native_service.WaitForIncomingResponse(); |
| 36 EXPECT_TRUE(result); | 35 EXPECT_TRUE(result); |
| 37 } | 36 } |
| 38 | 37 |
| 39 } // namespace shell | 38 } // namespace shell |
| 40 } // namespace mojo | 39 } // namespace mojo |
| OLD | NEW |