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

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

Issue 825613004: Mojo JS Bindings: fix the demos (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « mojo/services/public/js/application.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/js/test/echo_service.mojom.h" 5 #include "services/js/test/echo_service.mojom.h"
6 #include "services/js/test/js_application_test_base.h" 6 #include "services/js/test/js_application_test_base.h"
7 7
8 using mojo::String; 8 using mojo::String;
9 9
10 namespace js { 10 namespace js {
(...skipping 21 matching lines...) Expand all
32 class JSServiceProviderEchoTest : public test::JSApplicationTestBase { 32 class JSServiceProviderEchoTest : public test::JSApplicationTestBase {
33 public: 33 public:
34 JSServiceProviderEchoTest() : JSApplicationTestBase() {} 34 JSServiceProviderEchoTest() : JSApplicationTestBase() {}
35 ~JSServiceProviderEchoTest() override {} 35 ~JSServiceProviderEchoTest() override {}
36 36
37 protected: 37 protected:
38 // ApplicationTestBase: 38 // ApplicationTestBase:
39 void SetUp() override { 39 void SetUp() override {
40 ApplicationTestBase::SetUp(); 40 ApplicationTestBase::SetUp();
41 const std::string& url = JSAppURL("echo.js"); 41 const std::string& url = JSAppURL("echo.js");
42 // TODO(hansmuller): We should be able to pass a null ServiceProviderPtr
43 // here as the third parameter to ConnectToApplication since the parameter
44 // is annotated as nullable in the mojom, but the JS bindings currently
45 // don't correctly handle a null handle. So instead we allocate (and
46 // immediately close) a MessagePipe.
47 mojo::MessagePipe throwaway_pipe;
48 mojo::ServiceProviderPtr exposed_services;
49 exposed_services.Bind(throwaway_pipe.handle0.Pass());
50 application_impl()->shell()->ConnectToApplication( 42 application_impl()->shell()->ConnectToApplication(
51 url, GetProxy(&echo_service_provider_), exposed_services.Pass()); 43 url, GetProxy(&echo_service_provider_), nullptr);
52 } 44 }
53 45
54 mojo::ServiceProviderPtr echo_service_provider_; 46 mojo::ServiceProviderPtr echo_service_provider_;
55 47
56 private: 48 private:
57 MOJO_DISALLOW_COPY_AND_ASSIGN(JSServiceProviderEchoTest); 49 MOJO_DISALLOW_COPY_AND_ASSIGN(JSServiceProviderEchoTest);
58 }; 50 };
59 51
60 struct EchoStringCallback { 52 struct EchoStringCallback {
61 explicit EchoStringCallback(String *s) : echo_value(s) {} 53 explicit EchoStringCallback(String *s) : echo_value(s) {}
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 String foo; 114 String foo;
123 EchoStringCallback callback(&foo); 115 EchoStringCallback callback(&foo);
124 echo_service->EchoString("foo", callback); 116 echo_service->EchoString("foo", callback);
125 EXPECT_TRUE(echo_service.WaitForIncomingMethodCall()); 117 EXPECT_TRUE(echo_service.WaitForIncomingMethodCall());
126 EXPECT_EQ("foo", foo); 118 EXPECT_EQ("foo", foo);
127 echo_service->Quit(); 119 echo_service->Quit();
128 } 120 }
129 121
130 } // namespace 122 } // namespace
131 } // namespace js 123 } // namespace js
OLDNEW
« no previous file with comments | « mojo/services/public/js/application.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698