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

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

Issue 971083002: Create an apptesting framework for dart. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Update upload_binaries.py to add the apptest.dartzip artifact. Created 5 years, 9 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
(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/files/file_path.h"
6 #include "base/logging.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/dart/test/echo_service.mojom.h"
11
12 using mojo::String;
13
14 namespace dart {
15 namespace {
16
17 class DartEchoTest : public mojo::test::ApplicationTestBase {
18 public:
19 DartEchoTest() : ApplicationTestBase() {}
20 ~DartEchoTest() override {}
21
22 protected:
23 // ApplicationTestBase:
24 void SetUp() override {
25 ApplicationTestBase::SetUp();
26 application_impl()->ConnectToService("mojo:dart_echo", &echo_service_);
27 }
28
29 mojo::EchoServicePtr echo_service_;
30
31 private:
32 MOJO_DISALLOW_COPY_AND_ASSIGN(DartEchoTest);
33 };
34
35 struct EchoStringCallback {
36 explicit EchoStringCallback(String *s) : echo_value(s) {}
37 void Run(const String& value) const {
38 *echo_value = value;
39 }
40 String *echo_value;
41 };
42
43 TEST_F(DartEchoTest, EchoString) {
44 String foo;
45 EchoStringCallback callback(&foo);
46 echo_service_->EchoString("foo", callback);
47 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
48 EXPECT_EQ("foo", foo);
49 echo_service_->EchoString("quit", callback);
50 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
51 EXPECT_EQ("quit", foo);
52 }
53
54 TEST_F(DartEchoTest, EchoEmptyString) {
55 String empty;
56 EchoStringCallback callback(&empty);
57 echo_service_->EchoString("", callback);
58 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
59 EXPECT_EQ("", empty);
60 echo_service_->EchoString("quit", callback);
61 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
62 EXPECT_EQ("quit", empty);
63 }
64
65 TEST_F(DartEchoTest, EchoNullString) {
66 String null;
67 EchoStringCallback callback(&null);
68 echo_service_->EchoString(nullptr, callback);
69 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
70 EXPECT_TRUE(null.is_null());
71 echo_service_->EchoString("quit", callback);
72 EXPECT_TRUE(echo_service_.WaitForIncomingMethodCall());
73 EXPECT_EQ("quit", null);
74 }
75
76 } // namespace
77 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698