OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/js/test/js_application_test_base.h" | 5 #include "services/js/test/js_application_test_base.h" |
6 #include "services/js/test/pingpong_service.mojom.h" | 6 #include "services/js/test/pingpong_service.mojom.h" |
7 | 7 |
8 namespace js { | 8 namespace js { |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 pingpong_service_->Quit(); | 76 pingpong_service_->Quit(); |
77 } | 77 } |
78 | 78 |
79 // Verify that "pingpong.js" can connect to "pingpong-target.js", act as | 79 // Verify that "pingpong.js" can connect to "pingpong-target.js", act as |
80 // its client, and return a Promise that only resolves after the target.ping() | 80 // its client, and return a Promise that only resolves after the target.ping() |
81 // => client.pong() methods have executed 9 times. | 81 // => client.pong() methods have executed 9 times. |
82 TEST_F(JSPingPongTest, PingTargetURL) { | 82 TEST_F(JSPingPongTest, PingTargetURL) { |
83 bool returned_value = false; | 83 bool returned_value = false; |
84 PingTargetCallback callback(&returned_value); | 84 PingTargetCallback callback(&returned_value); |
85 pingpong_service_->PingTargetURL(JSAppURL("pingpong_target.js"), 9, callback); | 85 pingpong_service_->PingTargetURL(JSAppURL("pingpong_target.js"), 9, callback); |
86 EXPECT_TRUE(pingpong_service_.WaitForIncomingMethodCall()); | 86 EXPECT_TRUE(pingpong_service_.WaitForIncomingResponse()); |
87 EXPECT_TRUE(returned_value); | 87 EXPECT_TRUE(returned_value); |
88 pingpong_service_->Quit(); | 88 pingpong_service_->Quit(); |
89 } | 89 } |
90 | 90 |
91 // Same as the previous test except that instead of providing the | 91 // Same as the previous test except that instead of providing the |
92 // pingpong-target.js URL, we provide a connection to its PingPongService. | 92 // pingpong-target.js URL, we provide a connection to its PingPongService. |
93 TEST_F(JSPingPongTest, PingTargetService) { | 93 TEST_F(JSPingPongTest, PingTargetService) { |
94 PingPongServicePtr target; | 94 PingPongServicePtr target; |
95 application_impl()->ConnectToService(JSAppURL("pingpong_target.js"), &target); | 95 application_impl()->ConnectToService(JSAppURL("pingpong_target.js"), &target); |
96 bool returned_value = false; | 96 bool returned_value = false; |
97 PingTargetCallback callback(&returned_value); | 97 PingTargetCallback callback(&returned_value); |
98 pingpong_service_->PingTargetService(target.Pass(), 9, callback); | 98 pingpong_service_->PingTargetService(target.Pass(), 9, callback); |
99 EXPECT_TRUE(pingpong_service_.WaitForIncomingMethodCall()); | 99 EXPECT_TRUE(pingpong_service_.WaitForIncomingResponse()); |
100 EXPECT_TRUE(returned_value); | 100 EXPECT_TRUE(returned_value); |
101 pingpong_service_->Quit(); | 101 pingpong_service_->Quit(); |
102 } | 102 } |
103 | 103 |
104 // Verify that JS can implement an interface& "request" parameter. | 104 // Verify that JS can implement an interface& "request" parameter. |
105 TEST_F(JSPingPongTest, GetTargetService) { | 105 TEST_F(JSPingPongTest, GetTargetService) { |
106 PingPongServicePtr target; | 106 PingPongServicePtr target; |
107 PingPongClientImpl client; | 107 PingPongClientImpl client; |
108 pingpong_service_->GetPingPongService(GetProxy(&target)); | 108 pingpong_service_->GetPingPongService(GetProxy(&target)); |
109 PingPongClientPtr client_ptr; | 109 PingPongClientPtr client_ptr; |
110 client.Bind(GetProxy(&client_ptr)); | 110 client.Bind(GetProxy(&client_ptr)); |
111 target->SetClient(client_ptr.Pass()); | 111 target->SetClient(client_ptr.Pass()); |
112 target->Ping(1); | 112 target->Ping(1); |
113 EXPECT_EQ(2, client.WaitForPongValue()); | 113 EXPECT_EQ(2, client.WaitForPongValue()); |
114 target->Ping(100); | 114 target->Ping(100); |
115 EXPECT_EQ(101, client.WaitForPongValue()); | 115 EXPECT_EQ(101, client.WaitForPongValue()); |
116 target->Quit(); | 116 target->Quit(); |
117 pingpong_service_->Quit(); | 117 pingpong_service_->Quit(); |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 } // namespace | 121 } // namespace |
122 } // namespace js | 122 } // namespace js |
OLD | NEW |