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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/files/file_path.h"
7 #include "base/path_service.h"
8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/application/application_test_base.h"
10 #include "services/js/test/echo_service.mojom.h"
11
12 namespace mojo {
13 namespace {
14
15 class JSEchoTest : public test::ApplicationTestBase {
16 public:
17 JSEchoTest() : ApplicationTestBase() {}
18 ~JSEchoTest() override {}
19
20 protected:
21 // ApplicationTestBase:
22 void SetUp() override {
23 ApplicationTestBase::SetUp();
24 application_impl()->ConnectToService(service_path(), &echo_service_);
25 }
26
27 EchoServicePtr echo_service_;
28
29 private:
30 const std::string service_path() {
31 base::FilePath path;
32 PathService::Get(base::DIR_SOURCE_ROOT, &path);
33 path = path.AppendASCII("services")
34 .AppendASCII("js")
35 .AppendASCII("test")
36 .AppendASCII("echo.js");
37 return "file://" + path.AsUTF8Unsafe();
38 }
39
40 MOJO_DISALLOW_COPY_AND_ASSIGN(JSEchoTest);
41 };
42
43 struct EchoStringCallback {
44 explicit EchoStringCallback(String *s) : echo_value(s) {}
45 void Run(const String& value) const {
46 *echo_value = value;
47 }
48 String *echo_value;
49 };
50
51 TEST_F(JSEchoTest, EchoString) {
52 String foo;
53 EchoStringCallback callback(&foo);
54 echo_service_->EchoString("foo", callback);
55 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
56 EXPECT_EQ("foo", foo);
57 echo_service_->EchoString("quit", callback);
58 }
59
60 TEST_F(JSEchoTest, EchoEmptyString) {
61 String empty;
62 EchoStringCallback callback(&empty);
63 echo_service_->EchoString("", callback);
64 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
65 EXPECT_EQ("", empty);
66 echo_service_->EchoString("quit", callback);
67 }
68
69 TEST_F(JSEchoTest, EchoNullString) {
70 String null;
71 EchoStringCallback callback(&null);
72 echo_service_->EchoString(nullptr, callback);
73 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
74 EXPECT_TRUE(null.is_null());
75 echo_service_->EchoString("quit", callback);
76 }
77
78 } // namespace
79 } // namespace mojo
OLDNEW
« 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