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