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

Unified Diff: services/js/echo_apptest.cc

Issue 1954073003: Convert //services/js/echo_apptest.cc to use SynchronousInterfacePtr. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/js/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/js/echo_apptest.cc
diff --git a/services/js/echo_apptest.cc b/services/js/echo_apptest.cc
index 68ed79b51a819c1450c897c4e8df1199ab631b5b..6109d5cfeb5403b45b5efca1ef5ea781dfa186b0 100644
--- a/services/js/echo_apptest.cc
+++ b/services/js/echo_apptest.cc
@@ -3,7 +3,8 @@
// found in the LICENSE file.
#include "mojo/public/cpp/application/connect.h"
-#include "services/js/test/echo_service.mojom.h"
+#include "mojo/public/cpp/bindings/synchronous_interface_ptr.h"
+#include "services/js/test/echo_service.mojom-sync.h"
#include "services/js/test/js_application_test_base.h"
using mojo::String;
@@ -22,10 +23,10 @@ class JSEchoTest : public test::JSApplicationTestBase {
ApplicationTestBase::SetUp();
const std::string& url = JSAppURL("echo.js");
mojo::ConnectToService(application_impl()->shell(), url,
- GetProxy(&echo_service_));
+ GetSynchronousProxy(&echo_service_));
}
- mojo::EchoServicePtr echo_service_;
+ mojo::SynchronousInterfacePtr<mojo::EchoService> echo_service_;
private:
MOJO_DISALLOW_COPY_AND_ASSIGN(JSEchoTest);
@@ -51,45 +52,23 @@ class JSServiceProviderEchoTest : public test::JSApplicationTestBase {
MOJO_DISALLOW_COPY_AND_ASSIGN(JSServiceProviderEchoTest);
};
-struct EchoStringCallback {
- explicit EchoStringCallback(String *s) : echo_value(s) {}
- void Run(const String& value) const {
- *echo_value = value;
- }
- String *echo_value;
-};
-
-struct ShareEchoServiceCallback {
- explicit ShareEchoServiceCallback(bool *b) : value(b) {}
- void Run(bool callback_value) const {
- *value = callback_value;
- }
- bool *value;
-};
-
TEST_F(JSEchoTest, EchoString) {
String foo;
- EchoStringCallback callback(&foo);
- echo_service_->EchoString("foo", callback);
- EXPECT_TRUE(echo_service_.WaitForIncomingResponse());
+ EXPECT_TRUE(echo_service_->EchoString("foo", &foo));
EXPECT_EQ("foo", foo);
echo_service_->Quit();
}
TEST_F(JSEchoTest, EchoEmptyString) {
String empty;
- EchoStringCallback callback(&empty);
- echo_service_->EchoString("", callback);
- EXPECT_TRUE(echo_service_.WaitForIncomingResponse());
+ EXPECT_TRUE(echo_service_->EchoString("", &empty));
EXPECT_EQ("", empty);
echo_service_->Quit();
}
TEST_F(JSEchoTest, EchoNullString) {
String null;
- EchoStringCallback callback(&null);
- echo_service_->EchoString(nullptr, callback);
- EXPECT_TRUE(echo_service_.WaitForIncomingResponse());
+ EXPECT_TRUE(echo_service_->EchoString(nullptr, &null));
EXPECT_TRUE(null.is_null());
echo_service_->Quit();
}
@@ -97,30 +76,11 @@ TEST_F(JSEchoTest, EchoNullString) {
// Verify that a JS app's ServiceProvider can request and provide services.
// This test exercises the same code paths as examples/js/share_echo.js.
TEST_F(JSEchoTest, ShareEchoService) {
- bool returned_value;
- ShareEchoServiceCallback callback(&returned_value);
- echo_service_->ShareEchoService(callback);
- EXPECT_TRUE(echo_service_.WaitForIncomingResponse());
+ bool returned_value = false;
+ EXPECT_TRUE(echo_service_->ShareEchoService(&returned_value));
EXPECT_TRUE(returned_value);
echo_service_->Quit();
}
-// Verify that connecting via the echo service application's ServiceProvider
-// behaves the same as connecting to the echo service directly.
-TEST_F(JSServiceProviderEchoTest, UseApplicationServiceProvider) {
- mojo::EchoServicePtr echo_service;
- mojo::MessagePipe pipe;
- echo_service.Bind(
- mojo::InterfaceHandle<mojo::EchoService>(pipe.handle0.Pass(), 0u));
- echo_service_provider_->ConnectToService(
- mojo::EchoService::Name_, pipe.handle1.Pass());
- String foo;
- EchoStringCallback callback(&foo);
- echo_service->EchoString("foo", callback);
- EXPECT_TRUE(echo_service.WaitForIncomingResponse());
- EXPECT_EQ("foo", foo);
- echo_service->Quit();
-}
-
} // namespace
} // namespace js
« no previous file with comments | « services/js/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698