Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: services/js/pingpong_apptest.cc

Issue 1915403002: ApplicationImpl::ConnectToServiceDeprecated() -> mojo::ConnectToService() conversion, part 2. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "mojo/public/cpp/application/connect.h"
5 #include "services/js/test/js_application_test_base.h" 6 #include "services/js/test/js_application_test_base.h"
6 #include "services/js/test/pingpong_service.mojom.h" 7 #include "services/js/test/pingpong_service.mojom.h"
7 8
8 namespace js { 9 namespace js {
9 namespace { 10 namespace {
10 11
11 class PingPongClientImpl : public PingPongClient { 12 class PingPongClientImpl : public PingPongClient {
12 public: 13 public:
13 PingPongClientImpl() : last_pong_value_(0), binding_(this) {}; 14 PingPongClientImpl() : last_pong_value_(0), binding_(this) {};
14 ~PingPongClientImpl() override {}; 15 ~PingPongClientImpl() override {};
(...skipping 23 matching lines...) Expand all
38 class JSPingPongTest : public test::JSApplicationTestBase { 39 class JSPingPongTest : public test::JSApplicationTestBase {
39 public: 40 public:
40 JSPingPongTest() : JSApplicationTestBase() {} 41 JSPingPongTest() : JSApplicationTestBase() {}
41 ~JSPingPongTest() override {} 42 ~JSPingPongTest() override {}
42 43
43 protected: 44 protected:
44 // ApplicationTestBase: 45 // ApplicationTestBase:
45 void SetUp() override { 46 void SetUp() override {
46 ApplicationTestBase::SetUp(); 47 ApplicationTestBase::SetUp();
47 const std::string& url = JSAppURL("pingpong.js"); 48 const std::string& url = JSAppURL("pingpong.js");
48 application_impl()->ConnectToServiceDeprecated(url, &pingpong_service_); 49 mojo::ConnectToService(application_impl()->shell(), url,
50 GetProxy(&pingpong_service_));
49 PingPongClientPtr client_ptr; 51 PingPongClientPtr client_ptr;
50 pingpong_client_.Bind(GetProxy(&client_ptr)); 52 pingpong_client_.Bind(GetProxy(&client_ptr));
51 pingpong_service_->SetClient(client_ptr.Pass()); 53 pingpong_service_->SetClient(client_ptr.Pass());
52 } 54 }
53 55
54 PingPongServicePtr pingpong_service_; 56 PingPongServicePtr pingpong_service_;
55 PingPongClientImpl pingpong_client_; 57 PingPongClientImpl pingpong_client_;
56 58
57 private: 59 private:
58 MOJO_DISALLOW_COPY_AND_ASSIGN(JSPingPongTest); 60 MOJO_DISALLOW_COPY_AND_ASSIGN(JSPingPongTest);
(...skipping 26 matching lines...) Expand all
85 pingpong_service_->PingTargetURL(JSAppURL("pingpong_target.js"), 9, callback); 87 pingpong_service_->PingTargetURL(JSAppURL("pingpong_target.js"), 9, callback);
86 EXPECT_TRUE(pingpong_service_.WaitForIncomingResponse()); 88 EXPECT_TRUE(pingpong_service_.WaitForIncomingResponse());
87 EXPECT_TRUE(returned_value); 89 EXPECT_TRUE(returned_value);
88 pingpong_service_->Quit(); 90 pingpong_service_->Quit();
89 } 91 }
90 92
91 // Same as the previous test except that instead of providing the 93 // Same as the previous test except that instead of providing the
92 // pingpong-target.js URL, we provide a connection to its PingPongService. 94 // pingpong-target.js URL, we provide a connection to its PingPongService.
93 TEST_F(JSPingPongTest, PingTargetService) { 95 TEST_F(JSPingPongTest, PingTargetService) {
94 PingPongServicePtr target; 96 PingPongServicePtr target;
95 application_impl()->ConnectToServiceDeprecated(JSAppURL("pingpong_target.js"), 97 mojo::ConnectToService(application_impl()->shell(),
96 &target); 98 JSAppURL("pingpong_target.js"), GetProxy(&target));
97 bool returned_value = false; 99 bool returned_value = false;
98 PingTargetCallback callback(&returned_value); 100 PingTargetCallback callback(&returned_value);
99 pingpong_service_->PingTargetService(target.Pass(), 9, callback); 101 pingpong_service_->PingTargetService(target.Pass(), 9, callback);
100 EXPECT_TRUE(pingpong_service_.WaitForIncomingResponse()); 102 EXPECT_TRUE(pingpong_service_.WaitForIncomingResponse());
101 EXPECT_TRUE(returned_value); 103 EXPECT_TRUE(returned_value);
102 pingpong_service_->Quit(); 104 pingpong_service_->Quit();
103 } 105 }
104 106
105 // Verify that JS can implement an interface& "request" parameter. 107 // Verify that JS can implement an interface& "request" parameter.
106 TEST_F(JSPingPongTest, GetTargetService) { 108 TEST_F(JSPingPongTest, GetTargetService) {
107 PingPongServicePtr target; 109 PingPongServicePtr target;
108 PingPongClientImpl client; 110 PingPongClientImpl client;
109 pingpong_service_->GetPingPongService(GetProxy(&target)); 111 pingpong_service_->GetPingPongService(GetProxy(&target));
110 PingPongClientPtr client_ptr; 112 PingPongClientPtr client_ptr;
111 client.Bind(GetProxy(&client_ptr)); 113 client.Bind(GetProxy(&client_ptr));
112 target->SetClient(client_ptr.Pass()); 114 target->SetClient(client_ptr.Pass());
113 target->Ping(1); 115 target->Ping(1);
114 EXPECT_EQ(2, client.WaitForPongValue()); 116 EXPECT_EQ(2, client.WaitForPongValue());
115 target->Ping(100); 117 target->Ping(100);
116 EXPECT_EQ(101, client.WaitForPongValue()); 118 EXPECT_EQ(101, client.WaitForPongValue());
117 target->Quit(); 119 target->Quit();
118 pingpong_service_->Quit(); 120 pingpong_service_->Quit();
119 } 121 }
120 122
121 123
122 } // namespace 124 } // namespace
123 } // namespace js 125 } // namespace js
OLDNEW
« no previous file with comments | « services/js/network_apptest.cc ('k') | services/media/factory_service/audio_track_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698