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

Unified Diff: services/js/js_apptests.cc

Issue 767323002: Mojo JS Bindings: restore the ServiceProvider class, add an application test (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Removed console import from ServiceProvider Created 6 years 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/js_app_runner_delegate.cc ('k') | services/js/mojo_bridge_module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/js/js_apptests.cc
diff --git a/services/js/js_apptests.cc b/services/js/js_apptests.cc
new file mode 100644
index 0000000000000000000000000000000000000000..16595d0ab9921654fa1cd1c9a428d79b11542443
--- /dev/null
+++ b/services/js/js_apptests.cc
@@ -0,0 +1,79 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/application_test_base.h"
+#include "services/js/test/echo_service.mojom.h"
+
+namespace mojo {
+namespace {
+
+class JSEchoTest : public test::ApplicationTestBase {
+ public:
+ JSEchoTest() : ApplicationTestBase() {}
+ ~JSEchoTest() override {}
+
+ protected:
+ // ApplicationTestBase:
+ void SetUp() override {
+ ApplicationTestBase::SetUp();
+ application_impl()->ConnectToService(service_path(), &echo_service_);
+ }
+
+ EchoServicePtr echo_service_;
+
+ private:
+ const std::string service_path() {
+ base::FilePath path;
+ PathService::Get(base::DIR_SOURCE_ROOT, &path);
+ path = path.AppendASCII("services")
+ .AppendASCII("js")
+ .AppendASCII("test")
+ .AppendASCII("echo.js");
+ return "file://" + path.AsUTF8Unsafe();
+ }
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(JSEchoTest);
+};
+
+struct EchoStringCallback {
+ explicit EchoStringCallback(String *s) : echo_value(s) {}
+ void Run(const String& value) const {
+ *echo_value = value;
+ }
+ String *echo_value;
+};
+
+TEST_F(JSEchoTest, EchoString) {
+ String foo;
+ EchoStringCallback callback(&foo);
+ echo_service_->EchoString("foo", callback);
+ EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
+ EXPECT_EQ("foo", foo);
+ echo_service_->EchoString("quit", callback);
+}
+
+TEST_F(JSEchoTest, EchoEmptyString) {
+ String empty;
+ EchoStringCallback callback(&empty);
+ echo_service_->EchoString("", callback);
+ EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
+ EXPECT_EQ("", empty);
+ echo_service_->EchoString("quit", callback);
+}
+
+TEST_F(JSEchoTest, EchoNullString) {
+ String null;
+ EchoStringCallback callback(&null);
+ echo_service_->EchoString(nullptr, callback);
+ EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
+ EXPECT_TRUE(null.is_null());
+ echo_service_->EchoString("quit", callback);
+}
+
+} // namespace
+} // namespace mojo
« no previous file with comments | « services/js/js_app_runner_delegate.cc ('k') | services/js/mojo_bridge_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698